@@ -997,7 +997,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
997
997
// command configuration always applied on last configured command
998
998
arbitrary_command& cmd = cfg->arbitrary_commands ->get_last_command ();
999
999
if (!cmd.set_key_pattern (optarg)) {
1000
- fprintf (stderr, " error: key-pattern for command %s must be in the format of [S/R/G/P].\n " , cmd.command_name .c_str ());
1000
+ fprintf (stderr, " error: key-pattern for command %s must be in the format of [S/R/Z/ G/P].\n " , cmd.command_name .c_str ());
1001
1001
return -1 ;
1002
1002
}
1003
1003
break ;
@@ -1160,6 +1160,7 @@ void usage() {
1160
1160
" --command-key-pattern Key pattern for the command (default: R):\n "
1161
1161
" G for Gaussian distribution.\n "
1162
1162
" R for uniform Random.\n "
1163
+ " Z for zipf distribution (will limit keys to positive).\n "
1163
1164
" S for Sequential.\n "
1164
1165
" P for Parallel (Sequential were each client has a subset of the key-range).\n "
1165
1166
" \n "
@@ -1779,7 +1780,20 @@ int main(int argc, char *argv[])
1779
1780
obj_gen->set_key_range (cfg.key_minimum , cfg.key_maximum );
1780
1781
}
1781
1782
if (cfg.key_stddev >0 || cfg.key_median >0 ) {
1782
- if (cfg.key_pattern [key_pattern_set]!=' G' && cfg.key_pattern [key_pattern_get]!=' G' ) {
1783
+ // Check if Gaussian distribution is used in global key patterns or arbitrary commands
1784
+ bool has_gaussian = (cfg.key_pattern [key_pattern_set]==' G' || cfg.key_pattern [key_pattern_get]==' G' );
1785
+
1786
+ // Also check if any arbitrary command uses Gaussian distribution
1787
+ if (!has_gaussian && cfg.arbitrary_commands ->is_defined ()) {
1788
+ for (size_t i = 0 ; i < cfg.arbitrary_commands ->size (); i++) {
1789
+ if (cfg.arbitrary_commands ->at (i).key_pattern == ' G' ) {
1790
+ has_gaussian = true ;
1791
+ break ;
1792
+ }
1793
+ }
1794
+ }
1795
+
1796
+ if (!has_gaussian) {
1783
1797
fprintf (stderr, " error: key-stddev and key-median are only allowed together with key-pattern set to G.\n " );
1784
1798
usage ();
1785
1799
}
@@ -1790,7 +1804,21 @@ int main(int argc, char *argv[])
1790
1804
obj_gen->set_key_distribution (cfg.key_stddev , cfg.key_median );
1791
1805
}
1792
1806
obj_gen->set_expiry_range (cfg.expiry_range .min , cfg.expiry_range .max );
1793
- if (cfg.key_pattern [key_pattern_set] == ' Z' || cfg.key_pattern [key_pattern_get] == ' Z' ) {
1807
+
1808
+ // Check if Zipfian distribution is needed for global key patterns or arbitrary commands
1809
+ bool needs_zipfian = (cfg.key_pattern [key_pattern_set] == ' Z' || cfg.key_pattern [key_pattern_get] == ' Z' );
1810
+
1811
+ // Also check if any arbitrary command uses Zipfian distribution
1812
+ if (!needs_zipfian && cfg.arbitrary_commands ->is_defined ()) {
1813
+ for (size_t i = 0 ; i < cfg.arbitrary_commands ->size (); i++) {
1814
+ if (cfg.arbitrary_commands ->at (i).key_pattern == ' Z' ) {
1815
+ needs_zipfian = true ;
1816
+ break ;
1817
+ }
1818
+ }
1819
+ }
1820
+
1821
+ if (needs_zipfian) {
1794
1822
if (cfg.key_zipf_exp == 0.0 ) {
1795
1823
// user can't specify 0.0, so 0.0 means unset
1796
1824
cfg.key_zipf_exp = 1.0 ;
0 commit comments