@milaboratories/pframes-rs-node 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +3 -3
  2. package/export/addon-def.ts +27 -39
  3. package/export/addon.ts +6 -8
  4. package/export/dump.ts +37 -48
  5. package/export/export.ts +4 -6
  6. package/export/index.ts +2 -2
  7. package/export/node-pre-gyp.d.ts +1 -1
  8. package/export/tests/pframes.test.ts +279 -333
  9. package/export/tests/setup.ts +6 -15
  10. package/export/wrapper.ts +149 -221
  11. package/package.json +45 -43
  12. package/export_dist/addon-def.d.ts +0 -43
  13. package/export_dist/addon-def.d.ts.map +0 -1
  14. package/export_dist/addon.cjs +0 -24
  15. package/export_dist/addon.cjs.map +0 -1
  16. package/export_dist/addon.d.ts +0 -4
  17. package/export_dist/addon.d.ts.map +0 -1
  18. package/export_dist/addon.js +0 -21
  19. package/export_dist/addon.js.map +0 -1
  20. package/export_dist/dump.cjs +0 -115
  21. package/export_dist/dump.cjs.map +0 -1
  22. package/export_dist/dump.d.ts +0 -12
  23. package/export_dist/dump.d.ts.map +0 -1
  24. package/export_dist/dump.js +0 -107
  25. package/export_dist/dump.js.map +0 -1
  26. package/export_dist/export.cjs +0 -15
  27. package/export_dist/export.cjs.map +0 -1
  28. package/export_dist/export.d.ts +0 -3
  29. package/export_dist/export.d.ts.map +0 -1
  30. package/export_dist/export.js +0 -13
  31. package/export_dist/export.js.map +0 -1
  32. package/export_dist/index.cjs +0 -13
  33. package/export_dist/index.cjs.map +0 -1
  34. package/export_dist/index.d.ts +0 -3
  35. package/export_dist/index.d.ts.map +0 -1
  36. package/export_dist/index.js +0 -3
  37. package/export_dist/index.js.map +0 -1
  38. package/export_dist/tests/pframes.test.d.ts +0 -2
  39. package/export_dist/tests/pframes.test.d.ts.map +0 -1
  40. package/export_dist/tests/setup.d.ts +0 -2
  41. package/export_dist/tests/setup.d.ts.map +0 -1
  42. package/export_dist/wrapper.cjs +0 -542
  43. package/export_dist/wrapper.cjs.map +0 -1
  44. package/export_dist/wrapper.d.ts +0 -54
  45. package/export_dist/wrapper.d.ts.map +0 -1
  46. package/export_dist/wrapper.js +0 -539
  47. package/export_dist/wrapper.js.map +0 -1
@@ -1,26 +1,26 @@
1
1
  // Node.js core modules
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import process from 'node:process';
5
- import { tmpdir } from 'node:os';
6
- import type { Buffer } from 'node:buffer';
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import process from "node:process";
5
+ import { tmpdir } from "node:os";
6
+ import type { Buffer } from "node:buffer";
7
7
 
8
8
  // Testing framework
9
- import { describe, test } from 'vitest';
9
+ import { describe, test } from "vitest";
10
10
 
11
11
  // Project types and modules
12
- import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
12
+ import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
13
13
  import type {
14
- AxisId,
15
- PColumnIdAndSpec,
16
14
  PObjectId,
15
+ PTableColumnSpec,
17
16
  PTableSorting,
18
17
  PTableVector,
19
18
  QueryData,
20
- UniqueValuesResponse
21
- } from '@milaboratories/pl-model-common';
22
- import { PFrameFactory } from '..';
23
- import { ulid } from 'ulid';
19
+ UniqueValuesResponse,
20
+ } from "@milaboratories/pl-model-common";
21
+ import { PFrameFactory } from "..";
22
+ import { PFrame } from "../wrapper";
23
+ import { ulid } from "ulid";
24
24
 
25
25
  // ============================================================================
26
26
  // Test Utility Functions
@@ -30,8 +30,8 @@ import { ulid } from 'ulid';
30
30
  * Get the path to a test case directory
31
31
  */
32
32
  function getTestCaseDataPath(testCase: string): string {
33
- const currentDirectoryPath = path.relative('.', __dirname);
34
- const testDataPath = path.join(currentDirectoryPath, 'test_data');
33
+ const currentDirectoryPath = path.relative(".", __dirname);
34
+ const testDataPath = path.join(currentDirectoryPath, "test_data");
35
35
  return path.join(testDataPath, testCase);
36
36
  }
37
37
 
@@ -59,27 +59,21 @@ function readJsonTestFile(testCase: string, fileName: string): any {
59
59
  /**
60
60
  * Create a standard data source for tests that reads from test files
61
61
  */
62
- function createTestDataSource(
63
- testCase: string
64
- ): PFrameInternal.PFrameDataSourceV2 {
62
+ function createTestDataSource(testCase: string): PFrameInternal.PFrameDataSourceV2 {
65
63
  return {
66
- preloadBlob: function (
67
- blobIds: PFrameInternal.PFrameBlobId[]
68
- ): Promise<void> {
64
+ preloadBlob: function (blobIds: PFrameInternal.PFrameBlobId[]): Promise<void> {
69
65
  return new Promise((resolve) => {
70
66
  if (new Set(blobIds).size !== blobIds.length) {
71
- throw new Error('preload requires array of unique values');
67
+ throw new Error("preload requires array of unique values");
72
68
  }
73
69
  resolve();
74
70
  });
75
71
  },
76
- resolveBlobContent: function (
77
- blobId: PFrameInternal.PFrameBlobId
78
- ): Promise<Uint8Array> {
72
+ resolveBlobContent: function (blobId: PFrameInternal.PFrameBlobId): Promise<Uint8Array> {
79
73
  return new Promise((resolve) => {
80
74
  resolve(readTestFile(testCase, blobId));
81
75
  });
82
- }
76
+ },
83
77
  };
84
78
  }
85
79
 
@@ -89,8 +83,7 @@ function createTestDataSource(
89
83
  function createFailingDataSource(): PFrameInternal.PFrameDataSourceV2 {
90
84
  return {
91
85
  preloadBlob: (): Promise<void> => Promise.resolve(),
92
- resolveBlobContent: (): Promise<Uint8Array> =>
93
- Promise.reject(new Error('fail'))
86
+ resolveBlobContent: (): Promise<Uint8Array> => Promise.reject(new Error("fail")),
94
87
  };
95
88
  }
96
89
 
@@ -98,11 +91,11 @@ function createFailingDataSource(): PFrameInternal.PFrameDataSourceV2 {
98
91
  * Read a complete PFrame from test data directory
99
92
  * Automatically loads all .spec files and their corresponding .datainfo files
100
93
  */
101
- async function readPFrame(testCase: string): Promise<PFrameInternal.PFrameV13> {
94
+ async function readPFrame(testCase: string): Promise<PFrame> {
102
95
  const dataSource = createTestDataSource(testCase);
103
96
  const pframe = PFrameFactory.createPFrame({
104
97
  frameId: ulid() as PFrameInternal.PFrameId,
105
- spillPath: tmpdir() /*, logger: console.log */
98
+ spillPath: tmpdir() /*, logger: console.log */,
106
99
  });
107
100
  pframe.setDataSource(dataSource);
108
101
 
@@ -110,12 +103,12 @@ async function readPFrame(testCase: string): Promise<PFrameInternal.PFrameV13> {
110
103
  const files = fs.readdirSync(testCasePath);
111
104
 
112
105
  for (const file of files) {
113
- if (file.endsWith('.spec')) {
114
- const columnId = file.replace('.spec', '') as PObjectId;
106
+ if (file.endsWith(".spec")) {
107
+ const columnId = file.replace(".spec", "") as PObjectId;
115
108
  const columnSpec = readJsonTestFile(testCase, file);
116
109
  pframe.addColumnSpec(columnId, columnSpec);
117
110
 
118
- const dataInfoFile = file.replace('.spec', '.datainfo');
111
+ const dataInfoFile = file.replace(".spec", ".datainfo");
119
112
  if (files.includes(dataInfoFile)) {
120
113
  const dataInfo = readJsonTestFile(testCase, dataInfoFile);
121
114
  await pframe.setColumnData(columnId, dataInfo);
@@ -123,25 +116,25 @@ async function readPFrame(testCase: string): Promise<PFrameInternal.PFrameV13> {
123
116
  }
124
117
  }
125
118
 
126
- return pframe;
119
+ return pframe as unknown as PFrame;
127
120
  }
128
121
 
129
122
  // ============================================================================
130
123
  // Test Suites
131
124
  // ============================================================================
132
125
 
133
- describe('PFrame Column Operations', () => {
134
- test.concurrent('find_columns_request', async ({ expect }) => {
135
- const testCase = 'find_columns_request';
126
+ describe("PFrame Column Operations", () => {
127
+ test.concurrent("find_columns_request", async ({ expect }) => {
128
+ const testCase = "find_columns_request";
136
129
 
137
- const columnId = 'column1' as PObjectId;
138
- const columnSpec = readJsonTestFile(testCase, 'column.spec');
139
- const request = readJsonTestFile(testCase, 'request.json');
140
- const expectedResponse = readJsonTestFile(testCase, 'response.json');
130
+ const columnId = "column1" as PObjectId;
131
+ const columnSpec = readJsonTestFile(testCase, "column.spec");
132
+ const request = readJsonTestFile(testCase, "request.json");
133
+ const expectedResponse = readJsonTestFile(testCase, "response.json");
141
134
 
142
135
  using pframe = PFrameFactory.createPFrame({
143
136
  frameId: ulid() as PFrameInternal.PFrameId,
144
- spillPath: tmpdir()
137
+ spillPath: tmpdir(),
145
138
  });
146
139
  pframe.addColumnSpec(columnId, columnSpec);
147
140
 
@@ -149,58 +142,56 @@ describe('PFrame Column Operations', () => {
149
142
  expect(actualResponse).toEqual(expectedResponse);
150
143
  });
151
144
 
152
- test.concurrent('get_column_spec_request', async ({ expect }) => {
153
- const testCase = 'get_column_spec_request';
145
+ test.concurrent("get_column_spec_request", async ({ expect }) => {
146
+ const testCase = "get_column_spec_request";
154
147
 
155
- const columnId = 'column1' as PObjectId;
156
- const columnSpec = readJsonTestFile(testCase, 'column.spec');
157
- const expectedResponse = readJsonTestFile(testCase, 'response.json');
148
+ const columnId = "column1" as PObjectId;
149
+ const columnSpec = readJsonTestFile(testCase, "column.spec");
150
+ const expectedResponse = readJsonTestFile(testCase, "response.json");
158
151
 
159
152
  using pframe = PFrameFactory.createPFrame({
160
153
  frameId: ulid() as PFrameInternal.PFrameId,
161
- spillPath: tmpdir()
154
+ spillPath: tmpdir(),
162
155
  });
163
156
  pframe.addColumnSpec(columnId, columnSpec);
164
157
 
165
158
  const actualResponse = await pframe.getColumnSpec(columnId);
166
159
  expect(actualResponse).toEqual(expectedResponse);
167
160
 
168
- const unknownColumnId = 'unknown_column1' as PObjectId;
161
+ const unknownColumnId = "unknown_column1" as PObjectId;
169
162
  const unknownColumnSpec = await pframe.getColumnSpec(unknownColumnId);
170
163
  expect(unknownColumnSpec).toBeNull();
171
164
 
172
165
  const columnList = await pframe.listColumns();
173
- expect(columnList).toEqual([
174
- { columnId: columnId, spec: columnSpec, hasData: false }
175
- ]);
166
+ expect(columnList).toEqual([{ columnId: columnId, spec: columnSpec, hasData: false }]);
176
167
  });
177
168
 
178
- test.concurrent('delete_column_request', async ({ expect }) => {
179
- const testCase = 'delete_column_request';
169
+ test.concurrent("delete_column_request", async ({ expect }) => {
170
+ const testCase = "delete_column_request";
180
171
 
181
- const request = readJsonTestFile(testCase, 'request.json');
182
- const expectedResponse = readJsonTestFile(testCase, 'response.json');
172
+ const request = readJsonTestFile(testCase, "request.json");
173
+ const expectedResponse = readJsonTestFile(testCase, "response.json");
183
174
 
184
175
  using pframe = PFrameFactory.createPFrame({
185
176
  frameId: ulid() as PFrameInternal.PFrameId,
186
- spillPath: tmpdir()
177
+ spillPath: tmpdir(),
187
178
  });
188
179
 
189
180
  const actualResponse = await pframe.deleteColumn(request);
190
181
  expect(actualResponse).toEqual(expectedResponse);
191
182
  });
192
183
 
193
- test.concurrent('set_column_data_request', async ({ expect }) => {
194
- const testCase = 'set_column_data_request';
184
+ test.concurrent("set_column_data_request", async ({ expect }) => {
185
+ const testCase = "set_column_data_request";
195
186
 
196
- const columnId = 'column1' as PObjectId;
197
- const columnSpec = readJsonTestFile(testCase, 'column.spec');
198
- const dataInfo = readJsonTestFile(testCase, 'column.datainfo');
187
+ const columnId = "column1" as PObjectId;
188
+ const columnSpec = readJsonTestFile(testCase, "column.spec");
189
+ const dataInfo = readJsonTestFile(testCase, "column.datainfo");
199
190
  const dataSource = createTestDataSource(testCase);
200
191
 
201
192
  using pframe = PFrameFactory.createPFrame({
202
193
  frameId: ulid() as PFrameInternal.PFrameId,
203
- spillPath: tmpdir()
194
+ spillPath: tmpdir(),
204
195
  });
205
196
  pframe.setDataSource(dataSource);
206
197
 
@@ -208,33 +199,31 @@ describe('PFrame Column Operations', () => {
208
199
  await pframe.setColumnData(columnId, dataInfo);
209
200
 
210
201
  const columnList = await pframe.listColumns();
211
- expect(columnList).toEqual([
212
- { columnId: columnId, spec: columnSpec, hasData: true }
213
- ]);
202
+ expect(columnList).toEqual([{ columnId: columnId, spec: columnSpec, hasData: true }]);
214
203
  });
215
204
 
216
- test.concurrent('unique_values_request', async ({ expect }) => {
217
- const testCase = 'unique_values_request';
205
+ test.concurrent("unique_values_request", async ({ expect }) => {
206
+ const testCase = "unique_values_request";
218
207
 
219
- const columnId = 'column' as PObjectId;
220
- const columnSpec = readJsonTestFile(testCase, 'column.spec');
221
- const dataInfo = readJsonTestFile(testCase, 'column.datainfo');
208
+ const columnId = "column" as PObjectId;
209
+ const columnSpec = readJsonTestFile(testCase, "column.spec");
210
+ const dataInfo = readJsonTestFile(testCase, "column.datainfo");
222
211
  const dataSource = createTestDataSource(testCase);
223
- const request = readJsonTestFile(testCase, 'request.json');
212
+ const request = readJsonTestFile(testCase, "request.json");
224
213
 
225
214
  const expectedResponse: UniqueValuesResponse = {
226
215
  values: {
227
- type: 'Long',
216
+ type: "Long",
228
217
  data: new BigInt64Array([BigInt(10), BigInt(11), BigInt(12)]),
229
218
  isNA: new Uint8Array(),
230
- absent: new Uint8Array()
219
+ absent: new Uint8Array(),
231
220
  },
232
- overflow: false
221
+ overflow: false,
233
222
  };
234
223
 
235
224
  using pframe = PFrameFactory.createPFrame({
236
225
  frameId: ulid() as PFrameInternal.PFrameId,
237
- spillPath: tmpdir()
226
+ spillPath: tmpdir(),
238
227
  });
239
228
  pframe.setDataSource(dataSource);
240
229
 
@@ -246,328 +235,289 @@ describe('PFrame Column Operations', () => {
246
235
  });
247
236
  });
248
237
 
249
- describe('PFrame Table Creation', () => {
238
+ describe("PFrame Table Creation", () => {
250
239
  // Expected responses for table creation tests
251
240
  const createTableExpectedResponses = {
252
241
  request1: [
253
242
  {
254
- type: 'Int' as const,
243
+ type: "Int" as const,
255
244
  data: new Int32Array([10]),
256
245
  isNA: new Uint8Array(),
257
- absent: new Uint8Array()
246
+ absent: new Uint8Array(),
258
247
  },
259
248
  {
260
- type: 'Float' as const,
249
+ type: "Float" as const,
261
250
  data: new Float32Array([10.0]),
262
251
  isNA: new Uint8Array(),
263
- absent: new Uint8Array()
264
- }
252
+ absent: new Uint8Array(),
253
+ },
265
254
  ] as PTableVector[],
266
255
  request2: [
267
256
  {
268
- type: 'Long' as const,
257
+ type: "Long" as const,
269
258
  data: new BigInt64Array([BigInt(10)]),
270
259
  isNA: new Uint8Array(),
271
- absent: new Uint8Array()
260
+ absent: new Uint8Array(),
272
261
  },
273
262
  {
274
- type: 'Double' as const,
263
+ type: "Double" as const,
275
264
  data: new Float64Array([10.0]),
276
265
  isNA: new Uint8Array(),
277
- absent: new Uint8Array()
278
- }
266
+ absent: new Uint8Array(),
267
+ },
279
268
  ] as PTableVector[],
280
269
  request3: [
281
270
  {
282
- type: 'String' as const,
283
- data: ['10'],
271
+ type: "String" as const,
272
+ data: ["10"],
284
273
  isNA: new Uint8Array(),
285
- absent: new Uint8Array()
274
+ absent: new Uint8Array(),
286
275
  },
287
276
  {
288
- type: 'Bytes' as const,
277
+ type: "Bytes" as const,
289
278
  data: [new Uint8Array([49, 48])],
290
279
  isNA: new Uint8Array(),
291
- absent: new Uint8Array()
292
- }
280
+ absent: new Uint8Array(),
281
+ },
293
282
  ] as PTableVector[],
294
283
  request4: [
295
284
  {
296
- type: 'String' as const,
297
- data: ['10'],
285
+ type: "String" as const,
286
+ data: ["10"],
298
287
  isNA: new Uint8Array(),
299
- absent: new Uint8Array()
288
+ absent: new Uint8Array(),
300
289
  },
301
290
  {
302
- type: 'Float' as const,
291
+ type: "Float" as const,
303
292
  data: new Float32Array([NaN]),
304
293
  isNA: new Uint8Array([128]),
305
- absent: new Uint8Array()
306
- }
307
- ] as PTableVector[]
294
+ absent: new Uint8Array(),
295
+ },
296
+ ] as PTableVector[],
308
297
  };
309
298
 
310
- test.concurrent('create_table_request_1', async ({ expect }) => {
311
- const testCase = 'create_table_request_1';
312
- const request = readJsonTestFile(testCase, 'request.json');
299
+ test.concurrent("create_table_request_1", async ({ expect }) => {
300
+ const testCase = "create_table_request_1";
301
+ const request = readJsonTestFile(testCase, "request.json");
313
302
  const expectedResponse = createTableExpectedResponses.request1;
314
303
 
315
304
  using pframe = await readPFrame(testCase);
316
- using table = pframe.createTable(
317
- ulid() as PFrameInternal.PTableId,
318
- request
319
- );
305
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
320
306
 
321
- const columnIndices = Array.from(
322
- { length: table.getSpec().length },
323
- (_, i) => i
324
- );
307
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
325
308
  const actualResponse = await table.getData(columnIndices);
326
309
  expect(actualResponse).toEqual(expectedResponse);
327
310
  });
328
311
 
329
- test.concurrent('create_table_request_2', async ({ expect }) => {
330
- const testCase = 'create_table_request_2';
331
- const request = readJsonTestFile(testCase, 'request.json');
312
+ test.concurrent("create_table_request_2", async ({ expect }) => {
313
+ const testCase = "create_table_request_2";
314
+ const request = readJsonTestFile(testCase, "request.json");
332
315
  const expectedResponse = createTableExpectedResponses.request2;
333
316
 
334
317
  using pframe = await readPFrame(testCase);
335
- using table = pframe.createTable(
336
- ulid() as PFrameInternal.PTableId,
337
- request
338
- );
318
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
339
319
 
340
- const columnIndices = Array.from(
341
- { length: table.getSpec().length },
342
- (_, i) => i
343
- );
320
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
344
321
  const actualResponse = await table.getData(columnIndices);
345
322
  expect(actualResponse).toEqual(expectedResponse);
346
323
  });
347
324
 
348
- test.concurrent('create_table_request_3', async ({ expect }) => {
349
- const testCase = 'create_table_request_3';
350
- const request = readJsonTestFile(testCase, 'request.json');
325
+ test.concurrent("create_table_request_3", async ({ expect }) => {
326
+ const testCase = "create_table_request_3";
327
+ const request = readJsonTestFile(testCase, "request.json");
351
328
  const expectedResponse = createTableExpectedResponses.request3;
352
329
 
353
330
  using pframe = await readPFrame(testCase);
354
- using table = pframe.createTable(
355
- ulid() as PFrameInternal.PTableId,
356
- request
357
- );
331
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
358
332
 
359
- const columnIndices = Array.from(
360
- { length: table.getSpec().length },
361
- (_, i) => i
362
- );
333
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
363
334
  const actualResponse = await table.getData(columnIndices);
364
335
  expect(actualResponse).toEqual(expectedResponse);
365
336
  });
366
337
 
367
- test.concurrent('create_table_request_4', async ({ expect }) => {
368
- const testCase = 'create_table_request_4';
369
- const request = readJsonTestFile(testCase, 'request.json');
338
+ test.concurrent("create_table_request_4", async ({ expect }) => {
339
+ const testCase = "create_table_request_4";
340
+ const request = readJsonTestFile(testCase, "request.json");
370
341
  const expectedResponse = createTableExpectedResponses.request4;
371
342
 
372
343
  using pframe = await readPFrame(testCase);
373
- using table = pframe.createTable(
374
- ulid() as PFrameInternal.PTableId,
375
- request
376
- );
344
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
377
345
 
378
- const columnIndices = Array.from(
379
- { length: table.getSpec().length },
380
- (_, i) => i
381
- );
346
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
382
347
  const actualResponse = await table.getData(columnIndices);
383
348
  expect(actualResponse).toEqual(expectedResponse);
384
349
  });
385
350
 
386
- test.concurrent('create_table_request_fail', async ({ expect }) => {
387
- const testCase = 'create_table_request_fail';
351
+ test.concurrent("create_table_request_fail", async ({ expect }) => {
352
+ const testCase = "create_table_request_fail";
388
353
 
389
- const columnId = 'column' as PObjectId;
390
- const columnSpec = readJsonTestFile(testCase, 'column.spec');
391
- const dataInfo = readJsonTestFile(testCase, 'column.datainfo');
354
+ const columnId = "column" as PObjectId;
355
+ const columnSpec = readJsonTestFile(testCase, "column.spec");
356
+ const dataInfo = readJsonTestFile(testCase, "column.datainfo");
392
357
  const dataSource = createFailingDataSource();
393
- const request = readJsonTestFile(testCase, 'request.json');
358
+ const request = readJsonTestFile(testCase, "request.json");
394
359
 
395
360
  using pframe = PFrameFactory.createPFrame({
396
361
  frameId: ulid() as PFrameInternal.PFrameId,
397
- spillPath: tmpdir()
362
+ spillPath: tmpdir(),
398
363
  });
399
364
  pframe.setDataSource(dataSource);
400
365
 
401
366
  pframe.addColumnSpec(columnId, columnSpec);
402
367
  await pframe.setColumnData(columnId, dataInfo);
403
368
 
404
- using table = pframe.createTable(
405
- ulid() as PFrameInternal.PTableId,
406
- request
407
- );
369
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
408
370
 
409
371
  await expect(table.getShape()).rejects.toThrow();
410
372
  });
411
373
 
412
- // QueryData requests for createTableByDataQuery tests
413
- const createTableByDataQueryRequests = {
374
+ // QueryData requests for createTableV2 tests
375
+ const createTableV2Requests = {
414
376
  request1: {
415
- tableSpec: {
416
- axes: [{ name: 'axis', type: 'Int' }] as AxisId[],
417
- columns: [
418
- {
419
- columnId: 'column',
420
- spec: {
421
- kind: 'PColumn',
422
- axesSpec: [{ name: 'axis', type: 'Int' }],
423
- name: 'column',
424
- valueType: 'Float'
425
- }
426
- }
427
- ] as PColumnIdAndSpec[]
428
- },
429
- dataQuery: { type: 'column', columnId: 'column' } as QueryData
377
+ tableSpec: [
378
+ {
379
+ type: "axis",
380
+ id: { name: "axis", type: "Int" },
381
+ spec: { name: "axis", type: "Int" },
382
+ },
383
+ {
384
+ type: "column",
385
+ id: "column",
386
+ spec: {
387
+ kind: "PColumn",
388
+ axesSpec: [{ name: "axis", type: "Int" }],
389
+ name: "column",
390
+ valueType: "Float",
391
+ },
392
+ },
393
+ ] as PTableColumnSpec[],
394
+ dataQuery: { type: "column", columnId: "column" } as QueryData,
430
395
  },
431
396
  request2: {
432
- tableSpec: {
433
- axes: [{ name: 'axis', type: 'Long' }] as AxisId[],
434
- columns: [
435
- {
436
- columnId: 'column',
437
- spec: {
438
- kind: 'PColumn',
439
- axesSpec: [{ name: 'axis', type: 'Long' }],
440
- name: 'column',
441
- valueType: 'Double'
442
- }
443
- }
444
- ] as PColumnIdAndSpec[]
445
- },
446
- dataQuery: { type: 'column', columnId: 'column' } as QueryData
397
+ tableSpec: [
398
+ {
399
+ type: "axis",
400
+ id: { name: "axis", type: "Long" },
401
+ spec: { name: "axis", type: "Long" },
402
+ },
403
+ {
404
+ type: "column",
405
+ id: "column",
406
+ spec: {
407
+ kind: "PColumn",
408
+ axesSpec: [{ name: "axis", type: "Long" }],
409
+ name: "column",
410
+ valueType: "Double",
411
+ },
412
+ },
413
+ ] as PTableColumnSpec[],
414
+ dataQuery: { type: "column", columnId: "column" } as QueryData,
447
415
  },
448
416
  request3: {
449
- tableSpec: {
450
- axes: [{ name: 'axis', type: 'String' }] as AxisId[],
451
- columns: [
452
- {
453
- columnId: 'column',
454
- spec: {
455
- kind: 'PColumn',
456
- axesSpec: [{ name: 'axis', type: 'String' }],
457
- name: 'column',
458
- valueType: 'Bytes'
459
- }
460
- }
461
- ] as PColumnIdAndSpec[]
462
- },
463
- dataQuery: { type: 'column', columnId: 'column' } as QueryData
417
+ tableSpec: [
418
+ {
419
+ type: "axis",
420
+ id: { name: "axis", type: "String" },
421
+ spec: { name: "axis", type: "String" },
422
+ },
423
+ {
424
+ type: "column",
425
+ id: "column",
426
+ spec: {
427
+ kind: "PColumn",
428
+ axesSpec: [{ name: "axis", type: "String" }],
429
+ name: "column",
430
+ valueType: "Bytes",
431
+ },
432
+ },
433
+ ] as PTableColumnSpec[],
434
+ dataQuery: { type: "column", columnId: "column" } as QueryData,
464
435
  },
465
436
  request4: {
466
- tableSpec: {
467
- axes: [{ name: 'axis', type: 'String' }] as AxisId[],
468
- columns: [
469
- {
470
- columnId: 'column',
471
- spec: {
472
- kind: 'PColumn',
473
- axesSpec: [{ name: 'axis', type: 'String' }],
474
- name: 'column',
475
- valueType: 'Float'
476
- }
477
- }
478
- ] as PColumnIdAndSpec[]
479
- },
480
- dataQuery: { type: 'column', columnId: 'column' } as QueryData
481
- }
437
+ tableSpec: [
438
+ {
439
+ type: "axis",
440
+ id: { name: "axis", type: "String" },
441
+ spec: { name: "axis", type: "String" },
442
+ },
443
+ {
444
+ type: "column",
445
+ id: "column",
446
+ spec: {
447
+ kind: "PColumn",
448
+ axesSpec: [{ name: "axis", type: "String" }],
449
+ name: "column",
450
+ valueType: "Float",
451
+ },
452
+ },
453
+ ] as PTableColumnSpec[],
454
+ dataQuery: { type: "column", columnId: "column" } as QueryData,
455
+ },
482
456
  };
483
457
 
484
- test.concurrent('create_table_by_data_query_1', async ({ expect }) => {
485
- const testCase = 'create_table_request_1';
458
+ test.concurrent("create_table_by_data_query_1", async ({ expect }) => {
459
+ const testCase = "create_table_request_1";
486
460
  const expectedResponse = createTableExpectedResponses.request1;
487
- const queryDataRequest = createTableByDataQueryRequests.request1;
461
+ const queryDataRequest = createTableV2Requests.request1;
488
462
 
489
463
  using pframe = await readPFrame(testCase);
490
- using table = pframe.createTableByDataQuery(
491
- ulid() as PFrameInternal.PTableId,
492
- queryDataRequest
493
- );
464
+ using table = pframe.createTableV2(ulid() as PFrameInternal.PTableId, queryDataRequest);
494
465
 
495
- const columnIndices = Array.from(
496
- { length: table.getSpec().length },
497
- (_, i) => i
498
- );
466
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
499
467
  const actualResponse = await table.getData(columnIndices);
500
468
  expect(actualResponse).toEqual(expectedResponse);
501
469
  });
502
470
 
503
- test.concurrent('create_table_by_data_query_2', async ({ expect }) => {
504
- const testCase = 'create_table_request_2';
471
+ test.concurrent("create_table_by_data_query_2", async ({ expect }) => {
472
+ const testCase = "create_table_request_2";
505
473
  const expectedResponse = createTableExpectedResponses.request2;
506
- const queryDataRequest = createTableByDataQueryRequests.request2;
474
+ const queryDataRequest = createTableV2Requests.request2;
507
475
 
508
476
  using pframe = await readPFrame(testCase);
509
- using table = pframe.createTableByDataQuery(
510
- ulid() as PFrameInternal.PTableId,
511
- queryDataRequest
512
- );
477
+ using table = pframe.createTableV2(ulid() as PFrameInternal.PTableId, queryDataRequest);
513
478
 
514
- const columnIndices = Array.from(
515
- { length: table.getSpec().length },
516
- (_, i) => i
517
- );
479
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
518
480
  const actualResponse = await table.getData(columnIndices);
519
481
  expect(actualResponse).toEqual(expectedResponse);
520
482
  });
521
483
 
522
- test.concurrent('create_table_by_data_query_3', async ({ expect }) => {
523
- const testCase = 'create_table_request_3';
484
+ test.concurrent("create_table_by_data_query_3", async ({ expect }) => {
485
+ const testCase = "create_table_request_3";
524
486
  const expectedResponse = createTableExpectedResponses.request3;
525
- const queryDataRequest = createTableByDataQueryRequests.request3;
487
+ const queryDataRequest = createTableV2Requests.request3;
526
488
 
527
489
  using pframe = await readPFrame(testCase);
528
- using table = pframe.createTableByDataQuery(
529
- ulid() as PFrameInternal.PTableId,
530
- queryDataRequest
531
- );
490
+ using table = pframe.createTableV2(ulid() as PFrameInternal.PTableId, queryDataRequest);
532
491
 
533
- const columnIndices = Array.from(
534
- { length: table.getSpec().length },
535
- (_, i) => i
536
- );
492
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
537
493
  const actualResponse = await table.getData(columnIndices);
538
494
  expect(actualResponse).toEqual(expectedResponse);
539
495
  });
540
496
 
541
- test.concurrent('create_table_by_data_query_4', async ({ expect }) => {
542
- const testCase = 'create_table_request_4';
497
+ test.concurrent("create_table_by_data_query_4", async ({ expect }) => {
498
+ const testCase = "create_table_request_4";
543
499
  const expectedResponse = createTableExpectedResponses.request4;
544
- const queryDataRequest = createTableByDataQueryRequests.request4;
500
+ const queryDataRequest = createTableV2Requests.request4;
545
501
 
546
502
  using pframe = await readPFrame(testCase);
547
- using table = pframe.createTableByDataQuery(
548
- ulid() as PFrameInternal.PTableId,
549
- queryDataRequest
550
- );
503
+ using table = pframe.createTableV2(ulid() as PFrameInternal.PTableId, queryDataRequest);
551
504
 
552
- const columnIndices = Array.from(
553
- { length: table.getSpec().length },
554
- (_, i) => i
555
- );
505
+ const columnIndices = Array.from({ length: table.getSpec().length }, (_, i) => i);
556
506
  const actualResponse = await table.getData(columnIndices);
557
507
  expect(actualResponse).toEqual(expectedResponse);
558
508
  });
559
509
 
560
- test.concurrent('create_table_by_data_query_fail', async ({ expect }) => {
561
- const testCase = 'create_table_request_fail';
510
+ test.concurrent("create_table_by_data_query_fail", async ({ expect }) => {
511
+ const testCase = "create_table_request_fail";
562
512
 
563
- const columnId = 'column' as PObjectId;
564
- const columnSpec = readJsonTestFile(testCase, 'column.spec');
565
- const dataInfo = readJsonTestFile(testCase, 'column.datainfo');
513
+ const columnId = "column" as PObjectId;
514
+ const columnSpec = readJsonTestFile(testCase, "column.spec");
515
+ const dataInfo = readJsonTestFile(testCase, "column.datainfo");
566
516
  const dataSource = createFailingDataSource();
567
517
 
568
518
  using pframe = PFrameFactory.createPFrame({
569
519
  frameId: ulid() as PFrameInternal.PFrameId,
570
- spillPath: tmpdir()
520
+ spillPath: tmpdir(),
571
521
  });
572
522
  pframe.setDataSource(dataSource);
573
523
 
@@ -576,104 +526,103 @@ describe('PFrame Table Creation', () => {
576
526
 
577
527
  // Construct QueryData request for the failing column
578
528
  const queryDataRequest = {
579
- tableSpec: {
580
- axes: [{ name: 'axis', type: 'Long' }] as AxisId[],
581
- columns: [
582
- {
583
- columnId: 'column',
584
- spec: {
585
- kind: 'PColumn',
586
- axesSpec: [{ name: 'axis', type: 'Long' }],
587
- name: 'column',
588
- valueType: 'Long'
589
- }
590
- }
591
- ] as PColumnIdAndSpec[]
592
- },
529
+ tableSpec: [
530
+ {
531
+ type: "axis",
532
+ id: { name: "axis", type: "Long" },
533
+ spec: { name: "axis", type: "Long" },
534
+ },
535
+ {
536
+ type: "column",
537
+ id: "column",
538
+ spec: {
539
+ kind: "PColumn",
540
+ axesSpec: [{ name: "axis", type: "Long" }],
541
+ name: "column",
542
+ valueType: "Long",
543
+ },
544
+ },
545
+ ] as PTableColumnSpec[],
593
546
  dataQuery: {
594
- type: 'column',
595
- columnId: 'column'
596
- }
547
+ type: "column",
548
+ columnId: "column",
549
+ } as QueryData,
597
550
  };
598
551
 
599
- // Cast to access the method which may not be on the interface yet
600
- using table = pframe.createTableByDataQuery(
552
+ using table = (pframe as unknown as PFrame).createTableV2(
601
553
  ulid() as PFrameInternal.PTableId,
602
- queryDataRequest as any
554
+ queryDataRequest,
603
555
  );
604
556
 
605
557
  await expect(table.getShape()).rejects.toThrow();
606
558
  });
607
559
  });
608
560
 
609
- describe('PFrame Table Operations', () => {
610
- test.concurrent('sort_table_request', async ({ expect }) => {
611
- const testCase = 'sort_table_request';
561
+ describe("PFrame Table Operations", () => {
562
+ test.concurrent("sort_table_request", async ({ expect }) => {
563
+ const testCase = "sort_table_request";
612
564
 
613
- const request = readJsonTestFile(testCase, 'request.json');
614
- const sorting: PTableSorting[] = readJsonTestFile(testCase, 'sorting.json');
565
+ const request = readJsonTestFile(testCase, "request.json");
566
+ const sorting: PTableSorting[] = readJsonTestFile(testCase, "sorting.json");
615
567
 
616
568
  // Expected response for full sorted data
617
569
  let expectedFullResponse: PTableVector[] = [
618
570
  {
619
- type: 'Long', // Axis A1 - all values present
571
+ type: "Long", // Axis A1 - all values present
620
572
  data: new BigInt64Array([BigInt(0), BigInt(0), BigInt(1), BigInt(2)]),
621
573
  isNA: new Uint8Array(),
622
- absent: new Uint8Array()
574
+ absent: new Uint8Array(),
623
575
  },
624
576
  {
625
- type: 'String', // Axis A2 - positions 2,3 absent (no record in column2 for A1=1,2)
626
- data: ['FloatOne', 'FloatTwo', null, null],
577
+ type: "String", // Axis A2 - positions 2,3 absent (no record in column2 for A1=1,2)
578
+ data: ["FloatOne", "FloatTwo", null, null],
627
579
  isNA: new Uint8Array([48]),
628
- absent: new Uint8Array()
580
+ absent: new Uint8Array(),
629
581
  },
630
582
  {
631
- type: 'String', // Column column1 - positions 0,1 are NA (no data for A1=0)
632
- data: [null, null, 'IntOne', 'IntTwo'],
583
+ type: "String", // Column column1 - positions 0,1 are NA (no data for A1=0)
584
+ data: [null, null, "IntOne", "IntTwo"],
633
585
  isNA: new Uint8Array([192]),
634
- absent: new Uint8Array()
586
+ absent: new Uint8Array(),
635
587
  },
636
588
  {
637
- type: 'Float', // Column column2 - positions 2,3 are NA (no data for A1=1,2)
589
+ type: "Float", // Column column2 - positions 2,3 are NA (no data for A1=1,2)
638
590
  data: new Float32Array([1.0, 2.0, NaN, NaN]),
639
591
  isNA: new Uint8Array([48]),
640
- absent: new Uint8Array()
641
- }
592
+ absent: new Uint8Array(),
593
+ },
642
594
  ];
643
595
 
644
596
  // Expected response for range query (rows 1-2, reordered columns)
645
597
  const expectedRangeResponse: PTableVector[] = [
646
598
  {
647
- type: 'Float', // Column column2 - position 1 is NA
599
+ type: "Float", // Column column2 - position 1 is NA
648
600
  data: new Float32Array([2.0, NaN]),
649
601
  isNA: new Uint8Array([64]),
650
- absent: new Uint8Array()
602
+ absent: new Uint8Array(),
651
603
  },
652
604
  {
653
- type: 'String', // Column column1 - position 0 is NA
654
- data: [null, 'IntOne'],
605
+ type: "String", // Column column1 - position 0 is NA
606
+ data: [null, "IntOne"],
655
607
  isNA: new Uint8Array([128]),
656
- absent: new Uint8Array()
608
+ absent: new Uint8Array(),
657
609
  },
658
610
  {
659
- type: 'String', // Axis A2 - position 1 is absent
660
- data: ['FloatTwo', null],
611
+ type: "String", // Axis A2 - position 1 is absent
612
+ data: ["FloatTwo", null],
661
613
  isNA: new Uint8Array([64]),
662
- absent: new Uint8Array()
614
+ absent: new Uint8Array(),
663
615
  },
664
616
  {
665
- type: 'Long', // Axis A1 - all present
617
+ type: "Long", // Axis A1 - all present
666
618
  data: new BigInt64Array([BigInt(0), BigInt(1)]),
667
619
  isNA: new Uint8Array(),
668
- absent: new Uint8Array()
669
- }
620
+ absent: new Uint8Array(),
621
+ },
670
622
  ];
671
623
 
672
624
  using pframe = await readPFrame(testCase);
673
- using table = pframe.createTable(
674
- ulid() as PFrameInternal.PTableId,
675
- request
676
- );
625
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
677
626
 
678
627
  using sortedTable = table.sort(ulid() as PFrameInternal.PTableId, sorting);
679
628
  const footprint = await sortedTable.getFootprint();
@@ -681,7 +630,7 @@ describe('PFrame Table Operations', () => {
681
630
 
682
631
  // Test full sorted data
683
632
  const columnIndices = sortedTable.getColumnIndices(
684
- Array.from(sorting, (entry) => entry.column)
633
+ Array.from(sorting, (entry) => entry.column),
685
634
  );
686
635
  let actualResponse = await sortedTable.getData(columnIndices);
687
636
  expect(actualResponse).toEqual(expectedFullResponse);
@@ -689,31 +638,28 @@ describe('PFrame Table Operations', () => {
689
638
  // Test range query with reordered columns
690
639
  actualResponse = await sortedTable.getData(
691
640
  [columnIndices[3], columnIndices[2], columnIndices[1], columnIndices[0]],
692
- { range: { offset: 1, length: 2 } }
641
+ { range: { offset: 1, length: 2 } },
693
642
  );
694
643
  expect(actualResponse).toEqual(expectedRangeResponse);
695
644
  });
696
645
  });
697
646
 
698
- describe('PFrame Complex Operations', () => {
699
- test.concurrent('complex_join', async ({ expect }) => {
700
- const testCase = 'complex_join';
647
+ describe("PFrame Complex Operations", () => {
648
+ test.concurrent("complex_join", async ({ expect }) => {
649
+ const testCase = "complex_join";
701
650
  using pframe = await readPFrame(testCase);
702
651
 
703
- const request = readJsonTestFile(testCase, 'request.json');
704
- using table = pframe.createTable(
705
- ulid() as PFrameInternal.PTableId,
706
- request
707
- );
652
+ const request = readJsonTestFile(testCase, "request.json");
653
+ using table = pframe.createTable(ulid() as PFrameInternal.PTableId, request);
708
654
 
709
655
  const shape = await table.getShape();
710
656
  expect(shape).toEqual({
711
657
  columns: 6,
712
- rows: 7124
658
+ rows: 7124,
713
659
  });
714
660
 
715
661
  // Test profiling functionality (platform-dependent)
716
- if (process.platform === 'win32') {
662
+ if (process.platform === "win32") {
717
663
  expect(PFrameFactory.pprofDump()).rejects.toThrow();
718
664
  } else {
719
665
  const profile = await PFrameFactory.pprofDump();
@@ -724,12 +670,12 @@ describe('PFrame Complex Operations', () => {
724
670
 
725
671
  // Test out of bounds range
726
672
  const result = await table.getData([0], {
727
- range: { offset: 10000, length: 20000 }
673
+ range: { offset: 10000, length: 20000 },
728
674
  });
729
675
  expect(result).toMatchObject([{ data: [] }]);
730
676
 
731
677
  const result2 = await table.getData([0], {
732
- range: { offset: 7123, length: 2 }
678
+ range: { offset: 7123, length: 2 },
733
679
  });
734
680
  expect(result2[0].data.length).toBe(1);
735
681
  });