@milaboratories/pframes-rs-node 1.1.36 → 1.1.38
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/export/addon-def.ts +9 -52
- package/export/dump.ts +27 -112
- package/export/export.ts +2 -2
- package/export/wrapper.ts +39 -356
- package/export_dist/dump.cjs +17 -81
- package/export_dist/dump.cjs.map +1 -1
- package/export_dist/dump.js +16 -77
- package/export_dist/dump.js.map +1 -1
- package/export_dist/export.cjs.map +1 -1
- package/export_dist/export.d.ts +1 -1
- package/export_dist/export.js.map +1 -1
- package/export_dist/wrapper.cjs +31 -225
- package/export_dist/wrapper.cjs.map +1 -1
- package/export_dist/wrapper.js +32 -226
- package/export_dist/wrapper.js.map +1 -1
- package/package.json +4 -4
package/export/wrapper.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { ulid } from "ulid";
|
|
2
2
|
import {
|
|
3
3
|
AbortError,
|
|
4
|
-
type PColumnInfo,
|
|
5
|
-
type PColumnSpec,
|
|
6
4
|
PFrameError,
|
|
7
|
-
type PObjectId,
|
|
8
|
-
type PTableColumnId,
|
|
9
|
-
type PTableColumnSpec,
|
|
10
|
-
type PTableRecordFilter,
|
|
11
5
|
type PTableShape,
|
|
12
|
-
type PTableSorting,
|
|
13
6
|
type PTableVector,
|
|
14
7
|
type TableRange,
|
|
15
|
-
type UniqueValuesRequest,
|
|
16
8
|
type UniqueValuesResponse,
|
|
17
9
|
type DataQuery,
|
|
18
10
|
ensureError,
|
|
@@ -25,12 +17,9 @@ import { AddonSymbol } from "./addon";
|
|
|
25
17
|
import {
|
|
26
18
|
dump,
|
|
27
19
|
hashColumnId,
|
|
28
|
-
|
|
29
|
-
hashFilterColumnId,
|
|
20
|
+
hashAddColumnEntry,
|
|
30
21
|
hashUniqueValuesRequestColumnId,
|
|
31
|
-
|
|
32
|
-
hashCreateTableRequestColumnId,
|
|
33
|
-
hashCreateTableV2RequestColumnId,
|
|
22
|
+
hashDataQuery,
|
|
34
23
|
} from "./dump";
|
|
35
24
|
|
|
36
25
|
export async function pprofDump(): Promise<Uint8Array> {
|
|
@@ -43,7 +32,7 @@ export async function pprofDump(): Promise<Uint8Array> {
|
|
|
43
32
|
}
|
|
44
33
|
}
|
|
45
34
|
|
|
46
|
-
export class PFrame implements PFrameInternal.
|
|
35
|
+
export class PFrame implements PFrameInternal.PFrameV14 {
|
|
47
36
|
readonly #frame: NodeFrameSymbol;
|
|
48
37
|
|
|
49
38
|
readonly #id: PFrameInternal.PFrameId;
|
|
@@ -82,37 +71,41 @@ export class PFrame implements PFrameInternal.PFrameV13 {
|
|
|
82
71
|
}
|
|
83
72
|
}
|
|
84
73
|
|
|
85
|
-
|
|
74
|
+
async addColumns(
|
|
75
|
+
columns: PFrameInternal.AddColumnEntry[],
|
|
76
|
+
ops?: {
|
|
77
|
+
signal?: AbortSignal;
|
|
78
|
+
},
|
|
79
|
+
): Promise<void> {
|
|
86
80
|
const requestId = ulid();
|
|
87
81
|
dump(
|
|
88
82
|
[`${this.id}`, `${requestId}.json`],
|
|
89
83
|
{
|
|
90
84
|
timeStamp: Date.now(),
|
|
91
|
-
requestType: "
|
|
85
|
+
requestType: "addColumns",
|
|
92
86
|
requestData: {
|
|
93
|
-
|
|
94
|
-
columnSpec,
|
|
87
|
+
columns: columns.map(hashAddColumnEntry),
|
|
95
88
|
},
|
|
96
89
|
},
|
|
97
90
|
this.#logger,
|
|
98
91
|
);
|
|
99
92
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
this.#logger
|
|
106
|
-
|
|
93
|
+
for (const column of columns) {
|
|
94
|
+
const hashedId = hashColumnId(column.id);
|
|
95
|
+
// Data layer is spec-name-independent: only the structural `typeSpec`
|
|
96
|
+
// is dumped to `.typespec` (the full `PColumnSpec` no longer reaches node).
|
|
97
|
+
dump([`${this.id}`, `data`, `${hashedId}.typespec`], { ...column.typeSpec }, this.#logger);
|
|
98
|
+
dump([`${this.id}`, `data`, `${hashedId}.datainfo`], { ...column.data }, this.#logger);
|
|
99
|
+
}
|
|
107
100
|
|
|
108
101
|
try {
|
|
109
|
-
|
|
102
|
+
ops?.signal?.throwIfAborted();
|
|
103
|
+
return await AddonSymbol.pFrameAddColumns(this.#frame, columns, ops?.signal);
|
|
110
104
|
} catch (err: unknown) {
|
|
111
|
-
const error = new PFrameError(`PFrame
|
|
105
|
+
const error = new PFrameError(`PFrame addColumns request failed`);
|
|
112
106
|
error.cause = new Error(
|
|
113
|
-
`PFrame ${this.id}
|
|
114
|
-
`
|
|
115
|
-
`columnSpec: ${JSON.stringify(columnSpec)}, ` +
|
|
107
|
+
`PFrame ${this.id} addColumns request ${requestId} failed, ` +
|
|
108
|
+
`columns: ${JSON.stringify(columns)}, ` +
|
|
116
109
|
`error:\n` +
|
|
117
110
|
`${ensureError(err)}`,
|
|
118
111
|
);
|
|
@@ -197,51 +190,6 @@ export class PFrame implements PFrameInternal.PFrameV13 {
|
|
|
197
190
|
}
|
|
198
191
|
}
|
|
199
192
|
|
|
200
|
-
setColumnData(
|
|
201
|
-
columnId: PObjectId,
|
|
202
|
-
dataInfo: PFrameInternal.DataInfo<PFrameInternal.PFrameBlobId>,
|
|
203
|
-
ops?: {
|
|
204
|
-
signal?: AbortSignal;
|
|
205
|
-
},
|
|
206
|
-
): Promise<void> {
|
|
207
|
-
const requestId = ulid();
|
|
208
|
-
dump(
|
|
209
|
-
[`${this.id}`, `${requestId}.json`],
|
|
210
|
-
{
|
|
211
|
-
timeStamp: Date.now(),
|
|
212
|
-
requestType: "setColumnData",
|
|
213
|
-
requestData: {
|
|
214
|
-
columnId: hashColumnId(columnId),
|
|
215
|
-
dataInfo,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
this.#logger,
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
dump(
|
|
222
|
-
[`${this.id}`, `data`, `${hashColumnId(columnId)}.datainfo`],
|
|
223
|
-
{
|
|
224
|
-
...dataInfo,
|
|
225
|
-
},
|
|
226
|
-
this.#logger,
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
try {
|
|
230
|
-
ops?.signal?.throwIfAborted();
|
|
231
|
-
return AddonSymbol.pFrameSetColumnData(this.#frame, columnId, dataInfo, ops?.signal);
|
|
232
|
-
} catch (err: unknown) {
|
|
233
|
-
const error = new PFrameError(`PFrame setColumnData request failed`);
|
|
234
|
-
error.cause = new Error(
|
|
235
|
-
`PFrame ${this.id} setColumnData request ${requestId} failed, ` +
|
|
236
|
-
`columnId: ${JSON.stringify(columnId)}, ` +
|
|
237
|
-
`dataInfo: ${JSON.stringify(dataInfo)}, ` +
|
|
238
|
-
`error:\n` +
|
|
239
|
-
`${ensureError(err)}`,
|
|
240
|
-
);
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
193
|
dispose(): void {
|
|
246
194
|
const requestId = ulid();
|
|
247
195
|
dump(
|
|
@@ -271,182 +219,23 @@ export class PFrame implements PFrameInternal.PFrameV13 {
|
|
|
271
219
|
this.dispose();
|
|
272
220
|
}
|
|
273
221
|
|
|
274
|
-
|
|
275
|
-
request: PFrameInternal.FindColumnsRequest,
|
|
276
|
-
): Promise<PFrameInternal.FindColumnsResponse> {
|
|
277
|
-
const requestId = ulid();
|
|
278
|
-
dump(
|
|
279
|
-
[`${this.id}`, `${requestId}.json`],
|
|
280
|
-
{
|
|
281
|
-
timeStamp: Date.now(),
|
|
282
|
-
requestType: "findColumns",
|
|
283
|
-
requestData: request,
|
|
284
|
-
},
|
|
285
|
-
this.#logger,
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
const timer = PerfTimer.start();
|
|
289
|
-
try {
|
|
290
|
-
return await AddonSymbol.pFrameFindColumns(this.#frame, request);
|
|
291
|
-
} catch (err: unknown) {
|
|
292
|
-
const error = new PFrameError(`PFrame findColumns request failed`);
|
|
293
|
-
error.cause = new Error(
|
|
294
|
-
`PFrame ${this.id} findColumns request ${requestId} failed, ` +
|
|
295
|
-
`request: ${JSON.stringify(request)}, ` +
|
|
296
|
-
`error:\n` +
|
|
297
|
-
`${ensureError(err)}`,
|
|
298
|
-
);
|
|
299
|
-
throw error;
|
|
300
|
-
} finally {
|
|
301
|
-
this.#logger(
|
|
302
|
-
"info",
|
|
303
|
-
`PFrame ${this.id} findColumns request ${requestId} took ${timer.elapsed()}`,
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
async deleteColumn(
|
|
309
|
-
request: PFrameInternal.DeleteColumnFromColumnsRequest,
|
|
310
|
-
): Promise<PFrameInternal.DeleteColumnFromColumnsResponse> {
|
|
311
|
-
const requestId = ulid();
|
|
312
|
-
dump(
|
|
313
|
-
[`${this.id}`, `${requestId}.json`],
|
|
314
|
-
{
|
|
315
|
-
timeStamp: Date.now(),
|
|
316
|
-
requestType: "deleteColumn",
|
|
317
|
-
requestData: request,
|
|
318
|
-
},
|
|
319
|
-
this.#logger,
|
|
320
|
-
);
|
|
321
|
-
|
|
222
|
+
createTable(tableId: PFrameInternal.PTableId, dataQuery: DataQuery): PTable {
|
|
322
223
|
const timer = PerfTimer.start();
|
|
323
|
-
try {
|
|
324
|
-
return await AddonSymbol.pFrameDeleteColumn(this.#frame, request);
|
|
325
|
-
} catch (err: unknown) {
|
|
326
|
-
const error = new PFrameError(`PFrame deleteColumn request failed`);
|
|
327
|
-
error.cause = new Error(
|
|
328
|
-
`PFrame ${this.id} deleteColumn request ${requestId} failed, ` +
|
|
329
|
-
`request: ${JSON.stringify(request)}, ` +
|
|
330
|
-
`error:\n` +
|
|
331
|
-
`${ensureError(err)}`,
|
|
332
|
-
);
|
|
333
|
-
throw error;
|
|
334
|
-
} finally {
|
|
335
|
-
this.#logger(
|
|
336
|
-
"info",
|
|
337
|
-
`PFrame ${this.id} deleteColumn request ${requestId} took ${timer.elapsed()}`,
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
async getColumnSpec(columnId: PObjectId): Promise<PColumnSpec | null> {
|
|
343
|
-
const requestId = ulid();
|
|
344
|
-
dump(
|
|
345
|
-
[`${this.id}`, `${requestId}.json`],
|
|
346
|
-
{
|
|
347
|
-
timeStamp: Date.now(),
|
|
348
|
-
requestType: "getColumnSpec",
|
|
349
|
-
requestData: {
|
|
350
|
-
columnId: hashColumnId(columnId),
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
this.#logger,
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
try {
|
|
357
|
-
return await AddonSymbol.pFrameGetColumnSpec(this.#frame, columnId);
|
|
358
|
-
} catch (err: unknown) {
|
|
359
|
-
const error = new PFrameError(`PFrame getColumnSpec request failed`);
|
|
360
|
-
error.cause = new Error(
|
|
361
|
-
`PFrame ${this.id} getColumnSpec request ${requestId} failed, ` +
|
|
362
|
-
`columnId: ${JSON.stringify(columnId)}, ` +
|
|
363
|
-
`error:\n` +
|
|
364
|
-
`${ensureError(err)}`,
|
|
365
|
-
);
|
|
366
|
-
throw error;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
async listColumns(): Promise<PColumnInfo[]> {
|
|
371
|
-
const requestId = ulid();
|
|
372
|
-
dump(
|
|
373
|
-
[`${this.id}`, `${requestId}.json`],
|
|
374
|
-
{
|
|
375
|
-
timeStamp: Date.now(),
|
|
376
|
-
requestType: "listColumns",
|
|
377
|
-
},
|
|
378
|
-
this.#logger,
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
try {
|
|
382
|
-
return await AddonSymbol.pFrameListColumns(this.#frame);
|
|
383
|
-
} catch (err: unknown) {
|
|
384
|
-
const error = new PFrameError(`PFrame listColumns request failed`);
|
|
385
|
-
error.cause = new Error(
|
|
386
|
-
`PFrame ${this.id} listColumns request ${requestId} failed, ` +
|
|
387
|
-
`error:\n` +
|
|
388
|
-
`${ensureError(err)}`,
|
|
389
|
-
);
|
|
390
|
-
throw error;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
createTable(
|
|
395
|
-
requestId: PFrameInternal.PTableId,
|
|
396
|
-
request: PFrameInternal.CreateTableRequestV4,
|
|
397
|
-
): PTable {
|
|
398
224
|
const dumpData = {
|
|
399
225
|
timeStamp: Date.now(),
|
|
400
226
|
requestType: "createTable",
|
|
401
|
-
requestData:
|
|
227
|
+
requestData: hashDataQuery(dataQuery),
|
|
402
228
|
};
|
|
403
|
-
dump([`${this.id}`, `${
|
|
404
|
-
dump([`${this.id}`, `${
|
|
229
|
+
dump([`${this.id}`, `${tableId}.json`], dumpData, this.#logger);
|
|
230
|
+
dump([`${this.id}`, `${tableId}`, `${tableId}.json`], dumpData, this.#logger);
|
|
405
231
|
|
|
406
|
-
const timer = PerfTimer.start();
|
|
407
232
|
try {
|
|
408
|
-
const boxed = AddonSymbol.pFrameCreateTable(this.#frame,
|
|
409
|
-
return new PTable(this,
|
|
233
|
+
const boxed = AddonSymbol.pFrameCreateTable(this.#frame, tableId, dataQuery);
|
|
234
|
+
return new PTable(this, tableId, boxed, this.#logger);
|
|
410
235
|
} catch (err: unknown) {
|
|
411
236
|
const error = new PFrameError(`PFrame createTable request failed`);
|
|
412
237
|
error.cause = new Error(
|
|
413
|
-
`PFrame ${this.id} createTable request ${
|
|
414
|
-
`request: ${JSON.stringify(request)}, ` +
|
|
415
|
-
`error:\n` +
|
|
416
|
-
`${ensureError(err)}`,
|
|
417
|
-
);
|
|
418
|
-
throw error;
|
|
419
|
-
} finally {
|
|
420
|
-
this.#logger(
|
|
421
|
-
"info",
|
|
422
|
-
`PFrame ${this.id} createTable request ${requestId} took ${timer.elapsed()}`,
|
|
423
|
-
);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
createTableV2(
|
|
428
|
-
requestId: PFrameInternal.PTableId,
|
|
429
|
-
request: {
|
|
430
|
-
tableSpec: PTableColumnSpec[];
|
|
431
|
-
dataQuery: DataQuery;
|
|
432
|
-
},
|
|
433
|
-
): PTable {
|
|
434
|
-
const timer = PerfTimer.start();
|
|
435
|
-
const dumpData = {
|
|
436
|
-
timeStamp: Date.now(),
|
|
437
|
-
requestType: "createTableV2",
|
|
438
|
-
requestData: hashCreateTableV2RequestColumnId(request),
|
|
439
|
-
};
|
|
440
|
-
dump([`${this.id}`, `${requestId}.json`], dumpData, this.#logger);
|
|
441
|
-
dump([`${this.id}`, `${requestId}`, `${requestId}.json`], dumpData, this.#logger);
|
|
442
|
-
|
|
443
|
-
try {
|
|
444
|
-
const boxed = AddonSymbol.pFrameCreateTableV2(this.#frame, requestId, request);
|
|
445
|
-
return new PTable(this, requestId, boxed, this.#logger);
|
|
446
|
-
} catch (err: unknown) {
|
|
447
|
-
const error = new PFrameError(`PFrame createTableV2 request failed`);
|
|
448
|
-
error.cause = new Error(
|
|
449
|
-
`PFrame ${this.id} createTableV2 request ${requestId} failed, ` +
|
|
238
|
+
`PFrame ${this.id} createTable request ${tableId} failed, ` +
|
|
450
239
|
`error:\n` +
|
|
451
240
|
`${ensureError(err)}`,
|
|
452
241
|
);
|
|
@@ -454,13 +243,13 @@ export class PFrame implements PFrameInternal.PFrameV13 {
|
|
|
454
243
|
} finally {
|
|
455
244
|
this.#logger(
|
|
456
245
|
"info",
|
|
457
|
-
`PFrame ${this.id}
|
|
246
|
+
`PFrame ${this.id} createTable request ${tableId} took ${timer.elapsed()}`,
|
|
458
247
|
);
|
|
459
248
|
}
|
|
460
249
|
}
|
|
461
250
|
|
|
462
251
|
async getUniqueValues(
|
|
463
|
-
request:
|
|
252
|
+
request: PFrameInternal.UniqueValuesRequestV2,
|
|
464
253
|
ops?: {
|
|
465
254
|
signal?: AbortSignal;
|
|
466
255
|
},
|
|
@@ -502,7 +291,7 @@ export class PFrame implements PFrameInternal.PFrameV13 {
|
|
|
502
291
|
}
|
|
503
292
|
}
|
|
504
293
|
|
|
505
|
-
class PTable implements PFrameInternal.
|
|
294
|
+
class PTable implements PFrameInternal.PTableV9 {
|
|
506
295
|
readonly #frame: PFrame;
|
|
507
296
|
readonly #table: NodeTableSymbol;
|
|
508
297
|
|
|
@@ -522,59 +311,7 @@ class PTable implements PFrameInternal.PTableV8 {
|
|
|
522
311
|
this.#logger("info", `PTable ${this.id} created`);
|
|
523
312
|
}
|
|
524
313
|
|
|
525
|
-
|
|
526
|
-
const requestId = ulid();
|
|
527
|
-
dump(
|
|
528
|
-
[`${this.#frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
529
|
-
{
|
|
530
|
-
timeStamp: Date.now(),
|
|
531
|
-
requestType: "getSpec",
|
|
532
|
-
},
|
|
533
|
-
this.#logger,
|
|
534
|
-
);
|
|
535
|
-
|
|
536
|
-
try {
|
|
537
|
-
return AddonSymbol.pTableGetSpec(this.#table);
|
|
538
|
-
} catch (err: unknown) {
|
|
539
|
-
const error = new PFrameError(`PTable getSpec request failed`);
|
|
540
|
-
error.cause = new Error(
|
|
541
|
-
`PTable ${this.id} getSpec request ${requestId} failed, ` +
|
|
542
|
-
`error:\n` +
|
|
543
|
-
`${ensureError(err)}`,
|
|
544
|
-
);
|
|
545
|
-
throw error;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
getColumnIndices(columnIds: PTableColumnId[]): number[] {
|
|
550
|
-
const requestId = ulid();
|
|
551
|
-
dump(
|
|
552
|
-
[`${this.#frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
553
|
-
{
|
|
554
|
-
timeStamp: Date.now(),
|
|
555
|
-
requestType: "getColumnIndices",
|
|
556
|
-
requestData: {
|
|
557
|
-
columnIds: columnIds.map(hashTableColumnId),
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
|
-
this.#logger,
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
try {
|
|
564
|
-
return AddonSymbol.pTableGetColumnIndices(this.#table, columnIds);
|
|
565
|
-
} catch (err: unknown) {
|
|
566
|
-
const error = new PFrameError(`PTable getColumnIndices request failed`);
|
|
567
|
-
error.cause = new Error(
|
|
568
|
-
`PTable ${this.id} getColumnIndices request ${requestId} failed, ` +
|
|
569
|
-
`columnIds: ${JSON.stringify(columnIds)}, ` +
|
|
570
|
-
`error:\n` +
|
|
571
|
-
`${ensureError(err)}`,
|
|
572
|
-
);
|
|
573
|
-
throw error;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
async getFootprint(ops?: { signal?: AbortSignal }): Promise<number> {
|
|
314
|
+
async getFootprint(ops?: { withPredecessors?: boolean; signal?: AbortSignal }): Promise<number> {
|
|
578
315
|
const requestId = ulid();
|
|
579
316
|
dump(
|
|
580
317
|
[`${this.#frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
@@ -587,7 +324,11 @@ class PTable implements PFrameInternal.PTableV8 {
|
|
|
587
324
|
|
|
588
325
|
try {
|
|
589
326
|
ops?.signal?.throwIfAborted();
|
|
590
|
-
return await AddonSymbol.pTableGetFootprint(
|
|
327
|
+
return await AddonSymbol.pTableGetFootprint(
|
|
328
|
+
this.#table,
|
|
329
|
+
ops?.withPredecessors ?? false,
|
|
330
|
+
ops?.signal,
|
|
331
|
+
);
|
|
591
332
|
} catch (err: unknown) {
|
|
592
333
|
if (isAbortError(err)) {
|
|
593
334
|
throw new AbortError(`PTable ${this.id} getFootprint request ${requestId} cancelled`);
|
|
@@ -693,64 +434,6 @@ class PTable implements PFrameInternal.PTableV8 {
|
|
|
693
434
|
}
|
|
694
435
|
}
|
|
695
436
|
|
|
696
|
-
filter(requestId: PFrameInternal.PTableId, request: PTableRecordFilter[]): PTable {
|
|
697
|
-
const dumpData = {
|
|
698
|
-
timeStamp: Date.now(),
|
|
699
|
-
table: this.id,
|
|
700
|
-
requestType: "filter",
|
|
701
|
-
requestData: {
|
|
702
|
-
filters: request.map(hashFilterColumnId),
|
|
703
|
-
},
|
|
704
|
-
};
|
|
705
|
-
dump([`${this.#frame.id}`, `${requestId}.json`], dumpData, this.#logger);
|
|
706
|
-
dump([`${this.#frame.id}`, `${requestId}`, `${requestId}.json`], dumpData, this.#logger);
|
|
707
|
-
|
|
708
|
-
const timer = PerfTimer.start();
|
|
709
|
-
try {
|
|
710
|
-
const boxed = AddonSymbol.pTableFilter(this.#table, requestId, request);
|
|
711
|
-
return new PTable(this.#frame, requestId, boxed, this.#logger);
|
|
712
|
-
} catch (err: unknown) {
|
|
713
|
-
const error = new PFrameError(`PTable filter request failed`);
|
|
714
|
-
error.cause = new Error(
|
|
715
|
-
`PTable ${this.id} filter request ${requestId} failed, ` +
|
|
716
|
-
`request: ${JSON.stringify(request)}, ` +
|
|
717
|
-
`error:\n` +
|
|
718
|
-
`${ensureError(err)}`,
|
|
719
|
-
);
|
|
720
|
-
throw error;
|
|
721
|
-
} finally {
|
|
722
|
-
this.#logger("info", `PTable ${this.id} filter request ${requestId} took ${timer.elapsed()}`);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
sort(requestId: PFrameInternal.PTableId, request: PTableSorting[]): PTable {
|
|
727
|
-
const dumpData = {
|
|
728
|
-
timeStamp: Date.now(),
|
|
729
|
-
table: this.id,
|
|
730
|
-
requestType: "sort",
|
|
731
|
-
requestData: request.map(hashSortingColumnId),
|
|
732
|
-
};
|
|
733
|
-
dump([`${this.#frame.id}`, `${requestId}.json`], dumpData, this.#logger);
|
|
734
|
-
dump([`${this.#frame.id}`, `${requestId}`, `${requestId}.json`], dumpData, this.#logger);
|
|
735
|
-
|
|
736
|
-
const timer = PerfTimer.start();
|
|
737
|
-
try {
|
|
738
|
-
const boxed = AddonSymbol.pTableSort(this.#table, requestId, request);
|
|
739
|
-
return new PTable(this.#frame, requestId, boxed, this.#logger);
|
|
740
|
-
} catch (err: unknown) {
|
|
741
|
-
const error = new PFrameError(`PTable sort request failed`);
|
|
742
|
-
error.cause = new Error(
|
|
743
|
-
`PTable ${this.id} sort request ${requestId} failed, ` +
|
|
744
|
-
`request: ${JSON.stringify(request)}, ` +
|
|
745
|
-
`error:\n` +
|
|
746
|
-
`${ensureError(err)}`,
|
|
747
|
-
);
|
|
748
|
-
throw error;
|
|
749
|
-
} finally {
|
|
750
|
-
this.#logger("info", `PTable ${this.id} sort request ${requestId} took ${timer.elapsed()}`);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
437
|
dispose() {
|
|
755
438
|
const requestId = ulid();
|
|
756
439
|
dump(
|
package/export_dist/dump.cjs
CHANGED
|
@@ -6,82 +6,17 @@ let node_fs = require("node:fs");
|
|
|
6
6
|
function hashColumnId(columnId) {
|
|
7
7
|
return (0, node_crypto.createHash)("sha256").update(columnId).digest("hex");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (tableId.type === "column") return {
|
|
11
|
-
...tableId,
|
|
12
|
-
id: hashColumnId(tableId.id)
|
|
13
|
-
};
|
|
14
|
-
return tableId;
|
|
15
|
-
}
|
|
16
|
-
function hashFilterColumnId(filter) {
|
|
9
|
+
function hashAddColumnEntry(entry) {
|
|
17
10
|
return {
|
|
18
|
-
...
|
|
19
|
-
|
|
11
|
+
...entry,
|
|
12
|
+
id: hashColumnId(entry.id)
|
|
20
13
|
};
|
|
21
14
|
}
|
|
22
15
|
function hashUniqueValuesRequestColumnId(request) {
|
|
23
16
|
return {
|
|
24
17
|
...request,
|
|
25
|
-
columnId: hashColumnId(request.columnId)
|
|
26
|
-
filters: request.filters.map(hashFilterColumnId)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function hashSortingColumnId(sorting) {
|
|
30
|
-
return {
|
|
31
|
-
...sorting,
|
|
32
|
-
column: hashTableColumnId(sorting.column)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function hashJoinEntryColumnId(entry) {
|
|
36
|
-
const type = entry.type;
|
|
37
|
-
switch (type) {
|
|
38
|
-
case "column": return {
|
|
39
|
-
...entry,
|
|
40
|
-
columnId: hashColumnId(entry.columnId)
|
|
41
|
-
};
|
|
42
|
-
case "slicedColumn": return {
|
|
43
|
-
...entry,
|
|
44
|
-
columnId: hashColumnId(entry.columnId),
|
|
45
|
-
newId: hashColumnId(entry.newId)
|
|
46
|
-
};
|
|
47
|
-
case "artificialColumn": return {
|
|
48
|
-
...entry,
|
|
49
|
-
columnId: hashColumnId(entry.columnId),
|
|
50
|
-
newId: hashColumnId(entry.newId)
|
|
51
|
-
};
|
|
52
|
-
case "inlineColumn": return {
|
|
53
|
-
...entry,
|
|
54
|
-
newId: hashColumnId(entry.newId)
|
|
55
|
-
};
|
|
56
|
-
case "inner": return {
|
|
57
|
-
...entry,
|
|
58
|
-
entries: entry.entries.map(hashJoinEntryColumnId)
|
|
59
|
-
};
|
|
60
|
-
case "full": return {
|
|
61
|
-
...entry,
|
|
62
|
-
entries: entry.entries.map(hashJoinEntryColumnId)
|
|
63
|
-
};
|
|
64
|
-
case "outer": return {
|
|
65
|
-
...entry,
|
|
66
|
-
primary: hashJoinEntryColumnId(entry.primary),
|
|
67
|
-
secondary: entry.secondary.map(hashJoinEntryColumnId)
|
|
68
|
-
};
|
|
69
|
-
default: throw new Error(`Unsupported join entry type: ${type}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function hashCreateTableRequestColumnId(request) {
|
|
73
|
-
return {
|
|
74
|
-
...request,
|
|
75
|
-
src: hashJoinEntryColumnId(request.src),
|
|
76
|
-
filters: request.filters.map(hashFilterColumnId)
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function hashTableColumnSpec(spec) {
|
|
80
|
-
if (spec.type === "column") return {
|
|
81
|
-
...spec,
|
|
82
|
-
id: hashColumnId(spec.id)
|
|
18
|
+
columnId: hashColumnId(request.columnId)
|
|
83
19
|
};
|
|
84
|
-
return spec;
|
|
85
20
|
}
|
|
86
21
|
function hashDataQuery(query) {
|
|
87
22
|
switch (query.type) {
|
|
@@ -146,15 +81,19 @@ function hashDataQuery(query) {
|
|
|
146
81
|
...query,
|
|
147
82
|
input: hashDataQuery(query.input)
|
|
148
83
|
};
|
|
84
|
+
case "transformColumns": return {
|
|
85
|
+
...query,
|
|
86
|
+
input: hashDataQuery(query.input),
|
|
87
|
+
columns: query.columns.map((entry) => entry.specOverride ? {
|
|
88
|
+
...entry,
|
|
89
|
+
specOverride: {
|
|
90
|
+
...entry.specOverride,
|
|
91
|
+
id: hashColumnId(entry.specOverride.id)
|
|
92
|
+
}
|
|
93
|
+
} : entry)
|
|
94
|
+
};
|
|
149
95
|
}
|
|
150
96
|
}
|
|
151
|
-
function hashCreateTableV2RequestColumnId(request) {
|
|
152
|
-
return {
|
|
153
|
-
...request,
|
|
154
|
-
tableSpec: request.tableSpec.map(hashTableColumnSpec),
|
|
155
|
-
dataQuery: hashDataQuery(request.dataQuery)
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
97
|
async function dump(relativePath, data, logger) {
|
|
159
98
|
if (!process.env.MI_DUMP_PFRAMES_RS) return;
|
|
160
99
|
try {
|
|
@@ -170,12 +109,9 @@ async function dump(relativePath, data, logger) {
|
|
|
170
109
|
}
|
|
171
110
|
//#endregion
|
|
172
111
|
exports.dump = dump;
|
|
112
|
+
exports.hashAddColumnEntry = hashAddColumnEntry;
|
|
173
113
|
exports.hashColumnId = hashColumnId;
|
|
174
|
-
exports.
|
|
175
|
-
exports.hashCreateTableV2RequestColumnId = hashCreateTableV2RequestColumnId;
|
|
176
|
-
exports.hashFilterColumnId = hashFilterColumnId;
|
|
177
|
-
exports.hashSortingColumnId = hashSortingColumnId;
|
|
178
|
-
exports.hashTableColumnId = hashTableColumnId;
|
|
114
|
+
exports.hashDataQuery = hashDataQuery;
|
|
179
115
|
exports.hashUniqueValuesRequestColumnId = hashUniqueValuesRequestColumnId;
|
|
180
116
|
|
|
181
117
|
//# sourceMappingURL=dump.cjs.map
|
package/export_dist/dump.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.cjs","names":["fs"],"sources":["../export/dump.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PFrameInternal } from \"@milaboratories/pl-model-middle-layer\";\nimport type {
|
|
1
|
+
{"version":3,"file":"dump.cjs","names":["fs"],"sources":["../export/dump.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PFrameInternal } from \"@milaboratories/pl-model-middle-layer\";\nimport type { PObjectId, DataQuery } from \"@milaboratories/pl-model-common\";\n\nexport function hashColumnId(columnId: PObjectId): PObjectId {\n return createHash(\"sha256\").update(columnId).digest(\"hex\") as PObjectId;\n}\n\nexport function hashAddColumnEntry(\n entry: PFrameInternal.AddColumnEntry,\n): PFrameInternal.AddColumnEntry {\n return {\n ...entry,\n id: hashColumnId(entry.id),\n };\n}\n\nexport function hashUniqueValuesRequestColumnId(\n request: PFrameInternal.UniqueValuesRequestV2,\n): PFrameInternal.UniqueValuesRequestV2 {\n // V2 filters are index-based (no column ids), so only `columnId` is rewritten.\n return {\n ...request,\n columnId: hashColumnId(request.columnId),\n };\n}\n\nexport function hashDataQuery(query: DataQuery): DataQuery {\n switch (query.type) {\n case \"column\":\n return {\n ...query,\n column: hashColumnId(query.column),\n };\n case \"inlineColumn\":\n return {\n ...query,\n spec: {\n ...query.spec,\n id: hashColumnId(query.spec.id),\n },\n };\n case \"sparseToDenseColumn\":\n return {\n ...query,\n column: hashColumnId(query.column),\n ...(query.specOverride\n ? {\n specOverride: {\n ...query.specOverride,\n id: hashColumnId(query.specOverride.id),\n },\n }\n : {}),\n };\n case \"innerJoin\":\n case \"fullJoin\":\n return {\n ...query,\n entries: query.entries.map((e) => ({\n ...e,\n entry: hashDataQuery(e.entry),\n })),\n };\n case \"outerJoin\":\n return {\n ...query,\n primary: {\n ...query.primary,\n entry: hashDataQuery(query.primary.entry),\n },\n secondary: query.secondary.map((e) => ({\n ...e,\n entry: hashDataQuery(e.entry),\n })),\n };\n case \"linkerJoin\":\n return {\n ...query,\n linker: {\n ...query.linker,\n column: hashColumnId(query.linker.column),\n },\n secondary: query.secondary.map((e) => ({\n ...e,\n entry: hashDataQuery(e.entry),\n })),\n };\n case \"sliceAxes\":\n return {\n ...query,\n input: hashDataQuery(query.input),\n };\n case \"sort\":\n return {\n ...query,\n input: hashDataQuery(query.input),\n };\n case \"filter\":\n return {\n ...query,\n input: hashDataQuery(query.input),\n };\n case \"transformColumns\":\n return {\n ...query,\n input: hashDataQuery(query.input),\n columns: query.columns.map((entry) =>\n entry.specOverride\n ? {\n ...entry,\n specOverride: {\n ...entry.specOverride,\n id: hashColumnId(entry.specOverride.id),\n },\n }\n : entry,\n ) as typeof query.columns,\n };\n }\n}\n\nexport async function dump(\n relativePath: string[],\n data: { [key: string]: string | number | boolean | object } | Uint8Array,\n logger?: PFrameInternal.Logger,\n): Promise<void> {\n if (!process.env.MI_DUMP_PFRAMES_RS) return;\n try {\n const relativeUri = relativePath.map((part) => encodeURIComponent(part));\n const fileDir = join(process.env.MI_DUMP_PFRAMES_RS, ...relativeUri.slice(0, -1));\n await fs.mkdir(fileDir, { recursive: true });\n\n const filePath = join(process.env.MI_DUMP_PFRAMES_RS, ...relativeUri);\n const fileData = ArrayBuffer.isView(data) ? data : JSON.stringify(data, null, 2);\n await fs.writeFile(filePath, fileData, { flag: \"wx\" });\n } catch (error: unknown) {\n logger?.(\"info\", `error while dumping PFrames data: ${error}`);\n }\n}\n"],"mappings":";;;;;AAMA,SAAgB,aAAa,UAAgC;AAC3D,SAAA,GAAA,YAAA,YAAkB,SAAS,CAAC,OAAO,SAAS,CAAC,OAAO,MAAM;;AAG5D,SAAgB,mBACd,OAC+B;AAC/B,QAAO;EACL,GAAG;EACH,IAAI,aAAa,MAAM,GAAG;EAC3B;;AAGH,SAAgB,gCACd,SACsC;AAEtC,QAAO;EACL,GAAG;EACH,UAAU,aAAa,QAAQ,SAAS;EACzC;;AAGH,SAAgB,cAAc,OAA6B;AACzD,SAAQ,MAAM,MAAd;EACE,KAAK,SACH,QAAO;GACL,GAAG;GACH,QAAQ,aAAa,MAAM,OAAO;GACnC;EACH,KAAK,eACH,QAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,MAAM;IACT,IAAI,aAAa,MAAM,KAAK,GAAG;IAChC;GACF;EACH,KAAK,sBACH,QAAO;GACL,GAAG;GACH,QAAQ,aAAa,MAAM,OAAO;GAClC,GAAI,MAAM,eACN,EACE,cAAc;IACZ,GAAG,MAAM;IACT,IAAI,aAAa,MAAM,aAAa,GAAG;IACxC,EACF,GACD,EAAE;GACP;EACH,KAAK;EACL,KAAK,WACH,QAAO;GACL,GAAG;GACH,SAAS,MAAM,QAAQ,KAAK,OAAO;IACjC,GAAG;IACH,OAAO,cAAc,EAAE,MAAM;IAC9B,EAAE;GACJ;EACH,KAAK,YACH,QAAO;GACL,GAAG;GACH,SAAS;IACP,GAAG,MAAM;IACT,OAAO,cAAc,MAAM,QAAQ,MAAM;IAC1C;GACD,WAAW,MAAM,UAAU,KAAK,OAAO;IACrC,GAAG;IACH,OAAO,cAAc,EAAE,MAAM;IAC9B,EAAE;GACJ;EACH,KAAK,aACH,QAAO;GACL,GAAG;GACH,QAAQ;IACN,GAAG,MAAM;IACT,QAAQ,aAAa,MAAM,OAAO,OAAO;IAC1C;GACD,WAAW,MAAM,UAAU,KAAK,OAAO;IACrC,GAAG;IACH,OAAO,cAAc,EAAE,MAAM;IAC9B,EAAE;GACJ;EACH,KAAK,YACH,QAAO;GACL,GAAG;GACH,OAAO,cAAc,MAAM,MAAM;GAClC;EACH,KAAK,OACH,QAAO;GACL,GAAG;GACH,OAAO,cAAc,MAAM,MAAM;GAClC;EACH,KAAK,SACH,QAAO;GACL,GAAG;GACH,OAAO,cAAc,MAAM,MAAM;GAClC;EACH,KAAK,mBACH,QAAO;GACL,GAAG;GACH,OAAO,cAAc,MAAM,MAAM;GACjC,SAAS,MAAM,QAAQ,KAAK,UAC1B,MAAM,eACF;IACE,GAAG;IACH,cAAc;KACZ,GAAG,MAAM;KACT,IAAI,aAAa,MAAM,aAAa,GAAG;KACxC;IACF,GACD,MACL;GACF;;;AAIP,eAAsB,KACpB,cACA,MACA,QACe;AACf,KAAI,CAAC,QAAQ,IAAI,mBAAoB;AACrC,KAAI;EACF,MAAM,cAAc,aAAa,KAAK,SAAS,mBAAmB,KAAK,CAAC;EACxE,MAAM,WAAA,GAAA,UAAA,MAAe,QAAQ,IAAI,oBAAoB,GAAG,YAAY,MAAM,GAAG,GAAG,CAAC;AACjF,QAAMA,QAAAA,SAAG,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;EAE5C,MAAM,YAAA,GAAA,UAAA,MAAgB,QAAQ,IAAI,oBAAoB,GAAG,YAAY;EACrE,MAAM,WAAW,YAAY,OAAO,KAAK,GAAG,OAAO,KAAK,UAAU,MAAM,MAAM,EAAE;AAChF,QAAMA,QAAAA,SAAG,UAAU,UAAU,UAAU,EAAE,MAAM,MAAM,CAAC;UAC/C,OAAgB;AACvB,WAAS,QAAQ,qCAAqC,QAAQ"}
|