@graphty/graph-format 0.0.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +216 -43
- package/dist/graph-format.d.ts +1 -0
- package/dist/graph-format.d.ts.map +1 -0
- package/dist/graph-format.js +15798 -0
- package/dist/graph-format.js.map +1 -0
- package/dist/src/builder/arena.d.ts +85 -0
- package/dist/src/builder/arena.d.ts.map +1 -0
- package/dist/src/builder/arena.js +154 -0
- package/dist/src/builder/arena.js.map +1 -0
- package/dist/src/builder/compact.d.ts +515 -0
- package/dist/src/builder/compact.d.ts.map +1 -0
- package/dist/src/builder/compact.js +1553 -0
- package/dist/src/builder/compact.js.map +1 -0
- package/dist/src/builder/counting-sort.d.ts +96 -0
- package/dist/src/builder/counting-sort.d.ts.map +1 -0
- package/dist/src/builder/counting-sort.js +430 -0
- package/dist/src/builder/counting-sort.js.map +1 -0
- package/dist/src/builder/freeze.d.ts +72 -0
- package/dist/src/builder/freeze.d.ts.map +1 -0
- package/dist/src/builder/freeze.js +548 -0
- package/dist/src/builder/freeze.js.map +1 -0
- package/dist/src/builder/graph-builder.d.ts +602 -0
- package/dist/src/builder/graph-builder.d.ts.map +1 -0
- package/dist/src/builder/graph-builder.js +1940 -0
- package/dist/src/builder/graph-builder.js.map +1 -0
- package/dist/src/builder/options.d.ts +16 -0
- package/dist/src/builder/options.d.ts.map +1 -0
- package/dist/src/builder/options.js +21 -0
- package/dist/src/builder/options.js.map +1 -0
- package/dist/src/columns/bitmap.d.ts +96 -0
- package/dist/src/columns/bitmap.d.ts.map +1 -0
- package/dist/src/columns/bitmap.js +184 -0
- package/dist/src/columns/bitmap.js.map +1 -0
- package/dist/src/columns/column.d.ts +220 -0
- package/dist/src/columns/column.d.ts.map +1 -0
- package/dist/src/columns/column.js +2109 -0
- package/dist/src/columns/column.js.map +1 -0
- package/dist/src/columns/dictionary.d.ts +60 -0
- package/dist/src/columns/dictionary.d.ts.map +1 -0
- package/dist/src/columns/dictionary.js +102 -0
- package/dist/src/columns/dictionary.js.map +1 -0
- package/dist/src/columns/growable.d.ts +198 -0
- package/dist/src/columns/growable.d.ts.map +1 -0
- package/dist/src/columns/growable.js +296 -0
- package/dist/src/columns/growable.js.map +1 -0
- package/dist/src/columns/infer.d.ts +121 -0
- package/dist/src/columns/infer.d.ts.map +1 -0
- package/dist/src/columns/infer.js +268 -0
- package/dist/src/columns/infer.js.map +1 -0
- package/dist/src/columns/remap.d.ts +143 -0
- package/dist/src/columns/remap.d.ts.map +1 -0
- package/dist/src/columns/remap.js +588 -0
- package/dist/src/columns/remap.js.map +1 -0
- package/dist/src/columns/table.d.ts +184 -0
- package/dist/src/columns/table.d.ts.map +1 -0
- package/dist/src/columns/table.js +485 -0
- package/dist/src/columns/table.js.map +1 -0
- package/dist/src/constants.d.ts +34 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +79 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/errors.d.ts +76 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +32 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/ids/edge-id-index.d.ts +77 -0
- package/dist/src/ids/edge-id-index.d.ts.map +1 -0
- package/dist/src/ids/edge-id-index.js +155 -0
- package/dist/src/ids/edge-id-index.js.map +1 -0
- package/dist/src/ids/node-id-map.d.ts +280 -0
- package/dist/src/ids/node-id-map.d.ts.map +1 -0
- package/dist/src/ids/node-id-map.js +1139 -0
- package/dist/src/ids/node-id-map.js.map +1 -0
- package/dist/src/ids/string-store.d.ts +219 -0
- package/dist/src/ids/string-store.d.ts.map +1 -0
- package/dist/src/ids/string-store.js +526 -0
- package/dist/src/ids/string-store.js.map +1 -0
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/populate/from-csr.d.ts +61 -0
- package/dist/src/populate/from-csr.d.ts.map +1 -0
- package/dist/src/populate/from-csr.js +706 -0
- package/dist/src/populate/from-csr.js.map +1 -0
- package/dist/src/populate/from-edge-arrays.d.ts +51 -0
- package/dist/src/populate/from-edge-arrays.d.ts.map +1 -0
- package/dist/src/populate/from-edge-arrays.js +217 -0
- package/dist/src/populate/from-edge-arrays.js.map +1 -0
- package/dist/src/populate/from-records.d.ts +51 -0
- package/dist/src/populate/from-records.d.ts.map +1 -0
- package/dist/src/populate/from-records.js +447 -0
- package/dist/src/populate/from-records.js.map +1 -0
- package/dist/src/snapshot/derived.d.ts +211 -0
- package/dist/src/snapshot/derived.d.ts.map +1 -0
- package/dist/src/snapshot/derived.js +1254 -0
- package/dist/src/snapshot/derived.js.map +1 -0
- package/dist/src/snapshot/graph-meta.d.ts +23 -0
- package/dist/src/snapshot/graph-meta.d.ts.map +1 -0
- package/dist/src/snapshot/graph-meta.js +159 -0
- package/dist/src/snapshot/graph-meta.js.map +1 -0
- package/dist/src/snapshot/graph-snapshot.d.ts +509 -0
- package/dist/src/snapshot/graph-snapshot.d.ts.map +1 -0
- package/dist/src/snapshot/graph-snapshot.js +1247 -0
- package/dist/src/snapshot/graph-snapshot.js.map +1 -0
- package/dist/src/snapshot/hash.d.ts +90 -0
- package/dist/src/snapshot/hash.d.ts.map +1 -0
- package/dist/src/snapshot/hash.js +228 -0
- package/dist/src/snapshot/hash.js.map +1 -0
- package/dist/src/snapshot/queries.d.ts +74 -0
- package/dist/src/snapshot/queries.d.ts.map +1 -0
- package/dist/src/snapshot/queries.js +131 -0
- package/dist/src/snapshot/queries.js.map +1 -0
- package/dist/src/snapshot/validate.d.ts +192 -0
- package/dist/src/snapshot/validate.d.ts.map +1 -0
- package/dist/src/snapshot/validate.js +990 -0
- package/dist/src/snapshot/validate.js.map +1 -0
- package/dist/src/snapshot/views.d.ts +274 -0
- package/dist/src/snapshot/views.d.ts.map +1 -0
- package/dist/src/snapshot/views.js +856 -0
- package/dist/src/snapshot/views.js.map +1 -0
- package/dist/src/types/builder.d.ts +456 -0
- package/dist/src/types/builder.d.ts.map +1 -0
- package/dist/src/types/builder.js +11 -0
- package/dist/src/types/builder.js.map +1 -0
- package/dist/src/types/columns.d.ts +615 -0
- package/dist/src/types/columns.d.ts.map +1 -0
- package/dist/src/types/columns.js +14 -0
- package/dist/src/types/columns.js.map +1 -0
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +11 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/internal.d.ts +172 -0
- package/dist/src/types/internal.d.ts.map +1 -0
- package/dist/src/types/internal.js +13 -0
- package/dist/src/types/internal.js.map +1 -0
- package/dist/src/types/snapshot.d.ts +801 -0
- package/dist/src/types/snapshot.d.ts.map +1 -0
- package/dist/src/types/snapshot.js +14 -0
- package/dist/src/types/snapshot.js.map +1 -0
- package/dist/src/types/wire.d.ts +196 -0
- package/dist/src/types/wire.d.ts.map +1 -0
- package/dist/src/types/wire.js +8 -0
- package/dist/src/types/wire.js.map +1 -0
- package/dist/src/util/mask.d.ts +55 -0
- package/dist/src/util/mask.d.ts.map +1 -0
- package/dist/src/util/mask.js +71 -0
- package/dist/src/util/mask.js.map +1 -0
- package/dist/src/util/options.d.ts +22 -0
- package/dist/src/util/options.d.ts.map +1 -0
- package/dist/src/util/options.js +49 -0
- package/dist/src/util/options.js.map +1 -0
- package/dist/src/util/shared-buffers.d.ts +42 -0
- package/dist/src/util/shared-buffers.d.ts.map +1 -0
- package/dist/src/util/shared-buffers.js +52 -0
- package/dist/src/util/shared-buffers.js.map +1 -0
- package/dist/src/util/typed-array.d.ts +205 -0
- package/dist/src/util/typed-array.d.ts.map +1 -0
- package/dist/src/util/typed-array.js +289 -0
- package/dist/src/util/typed-array.js.map +1 -0
- package/dist/src/wire/bytes.d.ts +69 -0
- package/dist/src/wire/bytes.d.ts.map +1 -0
- package/dist/src/wire/bytes.js +361 -0
- package/dist/src/wire/bytes.js.map +1 -0
- package/dist/src/wire/carried-views.d.ts +111 -0
- package/dist/src/wire/carried-views.d.ts.map +1 -0
- package/dist/src/wire/carried-views.js +286 -0
- package/dist/src/wire/carried-views.js.map +1 -0
- package/dist/src/wire/from-wire.d.ts +144 -0
- package/dist/src/wire/from-wire.d.ts.map +1 -0
- package/dist/src/wire/from-wire.js +1425 -0
- package/dist/src/wire/from-wire.js.map +1 -0
- package/dist/src/wire/to-wire.d.ts +171 -0
- package/dist/src/wire/to-wire.d.ts.map +1 -0
- package/dist/src/wire/to-wire.js +652 -0
- package/dist/src/wire/to-wire.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +72 -7
- package/src/builder/arena.ts +192 -0
- package/src/builder/compact.ts +1811 -0
- package/src/builder/counting-sort.ts +506 -0
- package/src/builder/freeze.ts +689 -0
- package/src/builder/graph-builder.ts +2264 -0
- package/src/builder/options.ts +29 -0
- package/src/columns/bitmap.ts +196 -0
- package/src/columns/column.ts +2574 -0
- package/src/columns/dictionary.ts +114 -0
- package/src/columns/growable.ts +350 -0
- package/src/columns/infer.ts +285 -0
- package/src/columns/remap.ts +663 -0
- package/src/columns/table.ts +568 -0
- package/src/constants.ts +89 -0
- package/src/errors.ts +115 -0
- package/src/ids/edge-id-index.ts +179 -0
- package/src/ids/node-id-map.ts +1340 -0
- package/src/ids/string-store.ts +589 -0
- package/src/index.ts +139 -0
- package/src/lib-resizable-array-buffer.d.ts +34 -0
- package/src/populate/from-csr.ts +802 -0
- package/src/populate/from-edge-arrays.ts +257 -0
- package/src/populate/from-records.ts +536 -0
- package/src/snapshot/derived.ts +1486 -0
- package/src/snapshot/graph-meta.ts +167 -0
- package/src/snapshot/graph-snapshot.ts +1503 -0
- package/src/snapshot/hash.ts +241 -0
- package/src/snapshot/queries.ts +136 -0
- package/src/snapshot/validate.ts +1108 -0
- package/src/snapshot/views.ts +943 -0
- package/src/types/builder.ts +480 -0
- package/src/types/columns.ts +727 -0
- package/src/types/index.ts +14 -0
- package/src/types/internal.ts +195 -0
- package/src/types/snapshot.ts +886 -0
- package/src/types/wire.ts +207 -0
- package/src/util/mask.ts +89 -0
- package/src/util/options.ts +57 -0
- package/src/util/shared-buffers.ts +56 -0
- package/src/util/typed-array.ts +371 -0
- package/src/wire/bytes.ts +440 -0
- package/src/wire/carried-views.ts +327 -0
- package/src/wire/from-wire.ts +1690 -0
- package/src/wire/to-wire.ts +755 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../src/columns/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAiBhD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACH,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,YAAY,GACf,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,IAAa;IACnC,OAAO,CACH,IAAI,YAAY,WAAW;QAC3B,IAAI,YAAY,UAAU;QAC1B,IAAI,YAAY,YAAY;QAC5B,IAAI,YAAY,YAAY;QAC5B,IAAI,YAAY,UAAU,CAC7B,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,IAAa;IAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7F,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,SAAS,GAAG,IAA6D,CAAC;IA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CAAC,KAAK,CAAC,GAAG,CAAC;aAC3B,CACJ,CAAC;QACN,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvB,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAqB;IACrD,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QACzB,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-wide constants of @graphty/graph-format (design sections 2, 3.2, 9.2, 10.3 and 12.2).
|
|
3
|
+
*
|
|
4
|
+
* The four constants listed in design section 12.2 (INVALID_INDEX, MAX_COUNT, FORMAT_VERSION and
|
|
5
|
+
* SNAPSHOT_BRAND) are public and re-exported by src/index.ts. The remaining constants are shared by
|
|
6
|
+
* the builder, arena and wire modules but are not part of the public surface.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The one and only "no index" sentinel: 0xFFFFFFFF. Used for node, edge and arc indices alike, both as
|
|
10
|
+
* a JS return value (indexOf, findArc, edgeIndexOf, nodeColumn, edgeColumn, codeOf) and inside
|
|
11
|
+
* Uint32Array vectors (remaps, parents, labels). It never appears in rowPtr, colIdx, arcToEdge,
|
|
12
|
+
* edgeToArc or any view array (invariant I2), and because every count is bounded by MAX_COUNT it can
|
|
13
|
+
* never collide with a valid index (invariant I3).
|
|
14
|
+
*/
|
|
15
|
+
export declare const INVALID_INDEX = 4294967295;
|
|
16
|
+
/**
|
|
17
|
+
* Upper bound on nodeCount, edgeCount and arcCount: 0xFFFFFFFE (invariant I3). Crossing it at an add*
|
|
18
|
+
* call throws E_TOO_LARGE. One below INVALID_INDEX so the sentinel is always free.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_COUNT = 4294967294;
|
|
21
|
+
/**
|
|
22
|
+
* The data-model major version carried by every snapshot as `formatVersion` and compared by
|
|
23
|
+
* isGraphSnapshot(), fromWire() and fromBytes() (design section 13.5). A mismatch is
|
|
24
|
+
* E_UNSUPPORTED_VERSION with details.kind "format". It bumps only when the meaning of an invariant, a
|
|
25
|
+
* field, a flag or a sentinel changes.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FORMAT_VERSION = 1;
|
|
28
|
+
/**
|
|
29
|
+
* Brand property read by isGraphSnapshot() (design section 7.5). It is a Symbol.for() symbol rather
|
|
30
|
+
* than a private one so that two copies of the package inside one application still recognise each
|
|
31
|
+
* other's snapshots structurally, without instanceof.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SNAPSHOT_BRAND: unique symbol;
|
|
34
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,aAAa,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,MAAqD,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-wide constants of @graphty/graph-format (design sections 2, 3.2, 9.2, 10.3 and 12.2).
|
|
3
|
+
*
|
|
4
|
+
* The four constants listed in design section 12.2 (INVALID_INDEX, MAX_COUNT, FORMAT_VERSION and
|
|
5
|
+
* SNAPSHOT_BRAND) are public and re-exported by src/index.ts. The remaining constants are shared by
|
|
6
|
+
* the builder, arena and wire modules but are not part of the public surface.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The one and only "no index" sentinel: 0xFFFFFFFF. Used for node, edge and arc indices alike, both as
|
|
10
|
+
* a JS return value (indexOf, findArc, edgeIndexOf, nodeColumn, edgeColumn, codeOf) and inside
|
|
11
|
+
* Uint32Array vectors (remaps, parents, labels). It never appears in rowPtr, colIdx, arcToEdge,
|
|
12
|
+
* edgeToArc or any view array (invariant I2), and because every count is bounded by MAX_COUNT it can
|
|
13
|
+
* never collide with a valid index (invariant I3).
|
|
14
|
+
*/
|
|
15
|
+
export const INVALID_INDEX = 0xffffffff;
|
|
16
|
+
/**
|
|
17
|
+
* Upper bound on nodeCount, edgeCount and arcCount: 0xFFFFFFFE (invariant I3). Crossing it at an add*
|
|
18
|
+
* call throws E_TOO_LARGE. One below INVALID_INDEX so the sentinel is always free.
|
|
19
|
+
*/
|
|
20
|
+
export const MAX_COUNT = 0xfffffffe;
|
|
21
|
+
/**
|
|
22
|
+
* The data-model major version carried by every snapshot as `formatVersion` and compared by
|
|
23
|
+
* isGraphSnapshot(), fromWire() and fromBytes() (design section 13.5). A mismatch is
|
|
24
|
+
* E_UNSUPPORTED_VERSION with details.kind "format". It bumps only when the meaning of an invariant, a
|
|
25
|
+
* field, a flag or a sentinel changes.
|
|
26
|
+
*/
|
|
27
|
+
export const FORMAT_VERSION = 1;
|
|
28
|
+
/**
|
|
29
|
+
* Brand property read by isGraphSnapshot() (design section 7.5). It is a Symbol.for() symbol rather
|
|
30
|
+
* than a private one so that two copies of the package inside one application still recognise each
|
|
31
|
+
* other's snapshots structurally, without instanceof.
|
|
32
|
+
*/
|
|
33
|
+
export const SNAPSHOT_BRAND = Symbol.for("@graphty/graph-format/snapshot");
|
|
34
|
+
/**
|
|
35
|
+
* Alignment, in bytes, of every core-array segment inside the arena and of every segment inside the
|
|
36
|
+
* GSNP byte container (design sections 9.2 and 10.3). It is WebGPU's minStorageBufferOffsetAlignment
|
|
37
|
+
* default, so each segment can be bound as a storage buffer window without copying.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export const ALIGNMENT = 256;
|
|
41
|
+
/**
|
|
42
|
+
* Whether this host stores multi-byte integers little-endian, computed once at module load. Every
|
|
43
|
+
* supported platform (x86-64, ARM64, WebAssembly) is little-endian; on a big-endian host toBytes() and
|
|
44
|
+
* toWire() throw E_UNSUPPORTED with details.reason "big-endian host" so that no file is ever written
|
|
45
|
+
* that other hosts would reject (design section 9.2).
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export const IS_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
49
|
+
/**
|
|
50
|
+
* Wire major version written into the GSNP container header and the manifest (design section 9.2).
|
|
51
|
+
* A reader refuses any other major with E_UNSUPPORTED_VERSION (details.kind "wire").
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export const WIRE_MAJOR = 1;
|
|
55
|
+
/**
|
|
56
|
+
* Wire minor version written into the GSNP container header and the manifest (design section 9.2).
|
|
57
|
+
* Minors are additive: older readers ignore unknown manifest fields. Wire 1.0 tags non-finite
|
|
58
|
+
* numbers as `{ "$num": ... }` and wraps a JSON object whose only key is a tag name as
|
|
59
|
+
* `{ "$esc": ... }` (design section 5.9).
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
export const WIRE_MINOR = 0;
|
|
63
|
+
/**
|
|
64
|
+
* The manifest `format` discriminator of a WireManifest (design section 9.1).
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export const WIRE_FORMAT = "graphty-snapshot";
|
|
68
|
+
/**
|
|
69
|
+
* The four magic bytes at the start of a GSNP byte container: "GSNP" in ASCII (design section 9.2).
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export const CONTAINER_MAGIC = [0x47, 0x53, 0x4e, 0x50];
|
|
73
|
+
/**
|
|
74
|
+
* The u32 value written through a host-order Uint32Array at container offset 8 so a reader can detect
|
|
75
|
+
* an endianness mismatch (design section 9.2): a little-endian reader sees the bytes 04 03 02 01.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
export const ENDIAN_PROBE = 0x01020304;
|
|
79
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAY,IAAI,UAAU,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAE9F;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAE5B;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA8C,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEnG;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error class and the closed set of error codes of @graphty/graph-format (design section 11).
|
|
3
|
+
*
|
|
4
|
+
* Policy (design section 11.1): the builder and the constructors throw on malformed input, on the
|
|
5
|
+
* first error, with a GraphFormatError carrying a stable `code`; snapshot methods that take an index
|
|
6
|
+
* are total for in-range arguments and unchecked otherwise; only GraphFormatError instances are ever
|
|
7
|
+
* thrown by this package. Messages are plain ASCII and name the offending index, id or value when it
|
|
8
|
+
* is a number or a short string. ImportError (code E_IMPORT) is declared by @graphty/graph-io.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The closed union of error codes a GraphFormatError can carry (design section 11.2). Each code is
|
|
12
|
+
* stable across versions and is the value consumers branch on; the message is for humans.
|
|
13
|
+
*
|
|
14
|
+
* - E_INVALID_ID: NaN, a non-finite number, a bigint, an object, null, undefined or a string with a
|
|
15
|
+
* lone surrogate used as an id (details.reason "lone surrogate").
|
|
16
|
+
* - E_UNKNOWN_NODE: addEdge with addMissingNodes false, addEdgeByIndex with a dead or out-of-range
|
|
17
|
+
* index (details.index), or a requireIndex miss.
|
|
18
|
+
* - E_INDEX_RANGE: ids.idOf / table.value out of range; inducedSubgraph with a repeated or
|
|
19
|
+
* out-of-range index.
|
|
20
|
+
* - E_TOO_LARGE: nodeCount, edgeCount or arcCount would exceed MAX_COUNT.
|
|
21
|
+
* - E_INVALID_WEIGHT: a NaN weight at addEdge / setEdgeWeight / addEdges.
|
|
22
|
+
* - E_DIRECTED: mate() on a directed snapshot; setDirected() refused (locked, or a change the edge
|
|
23
|
+
* set does not allow).
|
|
24
|
+
* - E_SELF_LOOP: a self-loop under selfLoops "error".
|
|
25
|
+
* - E_DUPLICATE_EDGE: a parallel edge under duplicateEdges "error" (details source, target, edges).
|
|
26
|
+
* - E_DUPLICATE_EDGE_ID: a unique role "id" edge column violated (both edge indices in details).
|
|
27
|
+
* - E_DUPLICATE_ID: a unique node column violated; addGraph with onDuplicateNode "error"; a
|
|
28
|
+
* repeated id in the `ids` array or F64 given to fromEdgeArrays / fromCsr.
|
|
29
|
+
* - E_DUPLICATE_ROLE: two columns with the same role in one table.
|
|
30
|
+
* - E_UNKNOWN_COLUMN: require() of an absent column.
|
|
31
|
+
* - E_COLUMN_TYPE: requireTyped() dtype mismatch; a non-JSON default / fill / options / extra value
|
|
32
|
+
* (details.field); a string value with a lone surrogate.
|
|
33
|
+
* - E_COLUMN_LENGTH: set() with data.length !== rowCount * components.
|
|
34
|
+
* - E_COLUMN_ALIGNMENT: a u8 array without a constructible padded u32 view under adopt "strict".
|
|
35
|
+
* - E_COLUMN_EXISTS: declareNodeColumn / declareEdgeColumn twice with a different declaration.
|
|
36
|
+
* - E_COLUMN_IMMUTABLE: mutableData() / markDirty() / mutableValidity() / setAll() on an immutable
|
|
37
|
+
* column.
|
|
38
|
+
* - E_NO_DEFAULT: materializeDefault() on a column without a declared default.
|
|
39
|
+
* - E_PARTITION: contract() partition of the wrong length or holding INVALID_INDEX.
|
|
40
|
+
* - E_INVALID_PERMUTATION: relabel() with a perm that is not a permutation of 0..n-1.
|
|
41
|
+
* - E_MASK_LENGTH: filterEdges() / inducedSubgraph({ mask }) with a short mask.
|
|
42
|
+
* - E_GPU_INELIGIBLE: gpuView() / paddedU32View() on a string, list or json column.
|
|
43
|
+
* - E_INVALID_SNAPSHOT: validate() failure (details.invariant, row / arc / edge / column) or
|
|
44
|
+
* validate({ checksum: true }) on a snapshot without recorded checksums (details.reason
|
|
45
|
+
* "no-checksum").
|
|
46
|
+
* - E_BAD_SERIALIZATION: bad magic, endianness probe, manifest or buffer reference (details.ref).
|
|
47
|
+
* - E_UNSUPPORTED_VERSION: unknown wire major or formatVersion (details.kind "wire" | "format",
|
|
48
|
+
* details.found, details.supported).
|
|
49
|
+
* - E_DETACHED: a core accessor after a consuming transfer.
|
|
50
|
+
* - E_BUILDER_DISPOSED: any call on a disposed builder.
|
|
51
|
+
* - E_UNSUPPORTED: big-endian host (details.reason); unknown wire dtype (details.dtype) or id-map
|
|
52
|
+
* kind (details.kind).
|
|
53
|
+
* - E_IMPORT: reserved for @graphty/graph-io's ImportError.
|
|
54
|
+
*/
|
|
55
|
+
export type GraphFormatErrorCode = "E_INVALID_ID" | "E_UNKNOWN_NODE" | "E_INDEX_RANGE" | "E_TOO_LARGE" | "E_INVALID_WEIGHT" | "E_DIRECTED" | "E_SELF_LOOP" | "E_DUPLICATE_EDGE" | "E_DUPLICATE_EDGE_ID" | "E_DUPLICATE_ID" | "E_DUPLICATE_ROLE" | "E_UNKNOWN_COLUMN" | "E_COLUMN_TYPE" | "E_COLUMN_LENGTH" | "E_COLUMN_ALIGNMENT" | "E_COLUMN_EXISTS" | "E_COLUMN_IMMUTABLE" | "E_NO_DEFAULT" | "E_PARTITION" | "E_INVALID_PERMUTATION" | "E_MASK_LENGTH" | "E_GPU_INELIGIBLE" | "E_INVALID_SNAPSHOT" | "E_BAD_SERIALIZATION" | "E_UNSUPPORTED_VERSION" | "E_DETACHED" | "E_BUILDER_DISPOSED" | "E_UNSUPPORTED" | "E_IMPORT";
|
|
56
|
+
/**
|
|
57
|
+
* The only error type this package throws (design section 11.2). `code` is the stable, programmatic
|
|
58
|
+
* discriminator; `details` carries the machine-readable context named per code in the
|
|
59
|
+
* GraphFormatErrorCode documentation (index, id, edge, invariant, row, found, supported, ...) as a
|
|
60
|
+
* frozen shallow copy of what the thrower supplied. `name` is "GraphFormatError" so stack traces and
|
|
61
|
+
* test matchers read naturally.
|
|
62
|
+
*/
|
|
63
|
+
export declare class GraphFormatError extends Error {
|
|
64
|
+
/** The stable error code (design section 11.2). */
|
|
65
|
+
readonly code: GraphFormatErrorCode;
|
|
66
|
+
/** Machine-readable context for the failure; an empty frozen object when none was supplied. */
|
|
67
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a GraphFormatError.
|
|
70
|
+
* @param code - the stable error code the caller can branch on
|
|
71
|
+
* @param message - a plain-ASCII human-readable message naming the offending index, id or value
|
|
72
|
+
* @param details - optional machine-readable context; copied shallowly and frozen
|
|
73
|
+
*/
|
|
74
|
+
constructor(code: GraphFormatErrorCode, message: string, details?: Readonly<Record<string, unknown>>);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,oBAAoB,GAC1B,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,kBAAkB,GAClB,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,qBAAqB,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,GACf,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,oBAAoB,GACpB,cAAc,GACd,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,kBAAkB,GAClB,oBAAoB,GACpB,qBAAqB,GACrB,uBAAuB,GACvB,YAAY,GACZ,oBAAoB,GACpB,eAAe,GACf,UAAU,CAAC;AAIjB;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACvC,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAEpC,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEpD;;;;;OAKG;gBACS,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAMvG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error class and the closed set of error codes of @graphty/graph-format (design section 11).
|
|
3
|
+
*
|
|
4
|
+
* Policy (design section 11.1): the builder and the constructors throw on malformed input, on the
|
|
5
|
+
* first error, with a GraphFormatError carrying a stable `code`; snapshot methods that take an index
|
|
6
|
+
* are total for in-range arguments and unchecked otherwise; only GraphFormatError instances are ever
|
|
7
|
+
* thrown by this package. Messages are plain ASCII and name the offending index, id or value when it
|
|
8
|
+
* is a number or a short string. ImportError (code E_IMPORT) is declared by @graphty/graph-io.
|
|
9
|
+
*/
|
|
10
|
+
const EMPTY_DETAILS = Object.freeze({});
|
|
11
|
+
/**
|
|
12
|
+
* The only error type this package throws (design section 11.2). `code` is the stable, programmatic
|
|
13
|
+
* discriminator; `details` carries the machine-readable context named per code in the
|
|
14
|
+
* GraphFormatErrorCode documentation (index, id, edge, invariant, row, found, supported, ...) as a
|
|
15
|
+
* frozen shallow copy of what the thrower supplied. `name` is "GraphFormatError" so stack traces and
|
|
16
|
+
* test matchers read naturally.
|
|
17
|
+
*/
|
|
18
|
+
export class GraphFormatError extends Error {
|
|
19
|
+
/**
|
|
20
|
+
* Create a GraphFormatError.
|
|
21
|
+
* @param code - the stable error code the caller can branch on
|
|
22
|
+
* @param message - a plain-ASCII human-readable message naming the offending index, id or value
|
|
23
|
+
* @param details - optional machine-readable context; copied shallowly and frozen
|
|
24
|
+
*/
|
|
25
|
+
constructor(code, message, details) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "GraphFormatError";
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.details = details === undefined ? EMPTY_DETAILS : Object.freeze({ ...details });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8EH,MAAM,aAAa,GAAsC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAOvC;;;;;OAKG;IACH,YAAY,IAA0B,EAAE,OAAe,EAAE,OAA2C;QAChG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;CACJ"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge ids are optional data, not structure (design section 4.6): an edge column with role "id"
|
|
3
|
+
* (dtype string, dict, u32 or f64 in practice; any scalar numeric dtype is read the same way) holds
|
|
4
|
+
* them, importers declare it `unique: true`, and `snapshot.edgeIndexOf(id)` resolves an id through
|
|
5
|
+
* a Map built lazily on the first call. This module owns that lazy index and the uniqueness check
|
|
6
|
+
* freeze runs over the SET rows of a unique id column (E_DUPLICATE_EDGE_ID with both edge indices).
|
|
7
|
+
* Equality is SameValueZero (a JS Map key), the same rule as node ids.
|
|
8
|
+
*/
|
|
9
|
+
import { type Column, type EdgeId } from "../types/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* The id stored in one SET row of an edge id column: the decoded string of a string column, the
|
|
12
|
+
* dictionary value of a dict column, or the (first component of the) number of a numeric column.
|
|
13
|
+
* The caller has checked `column.isSet(row)`.
|
|
14
|
+
* @param column - the id column
|
|
15
|
+
* @param row - a set row
|
|
16
|
+
* @returns the id
|
|
17
|
+
*/
|
|
18
|
+
export declare function edgeIdOfRow(column: Column, row: number): EdgeId;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a column's dtype can hold edge ids (string, dict or a scalar numeric dtype).
|
|
21
|
+
* @param column - the column
|
|
22
|
+
* @returns true when edgeIdOfRow can read it
|
|
23
|
+
*/
|
|
24
|
+
export declare function canHoldEdgeIds(column: Column): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Build the id -> edge index map of an id column over its SET rows in one pass. When an id repeats
|
|
27
|
+
* the lowest edge index wins (a unique column never repeats; `findDuplicateEdgeId` reports it).
|
|
28
|
+
* @param column - the edge id column
|
|
29
|
+
* @returns a fresh Map from id to logical edge index
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildEdgeIdMap(column: Column): Map<EdgeId, number>;
|
|
32
|
+
/**
|
|
33
|
+
* The lazily built index behind `snapshot.edgeIndexOf(id)` (design section 4.6): a Map from id to
|
|
34
|
+
* logical edge index over the set rows of the role "id" edge column, built on the first lookup and
|
|
35
|
+
* rebuilt when a mutable column's `version` has changed since.
|
|
36
|
+
*/
|
|
37
|
+
export declare class EdgeIdIndex {
|
|
38
|
+
/** The edge id column. */
|
|
39
|
+
private readonly column;
|
|
40
|
+
/** The map, or null before the first lookup. */
|
|
41
|
+
private map;
|
|
42
|
+
/** column.version when the map was built. */
|
|
43
|
+
private builtVersion;
|
|
44
|
+
/**
|
|
45
|
+
* Wrap an edge id column; nothing is built until the first lookup.
|
|
46
|
+
* @param column - the edge column with role "id"; E_COLUMN_TYPE when its dtype cannot hold ids
|
|
47
|
+
*/
|
|
48
|
+
constructor(column: Column);
|
|
49
|
+
/**
|
|
50
|
+
* Whether the map has been built (and is current).
|
|
51
|
+
* @returns true when the next lookup will not build
|
|
52
|
+
*/
|
|
53
|
+
get built(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Number of distinct ids over the set rows; builds the map.
|
|
56
|
+
* @returns the id count
|
|
57
|
+
*/
|
|
58
|
+
get size(): number;
|
|
59
|
+
/**
|
|
60
|
+
* The logical edge index of an id.
|
|
61
|
+
* @param id - the edge id
|
|
62
|
+
* @returns the edge index, or INVALID_INDEX on a miss
|
|
63
|
+
*/
|
|
64
|
+
indexOf(id: EdgeId): number;
|
|
65
|
+
/**
|
|
66
|
+
* Whether an id is present.
|
|
67
|
+
* @param id - the edge id
|
|
68
|
+
* @returns true when some set row holds it
|
|
69
|
+
*/
|
|
70
|
+
has(id: EdgeId): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The map, built on first use and rebuilt after the column's version changed.
|
|
73
|
+
* @returns the id -> edge index map
|
|
74
|
+
*/
|
|
75
|
+
private ensure;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=edge-id-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-id-index.d.ts","sourceRoot":"","sources":["../../../src/ids/edge-id-index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAe7D;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAmB/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAiBtD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBlE;AAED;;;;GAIG;AACH,qBAAa,WAAW;IACpB,0BAA0B;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,gDAAgD;IAChD,OAAO,CAAC,GAAG,CAA6B;IAExC,6CAA6C;IAC7C,OAAO,CAAC,YAAY,CAAS;IAE7B;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAS1B;;;OAGG;IACH,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAK3B;;;;OAIG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB;;;OAGG;IACH,OAAO,CAAC,MAAM;CAQjB"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge ids are optional data, not structure (design section 4.6): an edge column with role "id"
|
|
3
|
+
* (dtype string, dict, u32 or f64 in practice; any scalar numeric dtype is read the same way) holds
|
|
4
|
+
* them, importers declare it `unique: true`, and `snapshot.edgeIndexOf(id)` resolves an id through
|
|
5
|
+
* a Map built lazily on the first call. This module owns that lazy index and the uniqueness check
|
|
6
|
+
* freeze runs over the SET rows of a unique id column (E_DUPLICATE_EDGE_ID with both edge indices).
|
|
7
|
+
* Equality is SameValueZero (a JS Map key), the same rule as node ids.
|
|
8
|
+
*/
|
|
9
|
+
import { INVALID_INDEX } from "../constants.js";
|
|
10
|
+
import { GraphFormatError } from "../errors.js";
|
|
11
|
+
/**
|
|
12
|
+
* The E_COLUMN_TYPE error for a column whose dtype cannot hold edge ids.
|
|
13
|
+
* @param column - the column
|
|
14
|
+
* @returns the error
|
|
15
|
+
*/
|
|
16
|
+
function unsupportedDtype(column) {
|
|
17
|
+
return new GraphFormatError("E_COLUMN_TYPE", `column ${JSON.stringify(column.meta.name)} of dtype ${column.dtype} cannot hold edge ids`, { column: column.meta.name, dtype: column.dtype, reason: "edge id dtype" });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The id stored in one SET row of an edge id column: the decoded string of a string column, the
|
|
21
|
+
* dictionary value of a dict column, or the (first component of the) number of a numeric column.
|
|
22
|
+
* The caller has checked `column.isSet(row)`.
|
|
23
|
+
* @param column - the id column
|
|
24
|
+
* @param row - a set row
|
|
25
|
+
* @returns the id
|
|
26
|
+
*/
|
|
27
|
+
export function edgeIdOfRow(column, row) {
|
|
28
|
+
switch (column.dtype) {
|
|
29
|
+
case "string":
|
|
30
|
+
return column.valueAt(row);
|
|
31
|
+
case "dict":
|
|
32
|
+
return column.dictionary[column.codes[row]];
|
|
33
|
+
case "f32":
|
|
34
|
+
case "f64":
|
|
35
|
+
case "i32":
|
|
36
|
+
case "u32":
|
|
37
|
+
case "u8":
|
|
38
|
+
return column.data[row * column.meta.components];
|
|
39
|
+
case "bool":
|
|
40
|
+
case "list":
|
|
41
|
+
case "json":
|
|
42
|
+
throw unsupportedDtype(column);
|
|
43
|
+
default:
|
|
44
|
+
throw unsupportedDtype(column);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether a column's dtype can hold edge ids (string, dict or a scalar numeric dtype).
|
|
49
|
+
* @param column - the column
|
|
50
|
+
* @returns true when edgeIdOfRow can read it
|
|
51
|
+
*/
|
|
52
|
+
export function canHoldEdgeIds(column) {
|
|
53
|
+
switch (column.dtype) {
|
|
54
|
+
case "string":
|
|
55
|
+
case "dict":
|
|
56
|
+
case "f32":
|
|
57
|
+
case "f64":
|
|
58
|
+
case "i32":
|
|
59
|
+
case "u32":
|
|
60
|
+
case "u8":
|
|
61
|
+
return true;
|
|
62
|
+
case "bool":
|
|
63
|
+
case "list":
|
|
64
|
+
case "json":
|
|
65
|
+
return false;
|
|
66
|
+
default:
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build the id -> edge index map of an id column over its SET rows in one pass. When an id repeats
|
|
72
|
+
* the lowest edge index wins (a unique column never repeats; `findDuplicateEdgeId` reports it).
|
|
73
|
+
* @param column - the edge id column
|
|
74
|
+
* @returns a fresh Map from id to logical edge index
|
|
75
|
+
*/
|
|
76
|
+
export function buildEdgeIdMap(column) {
|
|
77
|
+
if (!canHoldEdgeIds(column)) {
|
|
78
|
+
throw unsupportedDtype(column);
|
|
79
|
+
}
|
|
80
|
+
const map = new Map();
|
|
81
|
+
const rows = column.length;
|
|
82
|
+
for (let e = 0; e < rows; e++) {
|
|
83
|
+
if (!column.isSet(e)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const id = edgeIdOfRow(column, e);
|
|
87
|
+
if (!map.has(id)) {
|
|
88
|
+
map.set(id, e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return map;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The lazily built index behind `snapshot.edgeIndexOf(id)` (design section 4.6): a Map from id to
|
|
95
|
+
* logical edge index over the set rows of the role "id" edge column, built on the first lookup and
|
|
96
|
+
* rebuilt when a mutable column's `version` has changed since.
|
|
97
|
+
*/
|
|
98
|
+
export class EdgeIdIndex {
|
|
99
|
+
/**
|
|
100
|
+
* Wrap an edge id column; nothing is built until the first lookup.
|
|
101
|
+
* @param column - the edge column with role "id"; E_COLUMN_TYPE when its dtype cannot hold ids
|
|
102
|
+
*/
|
|
103
|
+
constructor(column) {
|
|
104
|
+
if (!canHoldEdgeIds(column)) {
|
|
105
|
+
throw unsupportedDtype(column);
|
|
106
|
+
}
|
|
107
|
+
this.column = column;
|
|
108
|
+
this.map = null;
|
|
109
|
+
this.builtVersion = -1;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether the map has been built (and is current).
|
|
113
|
+
* @returns true when the next lookup will not build
|
|
114
|
+
*/
|
|
115
|
+
get built() {
|
|
116
|
+
return this.map !== null && this.builtVersion === this.column.version;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Number of distinct ids over the set rows; builds the map.
|
|
120
|
+
* @returns the id count
|
|
121
|
+
*/
|
|
122
|
+
get size() {
|
|
123
|
+
return this.ensure().size;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The logical edge index of an id.
|
|
127
|
+
* @param id - the edge id
|
|
128
|
+
* @returns the edge index, or INVALID_INDEX on a miss
|
|
129
|
+
*/
|
|
130
|
+
indexOf(id) {
|
|
131
|
+
const index = this.ensure().get(id);
|
|
132
|
+
return index === undefined ? INVALID_INDEX : index;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Whether an id is present.
|
|
136
|
+
* @param id - the edge id
|
|
137
|
+
* @returns true when some set row holds it
|
|
138
|
+
*/
|
|
139
|
+
has(id) {
|
|
140
|
+
return this.ensure().has(id);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The map, built on first use and rebuilt after the column's version changed.
|
|
144
|
+
* @returns the id -> edge index map
|
|
145
|
+
*/
|
|
146
|
+
ensure() {
|
|
147
|
+
const { version } = this.column;
|
|
148
|
+
if (this.map === null || this.builtVersion !== version) {
|
|
149
|
+
this.map = buildEdgeIdMap(this.column);
|
|
150
|
+
this.builtVersion = version;
|
|
151
|
+
}
|
|
152
|
+
return this.map;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=edge-id-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-id-index.js","sourceRoot":"","sources":["../../../src/ids/edge-id-index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,MAAc;IACpC,OAAO,IAAI,gBAAgB,CACvB,eAAe,EACf,UAAU,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,KAAK,uBAAuB,EAC1F,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAC7E,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,GAAW;IACnD,QAAQ,MAAM,CAAC,KAAK,EAAE,CAAC;QACnB,KAAK,QAAQ;YACT,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,KAAK,MAAM;YACP,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAChD,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,IAAI;YACL,OAAO,MAAM,CAAC,IA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