@milaboratories/pl-model-middle-layer 1.8.12 → 1.8.14
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/pframe/internal_api/api_factory.d.ts +18 -0
- package/dist/pframe/internal_api/api_factory.d.ts.map +1 -1
- package/dist/pframe/internal_api/api_read.d.ts +28 -1
- package/dist/pframe/internal_api/api_read.d.ts.map +1 -1
- package/dist/pframe/internal_api/common.d.ts +1 -0
- package/dist/pframe/internal_api/common.d.ts.map +1 -1
- package/dist/pframe/internal_api/http_helpers.d.ts +79 -52
- package/dist/pframe/internal_api/http_helpers.d.ts.map +1 -1
- package/dist/pframe/internal_api/pframe.d.ts +27 -3
- package/dist/pframe/internal_api/pframe.d.ts.map +1 -1
- package/dist/pframe/internal_api/table.d.ts +54 -0
- package/dist/pframe/internal_api/table.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/pframe/internal_api/api_factory.ts +26 -0
- package/src/pframe/internal_api/api_read.ts +37 -1
- package/src/pframe/internal_api/common.ts +6 -1
- package/src/pframe/internal_api/http_helpers.ts +105 -64
- package/src/pframe/internal_api/pframe.ts +30 -7
- package/src/pframe/internal_api/table.ts +65 -0
|
@@ -37,4 +37,22 @@ export interface PFrameFactoryAPIV2 {
|
|
|
37
37
|
* any interactions with disposed PFrame will result in exception */
|
|
38
38
|
dispose(): void;
|
|
39
39
|
}
|
|
40
|
+
/** API exposed by PFrames library allowing to create and provide data for
|
|
41
|
+
* PFrame objects */
|
|
42
|
+
export interface PFrameFactoryAPIV3 extends Disposable {
|
|
43
|
+
/** Associates data source with this PFrame */
|
|
44
|
+
setDataSource(dataSource: PFrameDataSource): void;
|
|
45
|
+
/** Adds PColumn without data info */
|
|
46
|
+
addColumnSpec(columnId: PObjectId, columnSpec: PColumnSpec): void;
|
|
47
|
+
/**
|
|
48
|
+
* Assign data info to the specified PColumn.
|
|
49
|
+
* For parquet data info, schema resolution via network is performed during this call.
|
|
50
|
+
*/
|
|
51
|
+
setColumnData(columnId: PObjectId, dataInfo: DataInfo<PFrameBlobId>, options?: {
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
/** Releases all the data previously added to PFrame using methods above,
|
|
55
|
+
* any interactions with disposed PFrame will result in exception */
|
|
56
|
+
dispose(): void;
|
|
57
|
+
}
|
|
40
58
|
//# sourceMappingURL=api_factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_factory.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/api_factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,0BAA0B,EAC1B,WAAW,EACX,SAAS,EACV,MAAM,iCAAiC,CAAC;AAEzC,wFAAwF;AACxF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAGlC;+EAC+E;AAC/E,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,gGAAgG;AAChG,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD,qEAAqE;IACrE,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,IAAI,IACrB,YAAY,GACZ,uBAAuB,CAAC,IAAI,CAAC,GAC7B,yBAAyB,CAAC,IAAI,CAAC,GAC/B,0BAA0B,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAEnD;oBACoB;AACpB,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAElD,gCAAgC;IAChC,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,UA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AAE,WAAW,GAAG,IAAI,CAAC;IAElE,gDAAgD;IAChD,aAAa,CACX,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,EAChC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GACA,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;wEACoE;IACpE,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;oBACoB;AACpB,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,8CAA8C;IAC9C,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAElD,qCAAqC;IACrC,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAElE;;;OAGG;IACH,aAAa,CACX,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,EAChC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GACA,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;wEACoE;IACpE,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -2,7 +2,7 @@ import { FindColumnsRequest, FindColumnsResponse } from './find_columns';
|
|
|
2
2
|
import { DeleteColumnFromColumnsRequest, DeleteColumnFromColumnsResponse } from './delete_column';
|
|
3
3
|
import { PColumnInfo, PColumnSpec, PObjectId, UniqueValuesRequest, UniqueValuesResponse } from '@milaboratories/pl-model-common';
|
|
4
4
|
import { CreateTableRequestV3 } from './create_table';
|
|
5
|
-
import { PTableV6 } from './table';
|
|
5
|
+
import { PTableV6, PTableV7 } from './table';
|
|
6
6
|
/** Read interface exposed by PFrames library */
|
|
7
7
|
export interface PFrameReadAPIV8 {
|
|
8
8
|
/**
|
|
@@ -27,4 +27,31 @@ export interface PFrameReadAPIV8 {
|
|
|
27
27
|
signal?: AbortSignal;
|
|
28
28
|
}): Promise<UniqueValuesResponse>;
|
|
29
29
|
}
|
|
30
|
+
/** Read interface exposed by PFrames library */
|
|
31
|
+
export interface PFrameReadAPIV9 {
|
|
32
|
+
/**
|
|
33
|
+
* Finds columns given filtering criteria on column name, annotations etc.
|
|
34
|
+
* and a set of qualified axes specs to find only columns with compatible
|
|
35
|
+
* axes spec.
|
|
36
|
+
*
|
|
37
|
+
* Only column specs are used, this method will work even for columns
|
|
38
|
+
* with no assigned data.
|
|
39
|
+
* */
|
|
40
|
+
findColumns(request: FindColumnsRequest): Promise<FindColumnsResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Construct new axes integration with some entry removed but integration qualificaitons preserved.
|
|
43
|
+
* Removes more then one entry in case the removal will create several disjoint sets of axes.
|
|
44
|
+
*/
|
|
45
|
+
deleteColumn(request: DeleteColumnFromColumnsRequest): Promise<DeleteColumnFromColumnsResponse>;
|
|
46
|
+
/** Retrieve single column spec */
|
|
47
|
+
getColumnSpec(columnId: PObjectId): Promise<PColumnSpec>;
|
|
48
|
+
/** Retrieve information about all columns currently added to the PFrame */
|
|
49
|
+
listColumns(): Promise<PColumnInfo[]>;
|
|
50
|
+
/** Calculates data for the table and returns an object to access it */
|
|
51
|
+
createTable(request: CreateTableRequestV3): PTableV7;
|
|
52
|
+
/** Calculate set of unique values for a specific axis for the filtered set of records */
|
|
53
|
+
getUniqueValues(request: UniqueValuesRequest, ops?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<UniqueValuesResponse>;
|
|
56
|
+
}
|
|
30
57
|
//# sourceMappingURL=api_read.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_read.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/api_read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAClG,O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oBAAoB,CAAC,CAAC;CAClC;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B;;;;;;;SAOK;IACL,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEvE;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAEhG,kCAAkC;IAClC,aAAa,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzD,2EAA2E;IAC3E,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEtC,uEAAuE;IACvE,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,QAAQ,CAAC;IAErD,yFAAyF;IACzF,eAAe,CACb,OAAO,EAAE,mBAAmB,EAC5B,GAAG,CAAC,EAAE;QACJ,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GACA,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/common.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,MAAM,MAAM,GAAG,CACnB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAChC,OAAO,EAAE,MAAM,KACZ,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,kBAAkB,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,cAAc,EAAE,iBAAiB,EAAE,CAAC;CACrC;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,CAAA"}
|
|
@@ -1,70 +1,97 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
2
|
import type { RequestListener } from 'node:http';
|
|
3
3
|
import type { Branded, Base64Encoded } from '@milaboratories/pl-model-common';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type { Logger } from './common';
|
|
5
|
+
/** Parquet file name */
|
|
6
|
+
export type ParquetFileName = Branded<`${string}.parquet`, 'PFrameInternal.ParquetFileName'>;
|
|
7
|
+
/** HTTP range as of RFC 9110 <https://datatracker.ietf.org/doc/html/rfc9110#name-range> */
|
|
8
|
+
export type HttpRange = {
|
|
9
|
+
/**
|
|
10
|
+
* Get file content in the specified byte range
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```
|
|
14
|
+
* GET /file.parquet HTTP/1.1
|
|
15
|
+
* Range: bytes=0-1023
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
type: 'bounded';
|
|
6
19
|
/** Start byte position (inclusive) */
|
|
7
20
|
start: number;
|
|
8
21
|
/** End byte position (inclusive) */
|
|
9
22
|
end: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* File system abstraction for request handler factory,
|
|
13
|
-
* @see HttpHelpers.createRequestHandler.
|
|
14
|
-
* Assumes that it is working with flat directory structure.
|
|
15
|
-
* Accepts filenames with extension as input (e.g. `file.parquet`).
|
|
16
|
-
*/
|
|
17
|
-
export interface ObjectStore {
|
|
23
|
+
} | {
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @throws if file can become accessible after retry (e.g. on network error)
|
|
25
|
+
* Get byte range starting from the specified offset
|
|
21
26
|
*
|
|
22
27
|
* @example
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* return await fs
|
|
27
|
-
* .stat(filePath)
|
|
28
|
-
* .then((stat) => ({ size: stat.isFile() ? stat.size : -1 }))
|
|
29
|
-
* .catch(() => ({ size: -1 }));
|
|
30
|
-
* }
|
|
28
|
+
* ```
|
|
29
|
+
* GET /file.parquet HTTP/1.1
|
|
30
|
+
* Range: bytes=1024-
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
type: 'offset';
|
|
34
|
+
/** Start byte position (inclusive) */
|
|
35
|
+
offset: number;
|
|
36
|
+
} | {
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
36
|
-
* Action resolves when stream is closed by handler @see HttpHelpers.createRequestHandler
|
|
37
|
-
*
|
|
38
|
-
* @param filename - existing file name (for which @see ObjectStore.getFileSize returned non-negative value)
|
|
39
|
-
* @param range - valid range of bytes to read from the file (store may skip validation)
|
|
40
|
-
* @param action - function to execute with the stream, responsible for closing the stream
|
|
41
|
-
* @returns promise that resolves after the action is completed
|
|
38
|
+
* Get byte range starting from the specified suffix
|
|
42
39
|
*
|
|
43
40
|
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* async withReadStream(params: {
|
|
46
|
-
* filename: string;
|
|
47
|
-
* range: FileRange;
|
|
48
|
-
* action: (stream: Readable) => Promise<void>;
|
|
49
|
-
* }): Promise<void> {
|
|
50
|
-
* const { filename, range, action } = params;
|
|
51
|
-
* const filePath = this.resolve(filename);
|
|
52
|
-
*
|
|
53
|
-
* try {
|
|
54
|
-
* const stream = createReadStream(filePath, range);
|
|
55
|
-
* return await action(stream);
|
|
56
|
-
* } catch (err: unknown) {
|
|
57
|
-
* console.error(`failed to create read stream for ${filename} - ${ensureError(err)}`);
|
|
58
|
-
* throw;
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
41
|
* ```
|
|
42
|
+
* GET /file.parquet HTTP/1.1
|
|
43
|
+
* Range: bytes=-1024
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
type: 'suffix';
|
|
47
|
+
/** End byte position (inclusive) */
|
|
48
|
+
suffix: number;
|
|
49
|
+
};
|
|
50
|
+
/** HTTP method passed to object store */
|
|
51
|
+
export type HttpMethod = 'GET' | 'HEAD';
|
|
52
|
+
/** HTTP response from object store */
|
|
53
|
+
export type ObjectStoreResponse<Method extends HttpMethod = HttpMethod> = {
|
|
54
|
+
/** Will be translated to 500 Internal Server Error by the handler */
|
|
55
|
+
type: 'InternalError';
|
|
56
|
+
} | {
|
|
57
|
+
/** Will be translated to 404 Not Found by the handler */
|
|
58
|
+
type: 'NotFound';
|
|
59
|
+
} | {
|
|
60
|
+
/** Will be translated to 416 Range Not Satisfiable by the handler */
|
|
61
|
+
type: 'RangeNotSatisfiable';
|
|
62
|
+
/** Total file size in bytes */
|
|
63
|
+
size: number;
|
|
64
|
+
} | {
|
|
65
|
+
/** Will be translated to 200 OK or 206 Partial Content by the handler */
|
|
66
|
+
type: 'Ok';
|
|
67
|
+
/** Total file size in bytes */
|
|
68
|
+
size: number;
|
|
69
|
+
/** Stream of file content, undefined for HEAD requests */
|
|
70
|
+
data: Method extends 'HEAD' ? undefined : Readable;
|
|
71
|
+
};
|
|
72
|
+
/** Common options for object store creation */
|
|
73
|
+
export interface ObjectStoreOptions {
|
|
74
|
+
/** Logger instance, no logging is performed when not provided */
|
|
75
|
+
logger?: Logger;
|
|
76
|
+
}
|
|
77
|
+
/** Options for file system object store creation */
|
|
78
|
+
export interface FsStoreOptions extends ObjectStoreOptions {
|
|
79
|
+
/** Local directory to serve files from */
|
|
80
|
+
rootDir: string;
|
|
81
|
+
}
|
|
82
|
+
/** File system abstraction for request handler factory, @see HttpHelpers.createRequestHandler */
|
|
83
|
+
export interface ObjectStore {
|
|
84
|
+
/**
|
|
85
|
+
* Proxy HTTP(S) request for parquet file to object store.
|
|
86
|
+
* Callback promise resolves when stream is closed by handler @see HttpHelpers.createRequestHandler
|
|
87
|
+
* Callback API is used so that ObjectStore can limit the number of concurrent requests.
|
|
62
88
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
range
|
|
66
|
-
|
|
67
|
-
|
|
89
|
+
request<Method extends HttpMethod>(filename: ParquetFileName, params: {
|
|
90
|
+
method: Method;
|
|
91
|
+
range?: HttpRange;
|
|
92
|
+
signal?: AbortSignal;
|
|
93
|
+
callback: (response: ObjectStoreResponse<Method>) => Promise<void>;
|
|
94
|
+
}): void;
|
|
68
95
|
}
|
|
69
96
|
/** Object store base URL in format accepted by Apache DataFusion and DuckDB */
|
|
70
97
|
export type ObjectStoreUrl = Branded<string, 'PFrameInternal.ObjectStoreUrl'>;
|
|
@@ -125,7 +152,7 @@ export interface HttpHelpers {
|
|
|
125
152
|
* Create an object store for serving files from a local directory.
|
|
126
153
|
* Rejects if the provided path does not exist or is not a directory.
|
|
127
154
|
*/
|
|
128
|
-
createFsStore(
|
|
155
|
+
createFsStore(options: FsStoreOptions): Promise<ObjectStore>;
|
|
129
156
|
/**
|
|
130
157
|
* Create an HTTP request handler for serving files from an object store.
|
|
131
158
|
* Accepts only paths of the form `/<filename>.parquet`, returns 410 otherwise.
|
|
@@ -140,7 +167,7 @@ export interface HttpHelpers {
|
|
|
140
167
|
* ```ts
|
|
141
168
|
* const rootDir = '/path/to/directory/with/parquet/files';
|
|
142
169
|
*
|
|
143
|
-
* let store = await HttpHelpers.createFsStore(rootDir).catch((err: unknown) => {
|
|
170
|
+
* let store = await HttpHelpers.createFsStore({ rootDir }).catch((err: unknown) => {
|
|
144
171
|
* throw new Error(`Failed to create file store for ${rootDir} - ${ensureError(err)}`);
|
|
145
172
|
* });
|
|
146
173
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_helpers.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/http_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"http_helpers.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/http_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAwB;AACxB,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,MAAM,UAAU,EAAE,gCAAgC,CAAC,CAAC;AAE7F,2FAA2F;AAC3F,MAAM,MAAM,SAAS,GACjB;IACE;;;;;;;;OAQG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE;;;;;;;;OAQG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE;;;;;;;;OAQG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAExC,sCAAsC;AACtC,MAAM,MAAM,mBAAmB,CAAC,M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1
|
+
import type { PFrameFactoryAPIV2, PFrameFactoryAPIV3 } from './api_factory';
|
|
2
|
+
import type { PFrameReadAPIV8, PFrameReadAPIV9 } from './api_read';
|
|
3
|
+
import type { Logger } from './common';
|
|
4
4
|
export interface PFrameV9 extends PFrameFactoryAPIV2, PFrameReadAPIV8 {
|
|
5
5
|
}
|
|
6
|
+
export interface PFrameV10 extends PFrameFactoryAPIV3, PFrameReadAPIV9 {
|
|
7
|
+
}
|
|
8
|
+
export type PFrameOptions = {
|
|
9
|
+
/** Path to directory where PFrame can create temporary files */
|
|
10
|
+
spillPath: string;
|
|
11
|
+
/** Logger instance, no logging is performed when not provided */
|
|
12
|
+
logger?: Logger;
|
|
13
|
+
};
|
|
14
|
+
/** List of PFrame management functions exposed by PFrame module */
|
|
15
|
+
export interface PFrameFactory {
|
|
16
|
+
/**
|
|
17
|
+
* Create a new PFrame instance.
|
|
18
|
+
* @warning Use concurrency limiting to avoid OOM crashes when multiple instances are simultaneously in use.
|
|
19
|
+
*/
|
|
20
|
+
createPFrame(options: PFrameOptions): PFrameV10;
|
|
21
|
+
/**
|
|
22
|
+
* Dump active allocations from all PFrames instances in pprof format.
|
|
23
|
+
* The result of this function should be saved as `profile.pb.gz`.
|
|
24
|
+
* Use {@link https://pprof.me/} or {@link https://www.speedscope.app/}
|
|
25
|
+
* to view the allocation flamechart.
|
|
26
|
+
* @warning This method will always reject on Windows!
|
|
27
|
+
*/
|
|
28
|
+
pprofDump: () => Promise<Uint8Array>;
|
|
29
|
+
}
|
|
6
30
|
//# sourceMappingURL=pframe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pframe.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/pframe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"pframe.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/pframe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,QAAS,SAAQ,kBAAkB,EAAE,eAAe;CAAG;AAExE,MAAM,WAAW,SAAU,SAAQ,kBAAkB,EAAE,eAAe;CAAG;AAEzE,MAAM,MAAM,aAAa,GAAG;IAC1B,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAA;AAED,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAC;IAEhD;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;CACtC"}
|
|
@@ -53,4 +53,58 @@ export interface PTableV6 {
|
|
|
53
53
|
/** Deallocates all underlying resources */
|
|
54
54
|
dispose(): void;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Table view returned as a result of create table operation.
|
|
58
|
+
*
|
|
59
|
+
* PTable can be thought as having a composite primary key, consisting of axes,
|
|
60
|
+
* and a set of data columns derived from PColumn values.
|
|
61
|
+
* */
|
|
62
|
+
export interface PTableV7 extends Disposable {
|
|
63
|
+
/**
|
|
64
|
+
* Returns ordered array of table axes specs (primary key "columns" in SQL
|
|
65
|
+
* terms) and data column specs (regular "columns" in SQL terms).
|
|
66
|
+
*
|
|
67
|
+
* Data for a specific table column can be retrieved using unified indexing
|
|
68
|
+
* corresponding to elements in this array.
|
|
69
|
+
*
|
|
70
|
+
* Axes are always listed first.
|
|
71
|
+
* */
|
|
72
|
+
getSpec(): PTableColumnSpec[];
|
|
73
|
+
/** Transforms unified column identifiers into unified indices of columns. */
|
|
74
|
+
getColumnIndices(columnIds: PTableColumnId[]): number[];
|
|
75
|
+
/**
|
|
76
|
+
* Get PTable disk footprint in bytes
|
|
77
|
+
* Warning: This call materializes the join.
|
|
78
|
+
*/
|
|
79
|
+
getFootprint(ops?: {
|
|
80
|
+
withPredecessors?: boolean;
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
}): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Unified table shape
|
|
85
|
+
* Warning: This call materializes the join.
|
|
86
|
+
*/
|
|
87
|
+
getShape(ops?: {
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
}): Promise<PTableShape>;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve the data from the table. To retrieve only data required, it can be
|
|
92
|
+
* sliced both horizontally ({@link columnIndices}) and vertically
|
|
93
|
+
* ({@link range}).
|
|
94
|
+
* This call materializes the join.
|
|
95
|
+
*
|
|
96
|
+
* @param columnIndices unified indices of columns to be retrieved
|
|
97
|
+
* @param range optionally limit the range of records to retrieve
|
|
98
|
+
* */
|
|
99
|
+
getData(columnIndices: number[], ops?: {
|
|
100
|
+
range?: TableRange;
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
}): Promise<PTableVector[]>;
|
|
103
|
+
/** Filters the table and returns new PTable instance */
|
|
104
|
+
filter(request: PTableRecordFilter[]): PTableV7;
|
|
105
|
+
/** Sorts the table and returns new PTable instance. */
|
|
106
|
+
sort(request: PTableSorting[]): PTableV7;
|
|
107
|
+
/** Deallocates all underlying resources */
|
|
108
|
+
dispose(): void;
|
|
109
|
+
}
|
|
56
110
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,E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AW,CAAC;KACtB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzB;;;;;;;;SAQK;IACL,OAAO,CACL,aAAa,EAAE,MAAM,EAAE,EACvB,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,UAAU,CAAC;QACnB,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GACA,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAE3B,wDAAwD;IACxD,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAAC;IAEhD,uDAAuD;IACvD,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;IAEzC,2CAA2C;IAC3C,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-middle-layer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.14",
|
|
4
4
|
"description": "Common model between middle layer and non-block UI code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"remeda": "^2.28.0",
|
|
21
21
|
"zod": "~3.23.8",
|
|
22
22
|
"utility-types": "^3.11.0",
|
|
23
|
-
"@milaboratories/pl-model-common": "
|
|
23
|
+
"@milaboratories/pl-model-common": "1.19.13"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": "~5.6.3",
|
|
27
|
-
"@milaboratories/ts-builder": "1.0.5",
|
|
28
27
|
"@milaboratories/ts-configs": "1.0.6",
|
|
28
|
+
"@milaboratories/ts-builder": "1.0.5",
|
|
29
29
|
"@milaboratories/build-configs": "1.0.8"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
@@ -63,3 +63,29 @@ export interface PFrameFactoryAPIV2 {
|
|
|
63
63
|
* any interactions with disposed PFrame will result in exception */
|
|
64
64
|
dispose(): void;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
/** API exposed by PFrames library allowing to create and provide data for
|
|
68
|
+
* PFrame objects */
|
|
69
|
+
export interface PFrameFactoryAPIV3 extends Disposable {
|
|
70
|
+
/** Associates data source with this PFrame */
|
|
71
|
+
setDataSource(dataSource: PFrameDataSource): void;
|
|
72
|
+
|
|
73
|
+
/** Adds PColumn without data info */
|
|
74
|
+
addColumnSpec(columnId: PObjectId, columnSpec: PColumnSpec): void;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Assign data info to the specified PColumn.
|
|
78
|
+
* For parquet data info, schema resolution via network is performed during this call.
|
|
79
|
+
*/
|
|
80
|
+
setColumnData(
|
|
81
|
+
columnId: PObjectId,
|
|
82
|
+
dataInfo: DataInfo<PFrameBlobId>,
|
|
83
|
+
options?: {
|
|
84
|
+
signal?: AbortSignal,
|
|
85
|
+
}
|
|
86
|
+
): Promise<void>;
|
|
87
|
+
|
|
88
|
+
/** Releases all the data previously added to PFrame using methods above,
|
|
89
|
+
* any interactions with disposed PFrame will result in exception */
|
|
90
|
+
dispose(): void;
|
|
91
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
UniqueValuesResponse
|
|
9
9
|
} from '@milaboratories/pl-model-common';
|
|
10
10
|
import { CreateTableRequestV3 } from './create_table';
|
|
11
|
-
import { PTableV6 } from './table';
|
|
11
|
+
import { PTableV6, PTableV7 } from './table';
|
|
12
12
|
|
|
13
13
|
/** Read interface exposed by PFrames library */
|
|
14
14
|
export interface PFrameReadAPIV8 {
|
|
@@ -42,3 +42,39 @@ export interface PFrameReadAPIV8 {
|
|
|
42
42
|
}
|
|
43
43
|
): Promise<UniqueValuesResponse>;
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
/** Read interface exposed by PFrames library */
|
|
47
|
+
export interface PFrameReadAPIV9 {
|
|
48
|
+
/**
|
|
49
|
+
* Finds columns given filtering criteria on column name, annotations etc.
|
|
50
|
+
* and a set of qualified axes specs to find only columns with compatible
|
|
51
|
+
* axes spec.
|
|
52
|
+
*
|
|
53
|
+
* Only column specs are used, this method will work even for columns
|
|
54
|
+
* with no assigned data.
|
|
55
|
+
* */
|
|
56
|
+
findColumns(request: FindColumnsRequest): Promise<FindColumnsResponse>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Construct new axes integration with some entry removed but integration qualificaitons preserved.
|
|
60
|
+
* Removes more then one entry in case the removal will create several disjoint sets of axes.
|
|
61
|
+
*/
|
|
62
|
+
deleteColumn(request: DeleteColumnFromColumnsRequest): Promise<DeleteColumnFromColumnsResponse>;
|
|
63
|
+
|
|
64
|
+
/** Retrieve single column spec */
|
|
65
|
+
getColumnSpec(columnId: PObjectId): Promise<PColumnSpec>;
|
|
66
|
+
|
|
67
|
+
/** Retrieve information about all columns currently added to the PFrame */
|
|
68
|
+
listColumns(): Promise<PColumnInfo[]>;
|
|
69
|
+
|
|
70
|
+
/** Calculates data for the table and returns an object to access it */
|
|
71
|
+
createTable(request: CreateTableRequestV3): PTableV7;
|
|
72
|
+
|
|
73
|
+
/** Calculate set of unique values for a specific axis for the filtered set of records */
|
|
74
|
+
getUniqueValues(
|
|
75
|
+
request: UniqueValuesRequest,
|
|
76
|
+
ops?: {
|
|
77
|
+
signal?: AbortSignal,
|
|
78
|
+
}
|
|
79
|
+
): Promise<UniqueValuesResponse>;
|
|
80
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxisSpec, ValueType } from '@milaboratories/pl-model-common';
|
|
2
|
+
|
|
3
|
+
export type Logger = (
|
|
4
|
+
level: 'info' | 'warn' | 'error',
|
|
5
|
+
message: string
|
|
6
|
+
) => void;
|
|
2
7
|
|
|
3
8
|
export interface SingleAxisSelector {
|
|
4
9
|
name: string;
|
|
@@ -1,73 +1,114 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
2
|
import type { RequestListener } from 'node:http';
|
|
3
3
|
import type { Branded, Base64Encoded } from '@milaboratories/pl-model-common';
|
|
4
|
+
import type { Logger } from './common';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
export type
|
|
7
|
-
/** Start byte position (inclusive) */
|
|
8
|
-
start: number;
|
|
9
|
-
/** End byte position (inclusive) */
|
|
10
|
-
end: number;
|
|
11
|
-
};
|
|
6
|
+
/** Parquet file name */
|
|
7
|
+
export type ParquetFileName = Branded<`${string}.parquet`, 'PFrameInternal.ParquetFileName'>;
|
|
12
8
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
/** HTTP range as of RFC 9110 <https://datatracker.ietf.org/doc/html/rfc9110#name-range> */
|
|
10
|
+
export type HttpRange =
|
|
11
|
+
| {
|
|
12
|
+
/**
|
|
13
|
+
* Get file content in the specified byte range
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* GET /file.parquet HTTP/1.1
|
|
18
|
+
* Range: bytes=0-1023
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
type: 'bounded';
|
|
22
|
+
/** Start byte position (inclusive) */
|
|
23
|
+
start: number;
|
|
24
|
+
/** End byte position (inclusive) */
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
/**
|
|
29
|
+
* Get byte range starting from the specified offset
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```
|
|
33
|
+
* GET /file.parquet HTTP/1.1
|
|
34
|
+
* Range: bytes=1024-
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
type: 'offset';
|
|
38
|
+
/** Start byte position (inclusive) */
|
|
39
|
+
offset: number;
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
/**
|
|
43
|
+
* Get byte range starting from the specified suffix
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```
|
|
47
|
+
* GET /file.parquet HTTP/1.1
|
|
48
|
+
* Range: bytes=-1024
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
type: 'suffix';
|
|
52
|
+
/** End byte position (inclusive) */
|
|
53
|
+
suffix: number;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** HTTP method passed to object store */
|
|
57
|
+
export type HttpMethod = 'GET' | 'HEAD';
|
|
36
58
|
|
|
59
|
+
/** HTTP response from object store */
|
|
60
|
+
export type ObjectStoreResponse<Method extends HttpMethod = HttpMethod> =
|
|
61
|
+
| {
|
|
62
|
+
/** Will be translated to 500 Internal Server Error by the handler */
|
|
63
|
+
type: 'InternalError';
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
/** Will be translated to 404 Not Found by the handler */
|
|
67
|
+
type: 'NotFound';
|
|
68
|
+
}
|
|
69
|
+
| {
|
|
70
|
+
/** Will be translated to 416 Range Not Satisfiable by the handler */
|
|
71
|
+
type: 'RangeNotSatisfiable';
|
|
72
|
+
/** Total file size in bytes */
|
|
73
|
+
size: number;
|
|
74
|
+
}
|
|
75
|
+
| {
|
|
76
|
+
/** Will be translated to 200 OK or 206 Partial Content by the handler */
|
|
77
|
+
type: 'Ok';
|
|
78
|
+
/** Total file size in bytes */
|
|
79
|
+
size: number;
|
|
80
|
+
/** Stream of file content, undefined for HEAD requests */
|
|
81
|
+
data: Method extends 'HEAD' ? undefined : Readable;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Common options for object store creation */
|
|
85
|
+
export interface ObjectStoreOptions {
|
|
86
|
+
/** Logger instance, no logging is performed when not provided */
|
|
87
|
+
logger?: Logger;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Options for file system object store creation */
|
|
91
|
+
export interface FsStoreOptions extends ObjectStoreOptions {
|
|
92
|
+
/** Local directory to serve files from */
|
|
93
|
+
rootDir: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** File system abstraction for request handler factory, @see HttpHelpers.createRequestHandler */
|
|
97
|
+
export interface ObjectStore {
|
|
37
98
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param filename - existing file name (for which @see ObjectStore.getFileSize returned non-negative value)
|
|
42
|
-
* @param range - valid range of bytes to read from the file (store may skip validation)
|
|
43
|
-
* @param action - function to execute with the stream, responsible for closing the stream
|
|
44
|
-
* @returns promise that resolves after the action is completed
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```ts
|
|
48
|
-
* async withReadStream(params: {
|
|
49
|
-
* filename: string;
|
|
50
|
-
* range: FileRange;
|
|
51
|
-
* action: (stream: Readable) => Promise<void>;
|
|
52
|
-
* }): Promise<void> {
|
|
53
|
-
* const { filename, range, action } = params;
|
|
54
|
-
* const filePath = this.resolve(filename);
|
|
55
|
-
*
|
|
56
|
-
* try {
|
|
57
|
-
* const stream = createReadStream(filePath, range);
|
|
58
|
-
* return await action(stream);
|
|
59
|
-
* } catch (err: unknown) {
|
|
60
|
-
* console.error(`failed to create read stream for ${filename} - ${ensureError(err)}`);
|
|
61
|
-
* throw;
|
|
62
|
-
* }
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
99
|
+
* Proxy HTTP(S) request for parquet file to object store.
|
|
100
|
+
* Callback promise resolves when stream is closed by handler @see HttpHelpers.createRequestHandler
|
|
101
|
+
* Callback API is used so that ObjectStore can limit the number of concurrent requests.
|
|
65
102
|
*/
|
|
66
|
-
|
|
67
|
-
filename:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
103
|
+
request<Method extends HttpMethod>(
|
|
104
|
+
filename: ParquetFileName,
|
|
105
|
+
params: {
|
|
106
|
+
method: Method;
|
|
107
|
+
range?: HttpRange;
|
|
108
|
+
signal?: AbortSignal;
|
|
109
|
+
callback: (response: ObjectStoreResponse<Method>) => Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
): void;
|
|
71
112
|
}
|
|
72
113
|
|
|
73
114
|
/** Object store base URL in format accepted by Apache DataFusion and DuckDB */
|
|
@@ -136,7 +177,7 @@ export interface HttpHelpers {
|
|
|
136
177
|
* Create an object store for serving files from a local directory.
|
|
137
178
|
* Rejects if the provided path does not exist or is not a directory.
|
|
138
179
|
*/
|
|
139
|
-
createFsStore(
|
|
180
|
+
createFsStore(options: FsStoreOptions): Promise<ObjectStore>;
|
|
140
181
|
|
|
141
182
|
/**
|
|
142
183
|
* Create an HTTP request handler for serving files from an object store.
|
|
@@ -153,7 +194,7 @@ export interface HttpHelpers {
|
|
|
153
194
|
* ```ts
|
|
154
195
|
* const rootDir = '/path/to/directory/with/parquet/files';
|
|
155
196
|
*
|
|
156
|
-
* let store = await HttpHelpers.createFsStore(rootDir).catch((err: unknown) => {
|
|
197
|
+
* let store = await HttpHelpers.createFsStore({ rootDir }).catch((err: unknown) => {
|
|
157
198
|
* throw new Error(`Failed to create file store for ${rootDir} - ${ensureError(err)}`);
|
|
158
199
|
* });
|
|
159
200
|
*
|
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
import type { PFrameFactoryAPIV2 } from './api_factory';
|
|
2
|
-
import type { PFrameReadAPIV8 } from './api_read';
|
|
3
|
-
|
|
4
|
-
export type Logger = (
|
|
5
|
-
level: 'info' | 'warn' | 'error',
|
|
6
|
-
message: string
|
|
7
|
-
) => void;
|
|
1
|
+
import type { PFrameFactoryAPIV2, PFrameFactoryAPIV3 } from './api_factory';
|
|
2
|
+
import type { PFrameReadAPIV8, PFrameReadAPIV9 } from './api_read';
|
|
3
|
+
import type { Logger } from './common';
|
|
8
4
|
|
|
9
5
|
export interface PFrameV9 extends PFrameFactoryAPIV2, PFrameReadAPIV8 {}
|
|
6
|
+
|
|
7
|
+
export interface PFrameV10 extends PFrameFactoryAPIV3, PFrameReadAPIV9 {}
|
|
8
|
+
|
|
9
|
+
export type PFrameOptions = {
|
|
10
|
+
/** Path to directory where PFrame can create temporary files */
|
|
11
|
+
spillPath: string;
|
|
12
|
+
/** Logger instance, no logging is performed when not provided */
|
|
13
|
+
logger?: Logger;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** List of PFrame management functions exposed by PFrame module */
|
|
17
|
+
export interface PFrameFactory {
|
|
18
|
+
/**
|
|
19
|
+
* Create a new PFrame instance.
|
|
20
|
+
* @warning Use concurrency limiting to avoid OOM crashes when multiple instances are simultaneously in use.
|
|
21
|
+
*/
|
|
22
|
+
createPFrame(options: PFrameOptions): PFrameV10;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Dump active allocations from all PFrames instances in pprof format.
|
|
26
|
+
* The result of this function should be saved as `profile.pb.gz`.
|
|
27
|
+
* Use {@link https://pprof.me/} or {@link https://www.speedscope.app/}
|
|
28
|
+
* to view the allocation flamechart.
|
|
29
|
+
* @warning This method will always reject on Windows!
|
|
30
|
+
*/
|
|
31
|
+
pprofDump: () => Promise<Uint8Array>;
|
|
32
|
+
};
|
|
@@ -72,3 +72,68 @@ export interface PTableV6 {
|
|
|
72
72
|
/** Deallocates all underlying resources */
|
|
73
73
|
dispose(): void;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Table view returned as a result of create table operation.
|
|
78
|
+
*
|
|
79
|
+
* PTable can be thought as having a composite primary key, consisting of axes,
|
|
80
|
+
* and a set of data columns derived from PColumn values.
|
|
81
|
+
* */
|
|
82
|
+
export interface PTableV7 extends Disposable {
|
|
83
|
+
/**
|
|
84
|
+
* Returns ordered array of table axes specs (primary key "columns" in SQL
|
|
85
|
+
* terms) and data column specs (regular "columns" in SQL terms).
|
|
86
|
+
*
|
|
87
|
+
* Data for a specific table column can be retrieved using unified indexing
|
|
88
|
+
* corresponding to elements in this array.
|
|
89
|
+
*
|
|
90
|
+
* Axes are always listed first.
|
|
91
|
+
* */
|
|
92
|
+
getSpec(): PTableColumnSpec[];
|
|
93
|
+
|
|
94
|
+
/** Transforms unified column identifiers into unified indices of columns. */
|
|
95
|
+
getColumnIndices(columnIds: PTableColumnId[]): number[];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get PTable disk footprint in bytes
|
|
99
|
+
* Warning: This call materializes the join.
|
|
100
|
+
*/
|
|
101
|
+
getFootprint(ops?: {
|
|
102
|
+
withPredecessors?: boolean,
|
|
103
|
+
signal?: AbortSignal,
|
|
104
|
+
}): Promise<number>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Unified table shape
|
|
108
|
+
* Warning: This call materializes the join.
|
|
109
|
+
*/
|
|
110
|
+
getShape(ops?: {
|
|
111
|
+
signal?: AbortSignal,
|
|
112
|
+
}): Promise<PTableShape>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Retrieve the data from the table. To retrieve only data required, it can be
|
|
116
|
+
* sliced both horizontally ({@link columnIndices}) and vertically
|
|
117
|
+
* ({@link range}).
|
|
118
|
+
* This call materializes the join.
|
|
119
|
+
*
|
|
120
|
+
* @param columnIndices unified indices of columns to be retrieved
|
|
121
|
+
* @param range optionally limit the range of records to retrieve
|
|
122
|
+
* */
|
|
123
|
+
getData(
|
|
124
|
+
columnIndices: number[],
|
|
125
|
+
ops?: {
|
|
126
|
+
range?: TableRange,
|
|
127
|
+
signal?: AbortSignal,
|
|
128
|
+
},
|
|
129
|
+
): Promise<PTableVector[]>;
|
|
130
|
+
|
|
131
|
+
/** Filters the table and returns new PTable instance */
|
|
132
|
+
filter(request: PTableRecordFilter[]): PTableV7;
|
|
133
|
+
|
|
134
|
+
/** Sorts the table and returns new PTable instance. */
|
|
135
|
+
sort(request: PTableSorting[]): PTableV7;
|
|
136
|
+
|
|
137
|
+
/** Deallocates all underlying resources */
|
|
138
|
+
dispose(): void;
|
|
139
|
+
}
|