@milaboratories/pframes-rs-node 1.0.18 → 1.0.19
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 +14 -1
- package/export/dump.ts +59 -0
- package/export/wrapper.ts +363 -7
- package/export_dist/dump.d.ts +5 -0
- package/export_dist/dump.d.ts.map +1 -0
- package/export_dist/index.js +19 -19
- package/export_dist/index.js.map +1 -1
- package/export_dist/index.mjs +469 -103
- package/export_dist/index.mjs.map +1 -1
- package/export_dist/wrapper.d.ts +3 -1
- package/export_dist/wrapper.d.ts.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -27,4 +27,17 @@ Debugging is only supported using VSCode with the following extencions installed
|
|
|
27
27
|
1. Clone and build the latest `platforma-desktop-v2`
|
|
28
28
|
2. Set the correct RELATIVE path to `platforma-desktop-v2` in `.vscode/settings.json` variable `platformaDesktopPath`
|
|
29
29
|
3. Build this package by following the build steps from above
|
|
30
|
-
4. Use launch configuration for your platform to start debug session
|
|
30
|
+
4. Use VSCode launch configuration for your platform to start debug session
|
|
31
|
+
|
|
32
|
+
### Performance profiling
|
|
33
|
+
1. Clone and build the latest `platforma-desktop-v2`
|
|
34
|
+
2. Set the correct RELATIVE path to `platforma-desktop-v2` in `.vscode/settings.json` variable `platformaDesktopPath`
|
|
35
|
+
3. Build this package by following the build steps from above
|
|
36
|
+
4. Launch VSCode task (Cmd+Shift+P -> Tasks: Run Task -> Perf-profile platforma-desktop) for profiling
|
|
37
|
+
5. Execute the test scenario and quite platforma-desktop
|
|
38
|
+
6. Firefox profiler with recorded performance profile would automatically open in you browser of choice
|
|
39
|
+
(Warning! Firefox profiler does not work in Safari and with AdBlock enabled)
|
|
40
|
+
|
|
41
|
+
### Dump pframes requests
|
|
42
|
+
1. Run `platforma-desktop-v2` with `MI_DUMP_PFRAMES_RS=/absolute/path/to/dump/requests npm run dev`
|
|
43
|
+
2. Archive the `/absolute/path/to/dump/requests` folder and pass to the developer
|
package/export/dump.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Readable, Writable } from 'node:stream';
|
|
4
|
+
import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
5
|
+
|
|
6
|
+
async function fileExists(path: string): Promise<boolean> {
|
|
7
|
+
try {
|
|
8
|
+
await fs.promises.access(path);
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function ensureDirExists(fileOrDir: string): Promise<void> {
|
|
16
|
+
if (!(await fileExists(fileOrDir))) {
|
|
17
|
+
await fs.promises.mkdir(fileOrDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function writeFile(
|
|
22
|
+
filePath: string,
|
|
23
|
+
data: string | Uint8Array
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
const tempPath = `${filePath}.tmp`;
|
|
26
|
+
if (await fileExists(tempPath)) {
|
|
27
|
+
await fs.promises.rm(tempPath, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const buffer = typeof data === 'string' ? Buffer.from(data, 'utf8') : data;
|
|
31
|
+
const source = Readable.from(buffer);
|
|
32
|
+
const destination = fs.createWriteStream(tempPath, { flags: 'wx' });
|
|
33
|
+
await Readable.toWeb(source).pipeTo(Writable.toWeb(destination));
|
|
34
|
+
|
|
35
|
+
await fs.promises.rename(tempPath, filePath);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function dump(
|
|
39
|
+
relativePath: string[],
|
|
40
|
+
data: { [key: string]: Object } | Uint8Array,
|
|
41
|
+
logger?: PFrameInternal.Logger
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
if (!process.env.MI_DUMP_PFRAMES_RS) return;
|
|
44
|
+
try {
|
|
45
|
+
const fileDir = path.join(
|
|
46
|
+
process.env.MI_DUMP_PFRAMES_RS,
|
|
47
|
+
...relativePath.slice(0, -1)
|
|
48
|
+
);
|
|
49
|
+
await ensureDirExists(fileDir);
|
|
50
|
+
|
|
51
|
+
const filePath = path.join(process.env.MI_DUMP_PFRAMES_RS, ...relativePath);
|
|
52
|
+
const fileData = ArrayBuffer.isView(data)
|
|
53
|
+
? (data as Uint8Array)
|
|
54
|
+
: JSON.stringify(data);
|
|
55
|
+
await writeFile(filePath, fileData);
|
|
56
|
+
} catch (error: unknown) {
|
|
57
|
+
logger?.('warn', `error while dumping PFrames data: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
package/export/wrapper.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ulid } from 'ulid';
|
|
1
2
|
import {
|
|
2
3
|
PColumnInfo,
|
|
3
4
|
PColumnSpec,
|
|
@@ -15,11 +16,22 @@ import {
|
|
|
15
16
|
import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
16
17
|
import type { NodeFrameSymbol, NodeTableSymbol } from './addon-def';
|
|
17
18
|
import { AddonSymbol } from './addon';
|
|
19
|
+
import { dump } from './dump';
|
|
18
20
|
|
|
19
21
|
export class PFrame implements PFrameInternal.PFrameV3 {
|
|
22
|
+
public readonly id: string = ulid();
|
|
20
23
|
private readonly frame: NodeFrameSymbol;
|
|
21
24
|
|
|
22
|
-
constructor(logger?: PFrameInternal.Logger) {
|
|
25
|
+
constructor(public readonly logger?: PFrameInternal.Logger) {
|
|
26
|
+
dump(
|
|
27
|
+
[`${this.id}`, `${this.id}.json`],
|
|
28
|
+
{
|
|
29
|
+
timeStamp: Date.now(),
|
|
30
|
+
requestType: 'create'
|
|
31
|
+
},
|
|
32
|
+
this.logger
|
|
33
|
+
);
|
|
34
|
+
|
|
23
35
|
try {
|
|
24
36
|
this.frame = AddonSymbol.pFrameCreate(logger);
|
|
25
37
|
} catch (err: unknown) {
|
|
@@ -33,6 +45,28 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
addColumnSpec(columnId: PObjectId, columnSpec: PColumnSpec): void {
|
|
48
|
+
const requestId = ulid();
|
|
49
|
+
dump(
|
|
50
|
+
[`${this.id}`, `${requestId}.json`],
|
|
51
|
+
{
|
|
52
|
+
timeStamp: Date.now(),
|
|
53
|
+
requestType: 'addColumnSpec',
|
|
54
|
+
requestData: {
|
|
55
|
+
columnId,
|
|
56
|
+
columnSpec
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
this.logger
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
dump(
|
|
63
|
+
[`${this.id}`, `data`, `${columnId}.spec`],
|
|
64
|
+
{
|
|
65
|
+
...columnSpec
|
|
66
|
+
},
|
|
67
|
+
this.logger
|
|
68
|
+
);
|
|
69
|
+
|
|
36
70
|
try {
|
|
37
71
|
return AddonSymbol.pFrameAddColumnSpec(this.frame, columnId, columnSpec);
|
|
38
72
|
} catch (err: unknown) {
|
|
@@ -47,8 +81,69 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
47
81
|
}
|
|
48
82
|
|
|
49
83
|
setDataSource(dataSource: PFrameInternal.PFrameDataSource): void {
|
|
84
|
+
const requestId = ulid();
|
|
85
|
+
dump(
|
|
86
|
+
[`${this.id}`, `${requestId}.json`],
|
|
87
|
+
{
|
|
88
|
+
timeStamp: Date.now(),
|
|
89
|
+
requestType: 'setDataSource'
|
|
90
|
+
},
|
|
91
|
+
this.logger
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
let wrappedDataSource = {
|
|
95
|
+
preloadBlob: async (
|
|
96
|
+
blobIds: PFrameInternal.PFrameBlobId[]
|
|
97
|
+
): Promise<void> => {
|
|
98
|
+
const requestId = ulid();
|
|
99
|
+
dump(
|
|
100
|
+
[`${this.id}`, `${requestId}.json`],
|
|
101
|
+
{
|
|
102
|
+
timeStamp: Date.now(),
|
|
103
|
+
requestType: 'preloadBlob',
|
|
104
|
+
requestData: {
|
|
105
|
+
blobIds
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
this.logger
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const t0 = performance.now();
|
|
112
|
+
try {
|
|
113
|
+
return dataSource.preloadBlob(blobIds);
|
|
114
|
+
} finally {
|
|
115
|
+
const t1 = performance.now();
|
|
116
|
+
this.logger?.(
|
|
117
|
+
'info',
|
|
118
|
+
`PFrame preloaded ${blobIds.length} blobs, took ${Math.round(t1 - t0)}ms`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
resolveBlobContent: async (
|
|
123
|
+
blobId: PFrameInternal.PFrameBlobId
|
|
124
|
+
): Promise<Uint8Array> => {
|
|
125
|
+
const requestId = ulid();
|
|
126
|
+
dump(
|
|
127
|
+
[`${this.id}`, `${requestId}.json`],
|
|
128
|
+
{
|
|
129
|
+
timeStamp: Date.now(),
|
|
130
|
+
requestType: 'resolveBlobContent',
|
|
131
|
+
requestData: {
|
|
132
|
+
blobId
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
this.logger
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const blob = await dataSource.resolveBlobContent(blobId);
|
|
139
|
+
dump([`${this.id}`, `data`, `${blobId}`], blob, this.logger);
|
|
140
|
+
|
|
141
|
+
return blob;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
50
145
|
try {
|
|
51
|
-
return AddonSymbol.pFrameSetDataSource(this.frame,
|
|
146
|
+
return AddonSymbol.pFrameSetDataSource(this.frame, wrappedDataSource);
|
|
52
147
|
} catch (err: unknown) {
|
|
53
148
|
throw new Error(
|
|
54
149
|
`PFrame setDataSource request failed, ` +
|
|
@@ -60,6 +155,28 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
60
155
|
}
|
|
61
156
|
|
|
62
157
|
setColumnData(columnId: PObjectId, dataInfo: PFrameInternal.DataInfo): void {
|
|
158
|
+
const requestId = ulid();
|
|
159
|
+
dump(
|
|
160
|
+
[`${this.id}`, `${requestId}.json`],
|
|
161
|
+
{
|
|
162
|
+
timeStamp: Date.now(),
|
|
163
|
+
requestType: 'setColumnData',
|
|
164
|
+
requestData: {
|
|
165
|
+
columnId,
|
|
166
|
+
dataInfo
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
this.logger
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
dump(
|
|
173
|
+
[`${this.id}`, `data`, `${columnId}.datainfo`],
|
|
174
|
+
{
|
|
175
|
+
...dataInfo
|
|
176
|
+
},
|
|
177
|
+
this.logger
|
|
178
|
+
);
|
|
179
|
+
|
|
63
180
|
try {
|
|
64
181
|
return AddonSymbol.pFrameSetColumnData(this.frame, columnId, dataInfo);
|
|
65
182
|
} catch (err: unknown) {
|
|
@@ -74,6 +191,16 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
74
191
|
}
|
|
75
192
|
|
|
76
193
|
dispose(): void {
|
|
194
|
+
const requestId = ulid();
|
|
195
|
+
dump(
|
|
196
|
+
[`${this.id}`, `${requestId}.json`],
|
|
197
|
+
{
|
|
198
|
+
timeStamp: Date.now(),
|
|
199
|
+
requestType: 'dispose'
|
|
200
|
+
},
|
|
201
|
+
this.logger
|
|
202
|
+
);
|
|
203
|
+
|
|
77
204
|
try {
|
|
78
205
|
AddonSymbol.pFrameDispose(this.frame);
|
|
79
206
|
} catch (err: unknown) {
|
|
@@ -92,6 +219,18 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
92
219
|
async findColumns(
|
|
93
220
|
request: PFrameInternal.FindColumnsRequest
|
|
94
221
|
): Promise<PFrameInternal.FindColumnsResponse> {
|
|
222
|
+
const requestId = ulid();
|
|
223
|
+
dump(
|
|
224
|
+
[`${this.id}`, `${requestId}.json`],
|
|
225
|
+
{
|
|
226
|
+
timeStamp: Date.now(),
|
|
227
|
+
requestType: 'findColumns',
|
|
228
|
+
requestData: request
|
|
229
|
+
},
|
|
230
|
+
this.logger
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const t0 = performance.now();
|
|
95
234
|
try {
|
|
96
235
|
return await AddonSymbol.pFrameFindColumns(this.frame, request);
|
|
97
236
|
} catch (err: unknown) {
|
|
@@ -101,12 +240,30 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
101
240
|
`error:\n` +
|
|
102
241
|
`${(err as Error).toString()}`
|
|
103
242
|
);
|
|
243
|
+
} finally {
|
|
244
|
+
const t1 = performance.now();
|
|
245
|
+
this.logger?.(
|
|
246
|
+
'info',
|
|
247
|
+
`PFrame findColumns request took ${Math.round(t1 - t0)}ms`
|
|
248
|
+
);
|
|
104
249
|
}
|
|
105
250
|
}
|
|
106
251
|
|
|
107
252
|
async deleteColumn(
|
|
108
253
|
request: PFrameInternal.DeleteColumnFromColumnsRequest
|
|
109
254
|
): Promise<PFrameInternal.DeleteColumnFromColumnsResponse> {
|
|
255
|
+
const requestId = ulid();
|
|
256
|
+
dump(
|
|
257
|
+
[`${this.id}`, `${requestId}.json`],
|
|
258
|
+
{
|
|
259
|
+
timeStamp: Date.now(),
|
|
260
|
+
requestType: 'deleteColumn',
|
|
261
|
+
requestData: request
|
|
262
|
+
},
|
|
263
|
+
this.logger
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const t0 = performance.now();
|
|
110
267
|
try {
|
|
111
268
|
return await AddonSymbol.pFrameDeleteColumn(this.frame, request);
|
|
112
269
|
} catch (err: unknown) {
|
|
@@ -116,10 +273,30 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
116
273
|
`error:\n` +
|
|
117
274
|
`${(err as Error).toString()}`
|
|
118
275
|
);
|
|
276
|
+
} finally {
|
|
277
|
+
const t1 = performance.now();
|
|
278
|
+
this.logger?.(
|
|
279
|
+
'info',
|
|
280
|
+
`PFrame deleteColumn request took ${Math.round(t1 - t0)}ms`
|
|
281
|
+
);
|
|
119
282
|
}
|
|
120
283
|
}
|
|
121
284
|
|
|
122
285
|
async getColumnSpec(columnId: PObjectId): Promise<PColumnSpec> {
|
|
286
|
+
const requestId = ulid();
|
|
287
|
+
dump(
|
|
288
|
+
[`${this.id}`, `${requestId}.json`],
|
|
289
|
+
{
|
|
290
|
+
timeStamp: Date.now(),
|
|
291
|
+
requestType: 'getColumnSpec',
|
|
292
|
+
requestData: {
|
|
293
|
+
columnId
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
this.logger
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
const t0 = performance.now();
|
|
123
300
|
try {
|
|
124
301
|
return await AddonSymbol.pFrameGetColumnSpec(this.frame, columnId);
|
|
125
302
|
} catch (err: unknown) {
|
|
@@ -129,10 +306,27 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
129
306
|
`error:\n` +
|
|
130
307
|
`${(err as Error).toString()}`
|
|
131
308
|
);
|
|
309
|
+
} finally {
|
|
310
|
+
const t1 = performance.now();
|
|
311
|
+
this.logger?.(
|
|
312
|
+
'info',
|
|
313
|
+
`PFrame getColumnSpec request took ${Math.round(t1 - t0)}ms`
|
|
314
|
+
);
|
|
132
315
|
}
|
|
133
316
|
}
|
|
134
317
|
|
|
135
318
|
async listColumns(): Promise<PColumnInfo[]> {
|
|
319
|
+
const requestId = ulid();
|
|
320
|
+
dump(
|
|
321
|
+
[`${this.id}`, `${requestId}.json`],
|
|
322
|
+
{
|
|
323
|
+
timeStamp: Date.now(),
|
|
324
|
+
requestType: 'listColumns'
|
|
325
|
+
},
|
|
326
|
+
this.logger
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const t0 = performance.now();
|
|
136
330
|
try {
|
|
137
331
|
return await AddonSymbol.pFrameListColumns(this.frame);
|
|
138
332
|
} catch (err: unknown) {
|
|
@@ -141,6 +335,12 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
141
335
|
`error:\n` +
|
|
142
336
|
`${(err as Error).toString()}`
|
|
143
337
|
);
|
|
338
|
+
} finally {
|
|
339
|
+
const t1 = performance.now();
|
|
340
|
+
this.logger?.(
|
|
341
|
+
'info',
|
|
342
|
+
`PFrame listColumns request took ${Math.round(t1 - t0)}ms`
|
|
343
|
+
);
|
|
144
344
|
}
|
|
145
345
|
}
|
|
146
346
|
|
|
@@ -148,13 +348,27 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
148
348
|
request: PFrameInternal.CreateTableRequest,
|
|
149
349
|
signal?: AbortSignal
|
|
150
350
|
): Promise<PFrameInternal.PTableV3> {
|
|
351
|
+
const requestId = ulid();
|
|
352
|
+
const dumpData = {
|
|
353
|
+
timeStamp: Date.now(),
|
|
354
|
+
requestType: 'createTable',
|
|
355
|
+
requestData: request
|
|
356
|
+
};
|
|
357
|
+
dump([`${this.id}`, `${requestId}.json`], dumpData, this.logger);
|
|
358
|
+
dump(
|
|
359
|
+
[`${this.id}`, `${requestId}`, `${requestId}.json`],
|
|
360
|
+
dumpData,
|
|
361
|
+
this.logger
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
const t0 = performance.now();
|
|
151
365
|
try {
|
|
152
366
|
const boxed = await AddonSymbol.pFrameCreateTable(
|
|
153
367
|
this.frame,
|
|
154
368
|
request,
|
|
155
369
|
signal
|
|
156
370
|
);
|
|
157
|
-
return new PTable(boxed);
|
|
371
|
+
return new PTable(this, requestId, boxed);
|
|
158
372
|
} catch (err: unknown) {
|
|
159
373
|
throw new Error(
|
|
160
374
|
`PFrame createTable request failed, ` +
|
|
@@ -162,6 +376,12 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
162
376
|
`error:\n` +
|
|
163
377
|
`${(err as Error).toString()}`
|
|
164
378
|
);
|
|
379
|
+
} finally {
|
|
380
|
+
const t1 = performance.now();
|
|
381
|
+
this.logger?.(
|
|
382
|
+
'info',
|
|
383
|
+
`PFrame createTable request took ${Math.round(t1 - t0)}ms`
|
|
384
|
+
);
|
|
165
385
|
}
|
|
166
386
|
}
|
|
167
387
|
|
|
@@ -169,6 +389,18 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
169
389
|
request: UniqueValuesRequest,
|
|
170
390
|
signal?: AbortSignal
|
|
171
391
|
): Promise<UniqueValuesResponse> {
|
|
392
|
+
const requestId = ulid();
|
|
393
|
+
dump(
|
|
394
|
+
[`${this.id}`, `${requestId}.json`],
|
|
395
|
+
{
|
|
396
|
+
timeStamp: Date.now(),
|
|
397
|
+
requestType: 'getUniqueValues',
|
|
398
|
+
requestData: request
|
|
399
|
+
},
|
|
400
|
+
this.logger
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
const t0 = performance.now();
|
|
172
404
|
try {
|
|
173
405
|
return await AddonSymbol.pFrameGetUniqueValues(
|
|
174
406
|
this.frame,
|
|
@@ -182,14 +414,34 @@ export class PFrame implements PFrameInternal.PFrameV3 {
|
|
|
182
414
|
`error:\n` +
|
|
183
415
|
`${(err as Error).toString()}`
|
|
184
416
|
);
|
|
417
|
+
} finally {
|
|
418
|
+
const t1 = performance.now();
|
|
419
|
+
this.logger?.(
|
|
420
|
+
'info',
|
|
421
|
+
`PFrame getUniqueValues request took ${Math.round(t1 - t0)}ms`
|
|
422
|
+
);
|
|
185
423
|
}
|
|
186
424
|
}
|
|
187
425
|
}
|
|
188
426
|
|
|
189
427
|
class PTable implements PFrameInternal.PTableV3 {
|
|
190
|
-
constructor(
|
|
428
|
+
constructor(
|
|
429
|
+
private readonly frame: PFrame,
|
|
430
|
+
public readonly id: string,
|
|
431
|
+
private readonly table: NodeTableSymbol
|
|
432
|
+
) {}
|
|
191
433
|
|
|
192
434
|
getShape(): PTableShape {
|
|
435
|
+
const requestId = ulid();
|
|
436
|
+
dump(
|
|
437
|
+
[`${this.frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
438
|
+
{
|
|
439
|
+
timeStamp: Date.now(),
|
|
440
|
+
requestType: 'getShape'
|
|
441
|
+
},
|
|
442
|
+
this.frame.logger
|
|
443
|
+
);
|
|
444
|
+
|
|
193
445
|
try {
|
|
194
446
|
return AddonSymbol.pTableGetShape(this.table);
|
|
195
447
|
} catch (err: unknown) {
|
|
@@ -202,6 +454,16 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
202
454
|
}
|
|
203
455
|
|
|
204
456
|
getSpec(): PTableColumnSpec[] {
|
|
457
|
+
const requestId = ulid();
|
|
458
|
+
dump(
|
|
459
|
+
[`${this.frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
460
|
+
{
|
|
461
|
+
timeStamp: Date.now(),
|
|
462
|
+
requestType: 'getSpec'
|
|
463
|
+
},
|
|
464
|
+
this.frame.logger
|
|
465
|
+
);
|
|
466
|
+
|
|
205
467
|
try {
|
|
206
468
|
return AddonSymbol.pTableGetSpec(this.table);
|
|
207
469
|
} catch (err: unknown) {
|
|
@@ -214,6 +476,19 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
214
476
|
}
|
|
215
477
|
|
|
216
478
|
getColumnIndices(columnIds: PTableColumnId[]): number[] {
|
|
479
|
+
const requestId = ulid();
|
|
480
|
+
dump(
|
|
481
|
+
[`${this.frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
482
|
+
{
|
|
483
|
+
timeStamp: Date.now(),
|
|
484
|
+
requestType: 'getColumnIndices',
|
|
485
|
+
requestData: {
|
|
486
|
+
columnIds
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
this.frame.logger
|
|
490
|
+
);
|
|
491
|
+
|
|
217
492
|
try {
|
|
218
493
|
return AddonSymbol.pTableGetColumnIndices(this.table, columnIds);
|
|
219
494
|
} catch (err: unknown) {
|
|
@@ -230,8 +505,23 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
230
505
|
columnIndices: number[],
|
|
231
506
|
range?: TableRange
|
|
232
507
|
): Promise<PTableVector[]> {
|
|
508
|
+
const requestId = ulid();
|
|
509
|
+
dump(
|
|
510
|
+
[`${this.frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
511
|
+
{
|
|
512
|
+
timeStamp: Date.now(),
|
|
513
|
+
requestType: 'getData',
|
|
514
|
+
requestData: {
|
|
515
|
+
columnIndices,
|
|
516
|
+
range: range ?? null
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
this.frame.logger
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
const t0 = performance.now();
|
|
233
523
|
try {
|
|
234
|
-
return AddonSymbol.pTableGetData(this.table, columnIndices, range);
|
|
524
|
+
return await AddonSymbol.pTableGetData(this.table, columnIndices, range);
|
|
235
525
|
} catch (err: unknown) {
|
|
236
526
|
throw new Error(
|
|
237
527
|
`PTable getData request failed, ` +
|
|
@@ -240,6 +530,12 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
240
530
|
`error:\n` +
|
|
241
531
|
`${(err as Error).toString()}`
|
|
242
532
|
);
|
|
533
|
+
} finally {
|
|
534
|
+
const t1 = performance.now();
|
|
535
|
+
this.frame.logger?.(
|
|
536
|
+
'info',
|
|
537
|
+
`PTable getData request took ${Math.round(t1 - t0)}ms`
|
|
538
|
+
);
|
|
243
539
|
}
|
|
244
540
|
}
|
|
245
541
|
|
|
@@ -247,9 +543,28 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
247
543
|
request: PTableRecordFilter[],
|
|
248
544
|
signal?: AbortSignal
|
|
249
545
|
): Promise<PFrameInternal.PTableV3> {
|
|
546
|
+
const requestId = ulid();
|
|
547
|
+
const dumpData = {
|
|
548
|
+
timeStamp: Date.now(),
|
|
549
|
+
table: this.id,
|
|
550
|
+
requestType: 'filter',
|
|
551
|
+
requestData: request
|
|
552
|
+
};
|
|
553
|
+
dump(
|
|
554
|
+
[`${this.frame.id}`, `${requestId}.json`],
|
|
555
|
+
dumpData,
|
|
556
|
+
this.frame.logger
|
|
557
|
+
);
|
|
558
|
+
dump(
|
|
559
|
+
[`${this.frame.id}`, `${requestId}`, `${requestId}.json`],
|
|
560
|
+
dumpData,
|
|
561
|
+
this.frame.logger
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
const t0 = performance.now();
|
|
250
565
|
try {
|
|
251
566
|
const boxed = await AddonSymbol.pTableFilter(this.table, request, signal);
|
|
252
|
-
return new PTable(boxed);
|
|
567
|
+
return new PTable(this.frame, requestId, boxed);
|
|
253
568
|
} catch (err: unknown) {
|
|
254
569
|
throw new Error(
|
|
255
570
|
`PTable filter request failed, ` +
|
|
@@ -257,6 +572,12 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
257
572
|
`error:\n` +
|
|
258
573
|
`${(err as Error).toString()}`
|
|
259
574
|
);
|
|
575
|
+
} finally {
|
|
576
|
+
const t1 = performance.now();
|
|
577
|
+
this.frame.logger?.(
|
|
578
|
+
'info',
|
|
579
|
+
`PTable filter request took ${Math.round(t1 - t0)}ms`
|
|
580
|
+
);
|
|
260
581
|
}
|
|
261
582
|
}
|
|
262
583
|
|
|
@@ -264,9 +585,28 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
264
585
|
request: PTableSorting[],
|
|
265
586
|
signal?: AbortSignal
|
|
266
587
|
): Promise<PFrameInternal.PTableV3> {
|
|
588
|
+
const requestId = ulid();
|
|
589
|
+
const dumpData = {
|
|
590
|
+
timeStamp: Date.now(),
|
|
591
|
+
table: this.id,
|
|
592
|
+
requestType: 'sort',
|
|
593
|
+
requestData: request
|
|
594
|
+
};
|
|
595
|
+
dump(
|
|
596
|
+
[`${this.frame.id}`, `${requestId}.json`],
|
|
597
|
+
dumpData,
|
|
598
|
+
this.frame.logger
|
|
599
|
+
);
|
|
600
|
+
dump(
|
|
601
|
+
[`${this.frame.id}`, `${requestId}`, `${requestId}.json`],
|
|
602
|
+
dumpData,
|
|
603
|
+
this.frame.logger
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
const t0 = performance.now();
|
|
267
607
|
try {
|
|
268
608
|
const boxed = await AddonSymbol.pTableSort(this.table, request, signal);
|
|
269
|
-
return new PTable(boxed);
|
|
609
|
+
return new PTable(this.frame, requestId, boxed);
|
|
270
610
|
} catch (err: unknown) {
|
|
271
611
|
throw new Error(
|
|
272
612
|
`PTable sort request failed, ` +
|
|
@@ -274,10 +614,26 @@ class PTable implements PFrameInternal.PTableV3 {
|
|
|
274
614
|
`error:\n` +
|
|
275
615
|
`${(err as Error).toString()}`
|
|
276
616
|
);
|
|
617
|
+
} finally {
|
|
618
|
+
const t1 = performance.now();
|
|
619
|
+
this.frame.logger?.(
|
|
620
|
+
'info',
|
|
621
|
+
`PTable sort request took ${Math.round(t1 - t0)}ms`
|
|
622
|
+
);
|
|
277
623
|
}
|
|
278
624
|
}
|
|
279
625
|
|
|
280
626
|
dispose() {
|
|
627
|
+
const requestId = ulid();
|
|
628
|
+
dump(
|
|
629
|
+
[`${this.frame.id}`, `${this.id}`, `${requestId}.json`],
|
|
630
|
+
{
|
|
631
|
+
timeStamp: Date.now(),
|
|
632
|
+
requestType: 'dispose'
|
|
633
|
+
},
|
|
634
|
+
this.frame.logger
|
|
635
|
+
);
|
|
636
|
+
|
|
281
637
|
try {
|
|
282
638
|
AddonSymbol.pTableDispose(this.table);
|
|
283
639
|
} catch (err: unknown) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../export/dump.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAkC5E,wBAAsB,IAAI,CACxB,YAAY,EAAE,MAAM,EAAE,EACtB,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,UAAU,EAC5C,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|