distillate 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +44 -6
  2. package/dist/bitset-Cf2jwRJX.js +32 -0
  3. package/dist/bitset-QYGqxnEf.cjs +37 -0
  4. package/dist/blocked/index.cjs +14 -9
  5. package/dist/blocked/index.d.cts +7 -6
  6. package/dist/blocked/index.d.ts +7 -6
  7. package/dist/blocked/index.js +12 -8
  8. package/dist/bloom/index.cjs +16 -41
  9. package/dist/bloom/index.d.cts +5 -4
  10. package/dist/bloom/index.d.ts +5 -4
  11. package/dist/bloom/index.js +13 -39
  12. package/dist/bytes-DCuYtUVS.d.cts +4 -0
  13. package/dist/bytes-DCuYtUVS.d.ts +4 -0
  14. package/dist/frame/index.cjs +9 -0
  15. package/dist/frame/index.d.cts +2 -0
  16. package/dist/frame/index.d.ts +2 -0
  17. package/dist/frame/index.js +2 -0
  18. package/dist/fuse/index.cjs +26 -22
  19. package/dist/fuse/index.d.cts +7 -6
  20. package/dist/fuse/index.d.ts +7 -6
  21. package/dist/fuse/index.js +14 -11
  22. package/dist/hasher-3Cyn7Yg-.js +230 -0
  23. package/dist/hasher-MhY7aQ8F.cjs +289 -0
  24. package/dist/hll/index.cjs +12 -8
  25. package/dist/hll/index.d.cts +4 -3
  26. package/dist/hll/index.d.ts +4 -3
  27. package/dist/hll/index.js +11 -8
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.cts +2 -3
  30. package/dist/index.d.ts +2 -3
  31. package/dist/index.js +1 -1
  32. package/dist/scalable/index.cjs +340 -0
  33. package/dist/scalable/index.d.cts +173 -0
  34. package/dist/scalable/index.d.ts +173 -0
  35. package/dist/scalable/index.js +330 -0
  36. package/dist/{serialize-Bv1zWzrh.d.cts → serialize--xR6vGSW.d.cts} +44 -8
  37. package/dist/{serialize-Bv1zWzrh.d.ts → serialize--xR6vGSW.d.ts} +44 -8
  38. package/dist/serialize-CHikZ4GH.cjs +296 -0
  39. package/dist/serialize-CMSYFym-.js +201 -0
  40. package/package.json +25 -9
  41. package/dist/serialize-D59Ri81a.js +0 -392
  42. package/dist/serialize-Ul2LKFJU.cjs +0 -517
@@ -0,0 +1,289 @@
1
+ //#region src/core/bytes.ts
2
+ const encoder = new TextEncoder();
3
+ function normalize(input) {
4
+ if (typeof input === "string") return encoder.encode(input);
5
+ if (input instanceof Uint8Array) return input;
6
+ return new Uint8Array(input);
7
+ }
8
+ //#endregion
9
+ //#region src/core/hasher.ts
10
+ let RLO = 0;
11
+ let RHI = 0;
12
+ const LANES = {
13
+ w0: 0,
14
+ w1: 0,
15
+ w2: 0,
16
+ w3: 0
17
+ };
18
+ function mul64(alo, ahi, blo, bhi) {
19
+ const a0 = alo & 65535;
20
+ const a1 = alo >>> 16;
21
+ const a2 = ahi & 65535;
22
+ const a3 = ahi >>> 16;
23
+ const b0 = blo & 65535;
24
+ const b1 = blo >>> 16;
25
+ const b2 = bhi & 65535;
26
+ const b3 = bhi >>> 16;
27
+ let c0 = a0 * b0;
28
+ let c1 = c0 >>> 16;
29
+ c0 &= 65535;
30
+ c1 += a1 * b0;
31
+ let c2 = c1 >>> 16;
32
+ c1 &= 65535;
33
+ c1 += a0 * b1;
34
+ c2 += c1 >>> 16;
35
+ c1 &= 65535;
36
+ c2 += a2 * b0;
37
+ let c3 = c2 >>> 16;
38
+ c2 &= 65535;
39
+ c2 += a1 * b1;
40
+ c3 += c2 >>> 16;
41
+ c2 &= 65535;
42
+ c2 += a0 * b2;
43
+ c3 += c2 >>> 16;
44
+ c2 &= 65535;
45
+ c3 += a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3;
46
+ c3 &= 65535;
47
+ RLO = (c1 << 16 | c0) >>> 0;
48
+ RHI = (c3 << 16 | c2) >>> 0;
49
+ }
50
+ function fmix64(lo, hi) {
51
+ let l = lo;
52
+ let h = hi;
53
+ l = (l ^ h >>> 1) >>> 0;
54
+ mul64(l, h, 3981806797, 4283543511);
55
+ l = RLO;
56
+ h = RHI;
57
+ l = (l ^ h >>> 1) >>> 0;
58
+ mul64(l, h, 444984403, 3301882366);
59
+ l = RLO;
60
+ h = RHI;
61
+ l = (l ^ h >>> 1) >>> 0;
62
+ RLO = l;
63
+ RHI = h;
64
+ }
65
+ function rotl32(x, r) {
66
+ return (x << r | x >>> 32 - r) >>> 0;
67
+ }
68
+ function fmix32(h) {
69
+ let x = h;
70
+ x ^= x >>> 16;
71
+ x = Math.imul(x, 2246822507);
72
+ x ^= x >>> 13;
73
+ x = Math.imul(x, 3266489909);
74
+ x ^= x >>> 16;
75
+ return x >>> 0;
76
+ }
77
+ const K1 = 597399067;
78
+ const K2 = 2869860233;
79
+ const K3 = 951274213;
80
+ const K4 = 2716044179;
81
+ function computeLanes(bytes, seed, len) {
82
+ const nblocks = len >>> 4;
83
+ let h1 = seed >>> 0;
84
+ let h2 = seed >>> 0;
85
+ let h3 = seed >>> 0;
86
+ let h4 = seed >>> 0;
87
+ for (let i = 0; i < nblocks; i++) {
88
+ const b = i * 16;
89
+ let k1 = ((bytes[b] ?? 0) | (bytes[b + 1] ?? 0) << 8 | (bytes[b + 2] ?? 0) << 16 | (bytes[b + 3] ?? 0) << 24) >>> 0;
90
+ let k2 = ((bytes[b + 4] ?? 0) | (bytes[b + 5] ?? 0) << 8 | (bytes[b + 6] ?? 0) << 16 | (bytes[b + 7] ?? 0) << 24) >>> 0;
91
+ let k3 = ((bytes[b + 8] ?? 0) | (bytes[b + 9] ?? 0) << 8 | (bytes[b + 10] ?? 0) << 16 | (bytes[b + 11] ?? 0) << 24) >>> 0;
92
+ let k4 = ((bytes[b + 12] ?? 0) | (bytes[b + 13] ?? 0) << 8 | (bytes[b + 14] ?? 0) << 16 | (bytes[b + 15] ?? 0) << 24) >>> 0;
93
+ k1 = Math.imul(rotl32(Math.imul(k1, K1), 15), K2);
94
+ h1 ^= k1;
95
+ h1 = rotl32(h1, 19);
96
+ h1 = h1 + h2 >>> 0;
97
+ h1 = Math.imul(h1, 5) + 1444728091 >>> 0;
98
+ k2 = Math.imul(rotl32(Math.imul(k2, K2), 16), K3);
99
+ h2 ^= k2;
100
+ h2 = rotl32(h2, 17);
101
+ h2 = h2 + h3 >>> 0;
102
+ h2 = Math.imul(h2, 5) + 197830471 >>> 0;
103
+ k3 = Math.imul(rotl32(Math.imul(k3, K3), 17), K4);
104
+ h3 ^= k3;
105
+ h3 = rotl32(h3, 15);
106
+ h3 = h3 + h4 >>> 0;
107
+ h3 = Math.imul(h3, 5) + 2530024501 >>> 0;
108
+ k4 = Math.imul(rotl32(Math.imul(k4, K4), 18), K1);
109
+ h4 ^= k4;
110
+ h4 = rotl32(h4, 13);
111
+ h4 = h4 + h1 >>> 0;
112
+ h4 = Math.imul(h4, 5) + 850148119 >>> 0;
113
+ }
114
+ let k1 = 0;
115
+ let k2 = 0;
116
+ let k3 = 0;
117
+ let k4 = 0;
118
+ const tail = nblocks * 16;
119
+ const rem = len & 15;
120
+ if (rem >= 15) k4 ^= (bytes[tail + 14] ?? 0) << 16;
121
+ if (rem >= 14) k4 ^= (bytes[tail + 13] ?? 0) << 8;
122
+ if (rem >= 13) {
123
+ k4 ^= bytes[tail + 12] ?? 0;
124
+ k4 = Math.imul(rotl32(Math.imul(k4, K4), 18), K1);
125
+ h4 ^= k4;
126
+ }
127
+ if (rem >= 12) k3 ^= (bytes[tail + 11] ?? 0) << 24;
128
+ if (rem >= 11) k3 ^= (bytes[tail + 10] ?? 0) << 16;
129
+ if (rem >= 10) k3 ^= (bytes[tail + 9] ?? 0) << 8;
130
+ if (rem >= 9) {
131
+ k3 ^= bytes[tail + 8] ?? 0;
132
+ k3 = Math.imul(rotl32(Math.imul(k3, K3), 17), K4);
133
+ h3 ^= k3;
134
+ }
135
+ if (rem >= 8) k2 ^= (bytes[tail + 7] ?? 0) << 24;
136
+ if (rem >= 7) k2 ^= (bytes[tail + 6] ?? 0) << 16;
137
+ if (rem >= 6) k2 ^= (bytes[tail + 5] ?? 0) << 8;
138
+ if (rem >= 5) {
139
+ k2 ^= bytes[tail + 4] ?? 0;
140
+ k2 = Math.imul(rotl32(Math.imul(k2, K2), 16), K3);
141
+ h2 ^= k2;
142
+ }
143
+ if (rem >= 4) k1 ^= (bytes[tail + 3] ?? 0) << 24;
144
+ if (rem >= 3) k1 ^= (bytes[tail + 2] ?? 0) << 16;
145
+ if (rem >= 2) k1 ^= (bytes[tail + 1] ?? 0) << 8;
146
+ if (rem >= 1) {
147
+ k1 ^= bytes[tail] ?? 0;
148
+ k1 = Math.imul(rotl32(Math.imul(k1, K1), 15), K2);
149
+ h1 ^= k1;
150
+ }
151
+ h1 = (h1 ^ len) >>> 0;
152
+ h2 = (h2 ^ len) >>> 0;
153
+ h3 = (h3 ^ len) >>> 0;
154
+ h4 = (h4 ^ len) >>> 0;
155
+ h1 = h1 + h2 >>> 0;
156
+ h1 = h1 + h3 >>> 0;
157
+ h1 = h1 + h4 >>> 0;
158
+ h2 = h2 + h1 >>> 0;
159
+ h3 = h3 + h1 >>> 0;
160
+ h4 = h4 + h1 >>> 0;
161
+ h1 = fmix32(h1);
162
+ h2 = fmix32(h2);
163
+ h3 = fmix32(h3);
164
+ h4 = fmix32(h4);
165
+ h1 = h1 + h2 >>> 0;
166
+ h1 = h1 + h3 >>> 0;
167
+ h1 = h1 + h4 >>> 0;
168
+ h2 = h2 + h1 >>> 0;
169
+ h3 = h3 + h1 >>> 0;
170
+ h4 = h4 + h1 >>> 0;
171
+ LANES.w0 = h1;
172
+ LANES.w1 = h2;
173
+ LANES.w2 = h3;
174
+ LANES.w3 = h4;
175
+ }
176
+ const keyEncoder = new TextEncoder();
177
+ let keyBuf = new Uint8Array(256);
178
+ let encBytes = keyBuf;
179
+ let encLen = 0;
180
+ function encodeKey(key) {
181
+ if (typeof key === "string") {
182
+ const cap = key.length * 3;
183
+ if (keyBuf.length < cap) keyBuf = new Uint8Array(cap);
184
+ encLen = keyEncoder.encodeInto(key, keyBuf).written;
185
+ encBytes = keyBuf;
186
+ return;
187
+ }
188
+ encBytes = normalize(key);
189
+ encLen = encBytes.length;
190
+ }
191
+ function keyToLanes(key, seed) {
192
+ encodeKey(key);
193
+ computeLanes(encBytes, seed, encLen);
194
+ }
195
+ function hash128KeyInto(key, seed, out) {
196
+ keyToLanes(key, seed);
197
+ out.w0 = LANES.w0;
198
+ out.w1 = LANES.w1;
199
+ out.w2 = LANES.w2;
200
+ out.w3 = LANES.w3;
201
+ }
202
+ function reduce(x, range) {
203
+ const xlo = x & 65535;
204
+ const xhi = x >>> 16;
205
+ const rlo = range & 65535;
206
+ const rhi = range >>> 16;
207
+ const lolo = xlo * rlo;
208
+ const lohi = xlo * rhi;
209
+ const hilo = xhi * rlo;
210
+ const hihi = xhi * rhi;
211
+ const carry = (lolo >>> 16) + (lohi & 65535) + (hilo & 65535);
212
+ return hihi + (lohi >>> 16) + (hilo >>> 16) + (carry >>> 16) >>> 0;
213
+ }
214
+ function hash32x2Into(key, seed, out) {
215
+ keyToLanes(key, seed);
216
+ out[0] = LANES.w0;
217
+ out[1] = LANES.w1;
218
+ }
219
+ function probeAt(a, b, i, range) {
220
+ return reduce(a + Math.imul(i, b) + i * i >>> 0, range);
221
+ }
222
+ function probeLanesInto(a, b, count, range, out) {
223
+ for (let i = 0; i < count; i++) out[i] = probeAt(a, b, i, range);
224
+ }
225
+ function probeInto(key, count, range, seed, out) {
226
+ keyToLanes(key, seed);
227
+ probeLanesInto(LANES.w0, LANES.w1, count, range, out);
228
+ }
229
+ //#endregion
230
+ Object.defineProperty(exports, "RHI", {
231
+ enumerable: true,
232
+ get: function() {
233
+ return RHI;
234
+ }
235
+ });
236
+ Object.defineProperty(exports, "RLO", {
237
+ enumerable: true,
238
+ get: function() {
239
+ return RLO;
240
+ }
241
+ });
242
+ Object.defineProperty(exports, "fmix64", {
243
+ enumerable: true,
244
+ get: function() {
245
+ return fmix64;
246
+ }
247
+ });
248
+ Object.defineProperty(exports, "hash128KeyInto", {
249
+ enumerable: true,
250
+ get: function() {
251
+ return hash128KeyInto;
252
+ }
253
+ });
254
+ Object.defineProperty(exports, "hash32x2Into", {
255
+ enumerable: true,
256
+ get: function() {
257
+ return hash32x2Into;
258
+ }
259
+ });
260
+ Object.defineProperty(exports, "mul64", {
261
+ enumerable: true,
262
+ get: function() {
263
+ return mul64;
264
+ }
265
+ });
266
+ Object.defineProperty(exports, "probeAt", {
267
+ enumerable: true,
268
+ get: function() {
269
+ return probeAt;
270
+ }
271
+ });
272
+ Object.defineProperty(exports, "probeInto", {
273
+ enumerable: true,
274
+ get: function() {
275
+ return probeInto;
276
+ }
277
+ });
278
+ Object.defineProperty(exports, "probeLanesInto", {
279
+ enumerable: true,
280
+ get: function() {
281
+ return probeLanesInto;
282
+ }
283
+ });
284
+ Object.defineProperty(exports, "reduce", {
285
+ enumerable: true,
286
+ get: function() {
287
+ return reduce;
288
+ }
289
+ });
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_serialize = require("../serialize-Ul2LKFJU.cjs");
2
+ const require_hasher = require("../hasher-MhY7aQ8F.cjs");
3
+ const require_serialize = require("../serialize-CHikZ4GH.cjs");
3
4
  const require_params = require("../params-UTZbJ22c.cjs");
4
5
  const require_sizing = require("../sizing-BLzZk2zr.cjs");
5
6
  //#region src/hll/estimate.ts
@@ -100,7 +101,7 @@ var Registers = class {
100
101
  }
101
102
  };
102
103
  const RHO_BITS = 6;
103
- const RHO_MASK = (1 << RHO_BITS) - 1;
104
+ const RHO_MASK = 63;
104
105
  function encodeSparse(index, rho) {
105
106
  return index << RHO_BITS | rho;
106
107
  }
@@ -138,7 +139,8 @@ function compact(buf, len) {
138
139
  //#region src/hll/hll.ts
139
140
  const ERROR_CONSTANT = 1.04;
140
141
  const TYPE = 5;
141
- const PARAMS_SIZE = 6;
142
+ const PARAMS_SIZE = 8;
143
+ const PARAMS_FIELDS_END = 6;
142
144
  const DENSE = 0;
143
145
  const SPARSE = 1;
144
146
  const ENTRY_SIZE = 4;
@@ -181,6 +183,7 @@ var HyperLogLog = class HyperLogLog {
181
183
  if (type !== TYPE) throw new require_serialize.SerializationError(`expected DSTL type ${String(TYPE)}, got ${String(type)}`);
182
184
  if ((flags & 15) !== 0) throw new require_serialize.UnknownHashVariantError(`unsupported hash variant ${String(flags & 15)}`);
183
185
  require_serialize.assertMinBodyLength(body.length, PARAMS_SIZE, "hll");
186
+ require_serialize.assertParamsPadding(body, PARAMS_FIELDS_END, PARAMS_SIZE, "hll");
184
187
  const dv = new DataView(body.buffer, body.byteOffset, body.byteLength);
185
188
  const p = body[0] ?? 0;
186
189
  const encoding = body[1] ?? 0;
@@ -221,10 +224,10 @@ var HyperLogLog = class HyperLogLog {
221
224
  const entries = compact(sparse, this.#len);
222
225
  this.#len = entries;
223
226
  return require_serialize.writeFrame({
224
- version: 4,
227
+ version: 5,
225
228
  type: TYPE,
226
229
  flags: 0
227
- }, PARAMS_SIZE + entries * ENTRY_SIZE, (body, dv) => {
230
+ }, PARAMS_SIZE, entries * ENTRY_SIZE, (body, dv) => {
228
231
  body[0] = this.#p;
229
232
  body[1] = SPARSE;
230
233
  dv.setUint32(2, this.#seed, true);
@@ -233,10 +236,10 @@ var HyperLogLog = class HyperLogLog {
233
236
  }
234
237
  const payload = this.#registers.bytes;
235
238
  return require_serialize.writeFrame({
236
- version: 4,
239
+ version: 5,
237
240
  type: TYPE,
238
241
  flags: 0
239
- }, PARAMS_SIZE + payload.length, (body, dv) => {
242
+ }, PARAMS_SIZE, payload.length, (body, dv) => {
240
243
  body[0] = this.#p;
241
244
  body[1] = DENSE;
242
245
  dv.setUint32(2, this.#seed, true);
@@ -260,7 +263,7 @@ var HyperLogLog = class HyperLogLog {
260
263
  }
261
264
  add(key) {
262
265
  const s = this.#scratch;
263
- require_serialize.hash128KeyInto(key, this.#seed, s);
266
+ require_hasher.hash128KeyInto(key, this.#seed, s);
264
267
  const p = this.#p;
265
268
  const tail = s.w0 << p >>> 0;
266
269
  const rho = tail !== 0 ? Math.clz32(tail) + 1 : 32 - p + Math.clz32(s.w1) + 1;
@@ -355,6 +358,7 @@ exports.BadMagicError = require_serialize.BadMagicError;
355
358
  exports.ChecksumError = require_serialize.ChecksumError;
356
359
  exports.HyperLogLog = HyperLogLog;
357
360
  exports.ParamError = require_params.ParamError;
361
+ exports.ReservedBitsError = require_serialize.ReservedBitsError;
358
362
  exports.SerializationError = require_serialize.SerializationError;
359
363
  exports.TruncatedError = require_serialize.TruncatedError;
360
364
  exports.UnknownHashVariantError = require_serialize.UnknownHashVariantError;
@@ -1,4 +1,5 @@
1
- import { a as TruncatedError, c as BytesLike, i as SerializationError, n as ChecksumError, o as UnknownHashVariantError, r as FilterJSON, s as UnknownVersionError, t as BadMagicError } from "../serialize-Bv1zWzrh.cjs";
1
+ import { t as BytesLike } from "../bytes-DCuYtUVS.cjs";
2
+ import { a as ReservedBitsError, c as UnknownHashVariantError, l as UnknownVersionError, n as ChecksumError, o as SerializationError, r as FilterJSON, s as TruncatedError, t as BadMagicError } from "../serialize--xR6vGSW.cjs";
2
3
  import { t as ParamError } from "../params-DnqJBqLS.cjs";
3
4
  import { i as hllSizing, n as HllSizing } from "../sizing-wYOW27eY.cjs";
4
5
  //#region src/hll/hll.d.ts
@@ -19,7 +20,7 @@ interface HllParams {
19
20
  * sketch.add("alice");
20
21
  * ```
21
22
  */
22
- declare class HyperLogLog {
23
+ export declare class HyperLogLog {
23
24
  #private;
24
25
  /**
25
26
  * Creates a sketch at an explicit precision.
@@ -116,4 +117,4 @@ declare class HyperLogLog {
116
117
  count(): number;
117
118
  }
118
119
  //#endregion
119
- export { BadMagicError, ChecksumError, type FilterJSON, type HllParams, type HllSizing, HyperLogLog, ParamError, SerializationError, TruncatedError, UnknownHashVariantError, UnknownVersionError, hllSizing };
120
+ export { BadMagicError, ChecksumError, type FilterJSON, type HllParams, type HllSizing, ParamError, ReservedBitsError, SerializationError, TruncatedError, UnknownHashVariantError, UnknownVersionError, hllSizing };
@@ -1,4 +1,5 @@
1
- import { a as TruncatedError, c as BytesLike, i as SerializationError, n as ChecksumError, o as UnknownHashVariantError, r as FilterJSON, s as UnknownVersionError, t as BadMagicError } from "../serialize-Bv1zWzrh.js";
1
+ import { t as BytesLike } from "../bytes-DCuYtUVS.js";
2
+ import { a as ReservedBitsError, c as UnknownHashVariantError, l as UnknownVersionError, n as ChecksumError, o as SerializationError, r as FilterJSON, s as TruncatedError, t as BadMagicError } from "../serialize--xR6vGSW.js";
2
3
  import { t as ParamError } from "../params-DnqJBqLS.js";
3
4
  import { i as hllSizing, n as HllSizing } from "../sizing-wYOW27eY.js";
4
5
  //#region src/hll/hll.d.ts
@@ -19,7 +20,7 @@ interface HllParams {
19
20
  * sketch.add("alice");
20
21
  * ```
21
22
  */
22
- declare class HyperLogLog {
23
+ export declare class HyperLogLog {
23
24
  #private;
24
25
  /**
25
26
  * Creates a sketch at an explicit precision.
@@ -116,4 +117,4 @@ declare class HyperLogLog {
116
117
  count(): number;
117
118
  }
118
119
  //#endregion
119
- export { BadMagicError, ChecksumError, type FilterJSON, type HllParams, type HllSizing, HyperLogLog, ParamError, SerializationError, TruncatedError, UnknownHashVariantError, UnknownVersionError, hllSizing };
120
+ export { BadMagicError, ChecksumError, type FilterJSON, type HllParams, type HllSizing, ParamError, ReservedBitsError, SerializationError, TruncatedError, UnknownHashVariantError, UnknownVersionError, hllSizing };
package/dist/hll/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { _ as hash128KeyInto, a as UnknownHashVariantError, c as assertMinBodyLength, d as readHeader, f as toJSONEnvelope, i as TruncatedError, n as ChecksumError, o as UnknownVersionError, p as writeFrame, r as SerializationError, s as assertBodyLength, t as BadMagicError, u as fromJSONEnvelope } from "../serialize-D59Ri81a.js";
1
+ import { i as hash128KeyInto } from "../hasher-3Cyn7Yg-.js";
2
+ import { a as TruncatedError, c as assertBodyLength, f as fromJSONEnvelope, g as writeFrame, h as toJSONEnvelope, i as SerializationError, l as assertMinBodyLength, m as readHeader, n as ChecksumError, o as UnknownHashVariantError, r as ReservedBitsError, s as UnknownVersionError, t as BadMagicError, u as assertParamsPadding } from "../serialize-CMSYFym-.js";
2
3
  import { o as assertUint32, t as ParamError } from "../params-CeajSrwv.js";
3
4
  import { n as hllSizing } from "../sizing-BtUrtvF_.js";
4
5
  //#region src/hll/estimate.ts
@@ -99,7 +100,7 @@ var Registers = class {
99
100
  }
100
101
  };
101
102
  const RHO_BITS = 6;
102
- const RHO_MASK = (1 << RHO_BITS) - 1;
103
+ const RHO_MASK = 63;
103
104
  function encodeSparse(index, rho) {
104
105
  return index << RHO_BITS | rho;
105
106
  }
@@ -137,7 +138,8 @@ function compact(buf, len) {
137
138
  //#region src/hll/hll.ts
138
139
  const ERROR_CONSTANT = 1.04;
139
140
  const TYPE = 5;
140
- const PARAMS_SIZE = 6;
141
+ const PARAMS_SIZE = 8;
142
+ const PARAMS_FIELDS_END = 6;
141
143
  const DENSE = 0;
142
144
  const SPARSE = 1;
143
145
  const ENTRY_SIZE = 4;
@@ -180,6 +182,7 @@ var HyperLogLog = class HyperLogLog {
180
182
  if (type !== TYPE) throw new SerializationError(`expected DSTL type ${String(TYPE)}, got ${String(type)}`);
181
183
  if ((flags & 15) !== 0) throw new UnknownHashVariantError(`unsupported hash variant ${String(flags & 15)}`);
182
184
  assertMinBodyLength(body.length, PARAMS_SIZE, "hll");
185
+ assertParamsPadding(body, PARAMS_FIELDS_END, PARAMS_SIZE, "hll");
183
186
  const dv = new DataView(body.buffer, body.byteOffset, body.byteLength);
184
187
  const p = body[0] ?? 0;
185
188
  const encoding = body[1] ?? 0;
@@ -220,10 +223,10 @@ var HyperLogLog = class HyperLogLog {
220
223
  const entries = compact(sparse, this.#len);
221
224
  this.#len = entries;
222
225
  return writeFrame({
223
- version: 4,
226
+ version: 5,
224
227
  type: TYPE,
225
228
  flags: 0
226
- }, PARAMS_SIZE + entries * ENTRY_SIZE, (body, dv) => {
229
+ }, PARAMS_SIZE, entries * ENTRY_SIZE, (body, dv) => {
227
230
  body[0] = this.#p;
228
231
  body[1] = SPARSE;
229
232
  dv.setUint32(2, this.#seed, true);
@@ -232,10 +235,10 @@ var HyperLogLog = class HyperLogLog {
232
235
  }
233
236
  const payload = this.#registers.bytes;
234
237
  return writeFrame({
235
- version: 4,
238
+ version: 5,
236
239
  type: TYPE,
237
240
  flags: 0
238
- }, PARAMS_SIZE + payload.length, (body, dv) => {
241
+ }, PARAMS_SIZE, payload.length, (body, dv) => {
239
242
  body[0] = this.#p;
240
243
  body[1] = DENSE;
241
244
  dv.setUint32(2, this.#seed, true);
@@ -350,4 +353,4 @@ var HyperLogLog = class HyperLogLog {
350
353
  }
351
354
  };
352
355
  //#endregion
353
- export { BadMagicError, ChecksumError, HyperLogLog, ParamError, SerializationError, TruncatedError, UnknownHashVariantError, UnknownVersionError, hllSizing };
356
+ export { BadMagicError, ChecksumError, HyperLogLog, ParamError, ReservedBitsError, SerializationError, TruncatedError, UnknownHashVariantError, UnknownVersionError, hllSizing };
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#endregion
3
3
  //#region src/index.ts
4
- const VERSION = "0.9.0";
4
+ const VERSION = "0.11.0";
5
5
  //#endregion
6
6
  exports.VERSION = VERSION;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  //#region src/index.d.ts
2
2
  /** The installed `distillate` package version. */
3
- declare const VERSION: string;
4
- //#endregion
5
- export { VERSION };
3
+ export declare const VERSION: string;
4
+ //#endregion
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  //#region src/index.d.ts
2
2
  /** The installed `distillate` package version. */
3
- declare const VERSION: string;
4
- //#endregion
5
- export { VERSION };
3
+ export declare const VERSION: string;
4
+ //#endregion
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#endregion
2
2
  //#region src/index.ts
3
- const VERSION = "0.9.0";
3
+ const VERSION = "0.11.0";
4
4
  //#endregion
5
5
  export { VERSION };