void val_gen(WT_RAND_STATE *rnd, WT_ITEM *value, uint64_t keyno) { char *p; p = value->mem; value->data = value->mem; /* * Fixed-length records: take the low N bits from the last digit of * the record number. */ if (g.type == FIX) { switch (g.c_bitcnt) { case 8: p[0] = (char)mmrand(rnd, 1, 0xff); break; case 7: p[0] = (char)mmrand(rnd, 1, 0x7f); break; case 6: p[0] = (char)mmrand(rnd, 1, 0x3f); break; case 5: p[0] = (char)mmrand(rnd, 1, 0x1f); break; case 4: p[0] = (char)mmrand(rnd, 1, 0x0f); break; case 3: p[0] = (char)mmrand(rnd, 1, 0x07); break; case 2: p[0] = (char)mmrand(rnd, 1, 0x03); break; case 1: p[0] = 1; break; } value->size = 1; return; } /* * WiredTiger doesn't store zero-length data items in row-store files, * test that by inserting a zero-length data item every so often. */ if (keyno % 63 == 0) { p[0] = '\0'; value->size = 0; return; } /* * Data items have unique leading numbers by default and random lengths; * variable-length column-stores use a duplicate data value to test RLE. */ if (g.type == VAR && mmrand(rnd, 1, 100) < g.c_repeat_data_pct) { (void)strcpy(p, "DUPLICATEV"); p[10] = '/'; value->size = val_dup_data_len; } else { u64_to_string_zf(keyno, p, 11); p[10] = '/'; value->size = value_len(rnd, keyno, g.c_value_min, g.c_value_max); } }
static void key_gen_common(WT_ITEM *key, uint64_t keyno, const char * const suffix) { int len; char *p; p = key->mem; /* * The key always starts with a 10-digit string (the specified row) * followed by two digits, a random number between 1 and 15 if it's * an insert, otherwise 00. */ u64_to_string_zf(keyno, key->mem, 11); p[10] = '.'; p[11] = suffix[0]; p[12] = suffix[1]; len = 13; /* * In a column-store, the key is only used for Berkeley DB inserts, * and so it doesn't need a random length. */ if (g.type == ROW) { p[len] = '/'; /* * Because we're doing table lookup for key sizes, we weren't * able to set really big keys sizes in the table, the table * isn't big enough to keep our hash from selecting too many * big keys and blowing out the cache. Handle that here, use a * really big key 1 in 2500 times. */ len = keyno % 2500 == 0 && g.c_key_max < KILOBYTE(80) ? KILOBYTE(80) : (int)g.key_rand_len[keyno % WT_ELEMENTS(g.key_rand_len)]; } key->data = key->mem; key->size = (size_t)len; }
extern void workgen_u64_to_string_zf(uint64_t n, char *buf, size_t len) { u64_to_string_zf(n, buf, len); }