Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for splitting multi-key commands per slot #23

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,42 +140,6 @@ cmddef *valkey_lookup_cmd(const char *arg0, uint32_t arg0_len, const char *arg1,
return NULL;
}

/*
* Return true, if the valkey command is a vector command accepting one or
* more keys, otherwise return false
* Format: command key [ key ... ]
*/
static int valkey_argx(struct cmd *r) {
switch (r->type) {
case CMD_REQ_VALKEY_EXISTS:
case CMD_REQ_VALKEY_MGET:
case CMD_REQ_VALKEY_DEL:
return 1;

default:
break;
}

return 0;
}

/*
* Return true, if the valkey command is a vector command accepting one or
* more key-value pairs, otherwise return false
* Format: command key value [ key value ... ]
*/
static int valkey_argkvx(struct cmd *r) {
switch (r->type) {
case CMD_REQ_VALKEY_MSET:
return 1;

default:
break;
}

return 0;
}

/* Parses a bulk string starting at 'p' and ending somewhere before 'end'.
* Returns the remaining of the input after consuming the bulk string. The
* pointers *str and *len are pointed to the parsed string and its length. On
Expand Down Expand Up @@ -357,22 +321,6 @@ void valkey_parse_cmd(struct cmd *r) {
if (!push_keypos(r, arg, arglen))
goto oom;

/* Special commands where we want all keys (not only the first key). */
bjosv marked this conversation as resolved.
Show resolved Hide resolved
if (valkey_argx(r) || valkey_argkvx(r)) {
/* argx: MGET key [ key ... ] */
/* argkvx: MSET key value [ key value ... ] */
if (valkey_argkvx(r) && rnarg % 2 == 0)
goto error;
for (uint32_t i = 2; i < rnarg; i++) {
if ((p = valkey_parse_bulk(p, end, &arg, &arglen)) == NULL)
goto error;
if (valkey_argkvx(r) && i % 2 == 0)
continue; /* not a key */
if (!push_keypos(r, arg, arglen))
goto oom;
}
}

done:
ASSERT(r->type > CMD_UNKNOWN && r->type < CMD_SENTINEL);
r->result = CMD_PARSE_OK;
Expand Down Expand Up @@ -428,7 +376,6 @@ struct cmd *command_get(void) {
command->slot_num = -1;
command->frag_seq = NULL;
command->reply = NULL;
command->sub_commands = NULL;
command->node_addr = NULL;

command->keys = vkarray_create(1, sizeof(struct keypos));
Expand Down Expand Up @@ -468,10 +415,6 @@ void command_destroy(struct cmd *command) {

freeReplyObject(command->reply);

if (command->sub_commands != NULL) {
listRelease(command->sub_commands);
}

if (command->node_addr != NULL) {
sdsfree(command->node_addr);
command->node_addr = NULL;
Expand Down
6 changes: 1 addition & 5 deletions src/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,13 @@ struct cmd {
/* Command destination */
int slot_num; /* Command should be sent to slot.
* Set to -1 if command is sent to a given node,
* or if a slot can not be found or calculated,
* or if its a multi-key command cross different
* nodes (cross slot) */
* or if a slot can not be found or calculated. */
char *node_addr; /* Command sent to this node address */

struct cmd *
*frag_seq; /* sequence of fragment command, map from keys to fragments*/

valkeyReply *reply;

hilist *sub_commands; /* just for pipeline and multi-key commands */
};

void valkey_parse_cmd(struct cmd *r);
Expand Down
Loading
Loading