mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
`operator>=` is implemented as `operator_greater || operator_eq`, and `operator_eq` returns on the first differing limb. With the fully-random `u1`/`u2` shape the high limbs differ on nearly every row, so the equality loop exits immediately and never reaches the low limb. Add `mixed_u1 >= mixed_u2`, mirroring the existing `<=` coverage, so the `>=` queries also measure rows that share the high 64 bits and force the comparison to continue into the low limb. Co-Authored-By: Claude Opus 4.8 <[email protected]>
49 lines
2.4 KiB
XML
49 lines
2.4 KiB
XML
<test>
|
|
<!-- Comparison of 128-bit integer columns. Data shapes are chosen to exercise branch-prediction-hostile
|
|
patterns: fully random values (random sign for Int128), values that fit in the low 64 bits,
|
|
and values where half of the rows share the high 64 bits. -->
|
|
|
|
<create_query>
|
|
CREATE TABLE cmp128
|
|
(
|
|
u1 UInt128, u2 UInt128,
|
|
i1 Int128, i2 Int128,
|
|
small_u1 UInt128, small_u2 UInt128,
|
|
mixed_u1 UInt128, mixed_u2 UInt128
|
|
) ENGINE = Memory
|
|
</create_query>
|
|
<fill_query>
|
|
INSERT INTO cmp128 SELECT
|
|
bitShiftLeft(toUInt128(cityHash64(number, 1)), 64) + cityHash64(number, 2),
|
|
bitShiftLeft(toUInt128(cityHash64(number, 3)), 64) + cityHash64(number, 4),
|
|
toInt128(bitShiftLeft(toUInt128(cityHash64(number, 5)), 64) + cityHash64(number, 6)),
|
|
toInt128(bitShiftLeft(toUInt128(cityHash64(number, 7)), 64) + cityHash64(number, 8)),
|
|
toUInt128(cityHash64(number, 9)),
|
|
toUInt128(cityHash64(number, 10)),
|
|
bitShiftLeft(toUInt128(cityHash64(number, 11)), 64) + cityHash64(number, 12),
|
|
bitShiftLeft(toUInt128(cityHash64(number, if(number % 2 = 0, 11, 13))), 64) + cityHash64(number, 14)
|
|
FROM numbers(10000000)
|
|
</fill_query>
|
|
|
|
<settings>
|
|
<max_threads>1</max_threads>
|
|
</settings>
|
|
|
|
<query>SELECT count() FROM cmp128 WHERE u1 < u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE i1 < i2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE small_u1 < small_u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE mixed_u1 < mixed_u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE u1 > u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE u1 <= u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE i1 <= i2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE mixed_u1 <= mixed_u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE u1 >= u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE i1 >= i2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE mixed_u1 >= mixed_u2</query>
|
|
<query>SELECT count() FROM cmp128 WHERE u1 < bitShiftLeft(toUInt128(1), 127)</query>
|
|
<query>SELECT i1 FROM cmp128 ORDER BY i1 LIMIT 10</query>
|
|
<query>SELECT u1 FROM cmp128 ORDER BY u1 DESC LIMIT 10</query>
|
|
|
|
<drop_query>DROP TABLE IF EXISTS cmp128</drop_query>
|
|
</test>
|