@milaboratories/pframes-rs-node 1.1.37 → 1.1.38

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.
@@ -1,15 +1,7 @@
1
1
  import type {
2
- PColumnInfo,
3
- PColumnSpec,
4
- PObjectId,
5
- PTableColumnId,
6
- PTableColumnSpec,
7
- PTableRecordFilter,
8
2
  PTableShape,
9
- PTableSorting,
10
3
  PTableVector,
11
4
  TableRange,
12
- UniqueValuesRequest,
13
5
  UniqueValuesResponse,
14
6
  DataQuery,
15
7
  } from "@milaboratories/pl-model-common";
@@ -29,60 +21,35 @@ interface HeapProfiler {
29
21
 
30
22
  interface NodeFrame {
31
23
  pFrameCreate: (spillPath: string, logger: PFrameInternal.Logger | undefined) => NodeFrameSymbol;
32
- pFrameAddColumnSpec: (
33
- pFrame: NodeFrameSymbol,
34
- columnId: PObjectId,
35
- columnSpec: PColumnSpec,
36
- ) => void;
37
24
  pFrameSetDataSource: (
38
25
  pFrame: NodeFrameSymbol,
39
26
  dataSource: PFrameInternal.PFrameDataSourceV2,
40
27
  ) => void;
41
- pFrameSetColumnData: (
28
+ pFrameAddColumns: (
42
29
  pFrame: NodeFrameSymbol,
43
- columnId: PObjectId,
44
- dataInfo: PFrameInternal.DataInfo<PFrameInternal.PFrameBlobId>,
30
+ columns: PFrameInternal.AddColumnEntry[],
45
31
  signal: AbortSignal | undefined,
46
32
  ) => Promise<void>;
47
33
  pFrameDispose: (pFrame: NodeFrameSymbol) => void;
48
- pFrameFindColumns: (
49
- pFrame: NodeFrameSymbol,
50
- request: PFrameInternal.FindColumnsRequest,
51
- ) => Promise<PFrameInternal.FindColumnsResponse>;
52
- pFrameDeleteColumn: (
53
- pFrame: NodeFrameSymbol,
54
- request: PFrameInternal.DeleteColumnFromColumnsRequest,
55
- ) => Promise<PFrameInternal.DeleteColumnFromColumnsResponse>;
56
- pFrameGetColumnSpec: (
57
- pFrame: NodeFrameSymbol,
58
- columnId: PObjectId,
59
- ) => Promise<PColumnSpec | null>;
60
- pFrameListColumns: (pFrame: NodeFrameSymbol) => Promise<PColumnInfo[]>;
61
34
  pFrameCreateTable: (
62
35
  pFrame: NodeFrameSymbol,
63
36
  id: PFrameInternal.PTableId,
64
- request: PFrameInternal.CreateTableRequestV4,
65
- ) => NodeTableSymbol;
66
- pFrameCreateTableV2: (
67
- pFrame: NodeFrameSymbol,
68
- id: PFrameInternal.PTableId,
69
- request: {
70
- tableSpec: PTableColumnSpec[];
71
- dataQuery: DataQuery;
72
- },
37
+ dataQuery: DataQuery,
73
38
  ) => NodeTableSymbol;
74
39
  pFrameGetUniqueValues: (
75
40
  pFrame: NodeFrameSymbol,
76
41
  id: PFrameInternal.PTableId,
77
- request: UniqueValuesRequest,
42
+ request: PFrameInternal.UniqueValuesRequestV2,
78
43
  signal: AbortSignal | undefined,
79
44
  ) => Promise<UniqueValuesResponse>;
80
45
  }
81
46
 
82
47
  interface NodeTable {
83
- pTableGetSpec: (boxed: NodeTableSymbol) => PTableColumnSpec[];
84
- pTableGetColumnIndices: (boxed: NodeTableSymbol, columnIds: PTableColumnId[]) => number[];
85
- pTableGetFootprint: (boxed: NodeTableSymbol, signal: AbortSignal | undefined) => Promise<number>;
48
+ pTableGetFootprint: (
49
+ boxed: NodeTableSymbol,
50
+ withPredecessors: boolean,
51
+ signal: AbortSignal | undefined,
52
+ ) => Promise<number>;
86
53
  pTableGetShape: (boxed: NodeTableSymbol, signal: AbortSignal | undefined) => Promise<PTableShape>;
87
54
  pTableGetData: (
88
55
  boxed: NodeTableSymbol,
@@ -91,16 +58,6 @@ interface NodeTable {
91
58
  range: TableRange | undefined,
92
59
  signal: AbortSignal | undefined,
93
60
  ) => Promise<PTableVector[]>;
94
- pTableFilter: (
95
- boxed: NodeTableSymbol,
96
- id: PFrameInternal.PTableId,
97
- request: PTableRecordFilter[],
98
- ) => NodeTableSymbol;
99
- pTableSort: (
100
- boxed: NodeTableSymbol,
101
- id: PFrameInternal.PTableId,
102
- request: PTableSorting[],
103
- ) => NodeTableSymbol;
104
61
  pTableDispose: (boxed: NodeTableSymbol) => void;
105
62
  }
106
63
 
package/export/dump.ts CHANGED
@@ -2,119 +2,32 @@ import { createHash } from "node:crypto";
2
2
  import { promises as fs } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
5
- import type {
6
- PObjectId,
7
- PTableColumnId,
8
- PTableColumnSpec,
9
- PTableRecordFilter,
10
- PTableSorting,
11
- UniqueValuesRequest,
12
- DataQuery,
13
- } from "@milaboratories/pl-model-common";
5
+ import type { PObjectId, DataQuery } from "@milaboratories/pl-model-common";
14
6
 
15
7
  export function hashColumnId(columnId: PObjectId): PObjectId {
16
8
  return createHash("sha256").update(columnId).digest("hex") as PObjectId;
17
9
  }
18
10
 
19
- export function hashTableColumnId(tableId: PTableColumnId): PTableColumnId {
20
- if (tableId.type === "column") {
21
- return {
22
- ...tableId,
23
- id: hashColumnId(tableId.id),
24
- };
25
- }
26
- return tableId;
27
- }
28
-
29
- export function hashFilterColumnId(filter: PTableRecordFilter): PTableRecordFilter {
11
+ export function hashAddColumnEntry(
12
+ entry: PFrameInternal.AddColumnEntry,
13
+ ): PFrameInternal.AddColumnEntry {
30
14
  return {
31
- ...filter,
32
- column: hashTableColumnId(filter.column),
15
+ ...entry,
16
+ id: hashColumnId(entry.id),
33
17
  };
34
18
  }
35
19
 
36
- export function hashUniqueValuesRequestColumnId(request: UniqueValuesRequest): UniqueValuesRequest {
20
+ export function hashUniqueValuesRequestColumnId(
21
+ request: PFrameInternal.UniqueValuesRequestV2,
22
+ ): PFrameInternal.UniqueValuesRequestV2 {
23
+ // V2 filters are index-based (no column ids), so only `columnId` is rewritten.
37
24
  return {
38
25
  ...request,
39
26
  columnId: hashColumnId(request.columnId),
40
- filters: request.filters.map(hashFilterColumnId),
41
27
  };
42
28
  }
43
29
 
44
- export function hashSortingColumnId(sorting: PTableSorting): PTableSorting {
45
- return {
46
- ...sorting,
47
- column: hashTableColumnId(sorting.column),
48
- };
49
- }
50
-
51
- function hashJoinEntryColumnId(entry: PFrameInternal.JoinEntryV4): PFrameInternal.JoinEntryV4 {
52
- const type = entry.type;
53
- switch (type) {
54
- case "column":
55
- return {
56
- ...entry,
57
- columnId: hashColumnId(entry.columnId),
58
- };
59
- case "slicedColumn":
60
- return {
61
- ...entry,
62
- columnId: hashColumnId(entry.columnId),
63
- newId: hashColumnId(entry.newId),
64
- };
65
- case "artificialColumn":
66
- return {
67
- ...entry,
68
- columnId: hashColumnId(entry.columnId),
69
- newId: hashColumnId(entry.newId),
70
- };
71
- case "inlineColumn":
72
- return {
73
- ...entry,
74
- newId: hashColumnId(entry.newId),
75
- };
76
- case "inner":
77
- return {
78
- ...entry,
79
- entries: entry.entries.map(hashJoinEntryColumnId),
80
- };
81
- case "full":
82
- return {
83
- ...entry,
84
- entries: entry.entries.map(hashJoinEntryColumnId),
85
- };
86
- case "outer":
87
- return {
88
- ...entry,
89
- primary: hashJoinEntryColumnId(entry.primary),
90
- secondary: entry.secondary.map(hashJoinEntryColumnId),
91
- };
92
- default:
93
- throw new Error(`Unsupported join entry type: ${type}`);
94
- }
95
- }
96
-
97
- export function hashCreateTableRequestColumnId(
98
- request: PFrameInternal.CreateTableRequestV4,
99
- ): PFrameInternal.CreateTableRequestV4 {
100
- return {
101
- ...request,
102
- src: hashJoinEntryColumnId(request.src),
103
- filters: request.filters.map(hashFilterColumnId),
104
- };
105
- }
106
-
107
- function hashTableColumnSpec(spec: PTableColumnSpec): PTableColumnSpec {
108
- if (spec.type === "column") {
109
- return {
110
- ...spec,
111
- id: hashColumnId(spec.id),
112
- };
113
- }
114
- return spec;
115
- }
116
-
117
- function hashDataQuery(query: DataQuery): DataQuery {
30
+ export function hashDataQuery(query: DataQuery): DataQuery {
118
31
  switch (query.type) {
119
32
  case "column":
120
33
  return {
@@ -190,23 +103,25 @@ function hashDataQuery(query: DataQuery): DataQuery {
190
103
  ...query,
191
104
  input: hashDataQuery(query.input),
192
105
  };
106
+ case "transformColumns":
107
+ return {
108
+ ...query,
109
+ input: hashDataQuery(query.input),
110
+ columns: query.columns.map((entry) =>
111
+ entry.specOverride
112
+ ? {
113
+ ...entry,
114
+ specOverride: {
115
+ ...entry.specOverride,
116
+ id: hashColumnId(entry.specOverride.id),
117
+ },
118
+ }
119
+ : entry,
120
+ ) as typeof query.columns,
121
+ };
193
122
  }
194
123
  }
195
124
 
196
- export function hashCreateTableV2RequestColumnId(request: {
197
- tableSpec: PTableColumnSpec[];
198
- dataQuery: DataQuery;
199
- }): {
200
- tableSpec: PTableColumnSpec[];
201
- dataQuery: DataQuery;
202
- } {
203
- return {
204
- ...request,
205
- tableSpec: request.tableSpec.map(hashTableColumnSpec),
206
- dataQuery: hashDataQuery(request.dataQuery),
207
- };
208
- }
209
-
210
125
  export async function dump(
211
126
  relativePath: string[],
212
127
  data: { [key: string]: string | number | boolean | object } | Uint8Array,
package/export/export.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
2
2
  import { PFrame, pprofDump } from "./wrapper";
3
3
 
4
- export const PFrameFactory: PFrameInternal.PFrameFactoryV4 = {
5
- createPFrame: (options: PFrameInternal.PFrameOptionsV2): PFrameInternal.PFrameV13 => {
4
+ export const PFrameFactory: PFrameInternal.PFrameFactoryV5 = {
5
+ createPFrame: (options: PFrameInternal.PFrameOptionsV2): PFrameInternal.PFrameV14 => {
6
6
  return new PFrame(options);
7
7
  },
8
8
  pprofDump: async (): Promise<Uint8Array> => {