@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,526 @@
1
+ /**
2
+ * The Arrow Utf8 string store (design sections 4.2 and 5.1): `Uint32Array(rows + 1)` offsets plus one
3
+ * `Uint8Array` of concatenated UTF-8 bytes, kept next to a decoded JS-string representation. The two
4
+ * are caches of one logical value and are materialised lazily in either direction:
5
+ *
6
+ * - a store built from strings (`Utf8Store.fromStrings`, what the builder has) shares the source
7
+ * array by reference and encodes on the first read of `offsets` / `utf8` (toWire / toBytes /
8
+ * transferables), caching the result;
9
+ * - a store built from a wire buffer (`Utf8Store.fromEncoded`) decodes per row on `at()`, cached in
10
+ * a sparse array, and in bulk on `slice()` / `decodeAll()`, which are not cached.
11
+ *
12
+ * Nothing is encoded or decoded at construction. Row `i` occupies the byte range
13
+ * `[offsets[i], offsets[i + 1])`; `offsets[0]` need not be zero so that a zero-copy slice of a
14
+ * string column can share its parent's arrays. The encoder is a plain JS UTF-8 encoder that
15
+ * produces exactly the bytes `TextEncoder` would (a lone surrogate becomes U+FFFD); the decoder is
16
+ * `TextDecoder` behind an ASCII fast path.
17
+ */
18
+ import { GraphFormatError } from "../errors.js";
19
+ import { claimHolder } from "../util/shared-buffers.js";
20
+ /**
21
+ * Rows of at most this many bytes are decoded by a char-code loop when they are pure ASCII, which is
22
+ * about three times faster than TextDecoder for short ids; longer rows go straight to TextDecoder.
23
+ */
24
+ const ASCII_FAST_PATH_MAX_BYTES = 32;
25
+ let sharedDecoder = null;
26
+ let fatalDecoder = null;
27
+ /**
28
+ * The lazily created shared (replacing) decoder.
29
+ * @returns a TextDecoder that replaces malformed sequences with U+FFFD
30
+ */
31
+ function replacingDecoder() {
32
+ sharedDecoder ?? (sharedDecoder = new TextDecoder("utf-8"));
33
+ return sharedDecoder;
34
+ }
35
+ /**
36
+ * The lazily created fatal decoder used by validation.
37
+ * @returns a TextDecoder that throws on a malformed sequence
38
+ */
39
+ function strictDecoder() {
40
+ fatalDecoder ?? (fatalDecoder = new TextDecoder("utf-8", { fatal: true }));
41
+ return fatalDecoder;
42
+ }
43
+ /**
44
+ * Number of UTF-8 bytes `encodeUtf8Into` writes for a string (a lone surrogate counts as the three
45
+ * bytes of U+FFFD, matching TextEncoder).
46
+ * @param s - the string
47
+ * @returns the encoded byte length
48
+ */
49
+ export function utf8ByteLength(s) {
50
+ let bytes = 0;
51
+ const n = s.length;
52
+ for (let i = 0; i < n; i++) {
53
+ const c = s.charCodeAt(i);
54
+ if (c < 0x80) {
55
+ bytes += 1;
56
+ }
57
+ else if (c < 0x800) {
58
+ bytes += 2;
59
+ }
60
+ else if (c >= 0xd800 && c <= 0xdbff && i + 1 < n) {
61
+ const d = s.charCodeAt(i + 1);
62
+ if (d >= 0xdc00 && d <= 0xdfff) {
63
+ bytes += 4;
64
+ i++;
65
+ }
66
+ else {
67
+ bytes += 3;
68
+ }
69
+ }
70
+ else {
71
+ bytes += 3;
72
+ }
73
+ }
74
+ return bytes;
75
+ }
76
+ /**
77
+ * Encode a string as UTF-8 into `out` starting at `position`; the caller has sized `out` with
78
+ * `utf8ByteLength`. Produces the bytes TextEncoder would, including U+FFFD for a lone surrogate.
79
+ * @param s - the string
80
+ * @param out - the destination bytes
81
+ * @param position - the first byte to write
82
+ * @returns one past the last byte written
83
+ */
84
+ export function encodeUtf8Into(s, out, position) {
85
+ let p = position;
86
+ const n = s.length;
87
+ for (let i = 0; i < n; i++) {
88
+ let c = s.charCodeAt(i);
89
+ if (c < 0x80) {
90
+ out[p++] = c;
91
+ continue;
92
+ }
93
+ if (c < 0x800) {
94
+ out[p++] = 0xc0 | (c >> 6);
95
+ out[p++] = 0x80 | (c & 0x3f);
96
+ continue;
97
+ }
98
+ if (c >= 0xd800 && c <= 0xdfff) {
99
+ if (c <= 0xdbff && i + 1 < n) {
100
+ const d = s.charCodeAt(i + 1);
101
+ if (d >= 0xdc00 && d <= 0xdfff) {
102
+ c = 0x10000 + ((c - 0xd800) << 10) + (d - 0xdc00);
103
+ i++;
104
+ out[p++] = 0xf0 | (c >> 18);
105
+ out[p++] = 0x80 | ((c >> 12) & 0x3f);
106
+ out[p++] = 0x80 | ((c >> 6) & 0x3f);
107
+ out[p++] = 0x80 | (c & 0x3f);
108
+ continue;
109
+ }
110
+ }
111
+ c = 0xfffd;
112
+ }
113
+ out[p++] = 0xe0 | (c >> 12);
114
+ out[p++] = 0x80 | ((c >> 6) & 0x3f);
115
+ out[p++] = 0x80 | (c & 0x3f);
116
+ }
117
+ return p;
118
+ }
119
+ /**
120
+ * The length from which V8 represents a substring as a SlicedString that keeps its parent alive
121
+ * (`SlicedString::kMinLength`); shorter substrings are copied.
122
+ */
123
+ const SLICED_STRING_MIN_LENGTH = 13;
124
+ /**
125
+ * A copy of a string that no longer references the buffer it was sliced from. Importers cut ids
126
+ * and cell texts out of decoded input chunks, and V8 represents such a substring of 13 or more
127
+ * characters as a view on the chunk, so a retained id or value would keep the whole chunk alive
128
+ * for the life of the builder and the snapshot (measured: a 40 MiB CSV kept 47 MiB of decoded
129
+ * text resident through 100k retained ids). Concatenating one character and slicing it off makes
130
+ * V8 flatten the string into fresh storage; shorter strings are already copies and are returned
131
+ * as they are.
132
+ * @param s - the string
133
+ * @returns an equal string that owns its characters
134
+ */
135
+ export function detachString(s) {
136
+ return s.length < SLICED_STRING_MIN_LENGTH ? s : ` ${s}`.slice(1);
137
+ }
138
+ /**
139
+ * Whether a string contains a lone UTF-16 surrogate, which TextEncoder would replace with U+FFFD on
140
+ * the wire (design section 4.1: such an id is E_INVALID_ID).
141
+ * @param s - the string
142
+ * @returns true when a high surrogate lacks its low partner or a low surrogate stands alone
143
+ */
144
+ export function hasLoneSurrogate(s) {
145
+ const n = s.length;
146
+ for (let i = 0; i < n; i++) {
147
+ const c = s.charCodeAt(i);
148
+ if (c < 0xd800 || c > 0xdfff) {
149
+ continue;
150
+ }
151
+ if (c > 0xdbff) {
152
+ return true;
153
+ }
154
+ if (i + 1 >= n) {
155
+ return true;
156
+ }
157
+ const d = s.charCodeAt(i + 1);
158
+ if (d < 0xdc00 || d > 0xdfff) {
159
+ return true;
160
+ }
161
+ i++;
162
+ }
163
+ return false;
164
+ }
165
+ /**
166
+ * Decode one row of UTF-8 bytes with an ASCII fast path.
167
+ * @param utf8 - the byte store
168
+ * @param start - first byte of the row
169
+ * @param end - one past the last byte of the row
170
+ * @returns the decoded string (malformed sequences become U+FFFD)
171
+ */
172
+ export function decodeUtf8Row(utf8, start, end) {
173
+ const len = end - start;
174
+ if (len === 0) {
175
+ return "";
176
+ }
177
+ if (len <= ASCII_FAST_PATH_MAX_BYTES) {
178
+ let s = "";
179
+ let i = start;
180
+ for (; i < end; i++) {
181
+ const b = utf8[i];
182
+ if (b >= 0x80) {
183
+ break;
184
+ }
185
+ s += String.fromCharCode(b);
186
+ }
187
+ if (i === end) {
188
+ return s;
189
+ }
190
+ }
191
+ return replacingDecoder().decode(utf8.subarray(start, end));
192
+ }
193
+ /**
194
+ * Whether every byte of a range is ASCII.
195
+ * @param utf8 - the byte store
196
+ * @param start - first byte
197
+ * @param end - one past the last byte
198
+ * @returns true when no byte is >= 0x80
199
+ */
200
+ function isAsciiRange(utf8, start, end) {
201
+ for (let i = start; i < end; i++) {
202
+ if (utf8[i] >= 0x80) {
203
+ return false;
204
+ }
205
+ }
206
+ return true;
207
+ }
208
+ /**
209
+ * Decode a range of rows in one pass: when the whole byte range is ASCII, one TextDecoder call plus
210
+ * one substring per row (byte offsets equal char offsets); otherwise one decode per row.
211
+ * @param utf8 - the byte store
212
+ * @param offsets - the row offsets
213
+ * @param from - first row
214
+ * @param to - one past the last row
215
+ * @returns the decoded rows in order
216
+ */
217
+ export function decodeUtf8Rows(utf8, offsets, from, to) {
218
+ const out = new Array(to - from);
219
+ if (to <= from) {
220
+ return out;
221
+ }
222
+ const base = offsets[from];
223
+ const end = offsets[to];
224
+ if (isAsciiRange(utf8, base, end)) {
225
+ const whole = replacingDecoder().decode(utf8.subarray(base, end));
226
+ for (let i = from; i < to; i++) {
227
+ out[i - from] = whole.substring(offsets[i] - base, offsets[i + 1] - base);
228
+ }
229
+ return out;
230
+ }
231
+ for (let i = from; i < to; i++) {
232
+ out[i - from] = decodeUtf8Row(utf8, offsets[i], offsets[i + 1]);
233
+ }
234
+ return out;
235
+ }
236
+ /**
237
+ * Whether one row of bytes is well-formed UTF-8 (a fatal decode).
238
+ * @param utf8 - the byte store
239
+ * @param start - first byte of the row
240
+ * @param end - one past the last byte of the row
241
+ * @returns true when the row decodes without error
242
+ */
243
+ function isWellFormedUtf8Row(utf8, start, end) {
244
+ let ascii = true;
245
+ for (let i = start; i < end; i++) {
246
+ if (utf8[i] >= 0x80) {
247
+ ascii = false;
248
+ break;
249
+ }
250
+ }
251
+ if (ascii) {
252
+ return true;
253
+ }
254
+ try {
255
+ strictDecoder().decode(utf8.subarray(start, end));
256
+ return true;
257
+ }
258
+ catch {
259
+ return false;
260
+ }
261
+ }
262
+ /**
263
+ * Encode the first `length` entries of an array as an Arrow Utf8 store in one sizing pass and one
264
+ * writing pass. Entries that are not strings (the number rows of a mixed id map) encode as empty
265
+ * rows; offsets start at 0.
266
+ * @param source - the rows; only entries below `length` are read
267
+ * @param length - the number of rows to encode
268
+ * @returns fresh, exactly sized offsets (length + 1) and utf8 arrays
269
+ */
270
+ export function encodeUtf8Rows(source, length) {
271
+ const offsets = new Uint32Array(length + 1);
272
+ let total = 0;
273
+ for (let i = 0; i < length; i++) {
274
+ const v = source[i];
275
+ if (typeof v === "string") {
276
+ total += utf8ByteLength(v);
277
+ }
278
+ offsets[i + 1] = total;
279
+ }
280
+ const utf8 = new Uint8Array(total);
281
+ let p = 0;
282
+ for (let i = 0; i < length; i++) {
283
+ const v = source[i];
284
+ if (typeof v === "string") {
285
+ p = encodeUtf8Into(v, utf8, p);
286
+ }
287
+ }
288
+ return { offsets, utf8 };
289
+ }
290
+ /**
291
+ * Structure-level check of a Utf8 store's layout (design section 9.5): `rows + 1` offsets,
292
+ * non-decreasing, ending inside the byte store.
293
+ * @param offsets - the offsets array
294
+ * @param utf8 - the byte store
295
+ * @param rows - the expected row count
296
+ * @param ref - the manifest path named in the error, e.g. "ids.offsets"
297
+ */
298
+ export function checkUtf8Layout(offsets, utf8, rows, ref) {
299
+ if (offsets.length !== rows + 1) {
300
+ throw new GraphFormatError("E_BAD_SERIALIZATION", `${ref}: expected ${rows + 1} offsets, found ${offsets.length}`, { ref, reason: "offsets length", expected: rows + 1, found: offsets.length });
301
+ }
302
+ let previous = offsets[0];
303
+ for (let i = 1; i <= rows; i++) {
304
+ const current = offsets[i];
305
+ if (current < previous) {
306
+ throw new GraphFormatError("E_BAD_SERIALIZATION", `${ref}: offsets decrease at row ${i - 1}`, {
307
+ ref,
308
+ reason: "offsets not monotonic",
309
+ row: i - 1,
310
+ });
311
+ }
312
+ previous = current;
313
+ }
314
+ if (previous > utf8.length) {
315
+ throw new GraphFormatError("E_BAD_SERIALIZATION", `${ref}: offsets end at ${previous} but the byte store has ${utf8.length} bytes`, { ref, reason: "offsets exceed utf8", end: previous, byteLength: utf8.length });
316
+ }
317
+ }
318
+ /**
319
+ * An Arrow Utf8 string store with lazily materialised encoded and decoded representations (design
320
+ * sections 4.2 and 5.1). Immutable once built; every lazily computed representation is cached.
321
+ */
322
+ export class Utf8Store {
323
+ /**
324
+ * Construct a store; use the static factories. At least one representation is always given.
325
+ * @param length - the row count
326
+ * @param source - the decoded rows or null
327
+ * @param encoded - the offsets and bytes or null
328
+ */
329
+ constructor(length, source, encoded) {
330
+ this.length = length;
331
+ this.source = source;
332
+ this.cache = null;
333
+ this.encodedArrays = encoded;
334
+ }
335
+ /**
336
+ * A store over decoded strings, shared by reference: the builder-side representation. Encoding
337
+ * happens on the first read of `offsets` / `utf8`.
338
+ * @param source - the rows; only entries below `length` are ever read, so a builder array that
339
+ * keeps growing can be shared (design section 4.2)
340
+ * @param length - the row count; default source.length
341
+ * @returns the store
342
+ */
343
+ static fromStrings(source, length = source.length) {
344
+ return new Utf8Store(length, source, null);
345
+ }
346
+ /**
347
+ * A store over an encoded Utf8 layout, adopted by reference: the wire-side representation.
348
+ * Decoding happens per row on `at()` and in bulk on `slice()` / `decodeAll()`. The layout is not
349
+ * checked here; `checkUtf8Layout` does that for untrusted input.
350
+ * @param offsets - rows + 1 non-decreasing offsets
351
+ * @param utf8 - the concatenated bytes
352
+ * @returns the store
353
+ */
354
+ static fromEncoded(offsets, utf8) {
355
+ return new Utf8Store(Math.max(0, offsets.length - 1), null, { offsets, utf8 });
356
+ }
357
+ /**
358
+ * Whether the encoded representation exists (adopted or already materialised).
359
+ * @returns true when `offsets` / `utf8` can be read without encoding
360
+ */
361
+ get encoded() {
362
+ return this.encodedArrays !== null;
363
+ }
364
+ /**
365
+ * Whether the store is backed by a decoded source array, so `at()` never decodes.
366
+ * @returns true for a store built from strings
367
+ */
368
+ get decoded() {
369
+ return this.source !== null;
370
+ }
371
+ /**
372
+ * Whether the encoded arrays were transferred away while rows still depend on them (design
373
+ * section 9.1): a transferred buffer leaves zero-length views.
374
+ * @returns true when detached
375
+ */
376
+ get detached() {
377
+ return (this.source === null &&
378
+ this.length > 0 &&
379
+ this.encodedArrays !== null &&
380
+ this.encodedArrays.offsets.length === 0);
381
+ }
382
+ /**
383
+ * The `length + 1` offsets, encoding the source on first access.
384
+ * @returns the offsets array (cached)
385
+ */
386
+ get offsets() {
387
+ return this.ensureEncoded().offsets;
388
+ }
389
+ /**
390
+ * The concatenated UTF-8 bytes, encoding the source on first access.
391
+ * @returns the byte array (cached)
392
+ */
393
+ get utf8() {
394
+ return this.ensureEncoded().utf8;
395
+ }
396
+ /**
397
+ * The string of one row, decoded on first access and cached per row.
398
+ * @param row - the row index
399
+ * @returns the string; E_INDEX_RANGE when row is out of range
400
+ */
401
+ at(row) {
402
+ if (!(row >= 0 && row < this.length) || !Number.isInteger(row)) {
403
+ throw new GraphFormatError("E_INDEX_RANGE", `row ${row} out of range (length ${this.length})`, {
404
+ index: row,
405
+ size: this.length,
406
+ });
407
+ }
408
+ if (this.source !== null) {
409
+ return this.source[row];
410
+ }
411
+ this.cache ?? (this.cache = new Array(this.length));
412
+ const cached = this.cache[row];
413
+ if (cached !== undefined) {
414
+ return cached;
415
+ }
416
+ const { offsets, utf8 } = this.ensureEncoded();
417
+ const value = decodeUtf8Row(utf8, offsets[row], offsets[row + 1]);
418
+ this.cache[row] = value;
419
+ return value;
420
+ }
421
+ /**
422
+ * The strings of a row range decoded in one pass (one TextDecoder call for an all-ASCII range);
423
+ * nothing is cached. Bounds follow Array.prototype.slice (negative values count from the end,
424
+ * out-of-range values are clamped).
425
+ * @param start - first row (default 0)
426
+ * @param end - one past the last row (default length)
427
+ * @returns a fresh array of the rows in order
428
+ */
429
+ slice(start = 0, end = this.length) {
430
+ const [from, to] = resolveRange(start, end, this.length);
431
+ const { source } = this;
432
+ if (source !== null) {
433
+ const out = new Array(to - from);
434
+ for (let i = from; i < to; i++) {
435
+ out[i - from] = source[i];
436
+ }
437
+ return out;
438
+ }
439
+ const { offsets, utf8 } = this.ensureEncoded();
440
+ return decodeUtf8Rows(utf8, offsets, from, to);
441
+ }
442
+ /**
443
+ * Every row decoded in one pass; not cached.
444
+ * @returns a fresh array of all rows
445
+ */
446
+ decodeAll() {
447
+ return this.slice(0, this.length);
448
+ }
449
+ /**
450
+ * Decode every row of an encoded store once, in bulk, and keep the result as the decoded
451
+ * representation so that later `at()` calls are O(1) without a per-row decode. For a store that
452
+ * already has its decoded rows this is a no-op. Used before a pass that will touch every row
453
+ * anyway (building the reverse map of a wire-decoded id map).
454
+ */
455
+ materialiseDecoded() {
456
+ if (this.source === null) {
457
+ this.source = this.decodeAll();
458
+ this.cache = null;
459
+ }
460
+ }
461
+ /**
462
+ * Bytes of typed storage: the offsets and utf8 arrays when they exist, 0 for a store that has not
463
+ * been encoded yet. JS strings are never counted.
464
+ * @returns the byte count
465
+ */
466
+ byteLength() {
467
+ const enc = this.encodedArrays;
468
+ return enc === null ? 0 : enc.offsets.byteLength + enc.utf8.byteLength;
469
+ }
470
+ /**
471
+ * The first row whose bytes are not well-formed UTF-8, for full validation of untrusted input
472
+ * (design section 9.5: string ids are decoded with a fatal decoder). A source-backed store is
473
+ * always well-formed.
474
+ * @returns the row index, or -1 when every row is well-formed
475
+ */
476
+ firstMalformedRow() {
477
+ const enc = this.encodedArrays;
478
+ if (this.source !== null || enc === null) {
479
+ return -1;
480
+ }
481
+ const { offsets, utf8 } = enc;
482
+ for (let i = 0; i < this.length; i++) {
483
+ if (!isWellFormedUtf8Row(utf8, offsets[i], offsets[i + 1])) {
484
+ return i;
485
+ }
486
+ }
487
+ return -1;
488
+ }
489
+ /**
490
+ * The encoded representation, encoding the source once on first use. A store always has a source
491
+ * when it has no encoded arrays (the private constructor is only reached through the factories).
492
+ * @returns the offsets and bytes
493
+ */
494
+ ensureEncoded() {
495
+ let enc = this.encodedArrays;
496
+ if (enc === null) {
497
+ enc = encodeUtf8Rows(this.source, this.length);
498
+ this.encodedArrays = enc;
499
+ // the store is the first holder of the buffers it materialises (design section 9.1)
500
+ claimHolder(enc.offsets.buffer);
501
+ claimHolder(enc.utf8.buffer);
502
+ }
503
+ return enc;
504
+ }
505
+ }
506
+ /**
507
+ * Resolve Array.prototype.slice-style bounds against a length.
508
+ * @param start - the requested start (negative counts from the end)
509
+ * @param end - the requested end (negative counts from the end)
510
+ * @param length - the length of the sequence
511
+ * @returns the clamped [from, to] with from <= to
512
+ */
513
+ export function resolveRange(start, end, length) {
514
+ let from = Math.trunc(start);
515
+ let to = Math.trunc(end);
516
+ if (Number.isNaN(from)) {
517
+ from = 0;
518
+ }
519
+ if (Number.isNaN(to)) {
520
+ to = 0;
521
+ }
522
+ from = from < 0 ? Math.max(length + from, 0) : Math.min(from, length);
523
+ to = to < 0 ? Math.max(length + to, 0) : Math.min(to, length);
524
+ return [from, Math.max(from, to)];
525
+ }
526
+ //# sourceMappingURL=string-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-store.js","sourceRoot":"","sources":["../../../src/ids/string-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;GAGG;AACH,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAKrC,IAAI,aAAa,GAAmB,IAAI,CAAC;AACzC,IAAI,YAAY,GAAmB,IAAI,CAAC;AAExC;;;GAGG;AACH,SAAS,gBAAgB;IACrB,aAAa,KAAb,aAAa,GAAK,IAAI,WAAW,CAAC,OAAO,CAAC,EAAC;IAC3C,OAAO,aAAa,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa;IAClB,YAAY,KAAZ,YAAY,GAAK,IAAI,W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,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,GAAW,EAAE,MAAc;IACnE,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,IAAI,GAAG,CAAC,CAAC;IACb,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;QACnB,EAAE,GAAG,CAAC,CAAC;IACX,CAAC;IACD,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The public barrel of @graphty/graph-format: a frozen compressed-sparse-row graph data format over
3
+ * typed arrays, with a mutable builder, columnar typed attributes and an id map kept outside the CSR.
4
+ * This is the only public barrel; it exports exactly the surface of design section 12.2, as named
5
+ * exports (no star re-exports, nothing from src/types/internal.ts, no helper that a sibling module
6
+ * exports for the package's own use).
7
+ */
8
+ export { FORMAT_VERSION, INVALID_INDEX, MAX_COUNT, SNAPSHOT_BRAND } from "./constants.js";
9
+ export { GraphFormatError, type GraphFormatErrorCode } from "./errors.js";
10
+ export { GraphBuilder } from "./builder/graph-builder.js";
11
+ export { AttributeTable } from "./columns/table.js";
12
+ export { NodeIdMap } from "./ids/node-id-map.js";
13
+ export { GraphSnapshot } from "./snapshot/graph-snapshot.js";
14
+ export { gpuEligibility } from "./columns/column.js";
15
+ export { gatherArray, gatherColumn, remapArray, remapColumn, scatterArray, withComponents } from "./columns/remap.js";
16
+ export { fromCsr } from "./populate/from-csr.js";
17
+ export { fromEdgeArrays } from "./populate/from-edge-arrays.js";
18
+ export { fromRecords } from "./populate/from-records.js";
19
+ export { renumberPartition } from "./snapshot/derived.js";
20
+ export { equalsTopology, isGraphSnapshot } from "./snapshot/graph-snapshot.js";
21
+ export { expandEdges, foldArcs } from "./snapshot/views.js";
22
+ export { makeMask, maskCount, maskSet, maskTest, maskToIndices } from "./util/mask.js";
23
+ export { paddedU32View } from "./util/typed-array.js";
24
+ export { fromByteChunks, fromBytes } from "./wire/bytes.js";
25
+ export { fromWire } from "./wire/from-wire.js";
26
+ export type { BuilderOptionsPatch, ColumnHandle, ExtensionHandle, FreezeOptions, FreezeReport, GraphBuilderOptions, GraphSink, ResolvedBuilderOptions, SetDirectedOptions, } from "./types/builder.js";
27
+ export type { ArcIndex, BoolColumn, Column, ColumnBase, ColumnDecl, ColumnDeclPatch, ColumnDomain, ColumnInput, ColumnMeta, ColumnOf, ColumnOrigin, ColumnOriginInput, ColumnReducer, ColumnRole, DictColumn, Dtype, DtypeValue, DuplicatePolicy, EdgeId, EdgeIndex, EdgeMask, F32, F32Column, F64, F64Column, GpuEligibility, GraphMeta, GraphMetaPatch, I32, I32Column, IdCoercion, JsonColumn, KnownColumnRole, ListColumn, Loose, NodeId, NodeIndex, NodeMask, NumericVector, ScalarDtype, SetOptions, StringColumn, TypedArrayData, U8, U8Column, U32, U32Column, ValidationLevel, WeightReducer, } from "./types/columns.js";
28
+ export type { AdjacencyView, ArenaLayout, ArenaSegment, ByteLengthOptions, ContractOptions, CooView, CoreArrayName, CsrInput, DegreeOrderOptions, DegreeOrderView, DerivedGraph, EdgeArraysInput, EdgeListView, FlagClaims, FromCsrOptions, NodeIdMapKind, RecordsInput, ReverseView, SimplifyOptions, SnapshotFlags, ToUndirectedOptions, ValidateOptions, ViewName, } from "./types/snapshot.js";
29
+ export type { FromWireOptions, ToBytesOptions, ToWireOptions, WireArena, WireBufferRef, WireColumn, WireDtype, WireIdMap, WireManifest, WireSnapshot, WireUtf8, } from "./types/wire.js";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,M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AO,EACP,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,QAAQ,GACX,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,GACX,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The public barrel of @graphty/graph-format: a frozen compressed-sparse-row graph data format over
3
+ * typed arrays, with a mutable builder, columnar typed attributes and an id map kept outside the CSR.
4
+ * This is the only public barrel; it exports exactly the surface of design section 12.2, as named
5
+ * exports (no star re-exports, nothing from src/types/internal.ts, no helper that a sibling module
6
+ * exports for the package's own use).
7
+ */
8
+ // ============================================================ constants and errors
9
+ export { FORMAT_VERSION, INVALID_INDEX, MAX_COUNT, SNAPSHOT_BRAND } from "./constants.js";
10
+ export { GraphFormatError } from "./errors.js";
11
+ // ============================================================ classes
12
+ export { GraphBuilder } from "./builder/graph-builder.js";
13
+ export { AttributeTable } from "./columns/table.js";
14
+ export { NodeIdMap } from "./ids/node-id-map.js";
15
+ export { GraphSnapshot } from "./snapshot/graph-snapshot.js";
16
+ // ============================================================ functions
17
+ export { gpuEligibility } from "./columns/column.js";
18
+ export { gatherArray, gatherColumn, remapArray, remapColumn, scatterArray, withComponents } from "./columns/remap.js";
19
+ export { fromCsr } from "./populate/from-csr.js";
20
+ export { fromEdgeArrays } from "./populate/from-edge-arrays.js";
21
+ export { fromRecords } from "./populate/from-records.js";
22
+ export { renumberPartition } from "./snapshot/derived.js";
23
+ export { equalsTopology, isGraphSnapshot } from "./snapshot/graph-snapshot.js";
24
+ export { expandEdges, foldArcs } from "./snapshot/views.js";
25
+ export { makeMask, maskCount, maskSet, maskTest, maskToIndices } from "./util/mask.js";
26
+ export { paddedU32View } from "./util/typed-array.js";
27
+ export { fromByteChunks, fromBytes } from "./wire/bytes.js";
28
+ export { fromWire } from "./wire/from-wire.js";
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oFAAoF;AACpF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAC;AAE1E,uEAAuE;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,yEAAyE;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAA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