@milaboratories/pf-driver 1.0.39 → 1.0.41
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/dist/data_info_helpers.cjs +1 -1
- package/dist/data_info_helpers.cjs.map +1 -1
- package/dist/data_info_helpers.d.ts +1 -1
- package/dist/data_info_helpers.d.ts.map +1 -1
- package/dist/data_info_helpers.js +1 -1
- package/dist/data_info_helpers.js.map +1 -1
- package/dist/driver_decl.d.ts +2 -2
- package/dist/driver_decl.d.ts.map +1 -1
- package/dist/driver_double.cjs +1 -1
- package/dist/driver_double.cjs.map +1 -1
- package/dist/driver_double.d.ts +6 -6
- package/dist/driver_double.d.ts.map +1 -1
- package/dist/driver_double.js +1 -1
- package/dist/driver_double.js.map +1 -1
- package/dist/driver_impl.cjs +35 -32
- package/dist/driver_impl.cjs.map +1 -1
- package/dist/driver_impl.d.ts +7 -7
- package/dist/driver_impl.d.ts.map +1 -1
- package/dist/driver_impl.js +35 -32
- package/dist/driver_impl.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/pframe_pool.cjs +21 -19
- package/dist/pframe_pool.cjs.map +1 -1
- package/dist/pframe_pool.d.ts +4 -4
- package/dist/pframe_pool.d.ts.map +1 -1
- package/dist/pframe_pool.js +21 -19
- package/dist/pframe_pool.js.map +1 -1
- package/dist/ptable_cache_per_frame.cjs +6 -6
- package/dist/ptable_cache_per_frame.cjs.map +1 -1
- package/dist/ptable_cache_per_frame.d.ts +4 -4
- package/dist/ptable_cache_per_frame.d.ts.map +1 -1
- package/dist/ptable_cache_per_frame.js +6 -6
- package/dist/ptable_cache_per_frame.js.map +1 -1
- package/dist/ptable_cache_plain.cjs +5 -5
- package/dist/ptable_cache_plain.cjs.map +1 -1
- package/dist/ptable_cache_plain.d.ts +4 -4
- package/dist/ptable_cache_plain.d.ts.map +1 -1
- package/dist/ptable_cache_plain.js +5 -5
- package/dist/ptable_cache_plain.js.map +1 -1
- package/dist/ptable_def_pool.cjs +2 -2
- package/dist/ptable_def_pool.cjs.map +1 -1
- package/dist/ptable_def_pool.d.ts +4 -4
- package/dist/ptable_def_pool.js +2 -2
- package/dist/ptable_def_pool.js.map +1 -1
- package/dist/ptable_pool.cjs +30 -26
- package/dist/ptable_pool.cjs.map +1 -1
- package/dist/ptable_pool.d.ts +6 -6
- package/dist/ptable_pool.d.ts.map +1 -1
- package/dist/ptable_pool.js +30 -26
- package/dist/ptable_pool.js.map +1 -1
- package/dist/ptable_shared.cjs.map +1 -1
- package/dist/ptable_shared.d.ts +1 -1
- package/dist/ptable_shared.js.map +1 -1
- package/package.json +29 -29
- package/src/data_info_helpers.ts +6 -7
- package/src/driver_decl.ts +8 -16
- package/src/driver_double.test.ts +89 -83
- package/src/driver_double.ts +23 -19
- package/src/driver_impl.ts +115 -80
- package/src/index.ts +4 -4
- package/src/pframe_pool.ts +42 -37
- package/src/ptable_cache_per_frame.ts +16 -13
- package/src/ptable_cache_plain.ts +16 -12
- package/src/ptable_def_pool.ts +7 -7
- package/src/ptable_pool.ts +62 -45
- package/src/ptable_shared.ts +2 -2
|
@@ -3,40 +3,38 @@ import {
|
|
|
3
3
|
type CalculateTableDataResponse,
|
|
4
4
|
type PFrameDriver,
|
|
5
5
|
type PObjectId,
|
|
6
|
-
} from
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from
|
|
11
|
-
import { test } from 'vitest';
|
|
12
|
-
import { join } from 'node:path';
|
|
13
|
-
import {
|
|
14
|
-
createPFrameDriverDouble,
|
|
15
|
-
makeFolderPath,
|
|
16
|
-
} from './driver_double';
|
|
6
|
+
} from "@platforma-sdk/model";
|
|
7
|
+
import { readJson, PFrameInternal } from "@milaboratories/pl-model-middle-layer";
|
|
8
|
+
import { test } from "vitest";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { createPFrameDriverDouble, makeFolderPath } from "./driver_double";
|
|
17
11
|
|
|
18
|
-
test(
|
|
12
|
+
test("inline column support", async ({ expect }) => {
|
|
19
13
|
// Model context
|
|
20
14
|
|
|
21
15
|
await using driver = await createPFrameDriverDouble({});
|
|
22
|
-
using pFrame = driver.createPFrame([
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
key: ['axis1'],
|
|
36
|
-
val: 1,
|
|
16
|
+
using pFrame = driver.createPFrame([
|
|
17
|
+
{
|
|
18
|
+
id: "column1" as PObjectId,
|
|
19
|
+
spec: {
|
|
20
|
+
kind: "PColumn",
|
|
21
|
+
axesSpec: [
|
|
22
|
+
{
|
|
23
|
+
name: "axis1",
|
|
24
|
+
type: "String",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
name: "column1",
|
|
28
|
+
valueType: "Int",
|
|
37
29
|
},
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
data: [
|
|
31
|
+
{
|
|
32
|
+
key: ["axis1"],
|
|
33
|
+
val: 1,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
40
38
|
|
|
41
39
|
// UI context
|
|
42
40
|
|
|
@@ -45,8 +43,8 @@ test('inline column support', async ({ expect }) => {
|
|
|
45
43
|
|
|
46
44
|
const data = await uiDriver.calculateTableData(pFrameHandle, {
|
|
47
45
|
src: {
|
|
48
|
-
type:
|
|
49
|
-
column:
|
|
46
|
+
type: "column",
|
|
47
|
+
column: "column1" as PObjectId,
|
|
50
48
|
},
|
|
51
49
|
filters: [],
|
|
52
50
|
sorting: [],
|
|
@@ -55,39 +53,41 @@ test('inline column support', async ({ expect }) => {
|
|
|
55
53
|
expect(data).toEqual([
|
|
56
54
|
{
|
|
57
55
|
spec: {
|
|
58
|
-
type:
|
|
56
|
+
type: "axis",
|
|
59
57
|
id: {
|
|
60
|
-
name:
|
|
61
|
-
type:
|
|
58
|
+
name: "axis1",
|
|
59
|
+
type: "String",
|
|
62
60
|
},
|
|
63
61
|
spec: {
|
|
64
|
-
name:
|
|
65
|
-
type:
|
|
62
|
+
name: "axis1",
|
|
63
|
+
type: "String",
|
|
66
64
|
},
|
|
67
65
|
},
|
|
68
66
|
data: {
|
|
69
|
-
type:
|
|
70
|
-
data: [
|
|
67
|
+
type: "String",
|
|
68
|
+
data: ["axis1"],
|
|
71
69
|
isNA: new Uint8Array(),
|
|
72
70
|
absent: new Uint8Array(),
|
|
73
71
|
},
|
|
74
72
|
},
|
|
75
73
|
{
|
|
76
74
|
spec: {
|
|
77
|
-
type:
|
|
78
|
-
id:
|
|
75
|
+
type: "column",
|
|
76
|
+
id: "column1" as PObjectId,
|
|
79
77
|
spec: {
|
|
80
|
-
kind:
|
|
81
|
-
axesSpec: [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
kind: "PColumn",
|
|
79
|
+
axesSpec: [
|
|
80
|
+
{
|
|
81
|
+
name: "axis1",
|
|
82
|
+
type: "String",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
name: "column1",
|
|
86
|
+
valueType: "Int",
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
89
|
data: {
|
|
90
|
-
type:
|
|
90
|
+
type: "Int",
|
|
91
91
|
data: new Int32Array([1]),
|
|
92
92
|
isNA: new Uint8Array(),
|
|
93
93
|
absent: new Uint8Array(),
|
|
@@ -96,43 +96,49 @@ test('inline column support', async ({ expect }) => {
|
|
|
96
96
|
] satisfies CalculateTableDataResponse);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
test.for([
|
|
100
|
-
|
|
101
|
-
{ testCase
|
|
102
|
-
|
|
103
|
-
])(`stored column support - $testCase`, async ({ testCase }, { expect }) => {
|
|
104
|
-
const dataFolder = makeFolderPath(join(__dirname, '..', 'assets', testCase));
|
|
99
|
+
test.for([{ testCase: "01_json" }, { testCase: "02_binary" }, { testCase: "03_parquet" }])(
|
|
100
|
+
`stored column support - $testCase`,
|
|
101
|
+
async ({ testCase }, { expect }) => {
|
|
102
|
+
const dataFolder = makeFolderPath(join(__dirname, "..", "assets", testCase));
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
// Model context
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
await using driver = await createPFrameDriverDouble({ dataFolder });
|
|
107
|
+
const pFrame = driver.createPFrame([
|
|
108
|
+
{
|
|
109
|
+
id: "column" as PObjectId,
|
|
110
|
+
spec: await readJson(join(dataFolder, `column${PFrameInternal.SpecExtension}`)),
|
|
111
|
+
data: await readJson(join(dataFolder, `column${PFrameInternal.DataInfoExtension}`)),
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
// UI context
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
const uiDriver: PFrameDriver = driver;
|
|
118
|
+
const pFrameHandle = pFrame.key;
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
const data = await uiDriver.calculateTableData(pFrameHandle, {
|
|
121
|
+
src: {
|
|
122
|
+
type: "column",
|
|
123
|
+
column: "column" as PObjectId,
|
|
124
|
+
},
|
|
125
|
+
filters: [],
|
|
126
|
+
sorting: [],
|
|
127
|
+
});
|
|
128
|
+
const result = {
|
|
129
|
+
spec: data.map((d) => d.spec),
|
|
130
|
+
data: data
|
|
131
|
+
.map((d) => d.data)
|
|
132
|
+
.map((d) =>
|
|
133
|
+
[...d.data.keys()].map((i) =>
|
|
134
|
+
pTableValue(d, i, {
|
|
135
|
+
absent: "|~|",
|
|
136
|
+
na: null,
|
|
137
|
+
}),
|
|
138
|
+
),
|
|
139
|
+
),
|
|
140
|
+
};
|
|
141
|
+
const expected = await readJson(join(dataFolder, "response.json"));
|
|
142
|
+
expect(result).toEqual(expected);
|
|
143
|
+
},
|
|
144
|
+
);
|
package/src/driver_double.ts
CHANGED
|
@@ -4,24 +4,24 @@ import {
|
|
|
4
4
|
type Branded,
|
|
5
5
|
type PColumnSpec,
|
|
6
6
|
type PColumnValues,
|
|
7
|
-
} from
|
|
8
|
-
import { PFrameInternal } from
|
|
9
|
-
import { RefCountPoolBase, type PoolEntry } from
|
|
10
|
-
import { HttpHelpers } from
|
|
11
|
-
import fs from
|
|
12
|
-
import path from
|
|
13
|
-
import { tmpdir } from
|
|
14
|
-
import type { AbstractInternalPFrameDriver } from
|
|
7
|
+
} from "@platforma-sdk/model";
|
|
8
|
+
import { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
|
|
9
|
+
import { RefCountPoolBase, type PoolEntry } from "@milaboratories/ts-helpers";
|
|
10
|
+
import { HttpHelpers } from "@milaboratories/pframes-rs-node";
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import type { AbstractInternalPFrameDriver } from "./driver_decl";
|
|
15
15
|
import {
|
|
16
16
|
AbstractPFrameDriver,
|
|
17
17
|
type LocalBlobProvider,
|
|
18
18
|
type RemoteBlobProvider,
|
|
19
|
-
} from
|
|
20
|
-
import { makeJsonDataInfo } from
|
|
19
|
+
} from "./driver_impl";
|
|
20
|
+
import { makeJsonDataInfo } from "./data_info_helpers";
|
|
21
21
|
|
|
22
|
-
export type FileName = Branded<string,
|
|
23
|
-
export type FilePath = Branded<string,
|
|
24
|
-
export type FolderPath = Branded<string,
|
|
22
|
+
export type FileName = Branded<string, "FileName">;
|
|
23
|
+
export type FilePath = Branded<string, "FilePath">;
|
|
24
|
+
export type FolderPath = Branded<string, "FolderPath">;
|
|
25
25
|
|
|
26
26
|
export function makeFolderPath(dataFolder: string): FolderPath {
|
|
27
27
|
if (!fs.statSync(dataFolder, { throwIfNoEntry: false })?.isDirectory()) {
|
|
@@ -38,7 +38,8 @@ function makeBlobId(res: FileName): PFrameInternal.PFrameBlobId {
|
|
|
38
38
|
|
|
39
39
|
class LocalBlobProviderImpl
|
|
40
40
|
extends RefCountPoolBase<FileName, PFrameInternal.PFrameBlobId, FilePath>
|
|
41
|
-
implements LocalBlobProvider<FileName>
|
|
41
|
+
implements LocalBlobProvider<FileName>
|
|
42
|
+
{
|
|
42
43
|
constructor(private readonly dataFolder: FolderPath) {
|
|
43
44
|
super();
|
|
44
45
|
}
|
|
@@ -67,7 +68,9 @@ class LocalBlobProviderImpl
|
|
|
67
68
|
return resource;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
public makeDataSource(
|
|
71
|
+
public makeDataSource(
|
|
72
|
+
signal: AbortSignal,
|
|
73
|
+
): Omit<PFrameInternal.PFrameDataSourceV2, "parquetServer"> {
|
|
71
74
|
return {
|
|
72
75
|
preloadBlob: async (_blobIds: PFrameInternal.PFrameBlobId[]) => {},
|
|
73
76
|
resolveBlobContent: async (blobId: PFrameInternal.PFrameBlobId) => {
|
|
@@ -87,7 +90,7 @@ class RemoteBlobProviderImpl implements RemoteBlobProvider<FileName> {
|
|
|
87
90
|
public static async init(
|
|
88
91
|
dataFolder: FolderPath,
|
|
89
92
|
logger: PFrameInternal.Logger,
|
|
90
|
-
serverOptions: Omit<PFrameInternal.HttpServerOptions,
|
|
93
|
+
serverOptions: Omit<PFrameInternal.HttpServerOptions, "handler">,
|
|
91
94
|
): Promise<RemoteBlobProviderImpl> {
|
|
92
95
|
const pool = new LocalBlobProviderImpl(dataFolder);
|
|
93
96
|
|
|
@@ -118,8 +121,9 @@ class RemoteBlobProviderImpl implements RemoteBlobProvider<FileName> {
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
export type InternalPFrameDriverDouble =
|
|
122
|
-
|
|
124
|
+
export type InternalPFrameDriverDouble = AbstractInternalPFrameDriver<
|
|
125
|
+
PFrameInternal.DataInfo<FileName> | PColumnValues
|
|
126
|
+
>;
|
|
123
127
|
|
|
124
128
|
export async function createPFrameDriverDouble({
|
|
125
129
|
dataFolder = tmpdir() as FolderPath,
|
|
@@ -134,7 +138,7 @@ export async function createPFrameDriverDouble({
|
|
|
134
138
|
const resolveDataInfo = (
|
|
135
139
|
spec: PColumnSpec,
|
|
136
140
|
data: PFrameInternal.DataInfo<FileName> | PColumnValues,
|
|
137
|
-
) => isDataInfo(data) ? data : makeJsonDataInfo(spec, data);
|
|
141
|
+
) => (isDataInfo(data) ? data : makeJsonDataInfo(spec, data));
|
|
138
142
|
|
|
139
143
|
return new AbstractPFrameDriver({
|
|
140
144
|
logger,
|