Remove Uint8Array content-based equality comparison - #1258
KyleAMathews wants to merge 2 commits into
Conversation
…ference" (#779) This reverts the changes from PR #779 which added content-based comparison for small Uint8Arrays. All Uint8Arrays/Buffers now use reference-based hashing again. Specifically: - Remove Uint8Array content hashing in hash.ts (all sizes use reference hash) - Revert writeByte to private _writeByte in MurmurHashStream - Revert eq operator to use === instead of areValuesEqual - Revert in operator to use array.includes instead of normalizeValue - Remove areValuesEqual, areUint8ArraysEqual, and Uint8Array normalization from comparison.ts (keep normalizeValue for Date handling used by joins) - Delete uint8array-id-comparison integration test - Update related tests to expect reference-based hashing https://claude.ai/code/session_014bN4QUhGYQpuNAy1Ec42pC
|
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: -245 B (-0.27%) Total Size: 91.8 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.7 kB ℹ️ View Unchanged
|
kevin-dp
left a comment
There was a problem hiding this comment.
Approving but looks like you forgot to remove the "Uint8Arrays with same content have same hash" test and you should also add a changeset.
|
Closing as superseded by the current equality architecture. Current main intentionally defines binary content equality across |
Canonicalize satisfiable join operands through the compilation ValueIdentity, keep nullish operands row-disjoint, and preserve raw lazy-demand values with stable representatives. This restores equality-predicate consistency for binary and other established value domains without adding compound join syntax. Provenance: #593 Lucas Duailibe and Sam Willis; #861 Vincent Chan; #896 Tomas Zaluckij; #779/#899/#1258 Kyle Mathews and Claude; #899 review by Sam Willis; #1229 Hieu Nguyen, Hiếu Nguyễn Minh, Kevin De Porre, and Claude Opus 4.6; #1797 ValueIdentity architecture by Kyle Mathews. Prior art informed the evidence and design; no prior implementation lines were reused. #593/#861 remain design-gated. Weight: production source net +30 lines; emitted join module +65 B ESM gzip and +60 B CJS gzip. No public API, export, dependency, compatibility branch, or db-ivm change.
Canonicalize satisfiable join operands through the compilation ValueIdentity, keep nullish operands row-disjoint, and preserve raw lazy-demand values with stable representatives. This restores equality-predicate consistency for binary and other established value domains without adding compound join syntax. Provenance: #593 Lucas Duailibe and Sam Willis; #861 Vincent Chan; #896 Tomas Zaluckij; #779/#899/#1258 Kyle Mathews and Claude; #899 review by Sam Willis; #1229 Hieu Nguyen, Hiếu Nguyễn Minh, Kevin De Porre, and Claude Opus 4.6; #1797 ValueIdentity architecture by Kyle Mathews. Prior art informed the evidence and design; no prior implementation lines were reused. #593/#861 remain design-gated. Weight: production source net +30 lines; emitted join module +65 B ESM gzip and +60 B CJS gzip. No public API, export, dependency, compatibility branch, or db-ivm change.
* fix(db): align join keys with equality identity Canonicalize satisfiable join operands through the compilation ValueIdentity, keep nullish operands row-disjoint, and preserve raw lazy-demand values with stable representatives. This restores equality-predicate consistency for binary and other established value domains without adding compound join syntax. Provenance: #593 Lucas Duailibe and Sam Willis; #861 Vincent Chan; #896 Tomas Zaluckij; #779/#899/#1258 Kyle Mathews and Claude; #899 review by Sam Willis; #1229 Hieu Nguyen, Hiếu Nguyễn Minh, Kevin De Porre, and Claude Opus 4.6; #1797 ValueIdentity architecture by Kyle Mathews. Prior art informed the evidence and design; no prior implementation lines were reused. #593/#861 remain design-gated. Weight: production source net +30 lines; emitted join module +65 B ESM gzip and +60 B CJS gzip. No public API, export, dependency, compatibility branch, or db-ivm change. * Apply join equality review fixes * Reduce join result processing overhead
🎯 Changes
This PR removes the special handling for Uint8Array and Buffer content-based equality comparisons. Previously, the codebase attempted to normalize small Uint8Arrays (≤128 bytes) to string representations to enable content-based equality checks, while using reference equality for larger arrays.
Changes made:
normalizeValuelogic for Uint8Arrays/Buffers - Deleted the code that converted small Uint8Arrays to string representations (__u8__prefixed strings) for Map key usageareValuesEqualfunction - Deleted the utility function that provided special Uint8Array comparison logiceqoperator - Changed from usingnormalizeValueandareValuesEqualto simple reference equality (===)hashUint8Arrayfunction - Deleted the content-based hashing for small Uint8Arrays; all Uint8Arrays/Buffers now use reference-based hashingcachedReferenceHashRationale:
The previous approach of normalizing small Uint8Arrays to strings for content-based equality was complex and had limitations. Users working with Uint8Array IDs (like ULIDs) should use a derived string key in their data model instead of relying on implicit content-based comparison. This simplification:
✅ Checklist
pnpm test:pr.🚀 Release Impact
https://claude.ai/code/session_014bN4QUhGYQpuNAy1Ec42pC