@elaraai/east 1.0.78 → 1.0.80
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.
- package/README.md +1 -1
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +4 -5
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/compile/builtins/array.d.ts +59 -0
- package/dist/src/compile/builtins/array.d.ts.map +1 -0
- package/dist/src/compile/builtins/array.js +656 -0
- package/dist/src/compile/builtins/array.js.map +1 -0
- package/dist/src/compile/builtins/blob.d.ts +18 -0
- package/dist/src/compile/builtins/blob.d.ts.map +1 -0
- package/dist/src/compile/builtins/blob.js +150 -0
- package/dist/src/compile/builtins/blob.js.map +1 -0
- package/dist/src/compile/builtins/compare.d.ts +18 -0
- package/dist/src/compile/builtins/compare.d.ts.map +1 -0
- package/dist/src/compile/builtins/compare.js +52 -0
- package/dist/src/compile/builtins/compare.js.map +1 -0
- package/dist/src/compile/builtins/datetime.d.ts +21 -0
- package/dist/src/compile/builtins/datetime.d.ts.map +1 -0
- package/dist/src/compile/builtins/datetime.js +46 -0
- package/dist/src/compile/builtins/datetime.js.map +1 -0
- package/dist/src/compile/builtins/dict.d.ts +46 -0
- package/dist/src/compile/builtins/dict.d.ts.map +1 -0
- package/dist/src/compile/builtins/dict.js +551 -0
- package/dist/src/compile/builtins/dict.js.map +1 -0
- package/dist/src/compile/builtins/index.d.ts +9 -0
- package/dist/src/compile/builtins/index.d.ts.map +1 -0
- package/dist/src/compile/builtins/index.js +28 -0
- package/dist/src/compile/builtins/index.js.map +1 -0
- package/dist/src/compile/builtins/matrix.d.ts +31 -0
- package/dist/src/compile/builtins/matrix.d.ts.map +1 -0
- package/dist/src/compile/builtins/matrix.js +310 -0
- package/dist/src/compile/builtins/matrix.js.map +1 -0
- package/dist/src/compile/builtins/primitives.d.ts +36 -0
- package/dist/src/compile/builtins/primitives.d.ts.map +1 -0
- package/dist/src/compile/builtins/primitives.js +67 -0
- package/dist/src/compile/builtins/primitives.js.map +1 -0
- package/dist/src/compile/builtins/ref.d.ts +11 -0
- package/dist/src/compile/builtins/ref.d.ts.map +1 -0
- package/dist/src/compile/builtins/ref.js +30 -0
- package/dist/src/compile/builtins/ref.js.map +1 -0
- package/dist/src/compile/builtins/set.d.ts +41 -0
- package/dist/src/compile/builtins/set.d.ts.map +1 -0
- package/dist/src/compile/builtins/set.js +385 -0
- package/dist/src/compile/builtins/set.js.map +1 -0
- package/dist/src/compile/builtins/sparse.d.ts +19 -0
- package/dist/src/compile/builtins/sparse.d.ts.map +1 -0
- package/dist/src/compile/builtins/sparse.js +143 -0
- package/dist/src/compile/builtins/sparse.js.map +1 -0
- package/dist/src/compile/builtins/string.d.ts +34 -0
- package/dist/src/compile/builtins/string.d.ts.map +1 -0
- package/dist/src/compile/builtins/string.js +238 -0
- package/dist/src/compile/builtins/string.js.map +1 -0
- package/dist/src/compile/builtins/vector.d.ts +44 -0
- package/dist/src/compile/builtins/vector.d.ts.map +1 -0
- package/dist/src/compile/builtins/vector.js +463 -0
- package/dist/src/compile/builtins/vector.js.map +1 -0
- package/dist/src/compile/constructors.d.ts +13 -0
- package/dist/src/compile/constructors.d.ts.map +1 -0
- package/dist/src/compile/constructors.js +179 -0
- package/dist/src/compile/constructors.js.map +1 -0
- package/dist/src/compile/control.d.ts +13 -0
- package/dist/src/compile/control.d.ts.map +1 -0
- package/dist/src/compile/control.js +513 -0
- package/dist/src/compile/control.js.map +1 -0
- package/dist/src/compile/functions.d.ts +13 -0
- package/dist/src/compile/functions.d.ts.map +1 -0
- package/dist/src/compile/functions.js +492 -0
- package/dist/src/compile/functions.js.map +1 -0
- package/dist/src/compile/ir.d.ts +19 -0
- package/dist/src/compile/ir.d.ts.map +1 -0
- package/dist/src/compile/ir.js +193 -0
- package/dist/src/compile/ir.js.map +1 -0
- package/dist/src/compile/runtime.d.ts +78 -0
- package/dist/src/compile/runtime.d.ts.map +1 -0
- package/dist/src/compile/runtime.js +111 -0
- package/dist/src/compile/runtime.js.map +1 -0
- package/dist/src/compile/type_parameters.d.ts +4 -0
- package/dist/src/compile/type_parameters.d.ts.map +1 -0
- package/dist/src/compile/type_parameters.js +55 -0
- package/dist/src/compile/type_parameters.js.map +1 -0
- package/dist/src/compile/typed_arrays.d.ts +28 -0
- package/dist/src/compile/typed_arrays.d.ts.map +1 -0
- package/dist/src/compile/typed_arrays.js +77 -0
- package/dist/src/compile/typed_arrays.js.map +1 -0
- package/dist/src/compile.d.ts +6 -41
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +8 -4415
- package/dist/src/compile.js.map +1 -1
- package/dist/src/compile.open_beast.spec.js +5 -4
- package/dist/src/compile.open_beast.spec.js.map +1 -1
- package/dist/src/containers/sortedmap.d.ts +2 -1
- package/dist/src/containers/sortedmap.d.ts.map +1 -1
- package/dist/src/containers/sortedmap.js +4 -2
- package/dist/src/containers/sortedmap.js.map +1 -1
- package/dist/src/containers/sortedset.d.ts +2 -1
- package/dist/src/containers/sortedset.d.ts.map +1 -1
- package/dist/src/containers/sortedset.js +4 -2
- package/dist/src/containers/sortedset.js.map +1 -1
- package/dist/src/error.d.ts +15 -0
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +16 -0
- package/dist/src/error.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/patch/index.d.ts +1 -1
- package/dist/src/patch/index.d.ts.map +1 -1
- package/dist/src/patch/index.js +1 -1
- package/dist/src/patch/index.js.map +1 -1
- package/dist/src/patch/type_of_patch.d.ts +25 -1
- package/dist/src/patch/type_of_patch.d.ts.map +1 -1
- package/dist/src/patch/type_of_patch.js +33 -10
- package/dist/src/patch/type_of_patch.js.map +1 -1
- package/dist/src/platform.spec.js +19 -1
- package/dist/src/platform.spec.js.map +1 -1
- package/dist/src/runner_protocol.d.ts +316 -0
- package/dist/src/runner_protocol.d.ts.map +1 -0
- package/dist/src/runner_protocol.js +135 -0
- package/dist/src/runner_protocol.js.map +1 -0
- package/dist/src/serialization/beast2/index.d.ts +21 -5
- package/dist/src/serialization/beast2/index.d.ts.map +1 -1
- package/dist/src/serialization/beast2/index.js +12 -2
- package/dist/src/serialization/beast2/index.js.map +1 -1
- package/dist/src/serialization/beast2/index.spec.js +84 -3
- package/dist/src/serialization/beast2/index.spec.js.map +1 -1
- package/dist/src/serialization/beast2/shared.d.ts +32 -3
- package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
- package/dist/src/serialization/beast2/shared.js +135 -10
- package/dist/src/serialization/beast2/shared.js.map +1 -1
- package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v4/container.js +5 -3
- package/dist/src/serialization/beast2/v4/container.js.map +1 -1
- package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/aliasing.spec.js +75 -0
- package/dist/src/serialization/beast2/v5/aliasing.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/boundary.d.ts +176 -0
- package/dist/src/serialization/beast2/v5/boundary.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/boundary.js +297 -0
- package/dist/src/serialization/beast2/v5/boundary.js.map +1 -0
- package/dist/src/serialization/beast2/v5/boundary.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/boundary.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/boundary.spec.js +479 -0
- package/dist/src/serialization/beast2/v5/boundary.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/codec.d.ts +6 -5
- package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.js +18 -3
- package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/deflate.d.ts +24 -2
- package/dist/src/serialization/beast2/v5/deflate.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/deflate.js +47 -12
- package/dist/src/serialization/beast2/v5/deflate.js.map +1 -1
- package/dist/src/serialization/beast2/v5/deflate.spec.js +15 -1
- package/dist/src/serialization/beast2/v5/deflate.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/elements.d.ts +64 -0
- package/dist/src/serialization/beast2/v5/elements.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/elements.js +320 -0
- package/dist/src/serialization/beast2/v5/elements.js.map +1 -0
- package/dist/src/serialization/beast2/v5/elements.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/elements.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/elements.spec.js +161 -0
- package/dist/src/serialization/beast2/v5/elements.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/frame-pool.d.ts +62 -21
- package/dist/src/serialization/beast2/v5/frame-pool.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/frame-pool.js +138 -27
- package/dist/src/serialization/beast2/v5/frame-pool.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frame-pool.spec.js +198 -71
- package/dist/src/serialization/beast2/v5/frame-pool.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frame-worker.js +25 -15
- package/dist/src/serialization/beast2/v5/frame-worker.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.d.ts +22 -12
- package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.js +52 -27
- package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
- package/dist/src/serialization/beast2/v5/geometry.d.ts +38 -1
- package/dist/src/serialization/beast2/v5/geometry.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/geometry.js +73 -1
- package/dist/src/serialization/beast2/v5/geometry.js.map +1 -1
- package/dist/src/serialization/beast2/v5/geometry.spec.js +34 -23
- package/dist/src/serialization/beast2/v5/geometry.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/index.spec.js +32 -28
- package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.d.ts +42 -1
- package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.js +143 -28
- package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.spec.js +102 -24
- package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/manifest-writer.d.ts +110 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.js +118 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.js.map +1 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.spec.js +207 -0
- package/dist/src/serialization/beast2/v5/manifest-writer.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/manifest.d.ts +241 -0
- package/dist/src/serialization/beast2/v5/manifest.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/manifest.js +233 -0
- package/dist/src/serialization/beast2/v5/manifest.js.map +1 -0
- package/dist/src/serialization/beast2/v5/merge.d.ts +93 -0
- package/dist/src/serialization/beast2/v5/merge.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/merge.js +202 -0
- package/dist/src/serialization/beast2/v5/merge.js.map +1 -0
- package/dist/src/serialization/beast2/v5/merge.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/merge.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/merge.spec.js +118 -0
- package/dist/src/serialization/beast2/v5/merge.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/recut.d.ts +143 -0
- package/dist/src/serialization/beast2/v5/recut.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/recut.js +365 -0
- package/dist/src/serialization/beast2/v5/recut.js.map +1 -0
- package/dist/src/serialization/beast2/v5/recut.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/recut.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/recut.spec.js +215 -0
- package/dist/src/serialization/beast2/v5/recut.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/runs.d.ts +148 -0
- package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/runs.js +260 -0
- package/dist/src/serialization/beast2/v5/runs.js.map +1 -0
- package/dist/src/serialization/beast2/v5/runs.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/runs.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/runs.spec.js +182 -0
- package/dist/src/serialization/beast2/v5/runs.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/sha256.d.ts +19 -0
- package/dist/src/serialization/beast2/v5/sha256.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/sha256.js +103 -0
- package/dist/src/serialization/beast2/v5/sha256.js.map +1 -0
- package/dist/src/serialization/beast2/v5/sha256.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/sha256.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/sha256.spec.js +42 -0
- package/dist/src/serialization/beast2/v5/sha256.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/stream.d.ts +273 -86
- package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.js +576 -244
- package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
- package/dist/src/serialization/beast2/v5/sync-reader.spec.js +24 -10
- package/dist/src/serialization/beast2/v5/sync-reader.spec.js.map +1 -1
- package/dist/src/serialization/index.d.ts +1 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -1
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts +28 -0
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +141 -30
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/serialization/json.spec.js +47 -2
- package/dist/src/serialization/json.spec.js.map +1 -1
- package/dist/src/serialization/json_schema.d.ts +15 -11
- package/dist/src/serialization/json_schema.d.ts.map +1 -1
- package/dist/src/serialization/json_schema.js +21 -36
- package/dist/src/serialization/json_schema.js.map +1 -1
- package/dist/src/serialization/json_schema.spec.js +26 -32
- package/dist/src/serialization/json_schema.spec.js.map +1 -1
- package/dist/src/serialization/json_schema_to_type.d.ts +10 -5
- package/dist/src/serialization/json_schema_to_type.d.ts.map +1 -1
- package/dist/src/serialization/json_schema_to_type.js +13 -6
- package/dist/src/serialization/json_schema_to_type.js.map +1 -1
- package/dist/src/serialization/json_schema_to_type.spec.js +19 -0
- package/dist/src/serialization/json_schema_to_type.spec.js.map +1 -1
- package/dist/src/string_order.d.ts +36 -0
- package/dist/src/string_order.d.ts.map +1 -0
- package/dist/src/string_order.js +64 -0
- package/dist/src/string_order.js.map +1 -0
- package/dist/src/string_order.spec.d.ts +6 -0
- package/dist/src/string_order.spec.d.ts.map +1 -0
- package/dist/src/string_order.spec.js +79 -0
- package/dist/src/string_order.spec.js.map +1 -0
- package/dist/src/type_of_type.d.ts +17 -0
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.js +66 -0
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/type_of_type.to_etv.spec.js +69 -1
- package/dist/src/type_of_type.to_etv.spec.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The manifest writer: its directory is the Writer's blob taken apart — the
|
|
7
|
+
* header and each segment, named by SHA-256 — with a manifest naming them; the
|
|
8
|
+
* directory reads back as the value; an empty collection is a header and a
|
|
9
|
+
* manifest of no entries; the directories of three parity values are east-c's
|
|
10
|
+
* and east-py's to the byte; and a merge writes one too.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, test } from "node:test";
|
|
13
|
+
import assert from "node:assert/strict";
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { ArrayType, DictType, IntegerType, RecursiveType, SetType, StringType, StructType, VariantType } from "../../../types.js";
|
|
16
|
+
import { compareFor } from "../../../comparison.js";
|
|
17
|
+
import { isTypeValueEqual, toEastTypeValue } from "../../../type_of_type.js";
|
|
18
|
+
import { SortedMap, SortedSet, variant } from "../../../index.js";
|
|
19
|
+
import { Beast2ManifestWriter, COLLECTION_MANIFEST_KIND, carveBeast2, decodeCollectionManifest, encodeBeast2FenceFor, encodeBeast2PagedFor, mergeBeast2For, openBeast2LazyFor, openBeast2PagesFor, readBeast2Extents, readBeast2Manifest, segmentKeyTypeOf, segmentRuleFor, spliceBeast2, spliceBeast2Segments, } from "../index.js";
|
|
20
|
+
/** Every chunk a splice streams, as one array. */
|
|
21
|
+
async function collect(chunks) {
|
|
22
|
+
const parts = [];
|
|
23
|
+
for await (const chunk of chunks)
|
|
24
|
+
parts.push(chunk);
|
|
25
|
+
const out = new Uint8Array(parts.reduce((n, part) => n + part.length, 0));
|
|
26
|
+
let at = 0;
|
|
27
|
+
for (const part of parts) {
|
|
28
|
+
out.set(part, at);
|
|
29
|
+
at += part.length;
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/** A manifest directory held in memory, and the order its sink was called in. */
|
|
34
|
+
function directory() {
|
|
35
|
+
const objects = new Map();
|
|
36
|
+
const calls = [];
|
|
37
|
+
let manifest = null;
|
|
38
|
+
return {
|
|
39
|
+
objects,
|
|
40
|
+
calls,
|
|
41
|
+
sink: {
|
|
42
|
+
object(hash, bytes) {
|
|
43
|
+
calls.push(hash);
|
|
44
|
+
objects.set(hash, bytes);
|
|
45
|
+
},
|
|
46
|
+
manifest(bytes) {
|
|
47
|
+
calls.push("manifest");
|
|
48
|
+
manifest = bytes;
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
manifest: () => {
|
|
52
|
+
assert.ok(manifest !== null, "the manifest was written");
|
|
53
|
+
return manifest;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
58
|
+
const key = (prefix, i) => `${prefix}${String(i).padStart(7, "0")}`;
|
|
59
|
+
const DictSI = DictType(StringType, IntegerType);
|
|
60
|
+
const SetS = SetType(StringType);
|
|
61
|
+
const ArrayS = ArrayType(StringType);
|
|
62
|
+
const dict = new SortedMap(Array.from({ length: 50_000 }, (_, i) => [key("k", i), BigInt(i)]), compareFor(StringType));
|
|
63
|
+
const set = new SortedSet(Array.from({ length: 50_000 }, (_, i) => key("e", i)), compareFor(StringType));
|
|
64
|
+
const array = Array.from({ length: 50_000 }, (_, i) => key("a", i));
|
|
65
|
+
const cases = [
|
|
66
|
+
{ name: "a Dict", type: DictSI, value: dict, elements: () => dict.entries() },
|
|
67
|
+
{ name: "a Set", type: SetS, value: set, elements: () => set.keys() },
|
|
68
|
+
{ name: "an Array", type: ArrayS, value: array, elements: () => array.values() },
|
|
69
|
+
];
|
|
70
|
+
describe("beast2 v5 manifest writer", () => {
|
|
71
|
+
for (const { name, type, value, elements } of cases) {
|
|
72
|
+
test(`writes ${name} as the Writer's blob taken apart, each object under its SHA-256`, async () => {
|
|
73
|
+
const dir = directory();
|
|
74
|
+
const writer = new Beast2ManifestWriter(type, dir.sink);
|
|
75
|
+
for (const element of elements())
|
|
76
|
+
writer.add(element);
|
|
77
|
+
writer.finish();
|
|
78
|
+
const blob = encodeBeast2PagedFor(type)(value);
|
|
79
|
+
const extents = readBeast2Extents(blob);
|
|
80
|
+
const manifest = decodeCollectionManifest(dir.manifest());
|
|
81
|
+
assert.equal(manifest.kind, COLLECTION_MANIFEST_KIND);
|
|
82
|
+
assert.equal(manifest.level, 0n);
|
|
83
|
+
assert.equal(manifest.rule, segmentRuleFor(type));
|
|
84
|
+
assert.deepEqual(manifest.type, extents.typeValue);
|
|
85
|
+
const header = blob.subarray(0, extents.prefixEnd);
|
|
86
|
+
assert.equal(manifest.header, sha256(header));
|
|
87
|
+
assert.deepEqual(dir.objects.get(manifest.header), header);
|
|
88
|
+
assert.ok(manifest.entries.length > 1, "the value is cut into several segments");
|
|
89
|
+
assert.equal(manifest.entries.length, extents.offsets.length);
|
|
90
|
+
const keyType = segmentKeyTypeOf(type);
|
|
91
|
+
const pages = openBeast2PagesFor(type)(blob);
|
|
92
|
+
manifest.entries.forEach((entry, i) => {
|
|
93
|
+
const carved = carveBeast2(blob, i, i + 1, extents);
|
|
94
|
+
assert.deepEqual(dir.objects.get(entry.hash), carved, `segment ${i}`);
|
|
95
|
+
assert.equal(entry.hash, sha256(carved));
|
|
96
|
+
assert.equal(entry.count, BigInt(extents.counts[i]));
|
|
97
|
+
assert.equal(entry.bytes, BigInt(carved.length));
|
|
98
|
+
assert.deepEqual(new Uint8Array(entry.fence), keyType === null ? new Uint8Array(0) : encodeBeast2FenceFor(keyType)(pages.fence(i)));
|
|
99
|
+
});
|
|
100
|
+
assert.deepEqual(spliceBeast2(manifest.entries.map((entry) => dir.objects.get(entry.hash))), blob);
|
|
101
|
+
// Streamed under the header the manifest names, as a download splices.
|
|
102
|
+
assert.deepEqual(await collect(spliceBeast2Segments(header, manifest.entries.map((entry) => dir.objects.get(entry.hash)))), blob);
|
|
103
|
+
});
|
|
104
|
+
test(`writes ${name} as a directory that reads back as the value`, () => {
|
|
105
|
+
const dir = directory();
|
|
106
|
+
const writer = new Beast2ManifestWriter(type, dir.sink);
|
|
107
|
+
for (const element of elements())
|
|
108
|
+
writer.add(element);
|
|
109
|
+
writer.finish();
|
|
110
|
+
const manifest = readBeast2Manifest(dir.manifest());
|
|
111
|
+
assert.ok(manifest !== null);
|
|
112
|
+
const lazy = openBeast2LazyFor(type, { frozen: true })({
|
|
113
|
+
manifest,
|
|
114
|
+
segment: (i) => dir.objects.get(manifest.entries[i].hash),
|
|
115
|
+
});
|
|
116
|
+
assert.deepEqual([...(type === DictSI ? lazy.entries() : lazy)], [...elements()]);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
test("splices no segment written under another header", async () => {
|
|
120
|
+
const segmentsOf = (type, elements) => {
|
|
121
|
+
const dir = directory();
|
|
122
|
+
const writer = new Beast2ManifestWriter(type, dir.sink);
|
|
123
|
+
for (const element of elements)
|
|
124
|
+
writer.add(element);
|
|
125
|
+
writer.finish();
|
|
126
|
+
const manifest = decodeCollectionManifest(dir.manifest());
|
|
127
|
+
return { header: dir.objects.get(manifest.header), segments: manifest.entries.map((entry) => dir.objects.get(entry.hash)) };
|
|
128
|
+
};
|
|
129
|
+
const dicts = segmentsOf(DictSI, dict.entries());
|
|
130
|
+
const sets = segmentsOf(SetS, set.keys());
|
|
131
|
+
await assert.rejects(collect(spliceBeast2Segments(dicts.header, [dicts.segments[0], sets.segments[1]])), {
|
|
132
|
+
message: "beast2 v5: segment 1 was written under another header — the segments of one collection share theirs",
|
|
133
|
+
});
|
|
134
|
+
// An empty collection is its header and the tail.
|
|
135
|
+
const empty = encodeBeast2PagedFor(DictSI)(new SortedMap(undefined, compareFor(StringType)));
|
|
136
|
+
assert.deepEqual(await collect(spliceBeast2Segments(dicts.header, [])), empty);
|
|
137
|
+
});
|
|
138
|
+
test("hands the header over first and the manifest last", () => {
|
|
139
|
+
const dir = directory();
|
|
140
|
+
const writer = new Beast2ManifestWriter(DictSI, dir.sink);
|
|
141
|
+
for (const entry of dict.entries())
|
|
142
|
+
writer.add(entry);
|
|
143
|
+
writer.finish();
|
|
144
|
+
writer.finish();
|
|
145
|
+
const manifest = decodeCollectionManifest(dir.manifest());
|
|
146
|
+
assert.deepEqual(dir.calls, [manifest.header, ...manifest.entries.map((entry) => entry.hash), "manifest"]);
|
|
147
|
+
assert.equal(writer.segments, manifest.entries.length);
|
|
148
|
+
});
|
|
149
|
+
test("writes an empty collection as its header and a manifest of no entries", () => {
|
|
150
|
+
const dir = directory();
|
|
151
|
+
new Beast2ManifestWriter(DictSI, dir.sink).finish();
|
|
152
|
+
const manifest = decodeCollectionManifest(dir.manifest());
|
|
153
|
+
const blob = encodeBeast2PagedFor(DictSI)(new SortedMap(undefined, compareFor(StringType)));
|
|
154
|
+
const header = blob.subarray(0, readBeast2Extents(blob).prefixEnd);
|
|
155
|
+
assert.deepEqual(manifest.entries, []);
|
|
156
|
+
assert.equal(manifest.header, sha256(header));
|
|
157
|
+
assert.deepEqual([...dir.objects.keys()], [manifest.header]);
|
|
158
|
+
});
|
|
159
|
+
test("writes the directories east-c and east-py write", () => {
|
|
160
|
+
// The same values and digests are pinned in east-c's
|
|
161
|
+
// `tests/test_beast2_manifest.c` and east-py's `test_beast2_manifest.py`.
|
|
162
|
+
// A manifest names each object by its SHA-256, so its own digest pins
|
|
163
|
+
// every segment's bytes too.
|
|
164
|
+
const manifestOf = (type, elements) => {
|
|
165
|
+
const dir = directory();
|
|
166
|
+
const writer = new Beast2ManifestWriter(type, dir.sink);
|
|
167
|
+
for (const element of elements)
|
|
168
|
+
writer.add(element);
|
|
169
|
+
writer.finish();
|
|
170
|
+
return sha256(dir.manifest());
|
|
171
|
+
};
|
|
172
|
+
assert.equal(manifestOf(DictSI, dict.entries()), "5564111725b1962b7ae8c82cf91d24c4e1fb8d2c9613245693757fe4ff4187b0");
|
|
173
|
+
assert.equal(manifestOf(SetS, set.keys()), "7b2c57db1da82f98ef88018589dc7a4f96bac120472b35e9826dbd60c395789c");
|
|
174
|
+
assert.equal(manifestOf(ArrayS, array), "127030afceae0c9590ad26ed26521cff170b8024229f28ccd54d647fc218df4c");
|
|
175
|
+
assert.equal(manifestOf(DictSI, []), "356518ed344e3e210d0a2acb26eef7eff25cd76ba08b1aedd0640af5256cefb0");
|
|
176
|
+
});
|
|
177
|
+
test("records a recursive collection type under canonical ids, not this process's", () => {
|
|
178
|
+
// The ids a runtime gives recursive types are its own; the manifest's
|
|
179
|
+
// hash names the collection, so the type is recorded renamed — the
|
|
180
|
+
// wrapper numbered 0 — and east-c records the same (the corpus pins it).
|
|
181
|
+
const TreeType = RecursiveType((tree) => VariantType({ leaf: IntegerType, node: StructType({ left: tree, right: tree }) }));
|
|
182
|
+
const type = ArrayType(TreeType);
|
|
183
|
+
const dir = directory();
|
|
184
|
+
const writer = new Beast2ManifestWriter(type, dir.sink);
|
|
185
|
+
writer.add(variant("node", { left: variant("leaf", 1n), right: variant("leaf", 2n) }));
|
|
186
|
+
writer.finish();
|
|
187
|
+
const recorded = decodeCollectionManifest(dir.manifest()).type;
|
|
188
|
+
assert.ok(isTypeValueEqual(recorded, toEastTypeValue(type)));
|
|
189
|
+
const wrapper = recorded.value.value.value;
|
|
190
|
+
assert.equal(wrapper.id, 0n);
|
|
191
|
+
});
|
|
192
|
+
test("writes what a merge writes as a manifest directory", () => {
|
|
193
|
+
// Two interleaved halves of the Dict, merged, are the Dict.
|
|
194
|
+
const half = (parity) => encodeBeast2PagedFor(DictSI)(new SortedMap([...dict.entries()].filter((_, i) => i % 2 === parity), compareFor(StringType)));
|
|
195
|
+
const merged = directory();
|
|
196
|
+
const stats = mergeBeast2For(DictSI)([half(0), half(1)], merged.sink);
|
|
197
|
+
assert.equal(stats.entries, dict.size);
|
|
198
|
+
const whole = directory();
|
|
199
|
+
const writer = new Beast2ManifestWriter(DictSI, whole.sink);
|
|
200
|
+
for (const entry of dict.entries())
|
|
201
|
+
writer.add(entry);
|
|
202
|
+
writer.finish();
|
|
203
|
+
assert.deepEqual(merged.manifest(), whole.manifest());
|
|
204
|
+
assert.deepEqual(merged.objects, whole.objects);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
//# sourceMappingURL=manifest-writer.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest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EAAE;YAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The segment manifest: a collection held as N standalone segment blobs plus
|
|
7
|
+
* a small object naming them in order.
|
|
8
|
+
*
|
|
9
|
+
* A v5 collection blob is already `header · tag · segment frames · terminator ·
|
|
10
|
+
* index · footer`, and each segment frame is a self-contained piece of the
|
|
11
|
+
* canonical value. A manifest takes the last step and lets each segment be its
|
|
12
|
+
* own blob, so a store can address them individually: equal values then name
|
|
13
|
+
* equal segments, a one-row edit re-cuts one of them, and two values diff by
|
|
14
|
+
* comparing hashes rather than by decoding anything.
|
|
15
|
+
*
|
|
16
|
+
* This type lives here, beside the container it describes, because **every
|
|
17
|
+
* runtime must read it**. A task input staged as a manifest is one file naming
|
|
18
|
+
* sibling segment files, and a body that iterates it, or reads one key from it,
|
|
19
|
+
* pays for the segments it touches rather than for a splice of the whole value
|
|
20
|
+
* — which is the difference between a 2 GB input costing 2 GB and costing the
|
|
21
|
+
* rows it reads. {@link Beast2ManifestSource} is what a reader hands
|
|
22
|
+
* {@link Beast2Pages} to get that.
|
|
23
|
+
*
|
|
24
|
+
* Nothing about the manifest changes what a segment is, so any reader in any
|
|
25
|
+
* runtime still opens a segment blob on its own, and splicing the segments
|
|
26
|
+
* back under their shared header reproduces the single-blob form exactly.
|
|
27
|
+
*/
|
|
28
|
+
import { ArrayType, BlobType, IntegerType, StringType, StructType, type ValueTypeOf } from "../../../types.js";
|
|
29
|
+
import { type EastTypeValue } from "../../../type_of_type.js";
|
|
30
|
+
import { type Beast2SyncRangeReader } from "./range.js";
|
|
31
|
+
/** The `kind` tag every segment manifest carries — what tells a reader that an
|
|
32
|
+
* object naming other objects describes a collection, and the handle a
|
|
33
|
+
* garbage collector recognizes it by. */
|
|
34
|
+
export declare const COLLECTION_MANIFEST_KIND = "$segments";
|
|
35
|
+
/** One entry of a {@link CollectionManifestType}: a segment blob at level 0, a
|
|
36
|
+
* child manifest above it. */
|
|
37
|
+
export declare const CollectionManifestEntryType: StructType<{
|
|
38
|
+
/** The segment (or child manifest) object's content hash. */
|
|
39
|
+
readonly hash: StringType;
|
|
40
|
+
/** The entry's first key, in the canonical bare encoding
|
|
41
|
+
* `encodeBeast2FenceFor` produces; empty for an Array root, which has no
|
|
42
|
+
* key order to bisect. */
|
|
43
|
+
readonly fence: BlobType;
|
|
44
|
+
/** Elements (pairs, for a Dict root) in the segment or subtree. */
|
|
45
|
+
readonly count: IntegerType;
|
|
46
|
+
/** The object's size in bytes, so a reader budgets without a stat. */
|
|
47
|
+
readonly bytes: IntegerType;
|
|
48
|
+
}>;
|
|
49
|
+
export type CollectionManifestEntryType = typeof CollectionManifestEntryType;
|
|
50
|
+
export type CollectionManifestEntry = ValueTypeOf<typeof CollectionManifestEntryType>;
|
|
51
|
+
/**
|
|
52
|
+
* A collection's manifest: the value an object holds in place of the blob when
|
|
53
|
+
* the collection is stored as segment objects.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* `level` and the nesting it allows are carried from the first version on
|
|
57
|
+
* purpose. Struct encoding is positional, so a field appended later is another
|
|
58
|
+
* dual-decode tier on every reader in three runtimes — and a second index
|
|
59
|
+
* level is exactly what a manifest too large to hold whole would need. The
|
|
60
|
+
* byte is paid now.
|
|
61
|
+
*/
|
|
62
|
+
export declare const CollectionManifestType: StructType<{
|
|
63
|
+
/** Always {@link COLLECTION_MANIFEST_KIND}. */
|
|
64
|
+
readonly kind: StringType;
|
|
65
|
+
/** `0` when entries name segment blobs; `n` when they name level `n - 1`
|
|
66
|
+
* manifests. */
|
|
67
|
+
readonly level: IntegerType;
|
|
68
|
+
/** The root collection type — the manifest is self-describing about what it
|
|
69
|
+
* holds, exactly as a blob's type section is. */
|
|
70
|
+
readonly type: import("../../../types.js").RecursiveType<import("../../../types.js").VariantType<{
|
|
71
|
+
readonly Never: import("../../../types.js").NullType;
|
|
72
|
+
readonly Null: import("../../../types.js").NullType;
|
|
73
|
+
readonly Boolean: import("../../../types.js").NullType;
|
|
74
|
+
readonly Integer: import("../../../types.js").NullType;
|
|
75
|
+
readonly Float: import("../../../types.js").NullType;
|
|
76
|
+
readonly String: import("../../../types.js").NullType;
|
|
77
|
+
readonly DateTime: import("../../../types.js").NullType;
|
|
78
|
+
readonly Blob: import("../../../types.js").NullType;
|
|
79
|
+
readonly Ref: import("../../../types.js").RecursiveTypeMarker;
|
|
80
|
+
readonly Array: import("../../../types.js").RecursiveTypeMarker;
|
|
81
|
+
readonly Set: import("../../../types.js").RecursiveTypeMarker;
|
|
82
|
+
readonly Dict: StructType<{
|
|
83
|
+
readonly key: import("../../../types.js").RecursiveTypeMarker;
|
|
84
|
+
readonly value: import("../../../types.js").RecursiveTypeMarker;
|
|
85
|
+
}>;
|
|
86
|
+
readonly Struct: ArrayType<StructType<{
|
|
87
|
+
readonly name: StringType;
|
|
88
|
+
readonly type: import("../../../types.js").RecursiveTypeMarker;
|
|
89
|
+
}>>;
|
|
90
|
+
readonly Variant: ArrayType<StructType<{
|
|
91
|
+
readonly name: StringType;
|
|
92
|
+
readonly type: import("../../../types.js").RecursiveTypeMarker;
|
|
93
|
+
}>>;
|
|
94
|
+
readonly Recursive: import("../../../types.js").VariantType<{
|
|
95
|
+
readonly ref: IntegerType;
|
|
96
|
+
readonly wrapper: StructType<{
|
|
97
|
+
readonly id: IntegerType;
|
|
98
|
+
readonly inner: import("../../../types.js").RecursiveTypeMarker;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
readonly Function: StructType<{
|
|
102
|
+
readonly inputs: ArrayType<import("../../../types.js").RecursiveTypeMarker>;
|
|
103
|
+
readonly output: import("../../../types.js").RecursiveTypeMarker;
|
|
104
|
+
}>;
|
|
105
|
+
readonly AsyncFunction: StructType<{
|
|
106
|
+
readonly inputs: ArrayType<import("../../../types.js").RecursiveTypeMarker>;
|
|
107
|
+
readonly output: import("../../../types.js").RecursiveTypeMarker;
|
|
108
|
+
}>;
|
|
109
|
+
readonly Vector: import("../../../types.js").RecursiveTypeMarker;
|
|
110
|
+
readonly Matrix: import("../../../types.js").RecursiveTypeMarker;
|
|
111
|
+
}>>;
|
|
112
|
+
/** The boundary-rule id the segments were cut under (`segmentRuleFor`), so a
|
|
113
|
+
* reader knows whether they are cut the way this build cuts. */
|
|
114
|
+
readonly rule: StringType;
|
|
115
|
+
/** Hash of the canonical header bytes every segment is written under — what
|
|
116
|
+
* makes the segments spliceable into one blob. */
|
|
117
|
+
readonly header: StringType;
|
|
118
|
+
/** The segments, in canonical order. */
|
|
119
|
+
readonly entries: ArrayType<StructType<{
|
|
120
|
+
/** The segment (or child manifest) object's content hash. */
|
|
121
|
+
readonly hash: StringType;
|
|
122
|
+
/** The entry's first key, in the canonical bare encoding
|
|
123
|
+
* `encodeBeast2FenceFor` produces; empty for an Array root, which has no
|
|
124
|
+
* key order to bisect. */
|
|
125
|
+
readonly fence: BlobType;
|
|
126
|
+
/** Elements (pairs, for a Dict root) in the segment or subtree. */
|
|
127
|
+
readonly count: IntegerType;
|
|
128
|
+
/** The object's size in bytes, so a reader budgets without a stat. */
|
|
129
|
+
readonly bytes: IntegerType;
|
|
130
|
+
}>>;
|
|
131
|
+
}>;
|
|
132
|
+
export type CollectionManifestType = typeof CollectionManifestType;
|
|
133
|
+
export type CollectionManifest = ValueTypeOf<typeof CollectionManifestType>;
|
|
134
|
+
/**
|
|
135
|
+
* Whether a decoded object's root type is a {@link CollectionManifestType}.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Matched on the **exact** field set. Arbitrary user values flow through the
|
|
139
|
+
* same dispatch — a record's state is any struct the author chose — and a
|
|
140
|
+
* name-subset match would classify one as a manifest and read its fields as
|
|
141
|
+
* object hashes. The `kind` field is checked separately, after a decode, by
|
|
142
|
+
* {@link isCollectionManifest}.
|
|
143
|
+
*
|
|
144
|
+
* @param typeValue - the object's decoded root type
|
|
145
|
+
* @returns whether the type is exactly the manifest struct
|
|
146
|
+
*/
|
|
147
|
+
export declare function isCollectionManifestType(typeValue: EastTypeValue): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Whether a decoded value is a segment manifest — its type is the manifest
|
|
150
|
+
* struct and its `kind` is {@link COLLECTION_MANIFEST_KIND}.
|
|
151
|
+
*
|
|
152
|
+
* @param typeValue - the object's decoded root type
|
|
153
|
+
* @param value - the decoded value
|
|
154
|
+
* @returns whether the object is a manifest
|
|
155
|
+
*/
|
|
156
|
+
export declare function isCollectionManifest(typeValue: EastTypeValue, value: unknown): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Encodes a segment manifest.
|
|
159
|
+
*
|
|
160
|
+
* @param manifest - the manifest
|
|
161
|
+
* @returns the beast2 bytes
|
|
162
|
+
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* The collection type is written with its recursive types renamed
|
|
165
|
+
* canonically ({@link canonicalTypeValue}): the ids a runtime gives them are
|
|
166
|
+
* its own, and a manifest's hash names the collection in a store, so one
|
|
167
|
+
* collection must have one manifest whichever runtime writes it.
|
|
168
|
+
*/
|
|
169
|
+
export declare function encodeCollectionManifest(manifest: CollectionManifest): Uint8Array;
|
|
170
|
+
/**
|
|
171
|
+
* Decodes a segment manifest.
|
|
172
|
+
*
|
|
173
|
+
* @param data - the stored bytes
|
|
174
|
+
* @returns the manifest
|
|
175
|
+
* @throws {Error} When the bytes are not a manifest, or its `kind` is not
|
|
176
|
+
* {@link COLLECTION_MANIFEST_KIND} — a struct of the right shape carrying
|
|
177
|
+
* another tag is a different object that must not be read as segments.
|
|
178
|
+
*/
|
|
179
|
+
export declare function decodeCollectionManifest(data: Uint8Array): CollectionManifest;
|
|
180
|
+
/**
|
|
181
|
+
* The total element (pair) count a manifest describes.
|
|
182
|
+
*
|
|
183
|
+
* @param manifest - the manifest
|
|
184
|
+
* @returns the sum of its entries' counts
|
|
185
|
+
*/
|
|
186
|
+
export declare function manifestElementCount(manifest: CollectionManifest): number;
|
|
187
|
+
/**
|
|
188
|
+
* The total byte size of the segment objects a manifest names.
|
|
189
|
+
*
|
|
190
|
+
* @param manifest - the manifest
|
|
191
|
+
* @returns the sum of its entries' byte sizes
|
|
192
|
+
*/
|
|
193
|
+
export declare function manifestByteSize(manifest: CollectionManifest): number;
|
|
194
|
+
/**
|
|
195
|
+
* The manifest a blob holds, or `null` when it holds something else.
|
|
196
|
+
*
|
|
197
|
+
* @remarks
|
|
198
|
+
* Costs one head read through a ranged source: a blob declares its root type up
|
|
199
|
+
* front, and a manifest is recognized by that type's exact field set, so
|
|
200
|
+
* nothing more is read for a blob that turns out to be a value.
|
|
201
|
+
*
|
|
202
|
+
* @param source - the blob, or ranged access to it
|
|
203
|
+
* @returns the decoded manifest, or `null`
|
|
204
|
+
*/
|
|
205
|
+
export declare function readBeast2Manifest(source: Uint8Array | Beast2SyncRangeReader): CollectionManifest | null;
|
|
206
|
+
/**
|
|
207
|
+
* A collection presented to a reader as its manifest plus access to each
|
|
208
|
+
* segment — the form {@link Beast2Pages} opens when the segments are separate
|
|
209
|
+
* blobs rather than runs of one.
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* The reader never asks for a segment it does not decode, and never asks for a
|
|
213
|
+
* fence at all: a manifest carries every fence already, so a keyed read is one
|
|
214
|
+
* bisect over decoded keys and one segment. That is what makes a keyed read of
|
|
215
|
+
* a 1.5-million-entry input cost one segment on every runtime.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const source: Beast2ManifestSource = {
|
|
220
|
+
* manifest,
|
|
221
|
+
* segment: (i) => readFileSync(`${path}.segments/${manifest.entries[i].hash}.beast2`),
|
|
222
|
+
* };
|
|
223
|
+
* const rows = openBeast2LazyFor(manifest.type, { frozen: true })(source);
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
export interface Beast2ManifestSource {
|
|
227
|
+
/** The manifest describing the collection. */
|
|
228
|
+
readonly manifest: CollectionManifest;
|
|
229
|
+
/**
|
|
230
|
+
* Segment `i`'s standalone blob — its bytes, or ranged access to them.
|
|
231
|
+
*
|
|
232
|
+
* @param i - zero-based segment index
|
|
233
|
+
* @returns the segment blob
|
|
234
|
+
*/
|
|
235
|
+
segment(i: number): Uint8Array | Beast2SyncRangeReader;
|
|
236
|
+
}
|
|
237
|
+
/** Whether `source` is a {@link Beast2ManifestSource} rather than a blob or a
|
|
238
|
+
* range reader — judged by shape, since a value from another realm fails
|
|
239
|
+
* `instanceof`. */
|
|
240
|
+
export declare function isBeast2ManifestSource(source: unknown): source is Beast2ManifestSource;
|
|
241
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/manifest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,UAAU,EACV,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAqD,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIjH,OAAO,EAAsC,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE5F;;0CAE0C;AAC1C,eAAO,MAAM,wBAAwB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