@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.
Files changed (224) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -43
  3. package/dist/graph-format.d.ts +1 -0
  4. package/dist/graph-format.d.ts.map +1 -0
  5. package/dist/graph-format.js +15798 -0
  6. package/dist/graph-format.js.map +1 -0
  7. package/dist/src/builder/arena.d.ts +85 -0
  8. package/dist/src/builder/arena.d.ts.map +1 -0
  9. package/dist/src/builder/arena.js +154 -0
  10. package/dist/src/builder/arena.js.map +1 -0
  11. package/dist/src/builder/compact.d.ts +515 -0
  12. package/dist/src/builder/compact.d.ts.map +1 -0
  13. package/dist/src/builder/compact.js +1553 -0
  14. package/dist/src/builder/compact.js.map +1 -0
  15. package/dist/src/builder/counting-sort.d.ts +96 -0
  16. package/dist/src/builder/counting-sort.d.ts.map +1 -0
  17. package/dist/src/builder/counting-sort.js +430 -0
  18. package/dist/src/builder/counting-sort.js.map +1 -0
  19. package/dist/src/builder/freeze.d.ts +72 -0
  20. package/dist/src/builder/freeze.d.ts.map +1 -0
  21. package/dist/src/builder/freeze.js +548 -0
  22. package/dist/src/builder/freeze.js.map +1 -0
  23. package/dist/src/builder/graph-builder.d.ts +602 -0
  24. package/dist/src/builder/graph-builder.d.ts.map +1 -0
  25. package/dist/src/builder/graph-builder.js +1940 -0
  26. package/dist/src/builder/graph-builder.js.map +1 -0
  27. package/dist/src/builder/options.d.ts +16 -0
  28. package/dist/src/builder/options.d.ts.map +1 -0
  29. package/dist/src/builder/options.js +21 -0
  30. package/dist/src/builder/options.js.map +1 -0
  31. package/dist/src/columns/bitmap.d.ts +96 -0
  32. package/dist/src/columns/bitmap.d.ts.map +1 -0
  33. package/dist/src/columns/bitmap.js +184 -0
  34. package/dist/src/columns/bitmap.js.map +1 -0
  35. package/dist/src/columns/column.d.ts +220 -0
  36. package/dist/src/columns/column.d.ts.map +1 -0
  37. package/dist/src/columns/column.js +2109 -0
  38. package/dist/src/columns/column.js.map +1 -0
  39. package/dist/src/columns/dictionary.d.ts +60 -0
  40. package/dist/src/columns/dictionary.d.ts.map +1 -0
  41. package/dist/src/columns/dictionary.js +102 -0
  42. package/dist/src/columns/dictionary.js.map +1 -0
  43. package/dist/src/columns/growable.d.ts +198 -0
  44. package/dist/src/columns/growable.d.ts.map +1 -0
  45. package/dist/src/columns/growable.js +296 -0
  46. package/dist/src/columns/growable.js.map +1 -0
  47. package/dist/src/columns/infer.d.ts +121 -0
  48. package/dist/src/columns/infer.d.ts.map +1 -0
  49. package/dist/src/columns/infer.js +268 -0
  50. package/dist/src/columns/infer.js.map +1 -0
  51. package/dist/src/columns/remap.d.ts +143 -0
  52. package/dist/src/columns/remap.d.ts.map +1 -0
  53. package/dist/src/columns/remap.js +588 -0
  54. package/dist/src/columns/remap.js.map +1 -0
  55. package/dist/src/columns/table.d.ts +184 -0
  56. package/dist/src/columns/table.d.ts.map +1 -0
  57. package/dist/src/columns/table.js +485 -0
  58. package/dist/src/columns/table.js.map +1 -0
  59. package/dist/src/constants.d.ts +34 -0
  60. package/dist/src/constants.d.ts.map +1 -0
  61. package/dist/src/constants.js +79 -0
  62. package/dist/src/constants.js.map +1 -0
  63. package/dist/src/errors.d.ts +76 -0
  64. package/dist/src/errors.d.ts.map +1 -0
  65. package/dist/src/errors.js +32 -0
  66. package/dist/src/errors.js.map +1 -0
  67. package/dist/src/ids/edge-id-index.d.ts +77 -0
  68. package/dist/src/ids/edge-id-index.d.ts.map +1 -0
  69. package/dist/src/ids/edge-id-index.js +155 -0
  70. package/dist/src/ids/edge-id-index.js.map +1 -0
  71. package/dist/src/ids/node-id-map.d.ts +280 -0
  72. package/dist/src/ids/node-id-map.d.ts.map +1 -0
  73. package/dist/src/ids/node-id-map.js +1139 -0
  74. package/dist/src/ids/node-id-map.js.map +1 -0
  75. package/dist/src/ids/string-store.d.ts +219 -0
  76. package/dist/src/ids/string-store.d.ts.map +1 -0
  77. package/dist/src/ids/string-store.js +526 -0
  78. package/dist/src/ids/string-store.js.map +1 -0
  79. package/dist/src/index.d.ts +30 -0
  80. package/dist/src/index.d.ts.map +1 -0
  81. package/dist/src/index.js +29 -0
  82. package/dist/src/index.js.map +1 -0
  83. package/dist/src/populate/from-csr.d.ts +61 -0
  84. package/dist/src/populate/from-csr.d.ts.map +1 -0
  85. package/dist/src/populate/from-csr.js +706 -0
  86. package/dist/src/populate/from-csr.js.map +1 -0
  87. package/dist/src/populate/from-edge-arrays.d.ts +51 -0
  88. package/dist/src/populate/from-edge-arrays.d.ts.map +1 -0
  89. package/dist/src/populate/from-edge-arrays.js +217 -0
  90. package/dist/src/populate/from-edge-arrays.js.map +1 -0
  91. package/dist/src/populate/from-records.d.ts +51 -0
  92. package/dist/src/populate/from-records.d.ts.map +1 -0
  93. package/dist/src/populate/from-records.js +447 -0
  94. package/dist/src/populate/from-records.js.map +1 -0
  95. package/dist/src/snapshot/derived.d.ts +211 -0
  96. package/dist/src/snapshot/derived.d.ts.map +1 -0
  97. package/dist/src/snapshot/derived.js +1254 -0
  98. package/dist/src/snapshot/derived.js.map +1 -0
  99. package/dist/src/snapshot/graph-meta.d.ts +23 -0
  100. package/dist/src/snapshot/graph-meta.d.ts.map +1 -0
  101. package/dist/src/snapshot/graph-meta.js +159 -0
  102. package/dist/src/snapshot/graph-meta.js.map +1 -0
  103. package/dist/src/snapshot/graph-snapshot.d.ts +509 -0
  104. package/dist/src/snapshot/graph-snapshot.d.ts.map +1 -0
  105. package/dist/src/snapshot/graph-snapshot.js +1247 -0
  106. package/dist/src/snapshot/graph-snapshot.js.map +1 -0
  107. package/dist/src/snapshot/hash.d.ts +90 -0
  108. package/dist/src/snapshot/hash.d.ts.map +1 -0
  109. package/dist/src/snapshot/hash.js +228 -0
  110. package/dist/src/snapshot/hash.js.map +1 -0
  111. package/dist/src/snapshot/queries.d.ts +74 -0
  112. package/dist/src/snapshot/queries.d.ts.map +1 -0
  113. package/dist/src/snapshot/queries.js +131 -0
  114. package/dist/src/snapshot/queries.js.map +1 -0
  115. package/dist/src/snapshot/validate.d.ts +192 -0
  116. package/dist/src/snapshot/validate.d.ts.map +1 -0
  117. package/dist/src/snapshot/validate.js +990 -0
  118. package/dist/src/snapshot/validate.js.map +1 -0
  119. package/dist/src/snapshot/views.d.ts +274 -0
  120. package/dist/src/snapshot/views.d.ts.map +1 -0
  121. package/dist/src/snapshot/views.js +856 -0
  122. package/dist/src/snapshot/views.js.map +1 -0
  123. package/dist/src/types/builder.d.ts +456 -0
  124. package/dist/src/types/builder.d.ts.map +1 -0
  125. package/dist/src/types/builder.js +11 -0
  126. package/dist/src/types/builder.js.map +1 -0
  127. package/dist/src/types/columns.d.ts +615 -0
  128. package/dist/src/types/columns.d.ts.map +1 -0
  129. package/dist/src/types/columns.js +14 -0
  130. package/dist/src/types/columns.js.map +1 -0
  131. package/dist/src/types/index.d.ts +14 -0
  132. package/dist/src/types/index.d.ts.map +1 -0
  133. package/dist/src/types/index.js +11 -0
  134. package/dist/src/types/index.js.map +1 -0
  135. package/dist/src/types/internal.d.ts +172 -0
  136. package/dist/src/types/internal.d.ts.map +1 -0
  137. package/dist/src/types/internal.js +13 -0
  138. package/dist/src/types/internal.js.map +1 -0
  139. package/dist/src/types/snapshot.d.ts +801 -0
  140. package/dist/src/types/snapshot.d.ts.map +1 -0
  141. package/dist/src/types/snapshot.js +14 -0
  142. package/dist/src/types/snapshot.js.map +1 -0
  143. package/dist/src/types/wire.d.ts +196 -0
  144. package/dist/src/types/wire.d.ts.map +1 -0
  145. package/dist/src/types/wire.js +8 -0
  146. package/dist/src/types/wire.js.map +1 -0
  147. package/dist/src/util/mask.d.ts +55 -0
  148. package/dist/src/util/mask.d.ts.map +1 -0
  149. package/dist/src/util/mask.js +71 -0
  150. package/dist/src/util/mask.js.map +1 -0
  151. package/dist/src/util/options.d.ts +22 -0
  152. package/dist/src/util/options.d.ts.map +1 -0
  153. package/dist/src/util/options.js +49 -0
  154. package/dist/src/util/options.js.map +1 -0
  155. package/dist/src/util/shared-buffers.d.ts +42 -0
  156. package/dist/src/util/shared-buffers.d.ts.map +1 -0
  157. package/dist/src/util/shared-buffers.js +52 -0
  158. package/dist/src/util/shared-buffers.js.map +1 -0
  159. package/dist/src/util/typed-array.d.ts +205 -0
  160. package/dist/src/util/typed-array.d.ts.map +1 -0
  161. package/dist/src/util/typed-array.js +289 -0
  162. package/dist/src/util/typed-array.js.map +1 -0
  163. package/dist/src/wire/bytes.d.ts +69 -0
  164. package/dist/src/wire/bytes.d.ts.map +1 -0
  165. package/dist/src/wire/bytes.js +361 -0
  166. package/dist/src/wire/bytes.js.map +1 -0
  167. package/dist/src/wire/carried-views.d.ts +111 -0
  168. package/dist/src/wire/carried-views.d.ts.map +1 -0
  169. package/dist/src/wire/carried-views.js +286 -0
  170. package/dist/src/wire/carried-views.js.map +1 -0
  171. package/dist/src/wire/from-wire.d.ts +144 -0
  172. package/dist/src/wire/from-wire.d.ts.map +1 -0
  173. package/dist/src/wire/from-wire.js +1425 -0
  174. package/dist/src/wire/from-wire.js.map +1 -0
  175. package/dist/src/wire/to-wire.d.ts +171 -0
  176. package/dist/src/wire/to-wire.d.ts.map +1 -0
  177. package/dist/src/wire/to-wire.js +652 -0
  178. package/dist/src/wire/to-wire.js.map +1 -0
  179. package/dist/tsconfig.build.tsbuildinfo +1 -0
  180. package/package.json +72 -7
  181. package/src/builder/arena.ts +192 -0
  182. package/src/builder/compact.ts +1811 -0
  183. package/src/builder/counting-sort.ts +506 -0
  184. package/src/builder/freeze.ts +689 -0
  185. package/src/builder/graph-builder.ts +2264 -0
  186. package/src/builder/options.ts +29 -0
  187. package/src/columns/bitmap.ts +196 -0
  188. package/src/columns/column.ts +2574 -0
  189. package/src/columns/dictionary.ts +114 -0
  190. package/src/columns/growable.ts +350 -0
  191. package/src/columns/infer.ts +285 -0
  192. package/src/columns/remap.ts +663 -0
  193. package/src/columns/table.ts +568 -0
  194. package/src/constants.ts +89 -0
  195. package/src/errors.ts +115 -0
  196. package/src/ids/edge-id-index.ts +179 -0
  197. package/src/ids/node-id-map.ts +1340 -0
  198. package/src/ids/string-store.ts +589 -0
  199. package/src/index.ts +139 -0
  200. package/src/lib-resizable-array-buffer.d.ts +34 -0
  201. package/src/populate/from-csr.ts +802 -0
  202. package/src/populate/from-edge-arrays.ts +257 -0
  203. package/src/populate/from-records.ts +536 -0
  204. package/src/snapshot/derived.ts +1486 -0
  205. package/src/snapshot/graph-meta.ts +167 -0
  206. package/src/snapshot/graph-snapshot.ts +1503 -0
  207. package/src/snapshot/hash.ts +241 -0
  208. package/src/snapshot/queries.ts +136 -0
  209. package/src/snapshot/validate.ts +1108 -0
  210. package/src/snapshot/views.ts +943 -0
  211. package/src/types/builder.ts +480 -0
  212. package/src/types/columns.ts +727 -0
  213. package/src/types/index.ts +14 -0
  214. package/src/types/internal.ts +195 -0
  215. package/src/types/snapshot.ts +886 -0
  216. package/src/types/wire.ts +207 -0
  217. package/src/util/mask.ts +89 -0
  218. package/src/util/options.ts +57 -0
  219. package/src/util/shared-buffers.ts +56 -0
  220. package/src/util/typed-array.ts +371 -0
  221. package/src/wire/bytes.ts +440 -0
  222. package/src/wire/carried-views.ts +327 -0
  223. package/src/wire/from-wire.ts +1690 -0
  224. package/src/wire/to-wire.ts +755 -0
@@ -0,0 +1,652 @@
1
+ /**
2
+ * The wire encoder (design sections 4.5, 5.9, 9.1 and 12.2): `toWire()` turns a snapshot into a
3
+ * JSON-serialisable manifest plus a list of ArrayBuffers, `transferables()` lists the exclusively
4
+ * owned buffers a worker hand-off may transfer, and the segment collector shared with the GSNP
5
+ * container writer of bytes.ts lays every typed array out as a WireBufferRef.
6
+ *
7
+ * Two layouts exist. In REFERENCE mode (toWire) every distinct backing ArrayBuffer becomes one entry
8
+ * of `buffers` and a reference carries the array's own byteOffset, so the core stays views over the
9
+ * arena (one buffer) and nothing is copied unless `transfer: true` meets a shared buffer. In
10
+ * CONTAINER mode (toBytes / toByteChunks) every array is placed at a 256-byte-aligned offset of one
11
+ * buffer region in manifest order, core arrays first so the region's prefix is the arena.
12
+ *
13
+ * toWire allocates nothing for typed data except the first materialisation of a lazily kept
14
+ * representation: the Utf8 store of string ids and string columns and the f64 / tag arrays of a
15
+ * numeric or mixed id map are cached by their owners, the encoded dictionaries and the JSON text of
16
+ * json columns are cached here. Non-finite numbers and -0 inside metadata are carried as the tagged
17
+ * strings of design section 5.9 so the manifest survives JSON.stringify unchanged.
18
+ */
19
+ import { CORE_ORDER } from "../builder/arena.js";
20
+ import { isPlainObject } from "../columns/column.js";
21
+ import { ALIGNMENT, FORMAT_VERSION, IS_LITTLE_ENDIAN, WIRE_FORMAT, WIRE_MAJOR, WIRE_MINOR } from "../constants.js";
22
+ import { GraphFormatError } from "../errors.js";
23
+ import { NodeIdMap, nodeIdMapToTyped } from "../ids/node-id-map.js";
24
+ import { encodeUtf8Rows } from "../ids/string-store.js";
25
+ import { peekView } from "../snapshot/graph-snapshot.js";
26
+ import { viewArrays } from "../snapshot/views.js";
27
+ import { isShared, noteShared } from "../util/shared-buffers.js";
28
+ import { alignUp } from "../util/typed-array.js";
29
+ // ============================================================ constants
30
+ /**
31
+ * The `producer` string written into every manifest (design section 9.1): the package name and its
32
+ * npm version. Golden fixtures mask it when compared. Bumped together with package.json.
33
+ */
34
+ export const WIRE_PRODUCER = "@graphty/graph-format@0.1.0";
35
+ /** The views the wire carries when named by includeViews; the scalar views are never carried. */
36
+ const SCALAR_VIEWS = new Set(["totalWeight", "symmetric"]);
37
+ /** The core arrays in arena order (design section 10.3). */
38
+ const encoder = new TextEncoder();
39
+ // ============================================================ host endianness
40
+ /**
41
+ * Refuse to emit wire data on a big-endian host (design section 9.2): every supported platform is
42
+ * little-endian and there is no byte-swapping reader, so a big-endian host must never produce a file
43
+ * other hosts reject. The parameter exists so the refusal path is testable on a little-endian host.
44
+ * @param littleEndian - whether the host is little-endian; defaults to the detected value
45
+ */
46
+ export function assertLittleEndianHost(littleEndian = IS_LITTLE_ENDIAN) {
47
+ if (!littleEndian) {
48
+ throw new GraphFormatError("E_UNSUPPORTED", "the wire format cannot be written on a big-endian host", {
49
+ reason: "big-endian host",
50
+ });
51
+ }
52
+ }
53
+ // ============================================================ shared-buffer bookkeeping (9.1)
54
+ // ============================================================ JSON tagging (5.9)
55
+ /** The tag key of a non-finite or negative-zero number on the wire. */
56
+ const NUM_TAG = "$num";
57
+ const ESC_TAG = "$esc";
58
+ /**
59
+ * Encode a JSON value for the manifest (design section 5.9): `Infinity`, `-Infinity`, `NaN` and `-0`
60
+ * become `{ "$num": "..." }`, arrays and plain objects are copied recursively, everything else is
61
+ * returned as is. A user object whose ONLY key is `$num` or `$esc` would collide with the tags, so
62
+ * it is wrapped as `{ "$esc": { ...the object... } }` and unwrapped by the reader.
63
+ * The input has already passed assertJsonValue (design section 5.9), so no other shape can occur.
64
+ * @param value - the JSON value
65
+ * @returns the tagged copy
66
+ */
67
+ export function encodeJsonValue(value) {
68
+ if (typeof value === "number") {
69
+ if (Number.isNaN(value)) {
70
+ return { [NUM_TAG]: "NaN" };
71
+ }
72
+ if (value === Infinity) {
73
+ return { [NUM_TAG]: "Infinity" };
74
+ }
75
+ if (value === -Infinity) {
76
+ return { [NUM_TAG]: "-Infinity" };
77
+ }
78
+ if (Object.is(value, -0)) {
79
+ return { [NUM_TAG]: "-0" };
80
+ }
81
+ return value;
82
+ }
83
+ if (Array.isArray(value)) {
84
+ return value.map((item) => encodeJsonValue(item));
85
+ }
86
+ if (isPlainObject(value)) {
87
+ const keys = Object.keys(value);
88
+ const out = {};
89
+ for (const key of keys) {
90
+ defineJsonKey(out, key, encodeJsonValue(value[key]));
91
+ }
92
+ if (keys.length === 1 && (keys[0] === NUM_TAG || keys[0] === ESC_TAG)) {
93
+ return { [ESC_TAG]: out };
94
+ }
95
+ return out;
96
+ }
97
+ return value;
98
+ }
99
+ /**
100
+ * Add an own enumerable property to a plain object without going through a setter, so a key such as
101
+ * "__proto__" stays a data property (the manifest reader rejects it anyway).
102
+ * @param target - the object
103
+ * @param key - the property name
104
+ * @param value - the value
105
+ */
106
+ export function defineJsonKey(target, key, value) {
107
+ Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
108
+ }
109
+ /**
110
+ * Collects typed arrays into WireBufferRefs (design sections 9.1 and 9.2). In reference mode
111
+ * `buffers` is the list of distinct backing buffers (a shared buffer copied under `transfer`, its
112
+ * index recorded in `copied`); in container mode `segments` is the placement of every distinct array
113
+ * at a 256-aligned offset and `regionLength` the padded length of the region.
114
+ */
115
+ export class WireLayout {
116
+ /**
117
+ * Create a collector.
118
+ * @param mode - reference (toWire) or container (toBytes)
119
+ * @param transfer - reference mode only: copy shared buffers so the others can be transferred
120
+ */
121
+ constructor(mode, transfer = false) {
122
+ /** Reference mode: the distinct buffers, or their copies. */
123
+ this.buffers = [];
124
+ /** Reference mode: the indices of `buffers` holding copies of shared buffers. */
125
+ this.copied = [];
126
+ /** Container mode: every placed array in region order. */
127
+ this.segments = [];
128
+ this.bufferIndex = new Map();
129
+ this.placed = new Map();
130
+ this.cursor = 0;
131
+ this.mode = mode;
132
+ this.transfer = transfer;
133
+ }
134
+ /**
135
+ * Container mode: the padded byte length of the region (every segment padded to 256 bytes).
136
+ * @returns the region length
137
+ */
138
+ get regionLength() {
139
+ return alignUp(this.cursor, ALIGNMENT);
140
+ }
141
+ /**
142
+ * Reference mode: the index a buffer was assigned, or null when no array over it was placed.
143
+ * @param buffer - the buffer
144
+ * @returns the index into `buffers`, or null
145
+ */
146
+ indexOf(buffer) {
147
+ return this.bufferIndex.get(buffer) ?? null;
148
+ }
149
+ /**
150
+ * Place a typed array and return its reference. The same byte range is placed once. When the
151
+ * holder of the array (its column, table or id map) is shared, the buffer is recorded as shared
152
+ * so `finalise()` copies it under `transfer` (design section 9.1).
153
+ * @param view - the array
154
+ * @param dtype - its wire dtype ("utf8" for byte stores, "u8" for u8 columns and tags)
155
+ * @param sharedHolder - whether the object holding the array is held by more than one snapshot or table
156
+ * @returns the reference
157
+ */
158
+ ref(view, dtype, sharedHolder = false) {
159
+ if (sharedHolder) {
160
+ noteShared(view.buffer);
161
+ }
162
+ if (this.mode === "reference") {
163
+ return {
164
+ buffer: this.bufferIndexOf(view.buffer),
165
+ byteOffset: view.byteOffset,
166
+ byteLength: view.byteLength,
167
+ dtype,
168
+ length: view.length,
169
+ };
170
+ }
171
+ const key = `${this.bufferIndexOf(view.buffer)}:${view.byteOffset}:${view.byteLength}:${dtype}`;
172
+ const existing = this.placed.get(key);
173
+ if (existing !== undefined) {
174
+ return existing;
175
+ }
176
+ const byteOffset = alignUp(this.cursor, ALIGNMENT);
177
+ this.cursor = byteOffset + view.byteLength;
178
+ const ref = { buffer: 0, byteOffset, byteLength: view.byteLength, dtype, length: view.length };
179
+ this.placed.set(key, ref);
180
+ this.segments.push({ view, ref });
181
+ return ref;
182
+ }
183
+ /**
184
+ * Reference mode with `transfer`: replace every buffer recorded as shared by a copy and list its
185
+ * index in `copied` (design section 9.1). Called once after every array was placed, so the
186
+ * decision does not depend on the order in which shared holders were met.
187
+ */
188
+ finalise() {
189
+ if (this.mode !== "reference" || !this.transfer) {
190
+ return;
191
+ }
192
+ for (let i = 0; i < this.buffers.length; i++) {
193
+ const buffer = this.buffers[i];
194
+ if (isShared(buffer)) {
195
+ this.buffers[i] = buffer.slice(0);
196
+ this.copied.push(i);
197
+ }
198
+ }
199
+ }
200
+ /**
201
+ * The index of a backing buffer, assigning the next one on first sight.
202
+ * @param buffer - the buffer
203
+ * @returns the index
204
+ */
205
+ bufferIndexOf(buffer) {
206
+ const known = this.bufferIndex.get(buffer);
207
+ if (known !== undefined) {
208
+ return known;
209
+ }
210
+ const index = this.buffers.length;
211
+ this.bufferIndex.set(buffer, index);
212
+ this.buffers.push(buffer);
213
+ return index;
214
+ }
215
+ }
216
+ // ============================================================ dtype helpers
217
+ /**
218
+ * The wire dtype of a typed array by its class.
219
+ * @param view - the array
220
+ * @returns the dtype ("u8" for a Uint8Array; byte stores pass "utf8" explicitly)
221
+ */
222
+ function wireDtypeOf(view) {
223
+ if (view instanceof Uint32Array) {
224
+ return "u32";
225
+ }
226
+ if (view instanceof Int32Array) {
227
+ return "i32";
228
+ }
229
+ if (view instanceof Float32Array) {
230
+ return "f32";
231
+ }
232
+ if (view instanceof Float64Array) {
233
+ return "f64";
234
+ }
235
+ return "u8";
236
+ }
237
+ // ============================================================ caches of lazily kept representations
238
+ /** Encoded dictionaries, keyed by the dictionary array (shared between a static column and its temporal table). */
239
+ const DICTIONARY_CACHE = new WeakMap();
240
+ /** JSON text of json columns, keyed by the column, with the column version it was built from. */
241
+ const JSON_TEXT_CACHE = new WeakMap();
242
+ /**
243
+ * Whether a cached Utf8 store is still usable: the same row count and not detached by a transfer.
244
+ * @param encoded - the cached store
245
+ * @param rows - the expected row count
246
+ * @returns true when the cache can be reused
247
+ */
248
+ function cacheUsable(encoded, rows) {
249
+ return encoded.offsets.length === rows + 1;
250
+ }
251
+ /**
252
+ * The encoded form of a dictionary, built once per dictionary array.
253
+ * @param dictionary - the strings in code order
254
+ * @returns the offsets and bytes
255
+ */
256
+ function encodedDictionary(dictionary) {
257
+ const cached = DICTIONARY_CACHE.get(dictionary);
258
+ if (cached !== undefined && cacheUsable(cached, dictionary.length)) {
259
+ return cached;
260
+ }
261
+ const encoded = encodeUtf8Rows(dictionary, dictionary.length);
262
+ DICTIONARY_CACHE.set(dictionary, encoded);
263
+ return encoded;
264
+ }
265
+ /**
266
+ * The JSON text of every row of a json column as a Utf8 store (an unset row is empty text), built
267
+ * once per column version.
268
+ * @param column - the json column
269
+ * @returns the offsets and bytes
270
+ */
271
+ function encodedJsonText(column) {
272
+ const cached = JSON_TEXT_CACHE.get(column);
273
+ if (cached !== undefined && cached.version === column.version && cacheUsable(cached.encoded, column.length)) {
274
+ return cached.encoded;
275
+ }
276
+ const texts = new Array(column.length);
277
+ for (let row = 0; row < column.length; row++) {
278
+ const value = column.values[row];
279
+ texts[row] = value === undefined || !column.isSet(row) ? "" : JSON.stringify(encodeJsonValue(value));
280
+ }
281
+ const encoded = encodeUtf8Rows(texts, texts.length);
282
+ JSON_TEXT_CACHE.set(column, { version: column.version, encoded });
283
+ return encoded;
284
+ }
285
+ // ============================================================ column encoding
286
+ /**
287
+ * A Utf8 store as two references.
288
+ * @param layout - the collector
289
+ * @param encoded - the offsets and bytes
290
+ * @param shared - whether the holder of the store is shared
291
+ * @returns the wire store
292
+ */
293
+ function utf8Ref(layout, encoded, shared) {
294
+ return { offsets: layout.ref(encoded.offsets, "u32", shared), utf8: layout.ref(encoded.utf8, "utf8", shared) };
295
+ }
296
+ /**
297
+ * The manifest copy of a column's metadata: the JSON fields tagged per design section 5.9, the rest
298
+ * copied as is. The tagged fields no longer match ColumnMeta's static types when a value was
299
+ * non-finite; the reader decodes them before resolving the metadata again.
300
+ * @param meta - the resolved metadata
301
+ * @returns the manifest form
302
+ */
303
+ function encodeColumnMeta(meta) {
304
+ return {
305
+ name: meta.name,
306
+ domain: meta.domain,
307
+ dtype: meta.dtype,
308
+ components: meta.components,
309
+ itemDtype: meta.itemDtype,
310
+ itemComponents: meta.itemComponents,
311
+ nullable: meta.nullable,
312
+ mutable: meta.mutable,
313
+ role: meta.role,
314
+ refersTo: meta.refersTo,
315
+ unique: meta.unique,
316
+ default: encodeJsonValue(meta.default),
317
+ fill: encodeJsonValue(meta.fill),
318
+ options: meta.options === null ? null : encodeJsonValue(meta.options),
319
+ origin: meta.origin === null ? null : { ...meta.origin },
320
+ dynamic: meta.dynamic,
321
+ extra: encodeJsonValue(meta.extra),
322
+ };
323
+ }
324
+ /**
325
+ * Encode one column (design section 9.1): the buffers its dtype uses, null for the rest. A column
326
+ * held by more than one table (or belonging to a table held by more than one snapshot) has every
327
+ * buffer recorded as shared, including the ones it materialises lazily while being encoded.
328
+ * @param layout - the collector
329
+ * @param column - the column
330
+ * @param tableShared - whether the table holding the column is shared
331
+ * @returns the wire column
332
+ */
333
+ function encodeColumn(layout, column, tableShared) {
334
+ const shared = tableShared || isShared(column);
335
+ const base = {
336
+ meta: encodeColumnMeta(column.meta),
337
+ data: null,
338
+ validity: column.validity === null ? null : layout.ref(column.validity, "u32", shared),
339
+ nullCount: column.nullCount,
340
+ dictionary: null,
341
+ strings: null,
342
+ offsets: null,
343
+ child: null,
344
+ jsonText: null,
345
+ };
346
+ const { dtype } = column;
347
+ switch (dtype) {
348
+ case "f32":
349
+ case "f64":
350
+ case "i32":
351
+ case "u32":
352
+ case "u8":
353
+ base.data = layout.ref(column.data, dtype, shared);
354
+ break;
355
+ case "bool":
356
+ base.data = layout.ref(column.data, "u32", shared);
357
+ break;
358
+ case "dict":
359
+ base.data = layout.ref(column.codes, "u32", shared);
360
+ base.dictionary = utf8Ref(layout, encodedDictionary(column.dictionary), shared);
361
+ break;
362
+ case "string":
363
+ base.strings = {
364
+ offsets: layout.ref(column.offsets, "u32", shared),
365
+ utf8: layout.ref(column.utf8, "utf8", shared),
366
+ };
367
+ break;
368
+ case "list":
369
+ base.offsets = layout.ref(column.offsets, "u32", shared);
370
+ base.child = encodeColumn(layout, column.child, shared);
371
+ break;
372
+ case "json":
373
+ base.jsonText = utf8Ref(layout, encodedJsonText(column), shared);
374
+ break;
375
+ default: {
376
+ const name = dtype;
377
+ throw new GraphFormatError("E_UNSUPPORTED", `unknown dtype ${name}`, { dtype: name });
378
+ }
379
+ }
380
+ return base;
381
+ }
382
+ /**
383
+ * Encode every column of a table in declaration order.
384
+ * @param layout - the collector
385
+ * @param table - the table
386
+ * @returns the wire columns
387
+ */
388
+ function encodeTable(layout, table) {
389
+ const out = [];
390
+ const tableShared = isShared(table);
391
+ for (const column of table) {
392
+ out.push(encodeColumn(layout, column, tableShared));
393
+ }
394
+ return out;
395
+ }
396
+ // ============================================================ id map, meta, views
397
+ /**
398
+ * Encode the id map (design section 4.5), materialising its typed form on first use.
399
+ * @param layout - the collector
400
+ * @param snapshot - the snapshot
401
+ * @returns the wire id map
402
+ */
403
+ function encodeIds(layout, snapshot) {
404
+ const { ids } = snapshot;
405
+ if (!(ids instanceof NodeIdMap)) {
406
+ throw new GraphFormatError("E_UNSUPPORTED", "the snapshot's id map is not a NodeIdMap of this package", {
407
+ reason: "foreign id map",
408
+ });
409
+ }
410
+ const typed = nodeIdMapToTyped(ids);
411
+ const shared = isShared(ids);
412
+ return {
413
+ kind: typed.kind,
414
+ size: typed.size,
415
+ offset: typed.offset,
416
+ values: typed.values === null ? null : layout.ref(typed.values, wireDtypeOf(typed.values), shared),
417
+ tags: typed.tags === null ? null : layout.ref(typed.tags, "u8", shared),
418
+ numbers: typed.numbers === null ? null : layout.ref(typed.numbers, "f64", shared),
419
+ offsets: typed.offsets === null ? null : layout.ref(typed.offsets, "u32", shared),
420
+ utf8: typed.utf8 === null ? null : layout.ref(typed.utf8, "utf8", shared),
421
+ };
422
+ }
423
+ /**
424
+ * The manifest copy of the graph metadata with `extra` tagged per design section 5.9.
425
+ * @param meta - the metadata
426
+ * @returns the manifest form
427
+ */
428
+ function encodeGraphMeta(meta) {
429
+ return {
430
+ name: meta.name,
431
+ description: meta.description,
432
+ creator: meta.creator,
433
+ created: meta.created,
434
+ modified: meta.modified,
435
+ keywords: [...meta.keywords],
436
+ sourceFormat: meta.sourceFormat,
437
+ sourceVersion: meta.sourceVersion,
438
+ idType: meta.idType,
439
+ timeFormat: meta.timeFormat,
440
+ timeRepresentation: meta.timeRepresentation,
441
+ mode: meta.mode,
442
+ declaredMultigraph: meta.declaredMultigraph,
443
+ weightOrigin: meta.weightOrigin === null ? null : { ...meta.weightOrigin },
444
+ extra: encodeJsonValue(meta.extra),
445
+ };
446
+ }
447
+ /**
448
+ * The cached, non-scalar views named by includeViews, each as its materialised member arrays
449
+ * (design section 9.1). A view that is not resident is skipped: the receiver recomputes it.
450
+ * @param layout - the collector
451
+ * @param snapshot - the snapshot
452
+ * @param names - the requested views
453
+ * @returns the wire views, or null when none was carried
454
+ */
455
+ function encodeViews(layout, snapshot, names) {
456
+ if (names === undefined || names.length === 0) {
457
+ return null;
458
+ }
459
+ const out = {};
460
+ let count = 0;
461
+ for (const name of new Set(names)) {
462
+ if (SCALAR_VIEWS.has(name)) {
463
+ continue;
464
+ }
465
+ const value = peekView(snapshot, name);
466
+ if (value === null) {
467
+ continue;
468
+ }
469
+ const members = {};
470
+ let any = false;
471
+ for (const [member, array] of Object.entries(viewArrays(snapshot, name, value))) {
472
+ const view = array;
473
+ members[member] = layout.ref(view, wireDtypeOf(view));
474
+ any = true;
475
+ }
476
+ if (any) {
477
+ out[name] = members;
478
+ count++;
479
+ }
480
+ }
481
+ return count === 0 ? null : out;
482
+ }
483
+ /**
484
+ * Build the manifest of a snapshot over a collector (design section 9.1): core arrays first (an
485
+ * identity permutation, an absent weights array and a zero-length array are null), then the id map,
486
+ * the tables, the extension tables, the metadata and the requested views.
487
+ * @param snapshot - the snapshot
488
+ * @param layout - the collector
489
+ * @param includeViews - the views to carry
490
+ * @param includeColumns - whether attribute and extension tables are carried (default true)
491
+ * @returns the manifest and the collector
492
+ */
493
+ export function collectWire(snapshot, layout, includeViews, includeColumns = true) {
494
+ assertLittleEndianHost();
495
+ const identity = snapshot.flags.arcToEdgeIsIdentity;
496
+ const coreArrays = {
497
+ rowPtr: snapshot.rowPtr,
498
+ colIdx: snapshot.colIdx,
499
+ weights: snapshot.weights,
500
+ arcToEdge: identity ? null : snapshot.arcToEdge,
501
+ edgeToArc: identity ? null : snapshot.edgeToArc,
502
+ };
503
+ const coreRefs = {
504
+ rowPtr: null,
505
+ colIdx: null,
506
+ weights: null,
507
+ arcToEdge: null,
508
+ edgeToArc: null,
509
+ };
510
+ const rowPtrRef = layout.ref(snapshot.rowPtr, "u32");
511
+ coreRefs.rowPtr = rowPtrRef;
512
+ for (const name of CORE_ORDER) {
513
+ const array = coreArrays[name];
514
+ if (name !== "rowPtr" && array !== null && array.length > 0) {
515
+ coreRefs[name] = layout.ref(array, wireDtypeOf(array));
516
+ }
517
+ }
518
+ const arena = encodeArena(snapshot, layout, coreRefs);
519
+ const ids = encodeIds(layout, snapshot);
520
+ const nodeColumns = includeColumns ? encodeTable(layout, snapshot.nodes) : [];
521
+ const edgeColumns = includeColumns ? encodeTable(layout, snapshot.edges) : [];
522
+ const graphColumns = includeColumns ? encodeTable(layout, snapshot.graph) : [];
523
+ const extensions = [];
524
+ if (includeColumns) {
525
+ for (const [name, table] of snapshot.extensions) {
526
+ extensions.push({ name, rowCount: table.rowCount, columns: encodeTable(layout, table) });
527
+ }
528
+ }
529
+ const views = encodeViews(layout, snapshot, includeViews);
530
+ layout.finalise();
531
+ const manifest = {
532
+ format: WIRE_FORMAT,
533
+ wire: [WIRE_MAJOR, WIRE_MINOR],
534
+ producer: WIRE_PRODUCER,
535
+ formatVersion: FORMAT_VERSION,
536
+ directed: snapshot.directed,
537
+ counts: {
538
+ nodes: snapshot.nodeCount,
539
+ edges: snapshot.edgeCount,
540
+ arcs: snapshot.arcCount,
541
+ selfLoops: snapshot.selfLoopCount,
542
+ },
543
+ flags: { ...snapshot.flags },
544
+ core: {
545
+ rowPtr: rowPtrRef,
546
+ colIdx: coreRefs.colIdx,
547
+ weights: coreRefs.weights,
548
+ arcToEdge: coreRefs.arcToEdge,
549
+ edgeToArc: coreRefs.edgeToArc,
550
+ },
551
+ arena,
552
+ ids,
553
+ nodeColumns,
554
+ edgeColumns,
555
+ graphColumns,
556
+ extensions,
557
+ meta: encodeGraphMeta(snapshot.meta),
558
+ views,
559
+ copied: layout.copied,
560
+ label: snapshot.label,
561
+ };
562
+ return { manifest, layout };
563
+ }
564
+ /**
565
+ * The arena descriptor: in container mode the prefix of the region holding the core arrays (always
566
+ * present); in reference mode the snapshot's own arena when it has one.
567
+ * @param snapshot - the snapshot
568
+ * @param layout - the collector, after the core arrays were placed
569
+ * @param coreRefs - the core references
570
+ * @returns the descriptor, or null
571
+ */
572
+ function encodeArena(snapshot, layout, coreRefs) {
573
+ if (layout.mode === "container") {
574
+ let end = 0;
575
+ let hotByteLength = 0;
576
+ for (const name of CORE_ORDER) {
577
+ const ref = coreRefs[name];
578
+ if (ref === null) {
579
+ continue;
580
+ }
581
+ end = ref.byteOffset + ref.byteLength;
582
+ if (name === "rowPtr" || name === "colIdx" || name === "weights") {
583
+ hotByteLength = end;
584
+ }
585
+ }
586
+ return { buffer: 0, byteOffset: 0, byteLength: end, hotByteLength };
587
+ }
588
+ const { arena } = snapshot;
589
+ if (arena === null) {
590
+ return null;
591
+ }
592
+ const buffer = layout.indexOf(arena.buffer);
593
+ if (buffer === null) {
594
+ return null;
595
+ }
596
+ return { buffer, byteOffset: arena.byteOffset, byteLength: arena.byteLength, hotByteLength: arena.hotByteLength };
597
+ }
598
+ // ============================================================ public entry points
599
+ /**
600
+ * The plain-object wire form of a snapshot (design section 9.1): a JSON-serialisable manifest plus
601
+ * the distinct backing ArrayBuffers of the core, the id map, the columns and the extension tables.
602
+ * Without `transfer` every buffer is a plain reference and postMessage clones; with `transfer: true`
603
+ * every buffer held by more than one snapshot, table or column (design section 9.1, tracked by
604
+ * src/util/shared-buffers.ts) is copied (its index listed in `manifest.copied`) so the remaining
605
+ * buffers can be transferred with `transferables()`.
606
+ * @param snapshot - the snapshot
607
+ * @param options - transfer mode, the cached views to carry and whether columns are carried
608
+ * @returns the wire snapshot; E_UNSUPPORTED on a big-endian host
609
+ */
610
+ export function toWire(snapshot, options = {}) {
611
+ const transfer = options.transfer === true;
612
+ const layout = new WireLayout("reference", transfer);
613
+ const { manifest } = collectWire(snapshot, layout, options.includeViews, options.includeColumns !== false);
614
+ if (transfer) {
615
+ // the transfer list of THIS wire: exclusive originals plus the fresh copies of shared buffers
616
+ TRANSFER_LISTS.set(snapshot, [...layout.buffers]);
617
+ }
618
+ return { manifest, buffers: layout.buffers };
619
+ }
620
+ /** Per snapshot, the buffers its most recent `toWire({ transfer: true })` put into `wire.buffers`. */
621
+ const TRANSFER_LISTS = new WeakMap();
622
+ /**
623
+ * The postMessage transfer list of design section 9.1: the same set `toWire({ transfer: true })`
624
+ * put into `wire.buffers` -- exclusively owned originals plus the fresh copies made for shared
625
+ * buffers -- so `postMessage(wire, snapshot.transferables())` transfers exactly the buffers the
626
+ * wire carries, whatever `includeColumns` / `includeViews` selected (a buffer the wire does not
627
+ * reference is never listed, so no column is lost on either side). Before any transfer-mode toWire()
628
+ * call the list is computed for the default wire shape: the distinct exclusively owned buffers of
629
+ * the core, the id map, the typed columns, the string stores and the extension tables; a buffer
630
+ * held by more than one snapshot, table or column is excluded and an identity permutation is never
631
+ * included.
632
+ * @param snapshot - the snapshot
633
+ * @returns the buffers, in manifest order
634
+ */
635
+ export function transferables(snapshot) {
636
+ const recorded = TRANSFER_LISTS.get(snapshot);
637
+ if (recorded !== undefined) {
638
+ return [...recorded];
639
+ }
640
+ const layout = new WireLayout("reference", false);
641
+ collectWire(snapshot, layout, undefined, true);
642
+ return layout.buffers.filter((buffer) => !isShared(buffer));
643
+ }
644
+ /**
645
+ * The UTF-8 bytes of a manifest as the container stores them (design section 9.2).
646
+ * @param manifest - the manifest
647
+ * @returns the encoded JSON text
648
+ */
649
+ export function encodeManifest(manifest) {
650
+ return encoder.encode(JSON.stringify(manifest));
651
+ }
652
+ //# sourceMappingURL=to-wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-wire.js","sourceRoot":"","sources":["../../../src/wire/to-wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAoB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAsB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