@@ -126,15 +126,33 @@ def __init__(self, workload_settings, target_settings, shutdown_event=None):
126126
127127 def init_load_targets (self ):
128128 self .load_targets = []
129+ self .load_map = {}
130+ num_ratio = 0
129131 if self .ws .collections is not None :
130132 target_scope_collections = self .ws .collections [self .ts .bucket ]
131133 for scope in target_scope_collections .keys ():
132134 for collection in target_scope_collections [scope ].keys ():
133135 if target_scope_collections [scope ][collection ]['load' ] == 1 :
134136 self .load_targets += [scope + ":" + collection ]
137+ if target_scope_collections [scope ][collection ].get ('ratio' ):
138+ num_ratio += target_scope_collections [scope ][collection ].get ('ratio' )
135139 else :
136140 self .load_targets = ["_default:_default" ]
137141 self .num_load_targets = len (self .load_targets )
142+ if num_ratio > 0 :
143+ base_items = self .ws .items // num_ratio
144+ target_scope_collections = self .ws .collections [self .ts .bucket ]
145+ for scope in target_scope_collections .keys ():
146+ for collection in target_scope_collections [scope ].keys ():
147+ if target_scope_collections [scope ][collection ]['load' ] == 1 :
148+ self .load_targets += [scope + ":" + collection ]
149+ if target_scope_collections [scope ][collection ].get ('ratio' ):
150+ ratio = target_scope_collections [scope ][collection ].get ('ratio' )
151+ self .load_map [scope + ":" + collection ] = ratio * base_items
152+ else :
153+ for target in self .load_targets :
154+ self .load_map [target ] = self .ws .items // self .num_load_targets
155+ logger .info (f"load map { self .load_map } " )
138156
139157 def init_access_targets (self ):
140158 self .access_targets = []
@@ -448,7 +466,8 @@ def gen_cmd_sequence(self, cb: Client = None) -> Sequence:
448466 if not cb :
449467 cb = self .cb
450468 target = self .random_target ()
451- curr_items = self .ws .items // self .num_load_targets
469+ curr_items = self .load_map [target ]
470+ # curr_items = self.ws.items // self.num_load_targets
452471 deleted_items = 0
453472 if self .ws .creates or self .ws .deletes :
454473 max_batch_deletes_buffer = self .ws .deletes * self .ws .workers
@@ -673,10 +692,11 @@ def run(self, sid, *args):
673692class SeqUpsertsWorker (Worker ):
674693
675694 def run (self , sid , * args ):
695+ logger .info ("running SeqUpsertsWorker" )
676696 ws = copy .deepcopy (self .ws )
677- ws .items = ws .items // self .num_load_targets
678697 self .cb .connect_collections (self .load_targets )
679698 for target in self .load_targets :
699+ ws .items = self .load_map [target ]
680700 for key in SequentialKey (sid , ws , self .ts .prefix ):
681701 doc = self .docs .next (key )
682702 self .cb .update (target , key .string , doc )
@@ -970,7 +990,6 @@ def do_batch_update(self, *args, **kwargs):
970990 t0 = time .time ()
971991 self .op_delay = self .op_delay + (self .delta / self .ws .n1ql_batch_size )
972992
973- self .next_target ()
974993 target_curr_items = self .ws .items // self .num_load_targets
975994
976995 for i in range (self .ws .n1ql_batch_size ):
@@ -1354,18 +1373,28 @@ def start_all_workers(self):
13541373 self .shared_dict = self .manager .dict ()
13551374 if self .ws .collections is not None :
13561375 num_load = 0
1376+ num_ratio = 0
13571377 target_scope_collections = self .ws .collections [self .ts .bucket ]
13581378 for scope in target_scope_collections .keys ():
13591379 for collection in target_scope_collections [scope ].keys ():
13601380 if target_scope_collections [scope ][collection ]['load' ] == 1 :
13611381 num_load += 1
1382+ if target_scope_collections [scope ][collection ].get ('ratio' ):
1383+ num_ratio += target_scope_collections [scope ][collection ].get ('ratio' )
13621384
13631385 curr_items = self .ws .items // num_load
1386+ if num_ratio > 0 :
1387+ curr_items = self .ws .items // num_ratio
13641388 for scope in target_scope_collections .keys ():
13651389 for collection in target_scope_collections [scope ].keys ():
13661390 target = scope + ":" + collection
13671391 if target_scope_collections [scope ][collection ]['load' ] == 1 :
1368- self .shared_dict [target ] = [curr_items , 0 ]
1392+ if target_scope_collections [scope ][collection ].get ('ratio' ):
1393+ ratio = target_scope_collections [scope ][collection ]['ratio' ]
1394+ final_items = curr_items * ratio
1395+ self .shared_dict [target ] = [final_items , 0 ]
1396+ else :
1397+ self .shared_dict [target ] = [curr_items , 0 ]
13691398 else :
13701399 self .shared_dict [target ] = [0 , 0 ]
13711400 else :
0 commit comments