@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,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type inference for untyped sources (design section 5.1, decision C4): CSV cells, GML values, DOT
|
|
3
|
+
* strings, `fromRecords` and `addNodeRecord`. Inference runs per COLUMN, never per cell, widening
|
|
4
|
+
* monotonically in the order `(unset) -> bool -> i32 -> f64 -> string -> json`; it never yields
|
|
5
|
+
* `f32`. The lexical grammar for text is fixed so two implementations agree (invariant I15):
|
|
6
|
+
*
|
|
7
|
+
* - `bool` is exactly `true` / `false` (case-sensitive);
|
|
8
|
+
* - `i32` is `/^-?(0|[1-9][0-9]*)$/` within `[-2^31, 2^31)`;
|
|
9
|
+
* - `f64` is a decimal or exponent literal accepted by `Number()` that is not empty, not whitespace,
|
|
10
|
+
* not `Infinity` / `NaN` and not a hex / octal / binary form (and whose value is finite);
|
|
11
|
+
* - everything else is `string`. `0` / `1` text is `i32`, never `bool`.
|
|
12
|
+
*
|
|
13
|
+
* JS values map by `typeof`: `boolean -> bool`, integral `number` in i32 range -> `i32`, other
|
|
14
|
+
* `number -> f64`, `string -> string`, array or plain object -> `json`; `null` and `undefined` are
|
|
15
|
+
* unset and do not widen.
|
|
16
|
+
*/
|
|
17
|
+
import { GraphFormatError } from "../errors.js";
|
|
18
|
+
/** The widening order of design section 5.1; a column only ever moves to the right. */
|
|
19
|
+
export const WIDENING_ORDER = ["bool", "i32", "f64", "string", "json"];
|
|
20
|
+
const I32_TEXT = /^-?(0|[1-9][0-9]*)$/;
|
|
21
|
+
// integer part without leading zeros ("01" is a string, design section 5.1), optional fraction, optional exponent
|
|
22
|
+
const F64_TEXT = /^[+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([eE][+-]?[0-9]+)?$/;
|
|
23
|
+
const I32_MIN = -2147483648;
|
|
24
|
+
const I32_MAX = 2147483647;
|
|
25
|
+
/**
|
|
26
|
+
* The rank of a dtype in the widening order.
|
|
27
|
+
* @param dtype - an inferred dtype
|
|
28
|
+
* @returns 0 for bool up to 4 for json
|
|
29
|
+
*/
|
|
30
|
+
export function wideningRank(dtype) {
|
|
31
|
+
return WIDENING_ORDER.indexOf(dtype);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Widen a column's dtype by one observation: the wider of the two, where null (unset, nothing seen
|
|
35
|
+
* yet) is narrower than everything.
|
|
36
|
+
* @param current - the column's dtype so far, or null when no value has been seen
|
|
37
|
+
* @param observed - the dtype of the newly observed value, or null for an unset cell
|
|
38
|
+
* @returns the widened dtype (null only when both are null)
|
|
39
|
+
*/
|
|
40
|
+
export function widenDtype(current, observed) {
|
|
41
|
+
if (current === null) {
|
|
42
|
+
return observed;
|
|
43
|
+
}
|
|
44
|
+
if (observed === null) {
|
|
45
|
+
return current;
|
|
46
|
+
}
|
|
47
|
+
return wideningRank(observed) > wideningRank(current) ? observed : current;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Classify one text cell by the fixed lexical grammar. Exported as the reference implementation of
|
|
51
|
+
* the text grammar of design section 5.1, which the text importers of graph-io must reproduce
|
|
52
|
+
* exactly (invariant I15); the core itself only infers from JS values, so nothing in src/ calls it.
|
|
53
|
+
* @public
|
|
54
|
+
* @param text - the cell text, exactly as read (no trimming)
|
|
55
|
+
* @returns bool, i32, f64 or string
|
|
56
|
+
*/
|
|
57
|
+
export function inferTextDtype(text) {
|
|
58
|
+
if (text === "true" || text === "false") {
|
|
59
|
+
return "bool";
|
|
60
|
+
}
|
|
61
|
+
if (I32_TEXT.test(text)) {
|
|
62
|
+
const n = Number(text);
|
|
63
|
+
if (n >= I32_MIN && n <= I32_MAX) {
|
|
64
|
+
return "i32";
|
|
65
|
+
}
|
|
66
|
+
return Number.isFinite(n) ? "f64" : "string";
|
|
67
|
+
}
|
|
68
|
+
if (F64_TEXT.test(text) && Number.isFinite(Number(text))) {
|
|
69
|
+
return "f64";
|
|
70
|
+
}
|
|
71
|
+
return "string";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Classify one JS value by `typeof`.
|
|
75
|
+
* @param value - the cell value
|
|
76
|
+
* @returns the dtype, or null for an unset cell (`undefined` or `null`); E_COLUMN_TYPE for a bigint,
|
|
77
|
+
* symbol or function, which no dtype can hold
|
|
78
|
+
*/
|
|
79
|
+
export function inferValueDtype(value) {
|
|
80
|
+
if (value === undefined || value === null) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
switch (typeof value) {
|
|
84
|
+
case "boolean":
|
|
85
|
+
return "bool";
|
|
86
|
+
case "number":
|
|
87
|
+
return Number.isInteger(value) && value >= I32_MIN && value <= I32_MAX ? "i32" : "f64";
|
|
88
|
+
case "string":
|
|
89
|
+
return "string";
|
|
90
|
+
case "object":
|
|
91
|
+
return "json";
|
|
92
|
+
default:
|
|
93
|
+
throw new GraphFormatError("E_COLUMN_TYPE", `a ${typeof value} value cannot be stored in a column`, {
|
|
94
|
+
reason: "unsupported value type",
|
|
95
|
+
found: typeof value,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parse a text cell into the storage value of a dtype the column has widened to. A text column
|
|
101
|
+
* never widens to json, but a column that was inferred from JS values may later receive text; in
|
|
102
|
+
* that case the text is stored as a string value. Part of the reference text grammar of design
|
|
103
|
+
* section 5.1 (see inferTextDtype).
|
|
104
|
+
* @public
|
|
105
|
+
* @param text - the cell text
|
|
106
|
+
* @param dtype - the column's current dtype
|
|
107
|
+
* @returns a boolean for bool, a number for i32 / f64, the text itself for string / json
|
|
108
|
+
*/
|
|
109
|
+
export function parseText(text, dtype) {
|
|
110
|
+
switch (dtype) {
|
|
111
|
+
case "bool":
|
|
112
|
+
if (text === "true") {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (text === "false") {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
throw new GraphFormatError("E_COLUMN_TYPE", `text "${text}" is not a bool`, { value: text, dtype });
|
|
119
|
+
case "i32":
|
|
120
|
+
case "f64": {
|
|
121
|
+
const inferred = inferTextDtype(text);
|
|
122
|
+
if (inferred === "string") {
|
|
123
|
+
throw new GraphFormatError("E_COLUMN_TYPE", `text "${text}" is not a ${dtype}`, { value: text, dtype });
|
|
124
|
+
}
|
|
125
|
+
if (inferred === "bool") {
|
|
126
|
+
return text === "true" ? 1 : 0;
|
|
127
|
+
}
|
|
128
|
+
return Number(text);
|
|
129
|
+
}
|
|
130
|
+
case "string":
|
|
131
|
+
case "json":
|
|
132
|
+
return text;
|
|
133
|
+
default: {
|
|
134
|
+
const name = dtype;
|
|
135
|
+
throw new GraphFormatError("E_COLUMN_TYPE", `unknown dtype ${name}`, { dtype: name });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Convert a JS value to the storage value of a (possibly wider) inferred dtype, applying the
|
|
141
|
+
* widening conversions of design section 5.1: a bool widened to a number becomes 1 / 0, a number or
|
|
142
|
+
* boolean widened to string becomes its canonical JS text, anything widened to json is kept as is.
|
|
143
|
+
* @param value - the cell value (never undefined or null; unset cells are handled by the caller)
|
|
144
|
+
* @param dtype - the column's dtype
|
|
145
|
+
* @returns the storage value; E_COLUMN_TYPE when the value cannot be represented in the dtype
|
|
146
|
+
*/
|
|
147
|
+
export function coerceValue(value, dtype) {
|
|
148
|
+
switch (dtype) {
|
|
149
|
+
case "bool":
|
|
150
|
+
if (typeof value === "boolean") {
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
case "i32":
|
|
155
|
+
case "f64":
|
|
156
|
+
if (typeof value === "number") {
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
if (typeof value === "boolean") {
|
|
160
|
+
return value ? 1 : 0;
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case "string":
|
|
164
|
+
if (typeof value === "string") {
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
168
|
+
return String(value);
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case "json":
|
|
172
|
+
return value;
|
|
173
|
+
default: {
|
|
174
|
+
const name = dtype;
|
|
175
|
+
throw new GraphFormatError("E_COLUMN_TYPE", `unknown dtype ${name}`, { dtype: name });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
throw new GraphFormatError("E_COLUMN_TYPE", `a ${typeof value} value cannot be stored in a ${dtype} column`, {
|
|
179
|
+
dtype,
|
|
180
|
+
found: typeof value,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Infer the dtype of a whole column of JS values in one pass.
|
|
185
|
+
* @param values - the cell values; undefined and null are unset
|
|
186
|
+
* @returns the widened dtype, or null when every cell is unset
|
|
187
|
+
*/
|
|
188
|
+
export function inferValuesDtype(values) {
|
|
189
|
+
let dtype = null;
|
|
190
|
+
for (const value of values) {
|
|
191
|
+
dtype = widenDtype(dtype, inferValueDtype(value));
|
|
192
|
+
if (dtype === "json") {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return dtype;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Infer the dtype of a whole column of text cells in one pass. Part of the reference text grammar
|
|
200
|
+
* of design section 5.1 (see inferTextDtype).
|
|
201
|
+
* @public
|
|
202
|
+
* @param cells - the cell texts; an empty string is a string value, not an unset cell (the caller
|
|
203
|
+
* decides how blanks map to unset before calling)
|
|
204
|
+
* @returns the widened dtype, or null when the column is empty
|
|
205
|
+
*/
|
|
206
|
+
export function inferTextsDtype(cells) {
|
|
207
|
+
let dtype = null;
|
|
208
|
+
for (const text of cells) {
|
|
209
|
+
dtype = widenDtype(dtype, inferTextDtype(text));
|
|
210
|
+
if (dtype === "string") {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return dtype;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* A per-column inference accumulator for row-at-a-time sources (`addNodeRecord`, CSV streaming):
|
|
218
|
+
* observe every cell and read `dtype`; each observe call reports whether the column widened so the
|
|
219
|
+
* caller can reallocate storage and record the widening in FreezeReport.widened.
|
|
220
|
+
*/
|
|
221
|
+
export class DtypeInferrer {
|
|
222
|
+
constructor() {
|
|
223
|
+
this.current = null;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The column's dtype so far.
|
|
227
|
+
* @returns the widened dtype, or null until a set cell has been observed
|
|
228
|
+
*/
|
|
229
|
+
get dtype() {
|
|
230
|
+
return this.current;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Observe a JS value.
|
|
234
|
+
* @param value - the cell value; undefined and null are unset and never widen
|
|
235
|
+
* @returns true when the column's dtype changed
|
|
236
|
+
*/
|
|
237
|
+
observeValue(value) {
|
|
238
|
+
return this.apply(inferValueDtype(value));
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Observe a text cell. Part of the reference text grammar of design section 5.1 (see
|
|
242
|
+
* inferTextDtype).
|
|
243
|
+
* @public
|
|
244
|
+
* @param text - the cell text
|
|
245
|
+
* @returns true when the column's dtype changed
|
|
246
|
+
*/
|
|
247
|
+
observeText(text) {
|
|
248
|
+
return this.apply(inferTextDtype(text));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Force the dtype to at least the given one (a declared lower bound, or the dtype of a column
|
|
252
|
+
* being merged in).
|
|
253
|
+
* @param dtype - the dtype to widen to
|
|
254
|
+
* @returns true when the column's dtype changed
|
|
255
|
+
*/
|
|
256
|
+
widenTo(dtype) {
|
|
257
|
+
return this.apply(dtype);
|
|
258
|
+
}
|
|
259
|
+
apply(observed) {
|
|
260
|
+
const next = widenDtype(this.current, observed);
|
|
261
|
+
if (next === this.current) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
this.current = next;
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=infer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infer.js","sourceRoot":"","sources":["../../../src/columns/infer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAA6B,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEjG,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AACvC,kHAAkH;AAClH,MAAM,QAAQ,GAAG,gEAAgE,CAAC;AAClF,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC;AAC5B,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAoB;IAC7C,OAAO,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA6B,EAAE,QAA8B;IACpF,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,OAAO,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,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C,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remap and gather helpers for raw typed arrays, columns and whole tables (design section 5.11):
|
|
3
|
+
* the propagation of attribute data through compaction (freeze step 10), derived graphs (section
|
|
4
|
+
* 7.3) and consumer re-attachment after a builder mutation. One name per shape:
|
|
5
|
+
*
|
|
6
|
+
* - `remapArray(data, remap, newLength, fill, components)` and `remapColumn(column, remap,
|
|
7
|
+
* newLength)` take an OLD -> NEW map (`INVALID_INDEX` drops the row);
|
|
8
|
+
* - `gatherArray(data, indexMap, components)` and `gatherColumn(column, indexMap)` take a NEW ->
|
|
9
|
+
* OLD map (`out[i] = source[indexMap[i]]`);
|
|
10
|
+
* - `scatterArray(out, values, indexMap, components)` writes results computed on a derived graph
|
|
11
|
+
* back into the parent's index space (`out[indexMap[i]] = values[i]`).
|
|
12
|
+
*
|
|
13
|
+
* Index-valued columns (`meta.refersTo`, a u32 column or a list of u32) have their VALUES rewritten
|
|
14
|
+
* through the remap of the space they reference: an in-range value maps to its new index, a
|
|
15
|
+
* dangling reference becomes `INVALID_INDEX` with the row unset (invariant I12; for a list, the
|
|
16
|
+
* dangling items are dropped and a row whose every item dangled becomes unset and empty).
|
|
17
|
+
*/
|
|
18
|
+
import { type Column, type F32, type TypedArrayData, type U32 } from "../types/index.js";
|
|
19
|
+
import { AttributeTable } from "./table.js";
|
|
20
|
+
/**
|
|
21
|
+
* Move rows of an index-aligned array from an old index space to a new one through an OLD -> NEW
|
|
22
|
+
* remap (`FreezeReport.nodeRemap` / `edgeRemap`, `DerivedGraph.nodeRemap` / `edgeRemap`): row `i`
|
|
23
|
+
* lands at `remap[i]`, rows mapped to `INVALID_INDEX` are dropped, and rows of the new space no old
|
|
24
|
+
* row maps to hold `fill`.
|
|
25
|
+
* @param data - the old array, `oldRows * components` long
|
|
26
|
+
* @param remap - old index -> new index or INVALID_INDEX; rows beyond `remap.length` are dropped
|
|
27
|
+
* @param newLength - the row count of the new space
|
|
28
|
+
* @param fill - the value of rows no old row maps to
|
|
29
|
+
* @param components - values per row (default 1)
|
|
30
|
+
* @returns a new array of `newLength * components` values
|
|
31
|
+
*/
|
|
32
|
+
export declare function remapArray<T extends TypedArrayData>(data: T, remap: U32, newLength: number, fill: number, components?: number): T;
|
|
33
|
+
/**
|
|
34
|
+
* Gather rows through a NEW -> OLD index map: `out[i] = data[indexMap[i]]` (`DerivedGraph.nodeOrigin`
|
|
35
|
+
* / `edgeOrigin`).
|
|
36
|
+
* @param data - the source array, `oldRows * components` long
|
|
37
|
+
* @param indexMap - new index -> old index, every entry in range
|
|
38
|
+
* @param components - values per row (default 1)
|
|
39
|
+
* @returns a new array of `indexMap.length * components` values
|
|
40
|
+
*/
|
|
41
|
+
export declare function gatherArray<T extends TypedArrayData>(data: T, indexMap: U32, components?: number): T;
|
|
42
|
+
/**
|
|
43
|
+
* Scatter values computed on a derived graph back into the parent's index space: `out[indexMap[i]]
|
|
44
|
+
* = values[i]` (through `nodeOrigin` / `edgeOrigin`). Rows of `out` no value maps to are untouched.
|
|
45
|
+
* @param out - the destination in the parent's index space
|
|
46
|
+
* @param values - the values in the derived index space, `indexMap.length * components` long
|
|
47
|
+
* @param indexMap - derived index -> parent index, every entry in range
|
|
48
|
+
* @param components - values per row (default 1)
|
|
49
|
+
* @returns `out`
|
|
50
|
+
*/
|
|
51
|
+
export declare function scatterArray<T extends TypedArrayData>(out: T, values: T, indexMap: U32, components?: number): T;
|
|
52
|
+
/**
|
|
53
|
+
* Gather the rows of a column through a NEW -> OLD index map: `out[i] = column[indexMap[i]]`
|
|
54
|
+
* (design section 5.11, `DerivedGraph.nodeOrigin` / `edgeOrigin`). An INVALID_INDEX entry yields an
|
|
55
|
+
* unset row holding the fill (the column becomes nullable if it was not). Values of a refersTo
|
|
56
|
+
* column are NOT rewritten here; compose with remapReferences() when the referenced space changed.
|
|
57
|
+
* @param column - the source column
|
|
58
|
+
* @param indexMap - new index -> old index (or INVALID_INDEX for a row with no source)
|
|
59
|
+
* @returns a new column of `indexMap.length` rows
|
|
60
|
+
*/
|
|
61
|
+
export declare function gatherColumn(column: Column, indexMap: U32): Column;
|
|
62
|
+
/**
|
|
63
|
+
* Rewrite the values of an index-valued column through the remap of the space it references
|
|
64
|
+
* (design section 5.11): an in-range value maps to its new index; a dangling reference (mapped to
|
|
65
|
+
* INVALID_INDEX or out of range) becomes INVALID_INDEX with the row unset. For a list of u32 the
|
|
66
|
+
* dangling items are dropped and a row whose every item dangled becomes unset and empty. A column
|
|
67
|
+
* without refersTo is returned as it is.
|
|
68
|
+
* @param column - the column
|
|
69
|
+
* @param valueRemap - old index -> new index or INVALID_INDEX, over the referenced space
|
|
70
|
+
* @returns a new column when anything was rewritten; the same object otherwise
|
|
71
|
+
*/
|
|
72
|
+
export declare function remapReferences(column: Column, valueRemap: U32): Column;
|
|
73
|
+
/**
|
|
74
|
+
* Move a column's rows from an old index space to a new one through an OLD -> NEW remap, rewriting
|
|
75
|
+
* its values through `valueRemap` when it is an index-valued column (design section 5.11): rows
|
|
76
|
+
* mapped to INVALID_INDEX are dropped, rows of the new space no old row maps to are unset and hold
|
|
77
|
+
* the fill (the column becomes nullable if it was not), and dangling references become
|
|
78
|
+
* INVALID_INDEX with the row unset.
|
|
79
|
+
* @param column - the source column
|
|
80
|
+
* @param remap - old row -> new row or INVALID_INDEX
|
|
81
|
+
* @param newLength - the row count of the new space
|
|
82
|
+
* @param valueRemap - the remap of the space the column's values reference, or null to leave values alone
|
|
83
|
+
* @returns a new column of `newLength` rows
|
|
84
|
+
*/
|
|
85
|
+
export declare function remapColumnWith(column: Column, remap: U32, newLength: number, valueRemap: U32 | null): Column;
|
|
86
|
+
/**
|
|
87
|
+
* Move a column's rows through an OLD -> NEW remap and, when the column refers to its OWN index
|
|
88
|
+
* space (a node column with `refersTo: "node"` such as `parent`, an edge column with `refersTo:
|
|
89
|
+
* "edge"` such as `pair`), rewrite its values through the SAME remap (design sections 5.11 and
|
|
90
|
+
* 12.2). A column whose values reference the OTHER space (a node column referring to edges) has its
|
|
91
|
+
* rows moved and its values left untouched, because `remap` says nothing about that space; the
|
|
92
|
+
* internal remapColumnWith() / remapTable() take a second remap for it.
|
|
93
|
+
* @param column - the source column
|
|
94
|
+
* @param remap - old row -> new row or INVALID_INDEX
|
|
95
|
+
* @param newLength - the row count of the new space
|
|
96
|
+
* @returns a new column of `newLength` rows
|
|
97
|
+
*/
|
|
98
|
+
export declare function remapColumn(column: Column, remap: U32, newLength: number): Column;
|
|
99
|
+
/**
|
|
100
|
+
* Change the stride of an interleaved f32 array (design section 5.2, the generic stride helper):
|
|
101
|
+
* every row of `from` values becomes a row of `to` values, extra lanes filled with `fill` and
|
|
102
|
+
* surplus lanes dropped. A 2D layout result expands to the 3-component position column with
|
|
103
|
+
* `withComponents(xy, 2, 3, 0)`; the inverse drops `z`. Returns `data` itself when `from === to`.
|
|
104
|
+
* @param data - the interleaved values, `rows * from` long
|
|
105
|
+
* @param from - values per row of `data`, 1..16
|
|
106
|
+
* @param to - values per row of the result, 1..16
|
|
107
|
+
* @param fill - the value of the lanes `to` adds beyond `from`
|
|
108
|
+
* @returns a new array of `rows * to` values (the input when the stride is unchanged)
|
|
109
|
+
*/
|
|
110
|
+
export declare function withComponents(data: F32, from: number, to: number, fill: number): F32;
|
|
111
|
+
/**
|
|
112
|
+
* The remaps of the two index spaces a column's values may reference; null when that space was not
|
|
113
|
+
* renumbered.
|
|
114
|
+
*/
|
|
115
|
+
interface ReferenceRemaps {
|
|
116
|
+
/** Old node index -> new node index or INVALID_INDEX; null when nodes were not renumbered. */
|
|
117
|
+
readonly node: U32 | null;
|
|
118
|
+
/** Old edge index -> new edge index or INVALID_INDEX; null when edges were not renumbered. */
|
|
119
|
+
readonly edge: U32 | null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Remap every column of a table (freeze step 10, the compaction case; extension tables with
|
|
123
|
+
* `rowRemap` null): rows move through `rowRemap` when given, and every refersTo column's values are
|
|
124
|
+
* rewritten through the remap of the space it references. The result is a new table; the source is
|
|
125
|
+
* untouched.
|
|
126
|
+
* @param table - the source table
|
|
127
|
+
* @param rowRemap - old row -> new row or INVALID_INDEX; null when the table's rows are unchanged
|
|
128
|
+
* @param newLength - the row count of the new table (ignored, and equal to table.rowCount, when rowRemap is null)
|
|
129
|
+
* @param refs - the node and edge remaps for index-valued columns
|
|
130
|
+
* @returns the remapped table
|
|
131
|
+
*/
|
|
132
|
+
export declare function remapTable(table: AttributeTable, rowRemap: U32 | null, newLength: number, refs: ReferenceRemaps): AttributeTable;
|
|
133
|
+
/**
|
|
134
|
+
* Gather every column of a table through a NEW -> OLD index map (derived graphs: `nodeOrigin` /
|
|
135
|
+
* `edgeOrigin`), rewriting refersTo values through the remaps of the spaces they reference.
|
|
136
|
+
* @param table - the source table
|
|
137
|
+
* @param indexMap - new row -> old row
|
|
138
|
+
* @param refs - the node and edge remaps for index-valued columns
|
|
139
|
+
* @returns the gathered table of `indexMap.length` rows
|
|
140
|
+
*/
|
|
141
|
+
export declare function gatherTable(table: AttributeTable, indexMap: U32, refs: ReferenceRemaps): AttributeTable;
|
|
142
|
+
export {};
|
|
143
|
+
//# sourceMappingURL=remap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remap.d.ts","sourceRoot":"","sources":["../../../src/columns/remap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,KAAK,MAAM,EAAmB,KAAK,GAAG,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAI1G,OAAO,EAAE,cAAc,EAAE,MAAM,YAA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