def _op_multi_table_as_list(ops_arg, tables, pareto_tables, multiplier): result = [] if ops_arg._optype != Operation.OP_NONE: if pareto_tables <= 0: for table in tables: for i in range(0, multiplier): result.append(Operation(ops_arg._optype, table, ops_arg._key, ops_arg._value)) else: # Use the multiplier unless the length of the list will be large. # In any case, make sure there's at least a multiplier of 3, to # give a chance to hit all/most of the tables. ntables = len(tables) count = ntables * multiplier if count > 1000: count = 1000 mincount = ntables * 3 if mincount > count: count = mincount for i in range(0, count): tnum = _choose_pareto(ntables, pareto_tables) # Modify the pareto value to make it more flat # as tnum gets higher. Workgen knows how to handle # a portion of a pareto range. table = tables[tnum] key = Key(ops_arg._key) key._pareto.range_low = (1.0 * i)/count key._pareto.range_high = (1.0 * (i + 1))/count result.append(Operation(ops_arg._optype, table, key, ops_arg._value)) else: for op in _op_get_group_list(ops_arg): for o in _op_multi_table_as_list(op, tables, pareto_tables, \ multiplier): result.append(Operation(o)) return result
pareto_tables = _check_pareto(ops_arg) else: pareto_tables = 0 if pareto_tables != 0: multiplier = _primes[random.randint(0, len(_primes) - 1)] ops_list = _op_multi_table_as_list(ops_arg, tables, pareto_tables, \ multiplier) if pareto_tables != 0: random.shuffle(ops_list) for op in ops_list: ops = op_append(ops, op) return ops # should be 8 bytes format 'Q' _logkey = Key(Key.KEYGEN_APPEND, 8) def _op_log_op(op, log_table): keysize = op._key._size if keysize == 0: keysize = op._table.options.key_size valuesize = op._value._size if valuesize == 0: valuesize = op._table.options.value_size v = Value(keysize + valuesize) return Operation(Operation.OP_INSERT, log_table, _logkey, v) def _optype_is_write(optype): return optype == Operation.OP_INSERT or optype == Operation.OP_UPDATE or \