diff options
| author | eunhhu <[email protected]> | 2026-10-19 01:53:40 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-19 01:53:40 +0100 |
| commit | defb2cf06a9b5db9429ca368d8c2af127a5c9c3d (patch) | |
| tree | b13c94eb334ce2a5055854791900f8702ba9fc3b /benchmarks/tpcc/data.py | |
| parent | 809a83a5764ec0f0c84b96c43a20cfb906eee031 (diff) | |
| download | pure-defb2cf06a9b5db9429ca368d8c2af127a5c9c3d.tar.gz pure-defb2cf06a9b5db9429ca368d8c2af127a5c9c3d.zip | |
027's 5c: money as i64 minor units shown by .Nd: NUM_TEXT's decimal form takes digits (bits 20-24 as FIXED's), an integer's last N digits written after a point (1234 at two is 12.34, -5 -0.05, 0 0.00; width and zeros after the sign), verification allowing digits on FIXED and DECIMAL alone; unit test: ten rows of formats_and_held (-2^63 at two, 25 digits, a number's whole 1234, its 12.5 a limit); TPC-C's money i64 cents and its rates ten-thousandths (tables, messages, load, the transactions), SQLite's INTEGER columns and int64 bindings alike, the comparison now exact (no 1e-9 tolerance): after 20,000 transactions every row of every table the same (grouped SQLite too) and 3.3.2 holding on both; counts: b45 against b44 BFS without batches +0.09%, the rest within 0.001%; the bank's queries (s44 and s45 in turns, six each) in_credit -0.59%, per_branch -0.34%, ranks -0.20%, the rest within 0.01%, the seven answers the same bytes; 008 (NUM_TEXT's digits, a message row's i64 cells), 027 and 092
Diffstat (limited to 'benchmarks/tpcc/data.py')
| -rw-r--r-- | benchmarks/tpcc/data.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/benchmarks/tpcc/data.py b/benchmarks/tpcc/data.py index d8a4ccb..82ebb07 100644 --- a/benchmarks/tpcc/data.py +++ b/benchmarks/tpcc/data.py @@ -1,13 +1,15 @@ """TPC-C's initial database (clause 4.3.3.1) for W warehouses, as rows of the records in tpcc.aup (each composite key packed into one number, as there), and the same rows for SQLite's tables with their own keys. Texts the -transactions only carry along are left out (see tpcc.aup).""" +transactions only carry along are left out (see tpcc.aup). Money is in +cents and a rate in ten-thousandths, integers (i64s in tpcc.aup, INTEGER in +SQLite).""" import random import struct ITEMS, CUSTOMERS, ORDERS, DELIVERED = 100000, 3000, 3000, 2100 -# Each table's fields in record order (tpcc.aup), all numbers. +# Each table's fields in record order (tpcc.aup), numbers but for the i64s in INTEGERS. FIELDS = { 'warehouses': ('id', 'tax', 'ytd'), 'districts': ('id', 'tax', 'ytd', 'next_order', 'next_delivery'), @@ -18,6 +20,7 @@ FIELDS = { 'new_orders': ('id',), 'lines': ('id', 'item', 'supply', 'delivery', 'quantity', 'amount'), } +INTEGERS = {'tax', 'ytd', 'discount', 'balance', 'ytd_payment', 'price', 'amount'} def district_key(w, d): @@ -36,13 +39,12 @@ def generate(warehouses, seed=1, now=1.7e12): """The tables as lists of tuples in FIELDS order.""" rng = random.Random(seed) tables = {name: [] for name in FIELDS} - tables['items'] = [(i, round(rng.uniform(1, 100), 2)) for i in range(1, ITEMS + 1)] + tables['items'] = [(i, rng.randint(100, 10000)) for i in range(1, ITEMS + 1)] for w in range(1, warehouses + 1): - tables['warehouses'].append((w, round(rng.uniform(0, 0.2), 4), 300000.0)) + tables['warehouses'].append((w, rng.randint(0, 2000), 30000000)) tables['stock'].extend((w * 100000 + i, rng.randint(10, 100), 0, 0, 0) for i in range(1, ITEMS + 1)) for d in range(1, 11): - tables['districts'].append((district_key(w, d), round(rng.uniform(0, 0.2), 4), 30000.0, ORDERS + 1, - DELIVERED + 1)) + tables['districts'].append((district_key(w, d), rng.randint(0, 2000), 3000000, ORDERS + 1, DELIVERED + 1)) owners = list(range(1, CUSTOMERS + 1)) rng.shuffle(owners) last = {} @@ -55,14 +57,14 @@ def generate(warehouses, seed=1, now=1.7e12): tables['new_orders'].append((key,)) for n in range(1, count + 1): tables['lines'].append((key * 16 + n, rng.randint(1, ITEMS), w, now if delivered else 0, 5, - 0 if delivered else round(rng.uniform(0.01, 9999.99), 2))) + 0 if delivered else rng.randint(1, 999999))) for c in range(1, CUSTOMERS + 1): - tables['customers'].append((customer_key(w, d, c), round(rng.uniform(0, 0.5), 4), - 0 if rng.random() < 0.1 else 1, -10.0, 10.0, 1, 0, last[c])) + tables['customers'].append((customer_key(w, d, c), rng.randint(0, 5000), + 0 if rng.random() < 0.1 else 1, -1000, 1000, 1, 0, last[c])) return tables -def packed(rows): - """Rows in a list's stored form (each number's binary64, little-endian).""" - width = len(rows[0]) - return struct.pack(f'<{width * len(rows)}d', *(v for row in rows for v in row)) +def packed(table, rows): + """A table's rows in a list's stored form (each number's binary64, each i64's two's complement, little-endian).""" + row = '<' + ''.join('q' if field in INTEGERS else 'd' for field in FIELDS[table]) + return b''.join(struct.pack(row, *r) for r in rows) |
