Skip to content

Commit 547a1f0

Browse files
YaacovHazanyaacovhazan-Redislabs
authored andcommitted
fix parallel key-pattern command line option (#84)
when using the parallel key-pattern (P), it must be configured for all commands (SET:GET or --command-key-patterns's)
1 parent 62c5808 commit 547a1f0

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

memtier_benchmark.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,20 @@ static bool verify_arbitrary_command_option(struct benchmark_config *cfg) {
294294
return false;
295295
}
296296

297+
// verify that when using Parallel key pattern, it's configured to all commands
298+
size_t parallel_count = 0;
299+
for (size_t i = 0; i<cfg->arbitrary_commands->size(); i++) {
300+
arbitrary_command& cmd = cfg->arbitrary_commands->at(i);
301+
if (cmd.key_pattern == 'P') {
302+
parallel_count++;
303+
}
304+
}
305+
306+
if (parallel_count > 0 && parallel_count != cfg->arbitrary_commands->size()) {
307+
fprintf(stderr, "error: parallel key-pattern must be configured to all commands.\n");
308+
return false;
309+
}
310+
297311
return true;
298312
}
299313

@@ -624,8 +638,17 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
624638
cfg->key_pattern[key_pattern_set] != 'P') ||
625639
(cfg->key_pattern[key_pattern_get] != 'R' &&
626640
cfg->key_pattern[key_pattern_get] != 'S' &&
627-
cfg->key_pattern[key_pattern_get] != 'G')) {
628-
fprintf(stderr, "error: key-pattern must be in the format of [S/R/G/P]:[S/R/G].\n");
641+
cfg->key_pattern[key_pattern_get] != 'G' &&
642+
cfg->key_pattern[key_pattern_get] != 'P')) {
643+
fprintf(stderr, "error: key-pattern must be in the format of [S/R/G/P]:[S/R/G/P].\n");
644+
return -1;
645+
}
646+
647+
if ((cfg->key_pattern[key_pattern_set] == 'P' ||
648+
cfg->key_pattern[key_pattern_get] == 'P') &&
649+
(cfg->key_pattern[key_pattern_set] != cfg->key_pattern[key_pattern_get])) {
650+
651+
fprintf(stderr, "error: parallel key-pattern must be configured for both SET and GET commands.\n");
629652
return -1;
630653
}
631654
break;

0 commit comments

Comments
 (0)