Skip to content

Commit

Permalink
rowid hash is removed but we still typecheck. Its dead code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Dec 21, 2024
1 parent ab69c6c commit 29509d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
3 changes: 1 addition & 2 deletions packages/zero-cache/src/types/row-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {describe, expect, test} from 'vitest';
import {
type RowKey,
normalizedKeyOrder,
rowIDHash,
rowIDString,
rowKeyString,
} from './row-key.js';
Expand Down Expand Up @@ -101,7 +100,7 @@ describe('types/row-key', () => {
for (const keys of c.keys) {
expect(rowKeyString(keys)).toBe(c.rowKeyString);
expect(rowIDString({schema, table, rowKey: keys})).toBe(c.rowIDString);
expect(rowIDHash({schema, table, rowKey: keys})).toBe(c.rowIDHash);
// expect(rowIDHash({schema, table, rowKey: keys})).toBe(c.rowIDHash);
}
});
}
Expand Down
27 changes: 0 additions & 27 deletions packages/zero-cache/src/types/row-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {h64WithReverse} from '../../../shared/src/h64-with-reverse.js';
import {stringify, type JSONValue} from './bigint-json.js';

export type ColumnType = {readonly typeOid: number};
Expand Down Expand Up @@ -64,29 +63,3 @@ export function rowIDString(id: RowID): string {
rowIDStrings.set(id, val);
return val;
}

const rowIDHashes = new WeakMap<RowID, string>();

/**
* A RowIDHash is a 128-bit column-order-agnostic hash of the schema, table name, and
* column name / value tuples of a row key. It serves as a compact identifier for
* a row in the database that:
*
* * is guaranteed to fit within the constraints of the CVR store (Durable Object
* storage keys cannot exceed 2KiB)
* * can be used to compactly encode (and lookup) the rows of query results for CVR
* bookkeeping.
*
* The hash is encoded in `base36`, with the maximum 128-bit value being 25 characters long.
*/
export function rowIDHash(id: RowID): string {
let hash = rowIDHashes.get(id);
if (hash) {
return hash;
}

const str = rowIDString(id);
hash = h64WithReverse(str);
rowIDHashes.set(id, hash);
return hash;
}

0 comments on commit 29509d3

Please sign in to comment.