@nteract/sift 0.6.0 → 0.7.0-nightly.42413490472
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/docs/embedding-guide.md +417 -10
- package/lib/THIRD_PARTY_NOTICES.md +29 -4
- package/lib/handoff.css +12 -1
- package/lib/index.js +2847 -2052
- package/lib/protocol-B_bRY_76.js +885 -0
- package/lib/style.css +1 -1
- package/lib/types/packages/sift/src/auto-width.d.ts +9 -3
- package/lib/types/packages/sift/src/components/icons.d.ts +16 -0
- package/lib/types/packages/sift/src/file-data.d.ts +34 -5
- package/lib/types/packages/sift/src/filter-schema.d.ts +11 -0
- package/lib/types/packages/sift/src/index.d.ts +11 -4
- package/lib/types/packages/sift/src/parquet-file.d.ts +52 -5
- package/lib/types/packages/sift/src/permutation.d.ts +24 -0
- package/lib/types/packages/sift/src/predicate.d.ts +56 -3
- package/lib/types/packages/sift/src/query.d.ts +100 -0
- package/lib/types/packages/sift/src/react.d.ts +108 -6
- package/lib/types/packages/sift/src/table.d.ts +168 -2
- package/lib/types/packages/sift/src/wasm-summaries.d.ts +19 -1
- package/lib/types/packages/sift/src/windowed-resident.d.ts +20 -0
- package/lib/types/packages/sift/src/windowed.d.ts +116 -0
- package/lib/types/packages/sift/src/worker/client.d.ts +87 -0
- package/lib/types/packages/sift/src/worker/entry.d.ts +11 -0
- package/lib/types/packages/sift/src/worker/factory.d.ts +11 -0
- package/lib/types/packages/sift/src/worker/host.d.ts +31 -0
- package/lib/types/packages/sift/src/worker/protocol.d.ts +191 -0
- package/lib/wasm/sift_wasm.d.ts +67 -3
- package/lib/wasm/sift_wasm.js +109 -3
- package/lib/wasm/sift_wasm_bg.wasm +0 -0
- package/lib/worker.js +277 -0
- package/package.json +9 -6
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
import { measureNaturalWidth as e, prepare as t } from "@chenglou/pretext";
|
|
2
|
+
//#region src/parquet-features.ts
|
|
3
|
+
function n(e, t) {
|
|
4
|
+
let n = new Map(t.map((e) => [e.name, e]));
|
|
5
|
+
for (let t of e) {
|
|
6
|
+
let e = n.get(t.key);
|
|
7
|
+
e && (e.columnType && (t.columnType = e.columnType), e.numeric !== void 0 && (t.numeric = e.numeric), e.sortable !== void 0 && (t.sortable = e.sortable), e.width !== void 0 && t.width < e.width && (t.width = e.width), e.label !== void 0 && (t.label = e.label));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function r(e, t) {
|
|
11
|
+
let n = {};
|
|
12
|
+
for (let t of e) {
|
|
13
|
+
if (t.columnType === void 0 && t.numeric === void 0) continue;
|
|
14
|
+
let e = {};
|
|
15
|
+
t.columnType !== void 0 && (e.columnType = t.columnType), t.numeric !== void 0 && (e.numeric = t.numeric), n[t.name] = e;
|
|
16
|
+
}
|
|
17
|
+
if (t) for (let [e, r] of Object.entries(t)) n[e] = {
|
|
18
|
+
...n[e],
|
|
19
|
+
...r
|
|
20
|
+
};
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
function i(e) {
|
|
24
|
+
return new Set(e.filter((e) => e.pandasIndex).map((e) => e.name));
|
|
25
|
+
}
|
|
26
|
+
var a = /^(unnamed[: _]*\d*|index|_?id|rowid|row_?id|row_?num)$/i;
|
|
27
|
+
function o(e) {
|
|
28
|
+
return a.test(e);
|
|
29
|
+
}
|
|
30
|
+
function s(e, t) {
|
|
31
|
+
if (t) for (let n of e) {
|
|
32
|
+
let e = t[n.key];
|
|
33
|
+
e && Object.assign(n, e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/table-response.ts
|
|
38
|
+
async function c(e) {
|
|
39
|
+
if (!/^data:/i.test(e)) return fetch(e);
|
|
40
|
+
let t = new URL(e), n = t.pathname + t.search, r = n.indexOf(",");
|
|
41
|
+
if (r < 0) throw Error("Invalid table data URL: missing comma");
|
|
42
|
+
let i = n.slice(0, r), a = n.slice(r + 1), o = /;base64$/i.test(i), s = (o ? i.slice(0, -7) : i) || "text/plain;charset=US-ASCII", c = a.replace(/%([\da-f]{2})/gi, (e, t) => String.fromCharCode(Number.parseInt(t, 16))), l = o ? atob(c) : c, u = new Uint8Array(l.length);
|
|
43
|
+
for (let e = 0; e < l.length; e++) u[e] = l.charCodeAt(e);
|
|
44
|
+
return new Response(u, { headers: { "Content-Type": s } });
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/predicate.ts
|
|
48
|
+
function l(e, t) {
|
|
49
|
+
let n = Array.from({ length: t }, () => null);
|
|
50
|
+
if (!e || typeof e != "object") return n;
|
|
51
|
+
let r = e.columns;
|
|
52
|
+
if (!Array.isArray(r)) return n;
|
|
53
|
+
for (let e = 0; e < t && e < r.length; e++) {
|
|
54
|
+
let t = r[e];
|
|
55
|
+
!t || typeof t != "object" || (n[e] = {
|
|
56
|
+
nullCount: typeof t.null_count == "number" ? t.null_count : null,
|
|
57
|
+
min: u(t.min),
|
|
58
|
+
max: u(t.max),
|
|
59
|
+
boundedRowGroups: typeof t.bounded_row_groups == "number" ? t.bounded_row_groups : 0,
|
|
60
|
+
boundsExact: t.bounds_exact === !0,
|
|
61
|
+
hasInfinite: t.has_infinite === !0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return n;
|
|
65
|
+
}
|
|
66
|
+
function u(e) {
|
|
67
|
+
return typeof e == "number" || typeof e == "string" || typeof e == "boolean" ? e : null;
|
|
68
|
+
}
|
|
69
|
+
var d = null, f = null, p, m, h = () => import("./wasm/sift_wasm.js");
|
|
70
|
+
function g(e, t) {
|
|
71
|
+
p = e, m = t;
|
|
72
|
+
}
|
|
73
|
+
function _() {
|
|
74
|
+
return p;
|
|
75
|
+
}
|
|
76
|
+
function v() {
|
|
77
|
+
return m;
|
|
78
|
+
}
|
|
79
|
+
var y = null;
|
|
80
|
+
function b() {
|
|
81
|
+
return y;
|
|
82
|
+
}
|
|
83
|
+
function x(e) {
|
|
84
|
+
let t = e?.memory;
|
|
85
|
+
t instanceof WebAssembly.Memory && (y = t);
|
|
86
|
+
}
|
|
87
|
+
async function S() {
|
|
88
|
+
return d || (f ??= C().catch((e) => {
|
|
89
|
+
throw f = null, e;
|
|
90
|
+
}), f);
|
|
91
|
+
}
|
|
92
|
+
async function C() {
|
|
93
|
+
let e = await h();
|
|
94
|
+
try {
|
|
95
|
+
let t = p?.startsWith("data:") ? await (await c(p)).arrayBuffer() : p;
|
|
96
|
+
x(await e.default({ module_or_path: t }));
|
|
97
|
+
} catch (t) {
|
|
98
|
+
if (!m || m === p) throw t;
|
|
99
|
+
console.warn(`[sift] wasm load failed from ${p}; falling back to ${m}`, t), x(await e.default({ module_or_path: m }));
|
|
100
|
+
}
|
|
101
|
+
return d = e, d;
|
|
102
|
+
}
|
|
103
|
+
async function w(e) {
|
|
104
|
+
return (await S()).load_ipc(e);
|
|
105
|
+
}
|
|
106
|
+
function T() {
|
|
107
|
+
if (!d) throw Error("sift-wasm not initialized. Call ensureModule() first.");
|
|
108
|
+
return d;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/wasm-summaries.ts
|
|
112
|
+
var E = {
|
|
113
|
+
scope: "loaded",
|
|
114
|
+
precision: "exact",
|
|
115
|
+
source: "resident"
|
|
116
|
+
}, D = {
|
|
117
|
+
scope: "dataset",
|
|
118
|
+
precision: "exact",
|
|
119
|
+
source: "resident"
|
|
120
|
+
};
|
|
121
|
+
function O(e) {
|
|
122
|
+
return e ? e.truncated ? !1 : e.totalRows !== void 0 && e.totalRows.value === e.loadedRows : !0;
|
|
123
|
+
}
|
|
124
|
+
function k({ numRows: e, coverage: t, stats: n, loadedNullCount: r, uniqueCount: i }) {
|
|
125
|
+
let a = O(t), o = { loaded: e };
|
|
126
|
+
t?.totalRows && (o.dataset = t.totalRows);
|
|
127
|
+
let s = {
|
|
128
|
+
rows: o,
|
|
129
|
+
distribution: a ? D : E
|
|
130
|
+
}, c = a ? D : E;
|
|
131
|
+
n && n.nullCount !== null ? s.nullCount = {
|
|
132
|
+
value: n.nullCount,
|
|
133
|
+
scope: "dataset",
|
|
134
|
+
precision: "exact",
|
|
135
|
+
source: "metadata"
|
|
136
|
+
} : s.nullCount = {
|
|
137
|
+
value: r,
|
|
138
|
+
...c
|
|
139
|
+
};
|
|
140
|
+
let l = t?.rowGroups;
|
|
141
|
+
return n && l !== void 0 && n.boundedRowGroups === l && typeof n.min == "number" && typeof n.max == "number" && (s.range = {
|
|
142
|
+
value: {
|
|
143
|
+
min: n.min,
|
|
144
|
+
max: n.max
|
|
145
|
+
},
|
|
146
|
+
scope: "dataset",
|
|
147
|
+
precision: n.boundsExact ? "exact" : "estimated",
|
|
148
|
+
source: "metadata"
|
|
149
|
+
}), i !== void 0 && (s.distinctCount = {
|
|
150
|
+
value: i,
|
|
151
|
+
...c
|
|
152
|
+
}), s;
|
|
153
|
+
}
|
|
154
|
+
function A(e, t, n, r, i) {
|
|
155
|
+
let a = e.num_rows(t), s = e.store_null_counts(t), { coverage: c, datasetStats: l } = n, u = (e, t) => {
|
|
156
|
+
let r = l?.[e] ?? null;
|
|
157
|
+
return r && n.isColumnCast?.(e) && (r = null), k({
|
|
158
|
+
numRows: a,
|
|
159
|
+
coverage: c,
|
|
160
|
+
stats: r,
|
|
161
|
+
loadedNullCount: s[e] ?? 0,
|
|
162
|
+
uniqueCount: t
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
n.rowCount = a, n.columnSummaries = r.map((n, r) => {
|
|
166
|
+
switch (n.columnType) {
|
|
167
|
+
case "image": return null;
|
|
168
|
+
case "categorical": {
|
|
169
|
+
let n = e.store_value_counts(t, r), i = n.map(({ label: e, count: t }) => ({
|
|
170
|
+
label: e,
|
|
171
|
+
count: t,
|
|
172
|
+
pct: a > 0 ? Math.round(t / a * 1e3) / 10 : 0
|
|
173
|
+
})), o = i.slice(0, 3), c = n.slice(3).reduce((e, t) => e + t.count, 0), l = a > 0 ? Math.round(c / a * 1e3) / 10 : 0, d = n.map(({ label: e }) => e.length).sort((e, t) => e - t), f = d.length > 0 ? d[Math.floor(d.length / 2)] : 0;
|
|
174
|
+
return {
|
|
175
|
+
kind: "categorical",
|
|
176
|
+
uniqueCount: n.length,
|
|
177
|
+
topCategories: o,
|
|
178
|
+
othersCount: c,
|
|
179
|
+
othersPct: l,
|
|
180
|
+
allCategories: i,
|
|
181
|
+
medianTextLength: f,
|
|
182
|
+
nullCount: s[r] ?? 0,
|
|
183
|
+
scope: u(r, n.length)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
case "boolean": {
|
|
187
|
+
let [n, i, o] = e.store_bool_counts(t, r);
|
|
188
|
+
return {
|
|
189
|
+
kind: "boolean",
|
|
190
|
+
trueCount: n,
|
|
191
|
+
falseCount: i,
|
|
192
|
+
nullCount: o,
|
|
193
|
+
total: a,
|
|
194
|
+
scope: u(r)
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
case "timestamp": {
|
|
198
|
+
let n = e.store_temporal_histogram(t, r);
|
|
199
|
+
return n.length === 0 ? null : {
|
|
200
|
+
kind: "timestamp",
|
|
201
|
+
min: n[0].x0,
|
|
202
|
+
max: n[n.length - 1].x1,
|
|
203
|
+
bins: n,
|
|
204
|
+
nullCount: s[r] ?? 0,
|
|
205
|
+
scope: u(r)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
case "numeric": {
|
|
209
|
+
let a = e.store_histogram(t, r, 25);
|
|
210
|
+
if (a.length === 0) return null;
|
|
211
|
+
let c = i?.has(n.key) ?? o(n.key);
|
|
212
|
+
return {
|
|
213
|
+
kind: "numeric",
|
|
214
|
+
min: a[0].x0,
|
|
215
|
+
max: a[a.length - 1].x1,
|
|
216
|
+
bins: a,
|
|
217
|
+
isIndex: c ? !0 : void 0,
|
|
218
|
+
nullCount: s[r] ?? 0,
|
|
219
|
+
scope: u(r)
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/auto-width.ts
|
|
227
|
+
var j = "Inter, \"Helvetica Neue\", \"Segoe UI\", Helvetica, Arial, ui-sans-serif, system-ui, sans-serif", M = `600 11px ${j}`, N = `14px ${j}`, P = 60, F = 24;
|
|
228
|
+
function I(n, r) {
|
|
229
|
+
return e(t(n, r));
|
|
230
|
+
}
|
|
231
|
+
function L(e, t) {
|
|
232
|
+
let n = I(e.toUpperCase(), M) + P;
|
|
233
|
+
switch (t) {
|
|
234
|
+
case "boolean": return Math.max(90, Math.ceil(n));
|
|
235
|
+
case "timestamp": return Math.max(170, Math.ceil(n));
|
|
236
|
+
case "numeric": return Math.max(100, Math.ceil(n));
|
|
237
|
+
case "categorical": return Math.max(120, Math.min(280, Math.ceil(n)));
|
|
238
|
+
case "image": return Math.max(120, Math.ceil(n));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function R(e, t, n = 300, r = N) {
|
|
242
|
+
let i = Math.min(30, e.rowCount);
|
|
243
|
+
if (i !== 0) for (let a = 0; a < e.columns.length; a++) {
|
|
244
|
+
let o = e.columnSummaries[a];
|
|
245
|
+
if (o && o.isIndex === !0) {
|
|
246
|
+
let e = o.max, n = e == null ? "" : Math.round(e).toLocaleString(), i = Math.ceil(I(n, r)) + F;
|
|
247
|
+
i > t[a] && (t[a] = i);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
let s = [];
|
|
251
|
+
for (let t = 0; t < i; t++) {
|
|
252
|
+
let n = e.getCell(t, a);
|
|
253
|
+
if (!n) continue;
|
|
254
|
+
let i = I(n, r) + F;
|
|
255
|
+
s.push(i);
|
|
256
|
+
}
|
|
257
|
+
if (s.length === 0) continue;
|
|
258
|
+
s.sort((e, t) => e - t);
|
|
259
|
+
let c = s[Math.floor(s.length / 2)], l = Math.min(n, Math.ceil(c));
|
|
260
|
+
l > t[a] && (t[a] = l);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/wasm-table-data.ts
|
|
265
|
+
function z(e) {
|
|
266
|
+
switch (e) {
|
|
267
|
+
case "numeric": return "numeric";
|
|
268
|
+
case "boolean": return "boolean";
|
|
269
|
+
case "timestamp": return "timestamp";
|
|
270
|
+
case "image": return "image";
|
|
271
|
+
default: return "categorical";
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function B(e, t) {
|
|
275
|
+
let n = T(), r = n.num_rows(e), i = n.num_cols(e), a = n.col_names(e), o = [];
|
|
276
|
+
for (let r = 0; r < i; r++) {
|
|
277
|
+
let i = z(n.col_type(e, r)), s = i === "timestamp" ? n.col_timezone(e, r) ?? null : null, c = t?.[a[r]];
|
|
278
|
+
o.push({
|
|
279
|
+
key: a[r],
|
|
280
|
+
label: c?.label ?? a[r],
|
|
281
|
+
width: c?.width ?? L(a[r], i),
|
|
282
|
+
sortable: c?.sortable ?? !0,
|
|
283
|
+
numeric: i === "numeric",
|
|
284
|
+
columnType: i,
|
|
285
|
+
timezone: s
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
let s = /* @__PURE__ */ new Map(), c = 0, l = !1;
|
|
289
|
+
function u() {
|
|
290
|
+
c += 1;
|
|
291
|
+
let t = !1;
|
|
292
|
+
return () => {
|
|
293
|
+
t || (t = !0, --c, c === 0 && !l && (l = !0, n.free(e), s.clear()));
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function d(t) {
|
|
297
|
+
if (t.length === 0) return;
|
|
298
|
+
let r = t.filter((e) => !s.has(e));
|
|
299
|
+
if (r.length === 0) return;
|
|
300
|
+
let a = n.store_viewport_cells(e, Uint32Array.from(r));
|
|
301
|
+
for (let e = 0; e < a.rows.length; e++) {
|
|
302
|
+
let t = a.rows[e], n = [], r = [];
|
|
303
|
+
for (let t = 0; t < i; t++) {
|
|
304
|
+
let s = e * i + t, c = a.strings[s] ?? "";
|
|
305
|
+
if (a.nulls[s]) {
|
|
306
|
+
n.push(""), r.push(null);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
n.push(c);
|
|
310
|
+
let l = o[t].columnType;
|
|
311
|
+
l === "numeric" || l === "timestamp" ? r.push(a.numeric_values[s] ?? NaN) : l === "boolean" ? r.push(c === "Yes") : r.push(c);
|
|
312
|
+
}
|
|
313
|
+
s.set(t, {
|
|
314
|
+
strings: n,
|
|
315
|
+
raws: r
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
let f = {
|
|
320
|
+
columns: o,
|
|
321
|
+
rowCount: r,
|
|
322
|
+
getCell(t, r) {
|
|
323
|
+
if (o[r].columnType === "image") return "";
|
|
324
|
+
let i = s.get(t);
|
|
325
|
+
return i ? i.strings[r] : n.is_null(e, t, r) ? "" : n.get_cell_string(e, t, r);
|
|
326
|
+
},
|
|
327
|
+
getCellRaw(t, r) {
|
|
328
|
+
let i = o[r].columnType;
|
|
329
|
+
if (i === "image") {
|
|
330
|
+
if (n.is_null(e, t, r)) return null;
|
|
331
|
+
let i = n.get_cell_image_count(e, t, r);
|
|
332
|
+
if (i === 0) return null;
|
|
333
|
+
let a = [];
|
|
334
|
+
for (let o = 0; o < i; o++) {
|
|
335
|
+
let i = n.get_cell_image_bytes_at(e, t, r, o);
|
|
336
|
+
i.length > 0 && a.push(i);
|
|
337
|
+
}
|
|
338
|
+
return a.length > 0 ? a : null;
|
|
339
|
+
}
|
|
340
|
+
let a = s.get(t);
|
|
341
|
+
return a ? a.raws[r] : n.is_null(e, t, r) ? null : i === "numeric" || i === "timestamp" ? n.get_cell_f64(e, t, r) : i === "boolean" ? n.get_cell_string(e, t, r) === "Yes" : n.get_cell_string(e, t, r);
|
|
342
|
+
},
|
|
343
|
+
columnSummaries: o.map(() => null),
|
|
344
|
+
castColumn(t, r) {
|
|
345
|
+
n.cast_column(e, t, r), s.clear(), o[t].columnType = r, o[t].numeric = r === "numeric";
|
|
346
|
+
},
|
|
347
|
+
undoCastColumn(t) {
|
|
348
|
+
let r = n.undo_cast_column(e, t);
|
|
349
|
+
return s.clear(), o[t].columnType = r, o[t].numeric = r === "numeric", r;
|
|
350
|
+
},
|
|
351
|
+
isColumnCast(t) {
|
|
352
|
+
return n.has_original_column(e, t);
|
|
353
|
+
},
|
|
354
|
+
sortColumn(t, r) {
|
|
355
|
+
return n.store_sort_indices(e, t, r);
|
|
356
|
+
},
|
|
357
|
+
recomputeFilteredSummaries(t, r) {
|
|
358
|
+
for (let a = 0; a < i; a++) {
|
|
359
|
+
let i = o[a].columnType;
|
|
360
|
+
switch (i) {
|
|
361
|
+
case "categorical": {
|
|
362
|
+
let i = n.store_filtered_value_counts(e, a, t), o = (e) => r > 0 ? Math.round(e / r * 1e3) / 10 : 0, s = i.map(({ label: e, count: t }) => ({
|
|
363
|
+
label: e,
|
|
364
|
+
count: t,
|
|
365
|
+
pct: o(t)
|
|
366
|
+
})), c = s.slice(0, 3), l = i.slice(3).reduce((e, t) => e + t.count, 0), u = o(l), d = i.map(({ label: e }) => e.length).sort((e, t) => e - t), p = d.length > 0 ? d[Math.floor(d.length / 2)] : 0;
|
|
367
|
+
f.columnSummaries[a] = {
|
|
368
|
+
kind: "categorical",
|
|
369
|
+
uniqueCount: i.length,
|
|
370
|
+
topCategories: c,
|
|
371
|
+
othersCount: l,
|
|
372
|
+
othersPct: u,
|
|
373
|
+
allCategories: s,
|
|
374
|
+
medianTextLength: p
|
|
375
|
+
};
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
case "boolean": {
|
|
379
|
+
let [i, o, s] = n.store_filtered_bool_counts(e, a, t);
|
|
380
|
+
f.columnSummaries[a] = {
|
|
381
|
+
kind: "boolean",
|
|
382
|
+
trueCount: i,
|
|
383
|
+
falseCount: o,
|
|
384
|
+
nullCount: s,
|
|
385
|
+
total: r
|
|
386
|
+
};
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
case "numeric":
|
|
390
|
+
case "timestamp": {
|
|
391
|
+
let r = n.store_filtered_histogram(e, a, t, 25);
|
|
392
|
+
r.length === 0 ? f.columnSummaries[a] = null : f.columnSummaries[a] = {
|
|
393
|
+
kind: i,
|
|
394
|
+
min: r[0].x0,
|
|
395
|
+
max: r[r.length - 1].x1,
|
|
396
|
+
bins: r
|
|
397
|
+
};
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
filterRows(t) {
|
|
404
|
+
let r = [];
|
|
405
|
+
for (let e = 0; e < t.length; e++) {
|
|
406
|
+
let n = t[e];
|
|
407
|
+
if (n) switch (n.kind) {
|
|
408
|
+
case "range":
|
|
409
|
+
r.push({
|
|
410
|
+
kind: "range",
|
|
411
|
+
col: e,
|
|
412
|
+
min: n.min,
|
|
413
|
+
max: n.max
|
|
414
|
+
});
|
|
415
|
+
break;
|
|
416
|
+
case "set":
|
|
417
|
+
r.push({
|
|
418
|
+
kind: "set",
|
|
419
|
+
col: e,
|
|
420
|
+
values: Array.from(n.values)
|
|
421
|
+
});
|
|
422
|
+
break;
|
|
423
|
+
case "not-in":
|
|
424
|
+
r.push({
|
|
425
|
+
kind: "not_in",
|
|
426
|
+
col: e,
|
|
427
|
+
values: Array.from(n.values)
|
|
428
|
+
});
|
|
429
|
+
break;
|
|
430
|
+
case "boolean":
|
|
431
|
+
r.push({
|
|
432
|
+
kind: "boolean",
|
|
433
|
+
col: e,
|
|
434
|
+
value: n.value
|
|
435
|
+
});
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return n.store_filter_rows(e, r);
|
|
440
|
+
},
|
|
441
|
+
dispose: u()
|
|
442
|
+
};
|
|
443
|
+
function p(t) {
|
|
444
|
+
let r = !1, i = o.map((i, a) => {
|
|
445
|
+
let o = t?.[i.key], s = o?.columnType ?? z(n.col_type(e, a)), c = o?.numeric ?? s === "numeric";
|
|
446
|
+
return s === i.columnType && c === i.numeric ? i : (r = !0, {
|
|
447
|
+
...i,
|
|
448
|
+
columnType: s,
|
|
449
|
+
numeric: c
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
return r ? (o = i, s.clear(), f = {
|
|
453
|
+
...f,
|
|
454
|
+
columns: o,
|
|
455
|
+
columnSummaries: o.map(() => null),
|
|
456
|
+
dispose: u()
|
|
457
|
+
}, f) : null;
|
|
458
|
+
}
|
|
459
|
+
return {
|
|
460
|
+
handle: e,
|
|
461
|
+
tableData: f,
|
|
462
|
+
columns: o,
|
|
463
|
+
prefetchViewport: d,
|
|
464
|
+
refreshColumnTypes: p
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/parquet-file.ts
|
|
469
|
+
function V(e) {
|
|
470
|
+
return {
|
|
471
|
+
byteLength: e.byteLength,
|
|
472
|
+
read(t, n) {
|
|
473
|
+
return Promise.resolve(e.subarray(t, t + n));
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
var H = 64 * 1024, U = 64 * 1024, W = 8, G = 4 + W;
|
|
478
|
+
function K(e) {
|
|
479
|
+
return Object.prototype.toString.call(e) === "[object Uint8Array]";
|
|
480
|
+
}
|
|
481
|
+
function q(e, t) {
|
|
482
|
+
return e[t] === 80 && e[t + 1] === 65 && e[t + 2] === 82 && e[t + 3] === 49;
|
|
483
|
+
}
|
|
484
|
+
async function J(e, t, n, r) {
|
|
485
|
+
if (r?.throwIfAborted(), !Number.isInteger(t) || !Number.isInteger(n) || t < 0 || n < 0 || t + n > e.byteLength) throw Error(`Byte range ${t}+${n} lies outside the file (${e.byteLength})`);
|
|
486
|
+
let i = await e.read(t, n, r);
|
|
487
|
+
if (r?.throwIfAborted(), !K(i) || i.byteLength !== n) throw Error(`ByteSource.read(${t}, ${n}) returned ${i?.byteLength ?? "no"} bytes`);
|
|
488
|
+
return i;
|
|
489
|
+
}
|
|
490
|
+
function Y(e, t = U, n = Infinity) {
|
|
491
|
+
let r = [];
|
|
492
|
+
for (let t = 0; t + 1 < e.length; t += 2) r.push({
|
|
493
|
+
offset: e[t],
|
|
494
|
+
length: e[t + 1]
|
|
495
|
+
});
|
|
496
|
+
r.sort((e, t) => e.offset - t.offset);
|
|
497
|
+
let i = r.reduce((e, t) => e + t.length, 0), a = [];
|
|
498
|
+
for (let e of r) {
|
|
499
|
+
let r = a[a.length - 1], o = r ? r.offset + r.length : 0, s = e.offset - o;
|
|
500
|
+
if (r && (s <= 0 || s <= t && i + s <= n)) {
|
|
501
|
+
let t = Math.max(o, e.offset + e.length);
|
|
502
|
+
s > 0 && (i += s), r.length = t - r.offset;
|
|
503
|
+
} else a.push({ ...e });
|
|
504
|
+
}
|
|
505
|
+
return a;
|
|
506
|
+
}
|
|
507
|
+
async function X(e, t) {
|
|
508
|
+
let { limits: a, columnOverrides: o, signal: c } = t, u = t.overflow ?? "error";
|
|
509
|
+
if (u !== "error" && u !== "truncate") throw Error(`overflow must be "error" or "truncate", got ${String(u)}`);
|
|
510
|
+
let d = e.byteLength;
|
|
511
|
+
if (!Number.isInteger(d) || d < 0) throw Error("ByteSource.byteLength must be a non-negative integer");
|
|
512
|
+
if (d < G) throw Error("Table file is too small to be a Parquet file");
|
|
513
|
+
let f = Math.min(d, H), p = await J(e, d - f, f, c);
|
|
514
|
+
if (!q(p, p.byteLength - 4)) throw Error("Not a Parquet file: missing PAR1 footer magic");
|
|
515
|
+
let m = await S();
|
|
516
|
+
c?.throwIfAborted();
|
|
517
|
+
let h = m.parquet_footer_length(p.subarray(p.byteLength - W)), g = h + W;
|
|
518
|
+
if (g + 4 > d) throw Error("Parquet footer length exceeds the file length");
|
|
519
|
+
if (h > a.maxDecodedBytes) throw Error(`Parquet footer exceeds decoded bytes limit (${h} > ${a.maxDecodedBytes})`);
|
|
520
|
+
g > f && (f = g, p = await J(e, d - f, f, c));
|
|
521
|
+
let _ = m.parquet_open(p, d, a.maxRows, a.maxColumns, a.maxDecodedBytes, u === "truncate"), v = !0, y = () => {
|
|
522
|
+
v && (v = !1, m.parquet_close(_));
|
|
523
|
+
}, b;
|
|
524
|
+
try {
|
|
525
|
+
let t = m.parquet_file_info(_), d = m.parquet_file_column_hints(_), f = i(d);
|
|
526
|
+
b = m.parquet_create_store(_);
|
|
527
|
+
let p = b, h = B(p), g = h.tableData, x = h.columns;
|
|
528
|
+
n(x, d), s(x, o);
|
|
529
|
+
let S = r(d, o), C = Object.freeze(l(m.parquet_file_column_stats(_), x.length)), w = u === "truncate" ? a.maxDecodedBytes : Infinity, T = 0, E = !1, D = !1, O = !1, k = !1, j = {
|
|
530
|
+
rows: 0,
|
|
531
|
+
decodedBytes: 0
|
|
532
|
+
}, M = !1, N = !1, P = () => ({
|
|
533
|
+
loadedRows: T,
|
|
534
|
+
totalRows: {
|
|
535
|
+
value: t.num_rows,
|
|
536
|
+
scope: "dataset",
|
|
537
|
+
precision: "exact",
|
|
538
|
+
source: "metadata"
|
|
539
|
+
},
|
|
540
|
+
rowGroups: t.num_row_groups,
|
|
541
|
+
truncated: D || O,
|
|
542
|
+
...k ? { resumable: O } : {}
|
|
543
|
+
}), F = (e, t) => {
|
|
544
|
+
e.datasetStats = C, e.coverage = P(), e.recomputeSummaries = () => {
|
|
545
|
+
e.coverage = P(), A(m, p, e, t, f);
|
|
546
|
+
}, e.recomputeSummaries();
|
|
547
|
+
};
|
|
548
|
+
g.prefetchViewport = h.prefetchViewport, F(g, x);
|
|
549
|
+
let I = () => {
|
|
550
|
+
let e = h.refreshColumnTypes(S);
|
|
551
|
+
if (e) {
|
|
552
|
+
let t = g;
|
|
553
|
+
g = e, x = e.columns, g.prefetchViewport = h.prefetchViewport, F(g, x), t.dispose?.();
|
|
554
|
+
} else g.recomputeSummaries?.();
|
|
555
|
+
return e;
|
|
556
|
+
}, L = t.row_group_rows.slice();
|
|
557
|
+
return {
|
|
558
|
+
rowCount: t.num_rows,
|
|
559
|
+
rowGroupCount: t.num_row_groups,
|
|
560
|
+
rowGroupRows: L,
|
|
561
|
+
get tableData() {
|
|
562
|
+
return g;
|
|
563
|
+
},
|
|
564
|
+
get columns() {
|
|
565
|
+
return x;
|
|
566
|
+
},
|
|
567
|
+
get loadedRows() {
|
|
568
|
+
return T;
|
|
569
|
+
},
|
|
570
|
+
get truncated() {
|
|
571
|
+
return D;
|
|
572
|
+
},
|
|
573
|
+
get usage() {
|
|
574
|
+
return j;
|
|
575
|
+
},
|
|
576
|
+
setPaused(e) {
|
|
577
|
+
O !== e && (O = e, e && (k = !0), g.coverage = P(), T === t.num_rows && g.recomputeSummaries?.());
|
|
578
|
+
},
|
|
579
|
+
async appendRowGroup(t) {
|
|
580
|
+
if (!v || M) throw Error("Parquet file is closed");
|
|
581
|
+
if (N) throw Error("Append one Parquet row group at a time");
|
|
582
|
+
if (E) throw Error("Parquet preview budget is exhausted; no more row groups can be loaded");
|
|
583
|
+
N = !0;
|
|
584
|
+
try {
|
|
585
|
+
let n = Y(m.parquet_row_group_ranges(_, t), U, w), r = await Promise.all(n.map((t) => J(e, t.offset, t.length, c)));
|
|
586
|
+
if (!v) throw Error("Parquet file is closed");
|
|
587
|
+
let i = r.reduce((e, t) => e + t.byteLength, 0), a = new Uint8Array(i), o = new Float64Array(n.length * 2), s = 0;
|
|
588
|
+
n.forEach((e, t) => {
|
|
589
|
+
a.set(r[t], s), s += r[t].byteLength, o[t * 2] = e.offset, o[t * 2 + 1] = e.length;
|
|
590
|
+
});
|
|
591
|
+
let l = m.parquet_append_row_group(_, p, t, o, a);
|
|
592
|
+
T += l, {exhausted: E, truncated: D} = m.parquet_file_budget(_);
|
|
593
|
+
let u = m.parquet_file_usage(_);
|
|
594
|
+
return j = {
|
|
595
|
+
rows: u.rows,
|
|
596
|
+
decodedBytes: u.decoded_bytes
|
|
597
|
+
}, O = !1, {
|
|
598
|
+
rowsAppended: l,
|
|
599
|
+
replaced: I(),
|
|
600
|
+
exhausted: E
|
|
601
|
+
};
|
|
602
|
+
} finally {
|
|
603
|
+
N = !1;
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
finish() {
|
|
607
|
+
if (M) return {
|
|
608
|
+
rowsAppended: 0,
|
|
609
|
+
replaced: null
|
|
610
|
+
};
|
|
611
|
+
M = !0, O = !1, m.finish_arrow_stream_store(p);
|
|
612
|
+
let e = I();
|
|
613
|
+
return y(), {
|
|
614
|
+
rowsAppended: 0,
|
|
615
|
+
replaced: e
|
|
616
|
+
};
|
|
617
|
+
},
|
|
618
|
+
close: y,
|
|
619
|
+
dispose() {
|
|
620
|
+
y(), g.dispose?.();
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
} catch (e) {
|
|
624
|
+
throw b !== void 0 && m.free(b), y(), e instanceof Error ? e : Error(String(e));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/permutation.ts
|
|
629
|
+
function Z(e, t, n) {
|
|
630
|
+
for (let r = 0; r < t.length; r++) {
|
|
631
|
+
let i = t[r];
|
|
632
|
+
if (!i) continue;
|
|
633
|
+
let a = e.getCellRaw(n, r);
|
|
634
|
+
switch (i.kind) {
|
|
635
|
+
case "range": {
|
|
636
|
+
if (a == null) return !1;
|
|
637
|
+
let e = Number(a);
|
|
638
|
+
if (!Number.isFinite(e) || e < i.min || e > i.max) return !1;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
case "set": {
|
|
642
|
+
if (a == null) return !1;
|
|
643
|
+
let t = e.getCell(n, r);
|
|
644
|
+
if (!i.values.has(t)) return !1;
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
case "not-in": {
|
|
648
|
+
if (a == null) break;
|
|
649
|
+
let t = e.getCell(n, r);
|
|
650
|
+
if (i.values.has(t)) return !1;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
case "boolean":
|
|
654
|
+
if (a == null || !!a !== i.value) return !1;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return !0;
|
|
659
|
+
}
|
|
660
|
+
function Q(e, t, n, r) {
|
|
661
|
+
let i = t[n].columnType, a = i === "numeric" || i === "timestamp";
|
|
662
|
+
return (t, o) => {
|
|
663
|
+
let s;
|
|
664
|
+
if (a) {
|
|
665
|
+
let r = e.getCellRaw(t, n), i = e.getCellRaw(o, n), a = r == null ? NaN : Number(r), c = i == null ? NaN : Number(i), l = Number.isFinite(a) || a === Infinity || a === -Infinity, u = Number.isFinite(c) || c === Infinity || c === -Infinity;
|
|
666
|
+
if (!l && !u) s = 0;
|
|
667
|
+
else if (!l) return 1;
|
|
668
|
+
else if (u) s = a - c;
|
|
669
|
+
else return -1;
|
|
670
|
+
} else if (i === "boolean") {
|
|
671
|
+
let r = e.getCellRaw(t, n), i = e.getCellRaw(o, n);
|
|
672
|
+
if (r == null && i == null) s = 0;
|
|
673
|
+
else if (r == null) return 1;
|
|
674
|
+
else if (i == null) return -1;
|
|
675
|
+
else s = !!r - +!!i;
|
|
676
|
+
} else {
|
|
677
|
+
let r = e.getCellRaw(t, n), i = e.getCellRaw(o, n);
|
|
678
|
+
if (r == null && i == null) s = 0;
|
|
679
|
+
else if (r == null) return 1;
|
|
680
|
+
else if (i == null) return -1;
|
|
681
|
+
else {
|
|
682
|
+
let r = e.getCell(t, n), i = e.getCell(o, n);
|
|
683
|
+
s = r < i ? -1 : +(r > i);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return r === "asc" ? s : -s;
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function $(e, t, n, r, i) {
|
|
690
|
+
let a = n.some((e) => e !== null), o = [];
|
|
691
|
+
if (a) if (e.filterRows) {
|
|
692
|
+
let t = e.filterRows(n);
|
|
693
|
+
for (let e = 0; e < t.length; e++) o.push(t[e]);
|
|
694
|
+
} else for (let t = 0; t < i; t++) Z(e, n, t) && o.push(t);
|
|
695
|
+
else for (let e = 0; e < i; e++) o.push(e);
|
|
696
|
+
if (r) {
|
|
697
|
+
let { col: n, dir: i } = r;
|
|
698
|
+
if (e.sortColumn) {
|
|
699
|
+
let t = e.sortColumn(n, i === "asc");
|
|
700
|
+
if (a) {
|
|
701
|
+
let e = new Set(o);
|
|
702
|
+
o.length = 0;
|
|
703
|
+
for (let n = 0; n < t.length; n++) e.has(t[n]) && o.push(t[n]);
|
|
704
|
+
} else {
|
|
705
|
+
o.length = 0;
|
|
706
|
+
for (let e = 0; e < t.length; e++) o.push(t[e]);
|
|
707
|
+
}
|
|
708
|
+
} else o.sort(Q(e, t, n, i));
|
|
709
|
+
}
|
|
710
|
+
return o;
|
|
711
|
+
}
|
|
712
|
+
//#endregion
|
|
713
|
+
//#region src/windowed-resident.ts
|
|
714
|
+
var ee = 100;
|
|
715
|
+
function te(e) {
|
|
716
|
+
if (e == null) return NaN;
|
|
717
|
+
if (typeof e == "number") return e;
|
|
718
|
+
if (e instanceof Date) return e.getTime();
|
|
719
|
+
let t = Number(e);
|
|
720
|
+
return Number.isNaN(t) ? NaN : t;
|
|
721
|
+
}
|
|
722
|
+
function ne(e) {
|
|
723
|
+
return Array.isArray(e) ? e : e instanceof Uint8Array ? [e] : [];
|
|
724
|
+
}
|
|
725
|
+
function re(e, t = {}) {
|
|
726
|
+
let n = t.headRows ?? ee, r = /* @__PURE__ */ new Set(), i = {
|
|
727
|
+
filters: e.columns.map(() => null),
|
|
728
|
+
sort: null
|
|
729
|
+
}, a = null, o = e.rowCount, s = [...e.columnSummaries], c = !1, l = (e) => e.filters.some((e) => e !== null);
|
|
730
|
+
function u(e) {
|
|
731
|
+
for (let t of r) t(e);
|
|
732
|
+
}
|
|
733
|
+
function d(t, n) {
|
|
734
|
+
let { columns: r } = e, i = r.length;
|
|
735
|
+
e.prefetchViewport?.(Array.from(n));
|
|
736
|
+
let a = Array.from({ length: n.length * i }, () => ""), o = new Uint8Array(n.length * i), s = new Float64Array(n.length * i).fill(NaN);
|
|
737
|
+
for (let t = 0; t < n.length; t++) {
|
|
738
|
+
let c = n[t];
|
|
739
|
+
for (let n = 0; n < i; n++) {
|
|
740
|
+
let l = t * i + n, u = r[n].columnType, d = e.getCellRaw(c, n);
|
|
741
|
+
if (d == null) {
|
|
742
|
+
a[l] = "", o[l] = 1;
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
a[l] = e.getCell(c, n), u === "numeric" || u === "timestamp" ? s[l] = te(d) : u === "boolean" && (s[l] = +!!d);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return {
|
|
749
|
+
viewStart: t,
|
|
750
|
+
dataRows: n,
|
|
751
|
+
strings: a,
|
|
752
|
+
nulls: o,
|
|
753
|
+
numeric: s
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
function f(e, t) {
|
|
757
|
+
let n = Math.max(0, e), r = new Uint32Array(Math.max(0, Math.min(t, o) - n));
|
|
758
|
+
for (let e = 0; e < r.length; e++) r[e] = a ? a[n + e] : n + e;
|
|
759
|
+
return r;
|
|
760
|
+
}
|
|
761
|
+
function p() {
|
|
762
|
+
let t = Math.max(0, Math.min(n, e.rowCount));
|
|
763
|
+
return d(0, Uint32Array.from({ length: t }, (e, t) => t));
|
|
764
|
+
}
|
|
765
|
+
function m(t) {
|
|
766
|
+
let { columns: n, rowCount: r } = e;
|
|
767
|
+
l(i) || i.sort ? (a = $(e, n, i.filters, i.sort, r), o = a.length) : (a = null, o = r);
|
|
768
|
+
let c;
|
|
769
|
+
if (l(i) && e.recomputeFilteredSummaries) {
|
|
770
|
+
let t = new Uint8Array(r);
|
|
771
|
+
for (let e = 0; e < o; e++) t[a[e]] = 1;
|
|
772
|
+
e.recomputeFilteredSummaries(t, o), c = [...e.columnSummaries];
|
|
773
|
+
for (let e = 0; e < n.length; e++) {
|
|
774
|
+
let t = s[e], n = c[e];
|
|
775
|
+
t && n && t.isIndex && (n.isIndex = !0);
|
|
776
|
+
}
|
|
777
|
+
} else e.columnSummaries = [...s], c = [...s];
|
|
778
|
+
return {
|
|
779
|
+
generation: t,
|
|
780
|
+
filteredCount: o,
|
|
781
|
+
summaries: c,
|
|
782
|
+
summariesAll: [...s]
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
function h(e) {
|
|
786
|
+
if (c) return Promise.reject(/* @__PURE__ */ Error("Windowed data is disposed"));
|
|
787
|
+
try {
|
|
788
|
+
let t = e();
|
|
789
|
+
return Promise.resolve().then(() => t);
|
|
790
|
+
} catch (e) {
|
|
791
|
+
return Promise.reject(e);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
function g() {
|
|
795
|
+
if (c) throw Error("Windowed data is disposed");
|
|
796
|
+
}
|
|
797
|
+
let _ = {
|
|
798
|
+
kind: "windowed",
|
|
799
|
+
columns: e.columns,
|
|
800
|
+
rowCount: e.rowCount,
|
|
801
|
+
get coverage() {
|
|
802
|
+
return e.coverage;
|
|
803
|
+
},
|
|
804
|
+
get datasetStats() {
|
|
805
|
+
return e.datasetStats;
|
|
806
|
+
},
|
|
807
|
+
head: p(),
|
|
808
|
+
requestWindow(e, t) {
|
|
809
|
+
return h(() => d(Math.max(0, e), f(e, t)));
|
|
810
|
+
},
|
|
811
|
+
setQuery(e, t) {
|
|
812
|
+
return h(() => (i = {
|
|
813
|
+
filters: [...e.filters],
|
|
814
|
+
sort: e.sort
|
|
815
|
+
}, m(t)));
|
|
816
|
+
},
|
|
817
|
+
requestImage(t, n) {
|
|
818
|
+
return h(() => {
|
|
819
|
+
let r = ne(e.getCellRaw(t, n));
|
|
820
|
+
return r.length > 0 ? r : null;
|
|
821
|
+
});
|
|
822
|
+
},
|
|
823
|
+
castColumn: e.castColumn ? (t, n, r) => h(() => {
|
|
824
|
+
e.castColumn(t, n), e.columns[t].columnType = n, e.columns[t].numeric = n === "numeric", e.recomputeSummaries?.(), s = [...e.columnSummaries];
|
|
825
|
+
let i = m(r);
|
|
826
|
+
return _.head = p(), {
|
|
827
|
+
...i,
|
|
828
|
+
columns: e.columns
|
|
829
|
+
};
|
|
830
|
+
}) : void 0,
|
|
831
|
+
undoCastColumn: e.undoCastColumn ? (t, n) => h(() => {
|
|
832
|
+
let r = e.undoCastColumn(t);
|
|
833
|
+
e.columns[t].columnType = r, e.columns[t].numeric = r === "numeric", e.recomputeSummaries?.(), s = [...e.columnSummaries];
|
|
834
|
+
let i = m(n);
|
|
835
|
+
return _.head = p(), {
|
|
836
|
+
...i,
|
|
837
|
+
columns: e.columns
|
|
838
|
+
};
|
|
839
|
+
}) : void 0,
|
|
840
|
+
isColumnCast: e.isColumnCast ? (t) => e.isColumnCast(t) : void 0,
|
|
841
|
+
subscribe(e) {
|
|
842
|
+
return r.add(e), () => r.delete(e);
|
|
843
|
+
},
|
|
844
|
+
dispose() {
|
|
845
|
+
c || (c = !0, r.clear(), e.dispose?.());
|
|
846
|
+
},
|
|
847
|
+
notifyAppended() {
|
|
848
|
+
g(), _.rowCount = e.rowCount, a || (o = e.rowCount), s = [...e.columnSummaries], u({
|
|
849
|
+
type: "rows-appended",
|
|
850
|
+
rowCount: e.rowCount,
|
|
851
|
+
summariesAll: [...s]
|
|
852
|
+
});
|
|
853
|
+
},
|
|
854
|
+
notifyStreamingDone() {
|
|
855
|
+
g(), u({ type: "streaming-done" });
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
return _;
|
|
859
|
+
}
|
|
860
|
+
//#endregion
|
|
861
|
+
//#region src/worker/protocol.ts
|
|
862
|
+
var ie = 2.5;
|
|
863
|
+
function ae(e) {
|
|
864
|
+
return se([
|
|
865
|
+
e.dataRows.buffer,
|
|
866
|
+
e.nulls.buffer,
|
|
867
|
+
e.numeric.buffer
|
|
868
|
+
]);
|
|
869
|
+
}
|
|
870
|
+
function oe(e) {
|
|
871
|
+
let t = e.buffer;
|
|
872
|
+
return t instanceof ArrayBuffer && e.byteOffset === 0 && e.byteLength === t.byteLength ? e : new Uint8Array(e);
|
|
873
|
+
}
|
|
874
|
+
function se(e) {
|
|
875
|
+
let t = [];
|
|
876
|
+
for (let n of e) n instanceof ArrayBuffer && !t.includes(n) && t.push(n);
|
|
877
|
+
return t;
|
|
878
|
+
}
|
|
879
|
+
function ce(e) {
|
|
880
|
+
if (typeof WebAssembly < "u" && e instanceof WebAssembly.RuntimeError) return !0;
|
|
881
|
+
let t = e instanceof Error ? e.message : typeof e == "string" ? e : "";
|
|
882
|
+
return /malloc|unreachable|memory access out of bounds/i.test(t);
|
|
883
|
+
}
|
|
884
|
+
//#endregion
|
|
885
|
+
export { n as C, s as S, b as _, re as a, g as b, X as c, N as d, R as f, v as g, T as h, ae as i, J as l, S as m, ce as n, $ as o, A as p, oe as r, V as s, ie as t, B as u, _ as v, i as w, c as x, w as y };
|