Skip to content

Commit 645da22

Browse files
committed
update xxh3 with defaultHasher
1 parent 1b13b5d commit 645da22

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

packages/cubejs-backend-shared/src/promises.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable arrow-body-style,no-restricted-syntax */
2-
import { xxh3 } from '@node-rs/xxhash';
2+
import { defaultHasher } from './hasher';
33
import { LRUCache } from 'lru-cache';
44

55
import { Optional } from './type-helpers';
@@ -282,7 +282,9 @@ export const asyncDebounceFn = <Ret, Arguments>(
282282
});
283283

284284
return async (...args: Arguments[]) => {
285-
const key = xxh3.xxh64(args.map((v) => JSON.stringify(v)).join(',')).toString(16);
285+
const key = defaultHasher()
286+
.update(args.map((v) => JSON.stringify(v)).join(','))
287+
.digest('hex');
286288

287289
const existing = cache.get(key);
288290
if (existing) {

packages/cubejs-cubestore-driver/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@cubejs-backend/cubestore": "1.6.3",
3131
"@cubejs-backend/native": "1.6.3",
3232
"@cubejs-backend/shared": "1.6.3",
33-
"@node-rs/xxhash": "^1.7.6",
3433
"csv-write-stream": "^2.0.0",
3534
"flatbuffers": "23.3.3",
3635
"fs-extra": "^9.1.0",

packages/cubejs-cubestore-driver/src/CubeStoreQueueDriver.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { xxh3 } from '@node-rs/xxhash';
21
import {
32
QueueDriverInterface,
43
QueueDriverConnectionInterface,
@@ -16,13 +15,13 @@ import {
1615
GetActiveAndToProcessResponse,
1716
QueryKeysTuple,
1817
} from '@cubejs-backend/base-driver';
19-
import { getProcessUid } from '@cubejs-backend/shared';
18+
import { defaultHasher, getProcessUid } from '@cubejs-backend/shared';
2019

2120
import { CubeStoreDriver } from './CubeStoreDriver';
2221

2322
function hashQueryKey(queryKey: QueryKey, processUid?: string): QueryKeyHash {
2423
processUid = processUid || getProcessUid();
25-
const hash = xxh3.xxh128(JSON.stringify(queryKey)).toString(16);
24+
const hash = defaultHasher().update(JSON.stringify(queryKey)).digest('hex');
2625

2726
if (typeof queryKey === 'object' && queryKey.persistent) {
2827
return `${hash}@${processUid}` as any;

packages/cubejs-query-orchestrator/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@cubejs-backend/base-driver": "1.6.3",
3333
"@cubejs-backend/cubestore-driver": "1.6.3",
3434
"@cubejs-backend/shared": "1.6.3",
35-
"@node-rs/xxhash": "^1.7.6",
3635
"csv-write-stream": "^2.0.0",
3736
"lru-cache": "^11.1.0",
3837
"ramda": "^0.27.2"

packages/cubejs-query-orchestrator/src/orchestrator/utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { xxh3 } from '@node-rs/xxhash';
2-
3-
import { getProcessUid } from '@cubejs-backend/shared';
1+
import { defaultHasher, getProcessUid } from '@cubejs-backend/shared';
42
import { QueryKey, QueryKeyHash } from '@cubejs-backend/base-driver';
53
import { CacheKey } from './QueryCache';
64

@@ -18,7 +16,7 @@ export function getCacheHash(queryKey: QueryKey | CacheKey, processUid?: string)
1816
return queryKey as any;
1917
}
2018

21-
const hash = xxh3.xxh128(JSON.stringify(queryKey)).toString(16);
19+
const hash = defaultHasher().update(JSON.stringify(queryKey)).digest('hex');
2220

2321
if (typeof queryKey === 'object' && 'persistent' in queryKey && queryKey.persistent) {
2422
return `${hash}@${processUid}` as any;

packages/cubejs-server-core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"@cubejs-backend/schema-compiler": "1.6.3",
4040
"@cubejs-backend/shared": "1.6.3",
4141
"@cubejs-backend/templates": "1.6.3",
42-
"@node-rs/xxhash": "^1.7.6",
4342
"codesandbox-import-utils": "^2.1.12",
4443
"cross-spawn": "^7.0.1",
4544
"fs-extra": "^8.1.0",

packages/cubejs-server-core/src/core/RefreshScheduler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import R from 'ramda';
22
import pLimit from 'p-limit';
33
import { v4 as uuidv4 } from 'uuid';
4-
import { xxh3 } from '@node-rs/xxhash';
5-
import { Required } from '@cubejs-backend/shared';
4+
import { Required, defaultHasher } from '@cubejs-backend/shared';
65
import {
76
PreAggregationDescription,
87
PreAggregationPartitionRangeLoader
@@ -127,7 +126,9 @@ function getPreAggsJobsList(
127126
* Returns MD5 hash token of the job object.
128127
*/
129128
function getPreAggJobToken(job: PreAggJob) {
130-
return xxh3.xxh64(JSON.stringify(job)).toString(16);
129+
return defaultHasher()
130+
.update(JSON.stringify(job))
131+
.digest('hex');
131132
}
132133

133134
export class RefreshScheduler {

0 commit comments

Comments
 (0)