@milaboratories/pl-middle-layer 1.26.2 → 1.26.3
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/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1271 -1185
- package/dist/index.mjs.map +1 -1
- package/dist/pool/driver.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/pool/driver.ts +70 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/pool/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACzF,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EAEnB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,IAAI,eAAe,EAC/B,OAAO,EACP,SAAS,EAET,SAAS,EAIT,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAS9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/pool/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACzF,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAk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BAAyB,CAAC,SAAS,CAAC,GAC5C,OAAO,CAAC,0BAA0B,CAAC;IAiCzB,eAAe,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAkBnB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAKpD,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAK1D,OAAO,CAClB,MAAM,EAAE,YAAY,EACpB,aAAa,EAAE,MAAM,EAAE,EACvB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC;CAM3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.3",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"yaml": "^2.6.1",
|
|
30
30
|
"zod": "~3.23.8",
|
|
31
31
|
"@milaboratories/pl-http": "^1.0.3",
|
|
32
|
-
"@milaboratories/computable": "^2.3.4",
|
|
33
|
-
"@milaboratories/resolve-helper": "^1.0.2",
|
|
34
|
-
"@milaboratories/pl-client": "^2.7.3",
|
|
35
32
|
"@platforma-sdk/block-tools": "^2.5.7",
|
|
36
33
|
"@milaboratories/pl-drivers": "^1.5.11",
|
|
37
|
-
"@milaboratories/pl-
|
|
34
|
+
"@milaboratories/pl-client": "^2.7.3",
|
|
35
|
+
"@milaboratories/computable": "^2.3.4",
|
|
36
|
+
"@milaboratories/resolve-helper": "^1.0.2",
|
|
38
37
|
"@milaboratories/pl-model-middle-layer": "^1.7.1",
|
|
39
38
|
"@milaboratories/pl-tree": "^1.4.22",
|
|
39
|
+
"@milaboratories/pl-model-backend": "^1.0.1",
|
|
40
40
|
"@milaboratories/ts-helpers": "^1.1.3",
|
|
41
41
|
"@milaboratories/pl-model-common": "^1.10.4",
|
|
42
42
|
"@platforma-sdk/model": "^1.22.2",
|
package/src/pool/driver.ts
CHANGED
|
@@ -80,46 +80,80 @@ function migrateFilters(filters: PTableRecordFilter[]): PTableRecordSingleValueF
|
|
|
80
80
|
const bigintReplacer = (_: string, v: unknown) => (typeof v === 'bigint' ? v.toString() : v);
|
|
81
81
|
|
|
82
82
|
class PFrameHolder implements PFrameInternal.PFrameDataSource, Disposable {
|
|
83
|
-
public readonly
|
|
83
|
+
public readonly specPFrame: PFrameInternal.PFrameV2;
|
|
84
84
|
private readonly blobIdToResource = new Map<string, ResourceInfo>();
|
|
85
85
|
private readonly blobHandleComputables = new Map<
|
|
86
86
|
string,
|
|
87
87
|
ComputableStableDefined<LocalBlobHandleAndSize>
|
|
88
88
|
>();
|
|
89
89
|
|
|
90
|
+
private readonly createDataPFrame: () => PFrameInternal.PFrameV2;
|
|
91
|
+
public get disposableDataPFrame() {
|
|
92
|
+
const dataPFrame = this.createDataPFrame();
|
|
93
|
+
return {
|
|
94
|
+
dataPFrame,
|
|
95
|
+
[Symbol.dispose]: () => {
|
|
96
|
+
dataPFrame.dispose();
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
constructor(
|
|
91
102
|
private readonly blobDriver: DownloadDriver,
|
|
92
103
|
private readonly logger: MiLogger,
|
|
93
104
|
private readonly blobContentCache: LRUCache<string, Uint8Array>,
|
|
94
105
|
private readonly columns: InternalPFrameData,
|
|
95
106
|
) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
);
|
|
110
|
-
this.pFrame.setDataSource(this);
|
|
107
|
+
const logFunc: PFrameInternal.Logger = (level: 'info' | 'warn' | 'error', message: string) => {
|
|
108
|
+
switch (level) {
|
|
109
|
+
default:
|
|
110
|
+
case 'info':
|
|
111
|
+
return this.logger.info(message);
|
|
112
|
+
case 'warn':
|
|
113
|
+
return this.logger.warn(message);
|
|
114
|
+
case 'error':
|
|
115
|
+
return this.logger.error(message);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
111
119
|
for (const column of columns) {
|
|
112
|
-
for (const blob of allBlobs(column.data))
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
this.pFrame.addColumnSpec(column.id, column.spec);
|
|
116
|
-
this.pFrame.setColumnData(column.id, dataInfo);
|
|
117
|
-
} catch (err: unknown) {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`Adding column ${column.id} to PFrame failed: ${err as Error}; Spec: ${JSON.stringify(column.spec)}, DataInfo: ${JSON.stringify(dataInfo)}.`,
|
|
120
|
-
);
|
|
120
|
+
for (const blob of allBlobs(column.data)) {
|
|
121
|
+
this.blobIdToResource.set(blobKey(blob), blob);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
124
|
+
|
|
125
|
+
const createSpecPFrame = (): PFrameInternal.PFrameV2 => {
|
|
126
|
+
const pFrame = new PFrame(getDebugFlags().logPFrameRequests ? logFunc : undefined);
|
|
127
|
+
for (const column of columns) {
|
|
128
|
+
try {
|
|
129
|
+
pFrame.addColumnSpec(column.id, column.spec);
|
|
130
|
+
} catch (err: unknown) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Adding column ${column.id} to PFrame failed: ${err as Error}; Spec: ${JSON.stringify(column.spec)}.`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return pFrame;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const createDataPFrame = (): PFrameInternal.PFrameV2 => {
|
|
140
|
+
const pFrame = createSpecPFrame();
|
|
141
|
+
pFrame.setDataSource(this);
|
|
142
|
+
for (const column of columns) {
|
|
143
|
+
const dataInfo = mapBlobs(column.data, blobKey);
|
|
144
|
+
try {
|
|
145
|
+
pFrame.setColumnData(column.id, dataInfo);
|
|
146
|
+
} catch (err: unknown) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Setting column ${column.id} data to PFrame failed: ${err as Error}; Spec: ${JSON.stringify(column.spec)}, DataInfo: ${JSON.stringify(dataInfo)}.`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return pFrame;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
this.specPFrame = createSpecPFrame();
|
|
156
|
+
this.createDataPFrame = createDataPFrame;
|
|
123
157
|
}
|
|
124
158
|
|
|
125
159
|
private getOrCreateComputableForBlob(blobId: string) {
|
|
@@ -161,7 +195,7 @@ class PFrameHolder implements PFrameInternal.PFrameDataSource, Disposable {
|
|
|
161
195
|
|
|
162
196
|
[Symbol.dispose](): void {
|
|
163
197
|
for (const computable of this.blobHandleComputables.values()) computable.resetState();
|
|
164
|
-
this.
|
|
198
|
+
this.specPFrame.dispose();
|
|
165
199
|
}
|
|
166
200
|
}
|
|
167
201
|
|
|
@@ -222,13 +256,14 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
222
256
|
}
|
|
223
257
|
|
|
224
258
|
protected async createNewResource(params: FullPTableDef): Promise<PFrameInternal.PTableV2> {
|
|
225
|
-
const
|
|
259
|
+
const handle: PFrameHandle = params.pFrameHandle;
|
|
226
260
|
const rawPTable = await concurrencyLimiter.run(async () => {
|
|
227
261
|
if (getDebugFlags().logPFrameRequests)
|
|
228
262
|
logger.info(
|
|
229
263
|
`PTable creation (pTableHandle = ${this.calculateParamsKey(params)}): ${JSON.stringify(params, bigintReplacer)}`,
|
|
230
264
|
);
|
|
231
|
-
|
|
265
|
+
using disposableDataPFrame = this.pFrames.getByKey(handle).disposableDataPFrame;
|
|
266
|
+
return await disposableDataPFrame.dataPFrame.createTable({
|
|
232
267
|
src: joinEntryToInternal(params.def.src),
|
|
233
268
|
filters: migrateFilters(params.def.filters),
|
|
234
269
|
});
|
|
@@ -296,7 +331,7 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
296
331
|
: [],
|
|
297
332
|
};
|
|
298
333
|
const responce = await this.concurrencyLimiter.run(
|
|
299
|
-
async () => await this.pFrames.getByKey(handle).
|
|
334
|
+
async () => await this.pFrames.getByKey(handle).specPFrame.findColumns(iRequest),
|
|
300
335
|
);
|
|
301
336
|
return {
|
|
302
337
|
hits: responce.hits
|
|
@@ -311,13 +346,13 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
311
346
|
|
|
312
347
|
public async getColumnSpec(handle: PFrameHandle, columnId: PObjectId): Promise<PColumnSpec> {
|
|
313
348
|
return await this.concurrencyLimiter.run(
|
|
314
|
-
async () => await this.pFrames.getByKey(handle).
|
|
349
|
+
async () => await this.pFrames.getByKey(handle).specPFrame.getColumnSpec(columnId),
|
|
315
350
|
);
|
|
316
351
|
}
|
|
317
352
|
|
|
318
353
|
public async listColumns(handle: PFrameHandle): Promise<PColumnIdAndSpec[]> {
|
|
319
354
|
return await this.concurrencyLimiter.run(
|
|
320
|
-
async () => await this.pFrames.getByKey(handle).
|
|
355
|
+
async () => await this.pFrames.getByKey(handle).specPFrame.listColumns(),
|
|
321
356
|
);
|
|
322
357
|
}
|
|
323
358
|
|
|
@@ -330,7 +365,8 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
330
365
|
this.logger.info(
|
|
331
366
|
`Call calculateTableData, handle = ${handle}, request = ${JSON.stringify(request, bigintReplacer)}`,
|
|
332
367
|
);
|
|
333
|
-
|
|
368
|
+
using disposableDataPFrame = this.pFrames.getByKey(handle).disposableDataPFrame;
|
|
369
|
+
return await disposableDataPFrame.dataPFrame.createTable({
|
|
334
370
|
src: joinEntryToInternal(request.src),
|
|
335
371
|
filters: migrateFilters(request.filters),
|
|
336
372
|
});
|
|
@@ -365,7 +401,8 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
365
401
|
this.logger.info(
|
|
366
402
|
`Call getUniqueValues, handle = ${handle}, request = ${JSON.stringify(request, bigintReplacer)}`,
|
|
367
403
|
);
|
|
368
|
-
|
|
404
|
+
using disposableDataPFrame = this.pFrames.getByKey(handle).disposableDataPFrame;
|
|
405
|
+
return await disposableDataPFrame.dataPFrame.getUniqueValues({
|
|
369
406
|
...request,
|
|
370
407
|
filters: migrateFilters(request.filters),
|
|
371
408
|
});
|