@milaboratories/pl-middle-layer 1.23.7 → 1.23.8
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 +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -100
- package/dist/index.mjs.map +1 -1
- package/dist/pool/driver.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/pool/driver.ts +87 -62
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/pool/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,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,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;AAqI3D,qBAAa,YAAa,YAAW,eAAe;IAQhD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IARzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyD;IACjF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwE;IAChG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA+B;IAChE,0FAA0F;IAC1F,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA8B;gBAG9C,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,QAAQ;IAmE5B,YAAY,CACjB,GAAG,EAAE,SAAS,CAAC,kBAAkB,GAAG,aAAa,CAAC,EAClD,GAAG,EAAE,aAAa,GACjB,YAAY;IAaR,YAAY,CACjB,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,kBAAkB,GAAG,aAAa,CAAC,CAAC,EAC3D,GAAG,EAAE,aAAa,GACjB,YAAY;IAmBF,WAAW,CACtB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAiBlB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAM9E,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAM9D,kBAAkB,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,GAC5C,OAAO,CAAC,0BAA0B,CAAC;IAgCzB,eAAe,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAiBnB,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.23.
|
|
3
|
+
"version": "1.23.8",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"keywords": [],
|
|
20
20
|
"license": "UNLICENSED",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@milaboratories/pframes-node": "2.1.
|
|
22
|
+
"@milaboratories/pframes-node": "2.1.3",
|
|
23
23
|
"canonicalize": "^2.0.0",
|
|
24
24
|
"denque": "^2.1.0",
|
|
25
25
|
"lru-cache": "^11.0.2",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
"yaml": "^2.6.1",
|
|
30
30
|
"zod": "~3.23.8",
|
|
31
31
|
"@milaboratories/pl-http": "^1.0.2",
|
|
32
|
+
"@milaboratories/computable": "^2.3.4",
|
|
32
33
|
"@milaboratories/resolve-helper": "^1.0.2",
|
|
33
|
-
"@platforma-sdk/block-tools": "^2.5.1",
|
|
34
34
|
"@milaboratories/pl-drivers": "^1.5.6",
|
|
35
|
-
"@milaboratories/
|
|
35
|
+
"@milaboratories/pl-model-middle-layer": "^1.6.9",
|
|
36
|
+
"@platforma-sdk/block-tools": "^2.5.1",
|
|
36
37
|
"@milaboratories/pl-client": "^2.7.1",
|
|
37
38
|
"@milaboratories/pl-model-common": "^1.10.2",
|
|
38
39
|
"@milaboratories/pl-model-backend": "^1.0.1",
|
|
39
40
|
"@milaboratories/pl-tree": "^1.4.20",
|
|
40
41
|
"@platforma-sdk/model": "^1.21.0",
|
|
41
|
-
"@milaboratories/
|
|
42
|
-
"@
|
|
43
|
-
"@platforma-sdk/workflow-tengo": "2.9.0",
|
|
42
|
+
"@milaboratories/ts-helpers": "^1.1.3",
|
|
43
|
+
"@platforma-sdk/workflow-tengo": "2.9.1",
|
|
44
44
|
"@milaboratories/pl-local": "^1.10.0",
|
|
45
|
-
"@milaboratories/
|
|
45
|
+
"@milaboratories/pl-config": "^1.3.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"semver": "^7.6.3",
|
package/src/pool/driver.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DownloadDriver } from '@milaboratories/pl-drivers';
|
|
2
|
-
import { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { DownloadDriver } from '@milaboratories/pl-drivers';
|
|
2
|
+
import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
3
|
+
import type { PlTreeNodeAccessor, ResourceInfo } from '@milaboratories/pl-tree';
|
|
4
|
+
import { isPlTreeNodeAccessor } from '@milaboratories/pl-tree';
|
|
5
|
+
import type { ComputableCtx, ComputableStableDefined } from '@milaboratories/computable';
|
|
6
|
+
import type {
|
|
6
7
|
CalculateTableDataRequest,
|
|
7
8
|
CalculateTableDataResponse,
|
|
8
9
|
FindColumnsRequest,
|
|
@@ -21,21 +22,23 @@ import {
|
|
|
21
22
|
UniqueValuesResponse,
|
|
22
23
|
PFrameDriver as SdkPFrameDriver,
|
|
23
24
|
PColumn,
|
|
24
|
-
mapPObjectData,
|
|
25
25
|
PFrameDef,
|
|
26
26
|
JoinEntry,
|
|
27
27
|
PTableDef,
|
|
28
|
-
mapPTableDef,
|
|
29
28
|
ValueType,
|
|
30
29
|
PTableRecordSingleValueFilterV2,
|
|
31
30
|
PTableRecordFilter,
|
|
32
|
-
PColumnValues
|
|
33
|
-
|
|
31
|
+
PColumnValues } from '@platforma-sdk/model';
|
|
32
|
+
import {
|
|
33
|
+
mapPObjectData,
|
|
34
|
+
mapPTableDef,
|
|
35
|
+
extractAllColumns,
|
|
34
36
|
} from '@platforma-sdk/model';
|
|
35
37
|
import { RefCountResourcePool } from './ref_count_pool';
|
|
36
38
|
import { allBlobs, makeDataInfoResource, mapBlobs, parseDataInfoResource } from './data';
|
|
37
|
-
import { createHash
|
|
38
|
-
import {
|
|
39
|
+
import { createHash } from 'node:crypto';
|
|
40
|
+
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
41
|
+
import { assertNever } from '@milaboratories/ts-helpers';
|
|
39
42
|
import canonicalize from 'canonicalize';
|
|
40
43
|
import { PFrame } from '@milaboratories/pframes-node';
|
|
41
44
|
import * as fsp from 'node:fs/promises';
|
|
@@ -59,7 +62,7 @@ function migrateFilters(filters: PTableRecordFilter[]): PTableRecordSingleValueF
|
|
|
59
62
|
filtersV1.push(filter);
|
|
60
63
|
filtersV2.push({
|
|
61
64
|
...filter,
|
|
62
|
-
type: 'bySingleColumnV2'
|
|
65
|
+
type: 'bySingleColumnV2',
|
|
63
66
|
});
|
|
64
67
|
} else {
|
|
65
68
|
filtersV2.push(filter);
|
|
@@ -68,16 +71,16 @@ function migrateFilters(filters: PTableRecordFilter[]): PTableRecordSingleValueF
|
|
|
68
71
|
if (filtersV1.length > 0) {
|
|
69
72
|
const filtersV1Json = JSON.stringify(filtersV1);
|
|
70
73
|
console.warn(
|
|
71
|
-
`type overriten from 'bySingleColumn' to 'bySingleColumnV2' for filters: ${filtersV1Json}
|
|
74
|
+
`type overriten from 'bySingleColumn' to 'bySingleColumnV2' for filters: ${filtersV1Json}`,
|
|
72
75
|
);
|
|
73
76
|
}
|
|
74
|
-
return filters
|
|
77
|
+
return filters;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
const bigintReplacer = (_: string, v:
|
|
80
|
+
const bigintReplacer = (_: string, v: unknown) => (typeof v === 'bigint' ? v.toString() : v);
|
|
78
81
|
|
|
79
82
|
class PFrameHolder implements PFrameInternal.PFrameDataSource, Disposable {
|
|
80
|
-
public readonly pFrame
|
|
83
|
+
public readonly pFrame;
|
|
81
84
|
private readonly blobIdToResource = new Map<string, ResourceInfo>();
|
|
82
85
|
private readonly blobHandleComputables = new Map<
|
|
83
86
|
string,
|
|
@@ -86,10 +89,24 @@ class PFrameHolder implements PFrameInternal.PFrameDataSource, Disposable {
|
|
|
86
89
|
|
|
87
90
|
constructor(
|
|
88
91
|
private readonly blobDriver: DownloadDriver,
|
|
92
|
+
private readonly logger: MiLogger,
|
|
89
93
|
private readonly blobContentCache: LRUCache<string, Uint8Array>,
|
|
90
|
-
private readonly columns: InternalPFrameData
|
|
94
|
+
private readonly columns: InternalPFrameData,
|
|
91
95
|
) {
|
|
92
96
|
// pframe initialization
|
|
97
|
+
this.pFrame = new PFrame(
|
|
98
|
+
(level: 'info' | 'warn' | 'error', message: string) => {
|
|
99
|
+
switch (level) {
|
|
100
|
+
default:
|
|
101
|
+
case 'info':
|
|
102
|
+
return this.logger.info(message);
|
|
103
|
+
case 'warn':
|
|
104
|
+
return this.logger.warn(message);
|
|
105
|
+
case 'error':
|
|
106
|
+
return this.logger.error(message);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
);
|
|
93
110
|
this.pFrame.setDataSource(this);
|
|
94
111
|
for (const column of columns) {
|
|
95
112
|
for (const blob of allBlobs(column.data)) this.blobIdToResource.set(blobKey(blob), blob);
|
|
@@ -97,9 +114,9 @@ class PFrameHolder implements PFrameInternal.PFrameDataSource, Disposable {
|
|
|
97
114
|
try {
|
|
98
115
|
this.pFrame.addColumnSpec(column.id, column.spec);
|
|
99
116
|
this.pFrame.setColumnData(column.id, dataInfo);
|
|
100
|
-
} catch (err) {
|
|
117
|
+
} catch (err: unknown) {
|
|
101
118
|
throw new Error(
|
|
102
|
-
`Adding column ${column.id} to PFrame failed: ${err}; Spec: ${column.spec}, DataInfo: ${dataInfo}
|
|
119
|
+
`Adding column ${column.id} to PFrame failed: ${err as Error}; Spec: ${JSON.stringify(column.spec)}, DataInfo: ${JSON.stringify(dataInfo)}.`,
|
|
103
120
|
);
|
|
104
121
|
}
|
|
105
122
|
}
|
|
@@ -162,56 +179,63 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
162
179
|
|
|
163
180
|
constructor(
|
|
164
181
|
private readonly blobDriver: DownloadDriver,
|
|
165
|
-
private readonly logger: MiLogger
|
|
182
|
+
private readonly logger: MiLogger,
|
|
166
183
|
) {
|
|
167
184
|
const blobContentCache = new LRUCache<string, Uint8Array>({
|
|
168
185
|
maxSize: 1_000_000_000, // 1Gb
|
|
169
186
|
fetchMethod: async (key) => await fsp.readFile(key),
|
|
170
|
-
sizeCalculation: (v) => v.length
|
|
187
|
+
sizeCalculation: (v) => v.length,
|
|
171
188
|
});
|
|
172
189
|
const concurrencyLimiter = new ConcurrencyLimitingExecutor(1);
|
|
173
190
|
this.blobContentCache = blobContentCache;
|
|
174
191
|
this.concurrencyLimiter = concurrencyLimiter;
|
|
175
192
|
|
|
176
193
|
this.pFrames = new (class extends RefCountResourcePool<InternalPFrameData, PFrameHolder> {
|
|
177
|
-
constructor(
|
|
194
|
+
constructor(
|
|
195
|
+
private readonly blobDriver: DownloadDriver,
|
|
196
|
+
private readonly logger: MiLogger,
|
|
197
|
+
) {
|
|
178
198
|
super();
|
|
179
199
|
}
|
|
200
|
+
|
|
180
201
|
protected createNewResource(params: InternalPFrameData): PFrameHolder {
|
|
181
202
|
if (getDebugFlags().logPFrameRequests)
|
|
182
203
|
logger.info(
|
|
183
|
-
`PFrame creation (pFrameHandle = ${this.calculateParamsKey(params)}): ${JSON.stringify(params, bigintReplacer)}
|
|
204
|
+
`PFrame creation (pFrameHandle = ${this.calculateParamsKey(params)}): ${JSON.stringify(params, bigintReplacer)}`,
|
|
184
205
|
);
|
|
185
|
-
return new PFrameHolder(this.blobDriver, blobContentCache, params);
|
|
206
|
+
return new PFrameHolder(this.blobDriver, this.logger, blobContentCache, params);
|
|
186
207
|
}
|
|
208
|
+
|
|
187
209
|
protected calculateParamsKey(params: InternalPFrameData): string {
|
|
188
210
|
return stableKeyFromPFrameData(params);
|
|
189
211
|
}
|
|
190
|
-
})(this.blobDriver);
|
|
212
|
+
})(this.blobDriver, this.logger);
|
|
191
213
|
|
|
192
214
|
this.pTables = new (class extends RefCountResourcePool<
|
|
193
215
|
FullPTableDef,
|
|
194
216
|
Promise<PFrameInternal.PTableV2>
|
|
195
217
|
> {
|
|
196
218
|
constructor(
|
|
197
|
-
private readonly pFrames: RefCountResourcePool<InternalPFrameData, PFrameHolder
|
|
219
|
+
private readonly pFrames: RefCountResourcePool<InternalPFrameData, PFrameHolder>,
|
|
198
220
|
) {
|
|
199
221
|
super();
|
|
200
222
|
}
|
|
223
|
+
|
|
201
224
|
protected async createNewResource(params: FullPTableDef): Promise<PFrameInternal.PTableV2> {
|
|
202
225
|
const pFrame = this.pFrames.getByKey(params.pFrameHandle);
|
|
203
226
|
const rawPTable = await concurrencyLimiter.run(async () => {
|
|
204
227
|
if (getDebugFlags().logPFrameRequests)
|
|
205
228
|
logger.info(
|
|
206
|
-
`PTable creation (pTableHandle = ${this.calculateParamsKey(params)}): ${JSON.stringify(params, bigintReplacer)}
|
|
229
|
+
`PTable creation (pTableHandle = ${this.calculateParamsKey(params)}): ${JSON.stringify(params, bigintReplacer)}`,
|
|
207
230
|
);
|
|
208
231
|
return await pFrame.pFrame.createTable({
|
|
209
232
|
src: joinEntryToInternal(params.def.src),
|
|
210
|
-
filters: migrateFilters(params.def.filters)
|
|
233
|
+
filters: migrateFilters(params.def.filters),
|
|
211
234
|
});
|
|
212
235
|
});
|
|
213
236
|
return params.def.sorting.length !== 0 ? rawPTable.sort(params.def.sorting) : rawPTable;
|
|
214
237
|
}
|
|
238
|
+
|
|
215
239
|
protected calculateParamsKey(params: FullPTableDef): string {
|
|
216
240
|
return stableKeyFromFullPTableDef(params);
|
|
217
241
|
}
|
|
@@ -224,14 +248,14 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
224
248
|
|
|
225
249
|
public createPFrame(
|
|
226
250
|
def: PFrameDef<PlTreeNodeAccessor | PColumnValues>,
|
|
227
|
-
ctx: ComputableCtx
|
|
251
|
+
ctx: ComputableCtx,
|
|
228
252
|
): PFrameHandle {
|
|
229
253
|
const internalData = def
|
|
230
254
|
.filter((c) => valueTypes.find((t) => t === c.spec.valueType))
|
|
231
255
|
.map((c) =>
|
|
232
256
|
mapPObjectData(c, (d) =>
|
|
233
|
-
isPlTreeNodeAccessor(d) ? parseDataInfoResource(d) : makeDataInfoResource(c.spec, d)
|
|
234
|
-
)
|
|
257
|
+
isPlTreeNodeAccessor(d) ? parseDataInfoResource(d) : makeDataInfoResource(c.spec, d),
|
|
258
|
+
),
|
|
235
259
|
);
|
|
236
260
|
const res = this.pFrames.acquire(internalData);
|
|
237
261
|
ctx.addOnDestroy(res.unref);
|
|
@@ -240,17 +264,17 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
240
264
|
|
|
241
265
|
public createPTable(
|
|
242
266
|
def: PTableDef<PColumn<PlTreeNodeAccessor | PColumnValues>>,
|
|
243
|
-
ctx: ComputableCtx
|
|
267
|
+
ctx: ComputableCtx,
|
|
244
268
|
): PTableHandle {
|
|
245
269
|
const pFrameHandle = this.createPFrame(extractAllColumns(def.src), ctx);
|
|
246
270
|
const defIds = mapPTableDef(def, (c) => c.id);
|
|
247
271
|
const res = this.pTables.acquire({ def: defIds, pFrameHandle });
|
|
248
272
|
if (getDebugFlags().logPFrameRequests)
|
|
249
273
|
this.logger.info(
|
|
250
|
-
`Create PTable call (pFrameHandle = ${pFrameHandle}; pTableHandle = ${res}): ${JSON.stringify(
|
|
274
|
+
`Create PTable call (pFrameHandle = ${pFrameHandle}; pTableHandle = ${JSON.stringify(res)}): ${JSON.stringify(
|
|
251
275
|
mapPTableDef(def, (c) => c.spec),
|
|
252
|
-
bigintReplacer
|
|
253
|
-
)}
|
|
276
|
+
bigintReplacer,
|
|
277
|
+
)}`,
|
|
254
278
|
);
|
|
255
279
|
ctx.addOnDestroy(res.unref); // in addition to pframe unref added in createPFrame above
|
|
256
280
|
return res.key as PTableHandle;
|
|
@@ -262,54 +286,54 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
262
286
|
|
|
263
287
|
public async findColumns(
|
|
264
288
|
handle: PFrameHandle,
|
|
265
|
-
request: FindColumnsRequest
|
|
289
|
+
request: FindColumnsRequest,
|
|
266
290
|
): Promise<FindColumnsResponse> {
|
|
267
291
|
const iRequest: PFrameInternal.FindColumnsRequest = {
|
|
268
292
|
...request,
|
|
269
293
|
compatibleWith:
|
|
270
294
|
request.compatibleWith.length !== 0
|
|
271
295
|
? [{ axesSpec: request.compatibleWith, qualifications: [] }]
|
|
272
|
-
: []
|
|
296
|
+
: [],
|
|
273
297
|
};
|
|
274
298
|
return {
|
|
275
299
|
hits: (
|
|
276
300
|
await this.concurrencyLimiter.run(
|
|
277
|
-
async () => await this.pFrames.getByKey(handle).pFrame.findColumns(iRequest)
|
|
301
|
+
async () => await this.pFrames.getByKey(handle).pFrame.findColumns(iRequest),
|
|
278
302
|
)
|
|
279
|
-
).hits.map((h) => h.hit)
|
|
303
|
+
).hits.map((h) => h.hit),
|
|
280
304
|
};
|
|
281
305
|
}
|
|
282
306
|
|
|
283
307
|
public async getColumnSpec(handle: PFrameHandle, columnId: PObjectId): Promise<PColumnSpec> {
|
|
284
308
|
return await this.concurrencyLimiter.run(
|
|
285
|
-
async () => await this.pFrames.getByKey(handle).pFrame.getColumnSpec(columnId)
|
|
309
|
+
async () => await this.pFrames.getByKey(handle).pFrame.getColumnSpec(columnId),
|
|
286
310
|
);
|
|
287
311
|
}
|
|
288
312
|
|
|
289
313
|
public async listColumns(handle: PFrameHandle): Promise<PColumnIdAndSpec[]> {
|
|
290
314
|
return await this.concurrencyLimiter.run(
|
|
291
|
-
async () => await this.pFrames.getByKey(handle).pFrame.listColumns()
|
|
315
|
+
async () => await this.pFrames.getByKey(handle).pFrame.listColumns(),
|
|
292
316
|
);
|
|
293
317
|
}
|
|
294
318
|
|
|
295
319
|
public async calculateTableData(
|
|
296
320
|
handle: PFrameHandle,
|
|
297
|
-
request: CalculateTableDataRequest<PObjectId
|
|
321
|
+
request: CalculateTableDataRequest<PObjectId>,
|
|
298
322
|
): Promise<CalculateTableDataResponse> {
|
|
299
323
|
let table = await this.concurrencyLimiter.run(async () => {
|
|
300
324
|
if (getDebugFlags().logPFrameRequests)
|
|
301
325
|
this.logger.info(
|
|
302
|
-
`Call calculateTableData, handle = ${handle}, request = ${JSON.stringify(request, bigintReplacer)}
|
|
326
|
+
`Call calculateTableData, handle = ${handle}, request = ${JSON.stringify(request, bigintReplacer)}`,
|
|
303
327
|
);
|
|
304
328
|
return await this.pFrames.getByKey(handle).pFrame.createTable({
|
|
305
329
|
src: joinEntryToInternal(request.src),
|
|
306
|
-
filters: migrateFilters(request.filters)
|
|
330
|
+
filters: migrateFilters(request.filters),
|
|
307
331
|
});
|
|
308
332
|
});
|
|
309
333
|
|
|
310
334
|
if (request.sorting.length > 0) {
|
|
311
335
|
const sortedTable = await this.concurrencyLimiter.run(
|
|
312
|
-
async () => await table.sort(request.sorting)
|
|
336
|
+
async () => await table.sort(request.sorting),
|
|
313
337
|
);
|
|
314
338
|
table.dispose();
|
|
315
339
|
table = sortedTable;
|
|
@@ -317,28 +341,28 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
317
341
|
|
|
318
342
|
const spec = table.getSpec();
|
|
319
343
|
const data = await this.concurrencyLimiter.run(
|
|
320
|
-
async () => await table.getData([...spec.keys()])
|
|
344
|
+
async () => await table.getData([...spec.keys()]),
|
|
321
345
|
);
|
|
322
346
|
table.dispose();
|
|
323
347
|
|
|
324
348
|
return spec.map((spec, i) => ({
|
|
325
349
|
spec: spec,
|
|
326
|
-
data: data[i]
|
|
350
|
+
data: data[i],
|
|
327
351
|
}));
|
|
328
352
|
}
|
|
329
353
|
|
|
330
354
|
public async getUniqueValues(
|
|
331
355
|
handle: PFrameHandle,
|
|
332
|
-
request: UniqueValuesRequest
|
|
356
|
+
request: UniqueValuesRequest,
|
|
333
357
|
): Promise<UniqueValuesResponse> {
|
|
334
358
|
return await this.concurrencyLimiter.run(async () => {
|
|
335
359
|
if (getDebugFlags().logPFrameRequests)
|
|
336
360
|
this.logger.info(
|
|
337
|
-
`Call getUniqueValues, handle = ${handle}, request = ${JSON.stringify(request, bigintReplacer)}
|
|
361
|
+
`Call getUniqueValues, handle = ${handle}, request = ${JSON.stringify(request, bigintReplacer)}`,
|
|
338
362
|
);
|
|
339
363
|
return await this.pFrames.getByKey(handle).pFrame.getUniqueValues({
|
|
340
364
|
...request,
|
|
341
|
-
filters: migrateFilters(request.filters)
|
|
365
|
+
filters: migrateFilters(request.filters),
|
|
342
366
|
});
|
|
343
367
|
});
|
|
344
368
|
}
|
|
@@ -360,11 +384,11 @@ export class PFrameDriver implements SdkPFrameDriver {
|
|
|
360
384
|
public async getData(
|
|
361
385
|
handle: PTableHandle,
|
|
362
386
|
columnIndices: number[],
|
|
363
|
-
range?: TableRange
|
|
387
|
+
range?: TableRange,
|
|
364
388
|
): Promise<PTableVector[]> {
|
|
365
389
|
const pTable = await this.pTables.getByKey(handle); // internally concurrency limited
|
|
366
390
|
return await this.concurrencyLimiter.run(
|
|
367
|
-
async () => await pTable.getData(columnIndices, range)
|
|
391
|
+
async () => await pTable.getData(columnIndices, range),
|
|
368
392
|
);
|
|
369
393
|
}
|
|
370
394
|
}
|
|
@@ -375,19 +399,19 @@ function joinEntryToInternal(entry: JoinEntry<PObjectId>): PFrameInternal.JoinEn
|
|
|
375
399
|
return {
|
|
376
400
|
type: 'column',
|
|
377
401
|
columnId: entry.column,
|
|
378
|
-
qualifications: []
|
|
402
|
+
qualifications: [],
|
|
379
403
|
};
|
|
380
404
|
case 'inner':
|
|
381
405
|
case 'full':
|
|
382
406
|
return {
|
|
383
407
|
type: entry.type,
|
|
384
|
-
entries: entry.entries.map((col) => joinEntryToInternal(col))
|
|
408
|
+
entries: entry.entries.map((col) => joinEntryToInternal(col)),
|
|
385
409
|
};
|
|
386
410
|
case 'outer':
|
|
387
411
|
return {
|
|
388
412
|
type: 'outer',
|
|
389
413
|
primary: joinEntryToInternal(entry.primary),
|
|
390
|
-
secondary: entry.secondary.map((col) => joinEntryToInternal(col))
|
|
414
|
+
secondary: entry.secondary.map((col) => joinEntryToInternal(col)),
|
|
391
415
|
};
|
|
392
416
|
default:
|
|
393
417
|
assertNever(entry);
|
|
@@ -419,8 +443,8 @@ function stableKeyFromPFrameData(data: PColumn<PFrameInternal.DataInfo<ResourceI
|
|
|
419
443
|
keyLength: r.keyLength,
|
|
420
444
|
payload: Object.entries(r.data).map(([part, value]) => ({
|
|
421
445
|
key: part,
|
|
422
|
-
value
|
|
423
|
-
}))
|
|
446
|
+
value,
|
|
447
|
+
})),
|
|
424
448
|
};
|
|
425
449
|
break;
|
|
426
450
|
case 'JsonPartitioned':
|
|
@@ -429,8 +453,8 @@ function stableKeyFromPFrameData(data: PColumn<PFrameInternal.DataInfo<ResourceI
|
|
|
429
453
|
keyLength: r.partitionKeyLength,
|
|
430
454
|
payload: Object.entries(r.parts).map(([part, info]) => ({
|
|
431
455
|
key: part,
|
|
432
|
-
value: info.id.toString()
|
|
433
|
-
}))
|
|
456
|
+
value: info.id.toString(),
|
|
457
|
+
})),
|
|
434
458
|
};
|
|
435
459
|
break;
|
|
436
460
|
case 'BinaryPartitioned':
|
|
@@ -439,16 +463,17 @@ function stableKeyFromPFrameData(data: PColumn<PFrameInternal.DataInfo<ResourceI
|
|
|
439
463
|
keyLength: r.partitionKeyLength,
|
|
440
464
|
payload: Object.entries(r.parts).map(([part, info]) => ({
|
|
441
465
|
key: part,
|
|
442
|
-
value: [info.index.id.toString(), info.values.id.toString()] as const
|
|
443
|
-
}))
|
|
466
|
+
value: [info.index.id.toString(), info.values.id.toString()] as const,
|
|
467
|
+
})),
|
|
444
468
|
};
|
|
445
469
|
break;
|
|
446
470
|
default:
|
|
471
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
447
472
|
throw Error(`unsupported resource type: ${type satisfies never}`);
|
|
448
473
|
}
|
|
449
474
|
result.payload.sort((lhs, rhs) => lhs.key.localeCompare(rhs.key));
|
|
450
475
|
return result;
|
|
451
|
-
})
|
|
476
|
+
}),
|
|
452
477
|
);
|
|
453
478
|
orderedData.sort((lhs, rhs) => lhs.id.localeCompare(rhs.id));
|
|
454
479
|
|