@platforma-sdk/model 1.44.8 → 1.44.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/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/render/util/pcolumn_data.cjs +59 -2
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +5 -3
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js +58 -3
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/package.json +7 -7
- package/src/render/util/pcolumn_data.ts +71 -6
package/dist/index.cjs
CHANGED
|
@@ -104,6 +104,8 @@ exports.RT_BINARY_PARTITIONED = pcolumn_data.RT_BINARY_PARTITIONED;
|
|
|
104
104
|
exports.RT_BINARY_SUPER_PARTITIONED = pcolumn_data.RT_BINARY_SUPER_PARTITIONED;
|
|
105
105
|
exports.RT_JSON_PARTITIONED = pcolumn_data.RT_JSON_PARTITIONED;
|
|
106
106
|
exports.RT_JSON_SUPER_PARTITIONED = pcolumn_data.RT_JSON_SUPER_PARTITIONED;
|
|
107
|
+
exports.RT_PARQUET_PARTITIONED = pcolumn_data.RT_PARQUET_PARTITIONED;
|
|
108
|
+
exports.RT_PARQUET_SUPER_PARTITIONED = pcolumn_data.RT_PARQUET_SUPER_PARTITIONED;
|
|
107
109
|
exports.RT_RESOURCE_MAP = pcolumn_data.RT_RESOURCE_MAP;
|
|
108
110
|
exports.RT_RESOURCE_MAP_PARTITIONED = pcolumn_data.RT_RESOURCE_MAP_PARTITIONED;
|
|
109
111
|
exports.convertOrParsePColumnData = pcolumn_data.convertOrParsePColumnData;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { PFrameImpl } from './pframe.js';
|
|
|
12
12
|
export { fromPlOption, fromPlRef } from './ref_util.js';
|
|
13
13
|
export { RenderCtx, ResultPool } from './render/api.js';
|
|
14
14
|
export { TreeNodeAccessor, ifDef } from './render/accessor.js';
|
|
15
|
-
export { RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, convertOrParsePColumnData, getPartitionKeysList, getUniquePartitionKeys, parsePColumnData, parseResourceMap } from './render/util/pcolumn_data.js';
|
|
15
|
+
export { RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, convertOrParsePColumnData, getPartitionKeysList, getUniquePartitionKeys, parsePColumnData, parseResourceMap } from './render/util/pcolumn_data.js';
|
|
16
16
|
export { Trace, TraceEntry, deriveLabels } from './render/util/label.js';
|
|
17
17
|
export { filterDataInfoEntries } from './render/util/axis_filtering.js';
|
|
18
18
|
export { PColumnCollection } from './render/util/column_collection.js';
|
package/dist/package.json.cjs
CHANGED
package/dist/package.json.js
CHANGED
|
@@ -8,9 +8,11 @@ const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';
|
|
|
8
8
|
const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';
|
|
9
9
|
const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';
|
|
10
10
|
const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';
|
|
11
|
+
const RT_PARQUET_PARTITIONED = PCD_PREFIX + 'ParquetPartitioned';
|
|
11
12
|
const PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';
|
|
12
13
|
const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';
|
|
13
14
|
const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';
|
|
15
|
+
const RT_PARQUET_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'ParquetPartitioned';
|
|
14
16
|
function populateResourceMapData(acc, resourceParser, data, keyPrefix = [], addEntriesWithNoData) {
|
|
15
17
|
if (acc === undefined)
|
|
16
18
|
return false;
|
|
@@ -81,10 +83,12 @@ function getPartitionKeysList(acc) {
|
|
|
81
83
|
break;
|
|
82
84
|
case RT_JSON_PARTITIONED:
|
|
83
85
|
case RT_BINARY_PARTITIONED:
|
|
86
|
+
case RT_PARQUET_PARTITIONED:
|
|
84
87
|
keyLength = meta['partitionKeyLength'];
|
|
85
88
|
break;
|
|
86
89
|
case RT_BINARY_SUPER_PARTITIONED:
|
|
87
90
|
case RT_JSON_SUPER_PARTITIONED:
|
|
91
|
+
case RT_PARQUET_SUPER_PARTITIONED:
|
|
88
92
|
keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];
|
|
89
93
|
break;
|
|
90
94
|
}
|
|
@@ -92,6 +96,7 @@ function getPartitionKeysList(acc) {
|
|
|
92
96
|
case RT_RESOURCE_MAP:
|
|
93
97
|
case RT_JSON_PARTITIONED:
|
|
94
98
|
case RT_BINARY_PARTITIONED:
|
|
99
|
+
case RT_PARQUET_PARTITIONED:
|
|
95
100
|
for (let keyStr of acc.listInputFields()) {
|
|
96
101
|
if (rt === RT_BINARY_PARTITIONED) {
|
|
97
102
|
keyStr = removeIndexSuffix(keyStr).baseKey;
|
|
@@ -103,6 +108,7 @@ function getPartitionKeysList(acc) {
|
|
|
103
108
|
case RT_RESOURCE_MAP_PARTITIONED:
|
|
104
109
|
case RT_BINARY_SUPER_PARTITIONED:
|
|
105
110
|
case RT_JSON_SUPER_PARTITIONED:
|
|
111
|
+
case RT_PARQUET_SUPER_PARTITIONED:
|
|
106
112
|
for (const supKeyStr of acc.listInputFields()) {
|
|
107
113
|
const keyPrefix = [...JSON.parse(supKeyStr)];
|
|
108
114
|
const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });
|
|
@@ -121,7 +127,7 @@ function getPartitionKeysList(acc) {
|
|
|
121
127
|
return { data, keyLength };
|
|
122
128
|
}
|
|
123
129
|
function getUniquePartitionKeysForDataEntries(list) {
|
|
124
|
-
if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned')
|
|
130
|
+
if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned' && list.type !== 'ParquetPartitioned')
|
|
125
131
|
throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);
|
|
126
132
|
const { parts, partitionKeyLength } = list;
|
|
127
133
|
const result = [];
|
|
@@ -180,7 +186,9 @@ function parsePColumnData(acc, keyPrefix = []) {
|
|
|
180
186
|
const meta = acc.getDataAsJson();
|
|
181
187
|
// Prevent recursive super-partitioned resources
|
|
182
188
|
if (keyPrefix.length > 0
|
|
183
|
-
&& (resourceType === RT_JSON_SUPER_PARTITIONED
|
|
189
|
+
&& (resourceType === RT_JSON_SUPER_PARTITIONED
|
|
190
|
+
|| resourceType === RT_BINARY_SUPER_PARTITIONED
|
|
191
|
+
|| resourceType === RT_PARQUET_SUPER_PARTITIONED)) {
|
|
184
192
|
throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);
|
|
185
193
|
}
|
|
186
194
|
switch (resourceType) {
|
|
@@ -248,6 +256,24 @@ function parsePColumnData(acc, keyPrefix = []) {
|
|
|
248
256
|
parts,
|
|
249
257
|
};
|
|
250
258
|
}
|
|
259
|
+
case RT_PARQUET_PARTITIONED: {
|
|
260
|
+
if (typeof meta?.partitionKeyLength !== 'number') {
|
|
261
|
+
throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);
|
|
262
|
+
}
|
|
263
|
+
const parts = [];
|
|
264
|
+
for (const keyStr of acc.listInputFields()) {
|
|
265
|
+
const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });
|
|
266
|
+
if (value === undefined)
|
|
267
|
+
return undefined;
|
|
268
|
+
const key = [...keyPrefix, ...JSON.parse(keyStr)];
|
|
269
|
+
parts.push({ key, value });
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
type: 'ParquetPartitioned',
|
|
273
|
+
partitionKeyLength: meta.partitionKeyLength,
|
|
274
|
+
parts,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
251
277
|
case RT_JSON_SUPER_PARTITIONED: {
|
|
252
278
|
if (typeof meta?.superPartitionKeyLength !== 'number'
|
|
253
279
|
|| typeof meta?.partitionKeyLength !== 'number') {
|
|
@@ -306,6 +332,35 @@ function parsePColumnData(acc, keyPrefix = []) {
|
|
|
306
332
|
parts,
|
|
307
333
|
};
|
|
308
334
|
}
|
|
335
|
+
case RT_PARQUET_SUPER_PARTITIONED: {
|
|
336
|
+
if (typeof meta?.superPartitionKeyLength !== 'number'
|
|
337
|
+
|| typeof meta?.partitionKeyLength !== 'number') {
|
|
338
|
+
throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);
|
|
339
|
+
}
|
|
340
|
+
const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;
|
|
341
|
+
const parts = [];
|
|
342
|
+
// Process all super partitions
|
|
343
|
+
for (const supKeyStr of acc.listInputFields()) {
|
|
344
|
+
const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });
|
|
345
|
+
if (superPartition === undefined)
|
|
346
|
+
return undefined;
|
|
347
|
+
// Validate inner type
|
|
348
|
+
if (superPartition.resourceType.name !== RT_PARQUET_PARTITIONED) {
|
|
349
|
+
throw new Error(`Expected ${RT_PARQUET_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);
|
|
350
|
+
}
|
|
351
|
+
const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr));
|
|
352
|
+
if (innerResult === undefined)
|
|
353
|
+
return undefined;
|
|
354
|
+
if (innerResult.type !== 'ParquetPartitioned')
|
|
355
|
+
throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);
|
|
356
|
+
parts.push(...innerResult.parts);
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
type: 'ParquetPartitioned',
|
|
360
|
+
partitionKeyLength: totalKeyLength,
|
|
361
|
+
parts,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
309
364
|
default:
|
|
310
365
|
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
311
366
|
}
|
|
@@ -332,6 +387,8 @@ exports.RT_BINARY_PARTITIONED = RT_BINARY_PARTITIONED;
|
|
|
332
387
|
exports.RT_BINARY_SUPER_PARTITIONED = RT_BINARY_SUPER_PARTITIONED;
|
|
333
388
|
exports.RT_JSON_PARTITIONED = RT_JSON_PARTITIONED;
|
|
334
389
|
exports.RT_JSON_SUPER_PARTITIONED = RT_JSON_SUPER_PARTITIONED;
|
|
390
|
+
exports.RT_PARQUET_PARTITIONED = RT_PARQUET_PARTITIONED;
|
|
391
|
+
exports.RT_PARQUET_SUPER_PARTITIONED = RT_PARQUET_SUPER_PARTITIONED;
|
|
335
392
|
exports.RT_RESOURCE_MAP = RT_RESOURCE_MAP;
|
|
336
393
|
exports.RT_RESOURCE_MAP_PARTITIONED = RT_RESOURCE_MAP_PARTITIONED;
|
|
337
394
|
exports.convertOrParsePColumnData = convertOrParsePColumnData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pcolumn_data.cjs","sources":["../../../src/render/util/pcolumn_data.ts"],"sourcesContent":["import type {\n DataInfo } from '@milaboratories/pl-model-common';\nimport {\n dataInfoToEntries,\n isDataInfo,\n isDataInfoEntries,\n type BinaryChunk,\n type BinaryPartitionedDataInfoEntries,\n type DataInfoEntries,\n type JsonPartitionedDataInfoEntries,\n type PColumnDataEntry,\n type PColumnKey,\n} from '@milaboratories/pl-model-common';\nimport { TreeNodeAccessor } from '../accessor';\n\nconst PCD_PREFIX = 'PColumnData/';\n\nexport const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';\nexport const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';\n\nexport const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';\n\nconst PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';\nexport const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';\n\nexport type PColumnResourceMapEntry<T> = {\n key: PColumnKey;\n value: T;\n};\n\nexport type PColumnResourceMapData<T> = {\n isComplete: boolean;\n data: PColumnResourceMapEntry<T>[];\n};\n\nfunction populateResourceMapData<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n data: PColumnResourceMapEntry<T | undefined>[],\n keyPrefix: PColumnKey = [],\n addEntriesWithNoData: boolean,\n): boolean {\n if (acc === undefined) return false;\n switch (acc.resourceType.name) {\n case RT_RESOURCE_MAP: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const converted = value === undefined ? undefined : resourceParser(value);\n if (converted === undefined) isComplete = false;\n if (converted !== undefined || addEntriesWithNoData) data.push({ key, value: converted });\n }\n return isComplete;\n }\n case RT_RESOURCE_MAP_PARTITIONED: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) isComplete = false;\n else {\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const populateResult = populateResourceMapData(\n value,\n resourceParser,\n data,\n key,\n addEntriesWithNoData,\n );\n isComplete = isComplete && populateResult;\n }\n }\n return isComplete;\n }\n default:\n throw new Error(`Unknown resource type: ${acc.resourceType.name}`);\n }\n}\n\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: false\n): PColumnResourceMapData<NonNullable<T>>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: true\n): PColumnResourceMapData<T | undefined>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: boolean = false,\n): PColumnResourceMapData<T | undefined> {\n const data: PColumnResourceMapEntry<T | undefined>[] = [];\n const isComplete = populateResourceMapData(acc, resourceParser, data, [], addEntriesWithNoData);\n return { isComplete, data };\n}\n\nexport type PColumnKeyList = {\n /** array of keys */\n data: PColumnKey[];\n /** length of partition key */\n keyLength: number;\n};\n\nconst removeIndexSuffix = (keyStr: string): { baseKey: string; type: 'index' | 'values' } => {\n if (keyStr.endsWith('.index')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 6), type: 'index' };\n } else if (keyStr.endsWith('.values')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 7), type: 'values' };\n } else {\n throw new Error(`key must ends on .index/.values for binary p-column, got: ${keyStr}`);\n }\n};\n\n// @TODO define a class with various resource map operations\n/** Returns a list of all partition keys appeared in the p-column */\nexport function getPartitionKeysList(\n acc: TreeNodeAccessor | undefined,\n): PColumnKeyList | undefined {\n if (!acc) return undefined;\n\n const rt = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n const data: PColumnKey[] = [];\n\n let keyLength = 0;\n // @TODO validate meta shape\n switch (rt) {\n case RT_RESOURCE_MAP:\n keyLength = meta['keyLength'];\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n keyLength = meta['partitionKeyLength'] + meta['keyLength'];\n break;\n\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n keyLength = meta['partitionKeyLength'];\n break;\n\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];\n break;\n }\n\n switch (rt) {\n case RT_RESOURCE_MAP:\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n for (let keyStr of acc.listInputFields()) {\n if (rt === RT_BINARY_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n for (const supKeyStr of acc.listInputFields()) {\n const keyPrefix = [...JSON.parse(supKeyStr)] as PColumnKey;\n\n const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (value !== undefined) {\n for (let keyStr of value.listInputFields()) {\n if (rt === RT_BINARY_SUPER_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n }\n }\n break;\n }\n\n return { data, keyLength };\n}\n\nfunction getUniquePartitionKeysForDataEntries(list: DataInfoEntries<unknown>): (string | number)[][] {\n if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned')\n throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);\n\n const { parts, partitionKeyLength } = list;\n\n const result: Set<string | number>[] = [];\n for (let i = 0; i < partitionKeyLength; ++i) {\n result.push(new Set());\n }\n\n for (const part of parts) {\n const key = part.key;\n if (key.length !== partitionKeyLength) {\n throw new Error(\n `Key length (${key.length}) does not match partition length (${partitionKeyLength}) for key: ${JSON.stringify(\n key,\n )}`,\n );\n }\n for (let i = 0; i < partitionKeyLength; ++i) {\n result[i].add(key[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown>): (string | number)[][];\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | TreeNodeAccessor | undefined): (string | number)[][] | undefined;\nexport function getUniquePartitionKeys(\n acc: TreeNodeAccessor | DataInfoEntries<unknown> | undefined,\n): (string | number)[][] | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc))\n return getUniquePartitionKeysForDataEntries(acc);\n\n const list = getPartitionKeysList(acc);\n if (!list) return undefined;\n\n const { data, keyLength } = list;\n\n const result: Set<string | number>[] = [];\n\n for (let i = 0; i < keyLength; ++i) {\n result.push(new Set());\n }\n\n for (const l of data) {\n if (l.length !== keyLength) {\n throw new Error('key length does not match partition length');\n }\n for (let i = 0; i < keyLength; ++i) {\n result[i].add(l[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/**\n * Parses the PColumn data from a TreeNodeAccessor into a DataInfoEntries structure.\n * Returns undefined if any required data is missing.\n * Throws error on validation failures.\n *\n * @param acc - The TreeNodeAccessor containing PColumn data\n * @param keyPrefix - Optional key prefix for recursive calls\n * @returns DataInfoEntries representation of the PColumn data, or undefined if incomplete\n */\nexport function parsePColumnData(\n acc: TreeNodeAccessor | undefined,\n keyPrefix: PColumnKey = [],\n): JsonPartitionedDataInfoEntries<TreeNodeAccessor> | BinaryPartitionedDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (!acc.getIsReadyOrError()) return undefined;\n\n const resourceType = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n\n // Prevent recursive super-partitioned resources\n if (keyPrefix.length > 0\n && (resourceType === RT_JSON_SUPER_PARTITIONED || resourceType === RT_BINARY_SUPER_PARTITIONED)) {\n throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);\n }\n\n switch (resourceType) {\n case RT_RESOURCE_MAP:\n case RT_RESOURCE_MAP_PARTITIONED:\n throw new Error(`Only data columns are supported, got: ${resourceType}`);\n\n case RT_JSON_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(keyStr)];\n parts.push({ key, value });\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n const baseKeys = new Map<string, { index?: TreeNodeAccessor; values?: TreeNodeAccessor }>();\n\n // Group fields by base key (without .index/.values suffix)\n for (const keyStr of acc.listInputFields()) {\n const suffix = removeIndexSuffix(keyStr);\n\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n let entry = baseKeys.get(suffix.baseKey);\n if (!entry) {\n entry = {};\n baseKeys.set(suffix.baseKey, entry);\n }\n\n if (suffix.type === 'index') {\n entry.index = value;\n } else {\n entry.values = value;\n }\n }\n\n // Process complete binary chunks only\n for (const [baseKeyStr, entry] of baseKeys.entries()) {\n if (!entry.index || !entry.values) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(baseKeyStr)];\n parts.push({\n key,\n value: {\n index: entry.index,\n values: entry.values,\n },\n });\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_JSON_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_JSON_PARTITIONED) {\n throw new Error(`Expected ${RT_JSON_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'JsonPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_BINARY_PARTITIONED) {\n throw new Error(`Expected ${RT_BINARY_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'BinaryPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n default:\n throw new Error(`Unknown resource type: ${resourceType}`);\n }\n}\n\n/**\n * Converts or parses the input into DataInfoEntries format.\n\n * @param acc - The input data, which can be TreeNodeAccessor, DataInfoEntries, DataInfo, or undefined.\n * @returns The data in DataInfoEntries format, or undefined if the input was undefined or data is not ready.\n */\nexport function convertOrParsePColumnData(acc: TreeNodeAccessor | DataInfoEntries<TreeNodeAccessor> | DataInfo<TreeNodeAccessor> | undefined):\nDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc)) return acc;\n if (isDataInfo(acc)) return dataInfoToEntries(acc);\n if (acc instanceof TreeNodeAccessor) return parsePColumnData(acc);\n\n throw new Error(`Unexpected input type: ${typeof acc}`);\n}\n"],"names":["isDataInfoEntries","isDataInfo","dataInfoToEntries","TreeNodeAccessor"],"mappings":";;;;;AAeA,MAAM,UAAU,GAAG,cAAc;AAE1B,MAAM,eAAe,GAAG,UAAU,GAAG;AACrC,MAAM,2BAA2B,GAAG,UAAU,GAAG;AAEjD,MAAM,mBAAmB,GAAG,UAAU,GAAG;AACzC,MAAM,qBAAqB,GAAG,UAAU,GAAG;AAElD,MAAM,cAAc,GAAG,UAAU,GAAG,cAAc;AAC3C,MAAM,yBAAyB,GAAG,cA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BAAgB;AAAE,QAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;IAEjE,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,OAAO,GAAG,CAAA,CAAE,CAAC;AACzD;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"pcolumn_data.cjs","sources":["../../../src/render/util/pcolumn_data.ts"],"sourcesContent":["import type {\n DataInfo,\n PartitionedDataInfoEntries,\n} from '@milaboratories/pl-model-common';\nimport {\n dataInfoToEntries,\n isDataInfo,\n isDataInfoEntries,\n type BinaryChunk,\n type DataInfoEntries,\n type PColumnDataEntry,\n type PColumnKey,\n} from '@milaboratories/pl-model-common';\nimport { TreeNodeAccessor } from '../accessor';\n\nconst PCD_PREFIX = 'PColumnData/';\n\nexport const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';\nexport const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';\n\nexport const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';\nexport const RT_PARQUET_PARTITIONED = PCD_PREFIX + 'ParquetPartitioned';\n\nconst PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';\nexport const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';\nexport const RT_PARQUET_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'ParquetPartitioned';\n\nexport type PColumnResourceMapEntry<T> = {\n key: PColumnKey;\n value: T;\n};\n\nexport type PColumnResourceMapData<T> = {\n isComplete: boolean;\n data: PColumnResourceMapEntry<T>[];\n};\n\nfunction populateResourceMapData<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n data: PColumnResourceMapEntry<T | undefined>[],\n keyPrefix: PColumnKey = [],\n addEntriesWithNoData: boolean,\n): boolean {\n if (acc === undefined) return false;\n switch (acc.resourceType.name) {\n case RT_RESOURCE_MAP: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const converted = value === undefined ? undefined : resourceParser(value);\n if (converted === undefined) isComplete = false;\n if (converted !== undefined || addEntriesWithNoData) data.push({ key, value: converted });\n }\n return isComplete;\n }\n case RT_RESOURCE_MAP_PARTITIONED: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) isComplete = false;\n else {\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const populateResult = populateResourceMapData(\n value,\n resourceParser,\n data,\n key,\n addEntriesWithNoData,\n );\n isComplete = isComplete && populateResult;\n }\n }\n return isComplete;\n }\n default:\n throw new Error(`Unknown resource type: ${acc.resourceType.name}`);\n }\n}\n\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: false\n): PColumnResourceMapData<NonNullable<T>>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: true\n): PColumnResourceMapData<T | undefined>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: boolean = false,\n): PColumnResourceMapData<T | undefined> {\n const data: PColumnResourceMapEntry<T | undefined>[] = [];\n const isComplete = populateResourceMapData(acc, resourceParser, data, [], addEntriesWithNoData);\n return { isComplete, data };\n}\n\nexport type PColumnKeyList = {\n /** array of keys */\n data: PColumnKey[];\n /** length of partition key */\n keyLength: number;\n};\n\nconst removeIndexSuffix = (keyStr: string): { baseKey: string; type: 'index' | 'values' } => {\n if (keyStr.endsWith('.index')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 6), type: 'index' };\n } else if (keyStr.endsWith('.values')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 7), type: 'values' };\n } else {\n throw new Error(`key must ends on .index/.values for binary p-column, got: ${keyStr}`);\n }\n};\n\n// @TODO define a class with various resource map operations\n/** Returns a list of all partition keys appeared in the p-column */\nexport function getPartitionKeysList(\n acc: TreeNodeAccessor | undefined,\n): PColumnKeyList | undefined {\n if (!acc) return undefined;\n\n const rt = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n const data: PColumnKey[] = [];\n\n let keyLength = 0;\n // @TODO validate meta shape\n switch (rt) {\n case RT_RESOURCE_MAP:\n keyLength = meta['keyLength'];\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n keyLength = meta['partitionKeyLength'] + meta['keyLength'];\n break;\n\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n case RT_PARQUET_PARTITIONED:\n keyLength = meta['partitionKeyLength'];\n break;\n\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n case RT_PARQUET_SUPER_PARTITIONED:\n keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];\n break;\n }\n\n switch (rt) {\n case RT_RESOURCE_MAP:\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n case RT_PARQUET_PARTITIONED:\n for (let keyStr of acc.listInputFields()) {\n if (rt === RT_BINARY_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n case RT_PARQUET_SUPER_PARTITIONED:\n for (const supKeyStr of acc.listInputFields()) {\n const keyPrefix = [...JSON.parse(supKeyStr)] as PColumnKey;\n\n const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (value !== undefined) {\n for (let keyStr of value.listInputFields()) {\n if (rt === RT_BINARY_SUPER_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n }\n }\n break;\n }\n\n return { data, keyLength };\n}\n\nfunction getUniquePartitionKeysForDataEntries(list: DataInfoEntries<unknown>): (string | number)[][] {\n if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned' && list.type !== 'ParquetPartitioned')\n throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);\n\n const { parts, partitionKeyLength } = list;\n\n const result: Set<string | number>[] = [];\n for (let i = 0; i < partitionKeyLength; ++i) {\n result.push(new Set());\n }\n\n for (const part of parts) {\n const key = part.key;\n if (key.length !== partitionKeyLength) {\n throw new Error(\n `Key length (${key.length}) does not match partition length (${partitionKeyLength}) for key: ${JSON.stringify(\n key,\n )}`,\n );\n }\n for (let i = 0; i < partitionKeyLength; ++i) {\n result[i].add(key[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown>): (string | number)[][];\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | TreeNodeAccessor | undefined): (string | number)[][] | undefined;\nexport function getUniquePartitionKeys(\n acc: TreeNodeAccessor | DataInfoEntries<unknown> | undefined,\n): (string | number)[][] | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc))\n return getUniquePartitionKeysForDataEntries(acc);\n\n const list = getPartitionKeysList(acc);\n if (!list) return undefined;\n\n const { data, keyLength } = list;\n\n const result: Set<string | number>[] = [];\n\n for (let i = 0; i < keyLength; ++i) {\n result.push(new Set());\n }\n\n for (const l of data) {\n if (l.length !== keyLength) {\n throw new Error('key length does not match partition length');\n }\n for (let i = 0; i < keyLength; ++i) {\n result[i].add(l[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/**\n * Parses the PColumn data from a TreeNodeAccessor into a DataInfoEntries structure.\n * Returns undefined if any required data is missing.\n * Throws error on validation failures.\n *\n * @param acc - The TreeNodeAccessor containing PColumn data\n * @param keyPrefix - Optional key prefix for recursive calls\n * @returns DataInfoEntries representation of the PColumn data, or undefined if incomplete\n */\nexport function parsePColumnData(\n acc: TreeNodeAccessor | undefined,\n keyPrefix: PColumnKey = [],\n): PartitionedDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (!acc.getIsReadyOrError()) return undefined;\n\n const resourceType = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n\n // Prevent recursive super-partitioned resources\n if (keyPrefix.length > 0\n && (resourceType === RT_JSON_SUPER_PARTITIONED\n || resourceType === RT_BINARY_SUPER_PARTITIONED\n || resourceType === RT_PARQUET_SUPER_PARTITIONED)) {\n throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);\n }\n\n switch (resourceType) {\n case RT_RESOURCE_MAP:\n case RT_RESOURCE_MAP_PARTITIONED:\n throw new Error(`Only data columns are supported, got: ${resourceType}`);\n\n case RT_JSON_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(keyStr)];\n parts.push({ key, value });\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n const baseKeys = new Map<string, { index?: TreeNodeAccessor; values?: TreeNodeAccessor }>();\n\n // Group fields by base key (without .index/.values suffix)\n for (const keyStr of acc.listInputFields()) {\n const suffix = removeIndexSuffix(keyStr);\n\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n let entry = baseKeys.get(suffix.baseKey);\n if (!entry) {\n entry = {};\n baseKeys.set(suffix.baseKey, entry);\n }\n\n if (suffix.type === 'index') {\n entry.index = value;\n } else {\n entry.values = value;\n }\n }\n\n // Process complete binary chunks only\n for (const [baseKeyStr, entry] of baseKeys.entries()) {\n if (!entry.index || !entry.values) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(baseKeyStr)];\n parts.push({\n key,\n value: {\n index: entry.index,\n values: entry.values,\n },\n });\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_PARQUET_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(keyStr)];\n parts.push({ key, value });\n }\n\n return {\n type: 'ParquetPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_JSON_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_JSON_PARTITIONED) {\n throw new Error(`Expected ${RT_JSON_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'JsonPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_BINARY_PARTITIONED) {\n throw new Error(`Expected ${RT_BINARY_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'BinaryPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n case RT_PARQUET_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_PARQUET_PARTITIONED) {\n throw new Error(`Expected ${RT_PARQUET_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'ParquetPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'ParquetPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n default:\n throw new Error(`Unknown resource type: ${resourceType}`);\n }\n}\n\n/**\n * Converts or parses the input into DataInfoEntries format.\n\n * @param acc - The input data, which can be TreeNodeAccessor, DataInfoEntries, DataInfo, or undefined.\n * @returns The data in DataInfoEntries format, or undefined if the input was undefined or data is not ready.\n */\nexport function convertOrParsePColumnData(acc: TreeNodeAccessor | DataInfoEntries<TreeNodeAccessor> | DataInfo<TreeNodeAccessor> | undefined):\nDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc)) return acc;\n if (isDataInfo(acc)) return dataInfoToEntries(acc);\n if (acc instanceof TreeNodeAccessor) return parsePColumnData(acc);\n\n throw new Error(`Unexpected input type: ${typeof acc}`);\n}\n"],"names":["isDataInfoEntries","isDataInfo","dataInfoToEnt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,CAAC;AAAE,QAAA,OAAOC,+BAAiB,CAAC,GAAG,CAAC;IAClD,IAAI,GAAG,YAAYC,yBAAgB;AAAE,QAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;IAEjE,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,OAAO,GAAG,CAAA,CAAE,CAAC;AACzD;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { DataInfo } from '@milaboratories/pl-model-common';
|
|
2
|
-
import { type
|
|
1
|
+
import type { DataInfo, PartitionedDataInfoEntries } from '@milaboratories/pl-model-common';
|
|
2
|
+
import { type DataInfoEntries, type PColumnKey } from '@milaboratories/pl-model-common';
|
|
3
3
|
import { TreeNodeAccessor } from '../accessor';
|
|
4
4
|
export declare const RT_RESOURCE_MAP: string;
|
|
5
5
|
export declare const RT_RESOURCE_MAP_PARTITIONED: string;
|
|
6
6
|
export declare const RT_JSON_PARTITIONED: string;
|
|
7
7
|
export declare const RT_BINARY_PARTITIONED: string;
|
|
8
|
+
export declare const RT_PARQUET_PARTITIONED: string;
|
|
8
9
|
export declare const RT_JSON_SUPER_PARTITIONED: string;
|
|
9
10
|
export declare const RT_BINARY_SUPER_PARTITIONED: string;
|
|
11
|
+
export declare const RT_PARQUET_SUPER_PARTITIONED: string;
|
|
10
12
|
export type PColumnResourceMapEntry<T> = {
|
|
11
13
|
key: PColumnKey;
|
|
12
14
|
value: T;
|
|
@@ -37,7 +39,7 @@ export declare function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | T
|
|
|
37
39
|
* @param keyPrefix - Optional key prefix for recursive calls
|
|
38
40
|
* @returns DataInfoEntries representation of the PColumn data, or undefined if incomplete
|
|
39
41
|
*/
|
|
40
|
-
export declare function parsePColumnData(acc: TreeNodeAccessor | undefined, keyPrefix?: PColumnKey):
|
|
42
|
+
export declare function parsePColumnData(acc: TreeNodeAccessor | undefined, keyPrefix?: PColumnKey): PartitionedDataInfoEntries<TreeNodeAccessor> | undefined;
|
|
41
43
|
/**
|
|
42
44
|
* Converts or parses the input into DataInfoEntries format.
|
|
43
45
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pcolumn_data.d.ts","sourceRoot":"","sources":["../../../src/render/util/pcolumn_data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"pcolumn_data.d.ts","sourceRoot":"","sources":["../../../src/render/util/pcolumn_data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAKL,KAAK,eAAe,EAEpB,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,eAAe,QAA6B,CAAC;AAC1D,eAAO,MAAM,2BAA2B,QAAyC,CAAC;AAElF,eAAO,MAAM,mBAAmB,QAAiC,CAAC;AAClE,eAAO,MAAM,qBAAqB,QAAmC,CAAC;AACtE,eAAO,MAAM,sBAAsB,QAAoC,CAAC;AAGxE,eAAO,MAAM,yBAAyB,QAAqC,CAAC;AAC5E,eAAO,MAAM,2BAA2B,QAAuC,CAAC;AAChF,eAAO,MAAM,4BAA4B,QAAwC,CAAC;AAElF,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IACvC,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;CACpC,CAAC;AA8CF,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,cAAc,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,CAAC,GAAG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+6,11 @@ const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';
|
|
|
6
6
|
const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';
|
|
7
7
|
const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';
|
|
8
8
|
const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';
|
|
9
|
+
const RT_PARQUET_PARTITIONED = PCD_PREFIX + 'ParquetPartitioned';
|
|
9
10
|
const PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';
|
|
10
11
|
const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';
|
|
11
12
|
const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';
|
|
13
|
+
const RT_PARQUET_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'ParquetPartitioned';
|
|
12
14
|
function populateResourceMapData(acc, resourceParser, data, keyPrefix = [], addEntriesWithNoData) {
|
|
13
15
|
if (acc === undefined)
|
|
14
16
|
return false;
|
|
@@ -79,10 +81,12 @@ function getPartitionKeysList(acc) {
|
|
|
79
81
|
break;
|
|
80
82
|
case RT_JSON_PARTITIONED:
|
|
81
83
|
case RT_BINARY_PARTITIONED:
|
|
84
|
+
case RT_PARQUET_PARTITIONED:
|
|
82
85
|
keyLength = meta['partitionKeyLength'];
|
|
83
86
|
break;
|
|
84
87
|
case RT_BINARY_SUPER_PARTITIONED:
|
|
85
88
|
case RT_JSON_SUPER_PARTITIONED:
|
|
89
|
+
case RT_PARQUET_SUPER_PARTITIONED:
|
|
86
90
|
keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];
|
|
87
91
|
break;
|
|
88
92
|
}
|
|
@@ -90,6 +94,7 @@ function getPartitionKeysList(acc) {
|
|
|
90
94
|
case RT_RESOURCE_MAP:
|
|
91
95
|
case RT_JSON_PARTITIONED:
|
|
92
96
|
case RT_BINARY_PARTITIONED:
|
|
97
|
+
case RT_PARQUET_PARTITIONED:
|
|
93
98
|
for (let keyStr of acc.listInputFields()) {
|
|
94
99
|
if (rt === RT_BINARY_PARTITIONED) {
|
|
95
100
|
keyStr = removeIndexSuffix(keyStr).baseKey;
|
|
@@ -101,6 +106,7 @@ function getPartitionKeysList(acc) {
|
|
|
101
106
|
case RT_RESOURCE_MAP_PARTITIONED:
|
|
102
107
|
case RT_BINARY_SUPER_PARTITIONED:
|
|
103
108
|
case RT_JSON_SUPER_PARTITIONED:
|
|
109
|
+
case RT_PARQUET_SUPER_PARTITIONED:
|
|
104
110
|
for (const supKeyStr of acc.listInputFields()) {
|
|
105
111
|
const keyPrefix = [...JSON.parse(supKeyStr)];
|
|
106
112
|
const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });
|
|
@@ -119,7 +125,7 @@ function getPartitionKeysList(acc) {
|
|
|
119
125
|
return { data, keyLength };
|
|
120
126
|
}
|
|
121
127
|
function getUniquePartitionKeysForDataEntries(list) {
|
|
122
|
-
if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned')
|
|
128
|
+
if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned' && list.type !== 'ParquetPartitioned')
|
|
123
129
|
throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);
|
|
124
130
|
const { parts, partitionKeyLength } = list;
|
|
125
131
|
const result = [];
|
|
@@ -178,7 +184,9 @@ function parsePColumnData(acc, keyPrefix = []) {
|
|
|
178
184
|
const meta = acc.getDataAsJson();
|
|
179
185
|
// Prevent recursive super-partitioned resources
|
|
180
186
|
if (keyPrefix.length > 0
|
|
181
|
-
&& (resourceType === RT_JSON_SUPER_PARTITIONED
|
|
187
|
+
&& (resourceType === RT_JSON_SUPER_PARTITIONED
|
|
188
|
+
|| resourceType === RT_BINARY_SUPER_PARTITIONED
|
|
189
|
+
|| resourceType === RT_PARQUET_SUPER_PARTITIONED)) {
|
|
182
190
|
throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);
|
|
183
191
|
}
|
|
184
192
|
switch (resourceType) {
|
|
@@ -246,6 +254,24 @@ function parsePColumnData(acc, keyPrefix = []) {
|
|
|
246
254
|
parts,
|
|
247
255
|
};
|
|
248
256
|
}
|
|
257
|
+
case RT_PARQUET_PARTITIONED: {
|
|
258
|
+
if (typeof meta?.partitionKeyLength !== 'number') {
|
|
259
|
+
throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);
|
|
260
|
+
}
|
|
261
|
+
const parts = [];
|
|
262
|
+
for (const keyStr of acc.listInputFields()) {
|
|
263
|
+
const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });
|
|
264
|
+
if (value === undefined)
|
|
265
|
+
return undefined;
|
|
266
|
+
const key = [...keyPrefix, ...JSON.parse(keyStr)];
|
|
267
|
+
parts.push({ key, value });
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
type: 'ParquetPartitioned',
|
|
271
|
+
partitionKeyLength: meta.partitionKeyLength,
|
|
272
|
+
parts,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
249
275
|
case RT_JSON_SUPER_PARTITIONED: {
|
|
250
276
|
if (typeof meta?.superPartitionKeyLength !== 'number'
|
|
251
277
|
|| typeof meta?.partitionKeyLength !== 'number') {
|
|
@@ -304,6 +330,35 @@ function parsePColumnData(acc, keyPrefix = []) {
|
|
|
304
330
|
parts,
|
|
305
331
|
};
|
|
306
332
|
}
|
|
333
|
+
case RT_PARQUET_SUPER_PARTITIONED: {
|
|
334
|
+
if (typeof meta?.superPartitionKeyLength !== 'number'
|
|
335
|
+
|| typeof meta?.partitionKeyLength !== 'number') {
|
|
336
|
+
throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);
|
|
337
|
+
}
|
|
338
|
+
const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;
|
|
339
|
+
const parts = [];
|
|
340
|
+
// Process all super partitions
|
|
341
|
+
for (const supKeyStr of acc.listInputFields()) {
|
|
342
|
+
const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });
|
|
343
|
+
if (superPartition === undefined)
|
|
344
|
+
return undefined;
|
|
345
|
+
// Validate inner type
|
|
346
|
+
if (superPartition.resourceType.name !== RT_PARQUET_PARTITIONED) {
|
|
347
|
+
throw new Error(`Expected ${RT_PARQUET_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);
|
|
348
|
+
}
|
|
349
|
+
const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr));
|
|
350
|
+
if (innerResult === undefined)
|
|
351
|
+
return undefined;
|
|
352
|
+
if (innerResult.type !== 'ParquetPartitioned')
|
|
353
|
+
throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);
|
|
354
|
+
parts.push(...innerResult.parts);
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
type: 'ParquetPartitioned',
|
|
358
|
+
partitionKeyLength: totalKeyLength,
|
|
359
|
+
parts,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
307
362
|
default:
|
|
308
363
|
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
309
364
|
}
|
|
@@ -326,5 +381,5 @@ function convertOrParsePColumnData(acc) {
|
|
|
326
381
|
throw new Error(`Unexpected input type: ${typeof acc}`);
|
|
327
382
|
}
|
|
328
383
|
|
|
329
|
-
export { RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, convertOrParsePColumnData, getPartitionKeysList, getUniquePartitionKeys, parsePColumnData, parseResourceMap };
|
|
384
|
+
export { RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, convertOrParsePColumnData, getPartitionKeysList, getUniquePartitionKeys, parsePColumnData, parseResourceMap };
|
|
330
385
|
//# sourceMappingURL=pcolumn_data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pcolumn_data.js","sources":["../../../src/render/util/pcolumn_data.ts"],"sourcesContent":["import type {\n DataInfo } from '@milaboratories/pl-model-common';\nimport {\n dataInfoToEntries,\n isDataInfo,\n isDataInfoEntries,\n type BinaryChunk,\n type BinaryPartitionedDataInfoEntries,\n type DataInfoEntries,\n type JsonPartitionedDataInfoEntries,\n type PColumnDataEntry,\n type PColumnKey,\n} from '@milaboratories/pl-model-common';\nimport { TreeNodeAccessor } from '../accessor';\n\nconst PCD_PREFIX = 'PColumnData/';\n\nexport const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';\nexport const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';\n\nexport const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';\n\nconst PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';\nexport const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';\n\nexport type PColumnResourceMapEntry<T> = {\n key: PColumnKey;\n value: T;\n};\n\nexport type PColumnResourceMapData<T> = {\n isComplete: boolean;\n data: PColumnResourceMapEntry<T>[];\n};\n\nfunction populateResourceMapData<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n data: PColumnResourceMapEntry<T | undefined>[],\n keyPrefix: PColumnKey = [],\n addEntriesWithNoData: boolean,\n): boolean {\n if (acc === undefined) return false;\n switch (acc.resourceType.name) {\n case RT_RESOURCE_MAP: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const converted = value === undefined ? undefined : resourceParser(value);\n if (converted === undefined) isComplete = false;\n if (converted !== undefined || addEntriesWithNoData) data.push({ key, value: converted });\n }\n return isComplete;\n }\n case RT_RESOURCE_MAP_PARTITIONED: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) isComplete = false;\n else {\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const populateResult = populateResourceMapData(\n value,\n resourceParser,\n data,\n key,\n addEntriesWithNoData,\n );\n isComplete = isComplete && populateResult;\n }\n }\n return isComplete;\n }\n default:\n throw new Error(`Unknown resource type: ${acc.resourceType.name}`);\n }\n}\n\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: false\n): PColumnResourceMapData<NonNullable<T>>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: true\n): PColumnResourceMapData<T | undefined>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: boolean = false,\n): PColumnResourceMapData<T | undefined> {\n const data: PColumnResourceMapEntry<T | undefined>[] = [];\n const isComplete = populateResourceMapData(acc, resourceParser, data, [], addEntriesWithNoData);\n return { isComplete, data };\n}\n\nexport type PColumnKeyList = {\n /** array of keys */\n data: PColumnKey[];\n /** length of partition key */\n keyLength: number;\n};\n\nconst removeIndexSuffix = (keyStr: string): { baseKey: string; type: 'index' | 'values' } => {\n if (keyStr.endsWith('.index')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 6), type: 'index' };\n } else if (keyStr.endsWith('.values')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 7), type: 'values' };\n } else {\n throw new Error(`key must ends on .index/.values for binary p-column, got: ${keyStr}`);\n }\n};\n\n// @TODO define a class with various resource map operations\n/** Returns a list of all partition keys appeared in the p-column */\nexport function getPartitionKeysList(\n acc: TreeNodeAccessor | undefined,\n): PColumnKeyList | undefined {\n if (!acc) return undefined;\n\n const rt = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n const data: PColumnKey[] = [];\n\n let keyLength = 0;\n // @TODO validate meta shape\n switch (rt) {\n case RT_RESOURCE_MAP:\n keyLength = meta['keyLength'];\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n keyLength = meta['partitionKeyLength'] + meta['keyLength'];\n break;\n\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n keyLength = meta['partitionKeyLength'];\n break;\n\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];\n break;\n }\n\n switch (rt) {\n case RT_RESOURCE_MAP:\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n for (let keyStr of acc.listInputFields()) {\n if (rt === RT_BINARY_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n for (const supKeyStr of acc.listInputFields()) {\n const keyPrefix = [...JSON.parse(supKeyStr)] as PColumnKey;\n\n const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (value !== undefined) {\n for (let keyStr of value.listInputFields()) {\n if (rt === RT_BINARY_SUPER_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n }\n }\n break;\n }\n\n return { data, keyLength };\n}\n\nfunction getUniquePartitionKeysForDataEntries(list: DataInfoEntries<unknown>): (string | number)[][] {\n if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned')\n throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);\n\n const { parts, partitionKeyLength } = list;\n\n const result: Set<string | number>[] = [];\n for (let i = 0; i < partitionKeyLength; ++i) {\n result.push(new Set());\n }\n\n for (const part of parts) {\n const key = part.key;\n if (key.length !== partitionKeyLength) {\n throw new Error(\n `Key length (${key.length}) does not match partition length (${partitionKeyLength}) for key: ${JSON.stringify(\n key,\n )}`,\n );\n }\n for (let i = 0; i < partitionKeyLength; ++i) {\n result[i].add(key[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown>): (string | number)[][];\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | TreeNodeAccessor | undefined): (string | number)[][] | undefined;\nexport function getUniquePartitionKeys(\n acc: TreeNodeAccessor | DataInfoEntries<unknown> | undefined,\n): (string | number)[][] | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc))\n return getUniquePartitionKeysForDataEntries(acc);\n\n const list = getPartitionKeysList(acc);\n if (!list) return undefined;\n\n const { data, keyLength } = list;\n\n const result: Set<string | number>[] = [];\n\n for (let i = 0; i < keyLength; ++i) {\n result.push(new Set());\n }\n\n for (const l of data) {\n if (l.length !== keyLength) {\n throw new Error('key length does not match partition length');\n }\n for (let i = 0; i < keyLength; ++i) {\n result[i].add(l[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/**\n * Parses the PColumn data from a TreeNodeAccessor into a DataInfoEntries structure.\n * Returns undefined if any required data is missing.\n * Throws error on validation failures.\n *\n * @param acc - The TreeNodeAccessor containing PColumn data\n * @param keyPrefix - Optional key prefix for recursive calls\n * @returns DataInfoEntries representation of the PColumn data, or undefined if incomplete\n */\nexport function parsePColumnData(\n acc: TreeNodeAccessor | undefined,\n keyPrefix: PColumnKey = [],\n): JsonPartitionedDataInfoEntries<TreeNodeAccessor> | BinaryPartitionedDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (!acc.getIsReadyOrError()) return undefined;\n\n const resourceType = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n\n // Prevent recursive super-partitioned resources\n if (keyPrefix.length > 0\n && (resourceType === RT_JSON_SUPER_PARTITIONED || resourceType === RT_BINARY_SUPER_PARTITIONED)) {\n throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);\n }\n\n switch (resourceType) {\n case RT_RESOURCE_MAP:\n case RT_RESOURCE_MAP_PARTITIONED:\n throw new Error(`Only data columns are supported, got: ${resourceType}`);\n\n case RT_JSON_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(keyStr)];\n parts.push({ key, value });\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n const baseKeys = new Map<string, { index?: TreeNodeAccessor; values?: TreeNodeAccessor }>();\n\n // Group fields by base key (without .index/.values suffix)\n for (const keyStr of acc.listInputFields()) {\n const suffix = removeIndexSuffix(keyStr);\n\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n let entry = baseKeys.get(suffix.baseKey);\n if (!entry) {\n entry = {};\n baseKeys.set(suffix.baseKey, entry);\n }\n\n if (suffix.type === 'index') {\n entry.index = value;\n } else {\n entry.values = value;\n }\n }\n\n // Process complete binary chunks only\n for (const [baseKeyStr, entry] of baseKeys.entries()) {\n if (!entry.index || !entry.values) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(baseKeyStr)];\n parts.push({\n key,\n value: {\n index: entry.index,\n values: entry.values,\n },\n });\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_JSON_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_JSON_PARTITIONED) {\n throw new Error(`Expected ${RT_JSON_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'JsonPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_BINARY_PARTITIONED) {\n throw new Error(`Expected ${RT_BINARY_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'BinaryPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n default:\n throw new Error(`Unknown resource type: ${resourceType}`);\n }\n}\n\n/**\n * Converts or parses the input into DataInfoEntries format.\n\n * @param acc - The input data, which can be TreeNodeAccessor, DataInfoEntries, DataInfo, or undefined.\n * @returns The data in DataInfoEntries format, or undefined if the input was undefined or data is not ready.\n */\nexport function convertOrParsePColumnData(acc: TreeNodeAccessor | DataInfoEntries<TreeNodeAccessor> | DataInfo<TreeNodeAccessor> | undefined):\nDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc)) return acc;\n if (isDataInfo(acc)) return dataInfoToEntries(acc);\n if (acc instanceof TreeNodeAccessor) return parsePColumnData(acc);\n\n throw new Error(`Unexpected input type: ${typeof acc}`);\n}\n"],"names":[],"mappings":";;;AAeA,MAAM,UAAU,GAAG,cAAc;AAE1B,MAAM,eAAe,GAAG,UAAU,GAAG;AACrC,MAAM,2BAA2B,GAAG,UAAU,GAAG;AAEjD,MAAM,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AAAE,QAAA,OAAO,GAAG;IACtC,IAAI,UAAU,CAAC,GAAG,CAAC;AAAE,QAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;IAClD,IAAI,GAAG,YAAY,gBAAgB;AAAE,QAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;IAEjE,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,OAAO,GAAG,CAAA,CAAE,CAAC;AACzD;;;;"}
|
|
1
|
+
{"version":3,"file":"pcolumn_data.js","sources":["../../../src/render/util/pcolumn_data.ts"],"sourcesContent":["import type {\n DataInfo,\n PartitionedDataInfoEntries,\n} from '@milaboratories/pl-model-common';\nimport {\n dataInfoToEntries,\n isDataInfo,\n isDataInfoEntries,\n type BinaryChunk,\n type DataInfoEntries,\n type PColumnDataEntry,\n type PColumnKey,\n} from '@milaboratories/pl-model-common';\nimport { TreeNodeAccessor } from '../accessor';\n\nconst PCD_PREFIX = 'PColumnData/';\n\nexport const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';\nexport const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';\n\nexport const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';\nexport const RT_PARQUET_PARTITIONED = PCD_PREFIX + 'ParquetPartitioned';\n\nconst PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';\nexport const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';\nexport const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';\nexport const RT_PARQUET_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'ParquetPartitioned';\n\nexport type PColumnResourceMapEntry<T> = {\n key: PColumnKey;\n value: T;\n};\n\nexport type PColumnResourceMapData<T> = {\n isComplete: boolean;\n data: PColumnResourceMapEntry<T>[];\n};\n\nfunction populateResourceMapData<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n data: PColumnResourceMapEntry<T | undefined>[],\n keyPrefix: PColumnKey = [],\n addEntriesWithNoData: boolean,\n): boolean {\n if (acc === undefined) return false;\n switch (acc.resourceType.name) {\n case RT_RESOURCE_MAP: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const converted = value === undefined ? undefined : resourceParser(value);\n if (converted === undefined) isComplete = false;\n if (converted !== undefined || addEntriesWithNoData) data.push({ key, value: converted });\n }\n return isComplete;\n }\n case RT_RESOURCE_MAP_PARTITIONED: {\n let isComplete = acc.getInputsLocked();\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) isComplete = false;\n else {\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n const populateResult = populateResourceMapData(\n value,\n resourceParser,\n data,\n key,\n addEntriesWithNoData,\n );\n isComplete = isComplete && populateResult;\n }\n }\n return isComplete;\n }\n default:\n throw new Error(`Unknown resource type: ${acc.resourceType.name}`);\n }\n}\n\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: false\n): PColumnResourceMapData<NonNullable<T>>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: true\n): PColumnResourceMapData<T | undefined>;\nexport function parseResourceMap<T>(\n acc: TreeNodeAccessor | undefined,\n resourceParser: (acc: TreeNodeAccessor) => T | undefined,\n addEntriesWithNoData: boolean = false,\n): PColumnResourceMapData<T | undefined> {\n const data: PColumnResourceMapEntry<T | undefined>[] = [];\n const isComplete = populateResourceMapData(acc, resourceParser, data, [], addEntriesWithNoData);\n return { isComplete, data };\n}\n\nexport type PColumnKeyList = {\n /** array of keys */\n data: PColumnKey[];\n /** length of partition key */\n keyLength: number;\n};\n\nconst removeIndexSuffix = (keyStr: string): { baseKey: string; type: 'index' | 'values' } => {\n if (keyStr.endsWith('.index')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 6), type: 'index' };\n } else if (keyStr.endsWith('.values')) {\n return { baseKey: keyStr.substring(0, keyStr.length - 7), type: 'values' };\n } else {\n throw new Error(`key must ends on .index/.values for binary p-column, got: ${keyStr}`);\n }\n};\n\n// @TODO define a class with various resource map operations\n/** Returns a list of all partition keys appeared in the p-column */\nexport function getPartitionKeysList(\n acc: TreeNodeAccessor | undefined,\n): PColumnKeyList | undefined {\n if (!acc) return undefined;\n\n const rt = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n const data: PColumnKey[] = [];\n\n let keyLength = 0;\n // @TODO validate meta shape\n switch (rt) {\n case RT_RESOURCE_MAP:\n keyLength = meta['keyLength'];\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n keyLength = meta['partitionKeyLength'] + meta['keyLength'];\n break;\n\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n case RT_PARQUET_PARTITIONED:\n keyLength = meta['partitionKeyLength'];\n break;\n\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n case RT_PARQUET_SUPER_PARTITIONED:\n keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];\n break;\n }\n\n switch (rt) {\n case RT_RESOURCE_MAP:\n case RT_JSON_PARTITIONED:\n case RT_BINARY_PARTITIONED:\n case RT_PARQUET_PARTITIONED:\n for (let keyStr of acc.listInputFields()) {\n if (rt === RT_BINARY_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n\n break;\n\n case RT_RESOURCE_MAP_PARTITIONED:\n case RT_BINARY_SUPER_PARTITIONED:\n case RT_JSON_SUPER_PARTITIONED:\n case RT_PARQUET_SUPER_PARTITIONED:\n for (const supKeyStr of acc.listInputFields()) {\n const keyPrefix = [...JSON.parse(supKeyStr)] as PColumnKey;\n\n const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (value !== undefined) {\n for (let keyStr of value.listInputFields()) {\n if (rt === RT_BINARY_SUPER_PARTITIONED) {\n keyStr = removeIndexSuffix(keyStr).baseKey;\n }\n const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;\n data.push(key);\n }\n }\n }\n break;\n }\n\n return { data, keyLength };\n}\n\nfunction getUniquePartitionKeysForDataEntries(list: DataInfoEntries<unknown>): (string | number)[][] {\n if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned' && list.type !== 'ParquetPartitioned')\n throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);\n\n const { parts, partitionKeyLength } = list;\n\n const result: Set<string | number>[] = [];\n for (let i = 0; i < partitionKeyLength; ++i) {\n result.push(new Set());\n }\n\n for (const part of parts) {\n const key = part.key;\n if (key.length !== partitionKeyLength) {\n throw new Error(\n `Key length (${key.length}) does not match partition length (${partitionKeyLength}) for key: ${JSON.stringify(\n key,\n )}`,\n );\n }\n for (let i = 0; i < partitionKeyLength; ++i) {\n result[i].add(key[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown>): (string | number)[][];\nexport function getUniquePartitionKeys(acc: DataInfoEntries<unknown> | TreeNodeAccessor | undefined): (string | number)[][] | undefined;\nexport function getUniquePartitionKeys(\n acc: TreeNodeAccessor | DataInfoEntries<unknown> | undefined,\n): (string | number)[][] | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc))\n return getUniquePartitionKeysForDataEntries(acc);\n\n const list = getPartitionKeysList(acc);\n if (!list) return undefined;\n\n const { data, keyLength } = list;\n\n const result: Set<string | number>[] = [];\n\n for (let i = 0; i < keyLength; ++i) {\n result.push(new Set());\n }\n\n for (const l of data) {\n if (l.length !== keyLength) {\n throw new Error('key length does not match partition length');\n }\n for (let i = 0; i < keyLength; ++i) {\n result[i].add(l[i]);\n }\n }\n\n return result.map((s) => Array.from(s.values()));\n}\n\n/**\n * Parses the PColumn data from a TreeNodeAccessor into a DataInfoEntries structure.\n * Returns undefined if any required data is missing.\n * Throws error on validation failures.\n *\n * @param acc - The TreeNodeAccessor containing PColumn data\n * @param keyPrefix - Optional key prefix for recursive calls\n * @returns DataInfoEntries representation of the PColumn data, or undefined if incomplete\n */\nexport function parsePColumnData(\n acc: TreeNodeAccessor | undefined,\n keyPrefix: PColumnKey = [],\n): PartitionedDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (!acc.getIsReadyOrError()) return undefined;\n\n const resourceType = acc.resourceType.name;\n const meta = acc.getDataAsJson<Record<string, number>>();\n\n // Prevent recursive super-partitioned resources\n if (keyPrefix.length > 0\n && (resourceType === RT_JSON_SUPER_PARTITIONED\n || resourceType === RT_BINARY_SUPER_PARTITIONED\n || resourceType === RT_PARQUET_SUPER_PARTITIONED)) {\n throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);\n }\n\n switch (resourceType) {\n case RT_RESOURCE_MAP:\n case RT_RESOURCE_MAP_PARTITIONED:\n throw new Error(`Only data columns are supported, got: ${resourceType}`);\n\n case RT_JSON_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(keyStr)];\n parts.push({ key, value });\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n const baseKeys = new Map<string, { index?: TreeNodeAccessor; values?: TreeNodeAccessor }>();\n\n // Group fields by base key (without .index/.values suffix)\n for (const keyStr of acc.listInputFields()) {\n const suffix = removeIndexSuffix(keyStr);\n\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n let entry = baseKeys.get(suffix.baseKey);\n if (!entry) {\n entry = {};\n baseKeys.set(suffix.baseKey, entry);\n }\n\n if (suffix.type === 'index') {\n entry.index = value;\n } else {\n entry.values = value;\n }\n }\n\n // Process complete binary chunks only\n for (const [baseKeyStr, entry] of baseKeys.entries()) {\n if (!entry.index || !entry.values) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(baseKeyStr)];\n parts.push({\n key,\n value: {\n index: entry.index,\n values: entry.values,\n },\n });\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_PARQUET_PARTITIONED: {\n if (typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n for (const keyStr of acc.listInputFields()) {\n const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });\n if (value === undefined) return undefined;\n\n const key = [...keyPrefix, ...JSON.parse(keyStr)];\n parts.push({ key, value });\n }\n\n return {\n type: 'ParquetPartitioned',\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n }\n\n case RT_JSON_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_JSON_PARTITIONED) {\n throw new Error(`Expected ${RT_JSON_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'JsonPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n case RT_BINARY_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<BinaryChunk<TreeNodeAccessor>>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_BINARY_PARTITIONED) {\n throw new Error(`Expected ${RT_BINARY_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'BinaryPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n case RT_PARQUET_SUPER_PARTITIONED: {\n if (typeof meta?.superPartitionKeyLength !== 'number'\n || typeof meta?.partitionKeyLength !== 'number') {\n throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);\n }\n\n const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;\n const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];\n\n // Process all super partitions\n for (const supKeyStr of acc.listInputFields()) {\n const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });\n if (superPartition === undefined) return undefined;\n\n // Validate inner type\n if (superPartition.resourceType.name !== RT_PARQUET_PARTITIONED) {\n throw new Error(`Expected ${RT_PARQUET_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);\n }\n\n const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);\n\n if (innerResult === undefined) return undefined;\n\n if (innerResult.type !== 'ParquetPartitioned')\n throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);\n\n parts.push(...innerResult.parts);\n }\n\n return {\n type: 'ParquetPartitioned',\n partitionKeyLength: totalKeyLength,\n parts,\n };\n }\n\n default:\n throw new Error(`Unknown resource type: ${resourceType}`);\n }\n}\n\n/**\n * Converts or parses the input into DataInfoEntries format.\n\n * @param acc - The input data, which can be TreeNodeAccessor, DataInfoEntries, DataInfo, or undefined.\n * @returns The data in DataInfoEntries format, or undefined if the input was undefined or data is not ready.\n */\nexport function convertOrParsePColumnData(acc: TreeNodeAccessor | DataInfoEntries<TreeNodeAccessor> | DataInfo<TreeNodeAccessor> | undefined):\nDataInfoEntries<TreeNodeAccessor> | undefined {\n if (acc === undefined) return undefined;\n\n if (isDataInfoEntries(acc)) return acc;\n if (isDataInfo(acc)) return dataInfoToEntries(acc);\n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AG,CAAC;AAAE,QAAA,OAAO,GAAG;IACtC,IAAI,UAAU,CAAC,GAAG,CAAC;AAAE,QAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;IAClD,IAAI,GAAG,YAAY,gBAAgB;AAAE,QAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;IAEjE,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,OAAO,GAAG,CAAA,CAAE,CAAC;AACzD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.44.
|
|
3
|
+
"version": "1.44.14",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"utility-types": "^3.11.0",
|
|
23
23
|
"canonicalize": "~2.1.0",
|
|
24
24
|
"zod": "~3.23.8",
|
|
25
|
-
"@milaboratories/pl-
|
|
26
|
-
"@milaboratories/pl-
|
|
25
|
+
"@milaboratories/pl-model-common": "1.21.3",
|
|
26
|
+
"@milaboratories/pl-error-like": "1.12.5"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "~5.6.3",
|
|
30
30
|
"vitest": "^2.1.9",
|
|
31
31
|
"fast-json-patch": "^3.1.1",
|
|
32
|
-
"@platforma-sdk/eslint-config": "1.1.0",
|
|
33
|
-
"@milaboratories/ts-builder": "1.0.5",
|
|
34
32
|
"@milaboratories/build-configs": "1.0.8",
|
|
35
|
-
"@milaboratories/
|
|
36
|
-
"@milaboratories/
|
|
33
|
+
"@milaboratories/helpers": "1.12.0",
|
|
34
|
+
"@milaboratories/ts-builder": "1.0.5",
|
|
35
|
+
"@platforma-sdk/eslint-config": "1.1.0",
|
|
36
|
+
"@milaboratories/ts-configs": "1.0.6"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"type-check": "ts-builder types --target node",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
DataInfo
|
|
2
|
+
DataInfo,
|
|
3
|
+
PartitionedDataInfoEntries,
|
|
4
|
+
} from '@milaboratories/pl-model-common';
|
|
3
5
|
import {
|
|
4
6
|
dataInfoToEntries,
|
|
5
7
|
isDataInfo,
|
|
6
8
|
isDataInfoEntries,
|
|
7
9
|
type BinaryChunk,
|
|
8
|
-
type BinaryPartitionedDataInfoEntries,
|
|
9
10
|
type DataInfoEntries,
|
|
10
|
-
type JsonPartitionedDataInfoEntries,
|
|
11
11
|
type PColumnDataEntry,
|
|
12
12
|
type PColumnKey,
|
|
13
13
|
} from '@milaboratories/pl-model-common';
|
|
@@ -20,10 +20,12 @@ export const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap
|
|
|
20
20
|
|
|
21
21
|
export const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';
|
|
22
22
|
export const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';
|
|
23
|
+
export const RT_PARQUET_PARTITIONED = PCD_PREFIX + 'ParquetPartitioned';
|
|
23
24
|
|
|
24
25
|
const PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';
|
|
25
26
|
export const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';
|
|
26
27
|
export const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';
|
|
28
|
+
export const RT_PARQUET_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'ParquetPartitioned';
|
|
27
29
|
|
|
28
30
|
export type PColumnResourceMapEntry<T> = {
|
|
29
31
|
key: PColumnKey;
|
|
@@ -140,11 +142,13 @@ export function getPartitionKeysList(
|
|
|
140
142
|
|
|
141
143
|
case RT_JSON_PARTITIONED:
|
|
142
144
|
case RT_BINARY_PARTITIONED:
|
|
145
|
+
case RT_PARQUET_PARTITIONED:
|
|
143
146
|
keyLength = meta['partitionKeyLength'];
|
|
144
147
|
break;
|
|
145
148
|
|
|
146
149
|
case RT_BINARY_SUPER_PARTITIONED:
|
|
147
150
|
case RT_JSON_SUPER_PARTITIONED:
|
|
151
|
+
case RT_PARQUET_SUPER_PARTITIONED:
|
|
148
152
|
keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];
|
|
149
153
|
break;
|
|
150
154
|
}
|
|
@@ -153,6 +157,7 @@ export function getPartitionKeysList(
|
|
|
153
157
|
case RT_RESOURCE_MAP:
|
|
154
158
|
case RT_JSON_PARTITIONED:
|
|
155
159
|
case RT_BINARY_PARTITIONED:
|
|
160
|
+
case RT_PARQUET_PARTITIONED:
|
|
156
161
|
for (let keyStr of acc.listInputFields()) {
|
|
157
162
|
if (rt === RT_BINARY_PARTITIONED) {
|
|
158
163
|
keyStr = removeIndexSuffix(keyStr).baseKey;
|
|
@@ -166,6 +171,7 @@ export function getPartitionKeysList(
|
|
|
166
171
|
case RT_RESOURCE_MAP_PARTITIONED:
|
|
167
172
|
case RT_BINARY_SUPER_PARTITIONED:
|
|
168
173
|
case RT_JSON_SUPER_PARTITIONED:
|
|
174
|
+
case RT_PARQUET_SUPER_PARTITIONED:
|
|
169
175
|
for (const supKeyStr of acc.listInputFields()) {
|
|
170
176
|
const keyPrefix = [...JSON.parse(supKeyStr)] as PColumnKey;
|
|
171
177
|
|
|
@@ -187,7 +193,7 @@ export function getPartitionKeysList(
|
|
|
187
193
|
}
|
|
188
194
|
|
|
189
195
|
function getUniquePartitionKeysForDataEntries(list: DataInfoEntries<unknown>): (string | number)[][] {
|
|
190
|
-
if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned')
|
|
196
|
+
if (list.type !== 'JsonPartitioned' && list.type !== 'BinaryPartitioned' && list.type !== 'ParquetPartitioned')
|
|
191
197
|
throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${list.type}`);
|
|
192
198
|
|
|
193
199
|
const { parts, partitionKeyLength } = list;
|
|
@@ -260,7 +266,7 @@ export function getUniquePartitionKeys(
|
|
|
260
266
|
export function parsePColumnData(
|
|
261
267
|
acc: TreeNodeAccessor | undefined,
|
|
262
268
|
keyPrefix: PColumnKey = [],
|
|
263
|
-
):
|
|
269
|
+
): PartitionedDataInfoEntries<TreeNodeAccessor> | undefined {
|
|
264
270
|
if (acc === undefined) return undefined;
|
|
265
271
|
|
|
266
272
|
if (!acc.getIsReadyOrError()) return undefined;
|
|
@@ -270,7 +276,9 @@ export function parsePColumnData(
|
|
|
270
276
|
|
|
271
277
|
// Prevent recursive super-partitioned resources
|
|
272
278
|
if (keyPrefix.length > 0
|
|
273
|
-
&& (resourceType === RT_JSON_SUPER_PARTITIONED
|
|
279
|
+
&& (resourceType === RT_JSON_SUPER_PARTITIONED
|
|
280
|
+
|| resourceType === RT_BINARY_SUPER_PARTITIONED
|
|
281
|
+
|| resourceType === RT_PARQUET_SUPER_PARTITIONED)) {
|
|
274
282
|
throw new Error(`Unexpected nested super-partitioned resource: ${resourceType}`);
|
|
275
283
|
}
|
|
276
284
|
|
|
@@ -349,6 +357,27 @@ export function parsePColumnData(
|
|
|
349
357
|
};
|
|
350
358
|
}
|
|
351
359
|
|
|
360
|
+
case RT_PARQUET_PARTITIONED: {
|
|
361
|
+
if (typeof meta?.partitionKeyLength !== 'number') {
|
|
362
|
+
throw new Error(`Missing partitionKeyLength in metadata for ${resourceType}`);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];
|
|
366
|
+
for (const keyStr of acc.listInputFields()) {
|
|
367
|
+
const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });
|
|
368
|
+
if (value === undefined) return undefined;
|
|
369
|
+
|
|
370
|
+
const key = [...keyPrefix, ...JSON.parse(keyStr)];
|
|
371
|
+
parts.push({ key, value });
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return {
|
|
375
|
+
type: 'ParquetPartitioned',
|
|
376
|
+
partitionKeyLength: meta.partitionKeyLength,
|
|
377
|
+
parts,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
352
381
|
case RT_JSON_SUPER_PARTITIONED: {
|
|
353
382
|
if (typeof meta?.superPartitionKeyLength !== 'number'
|
|
354
383
|
|| typeof meta?.partitionKeyLength !== 'number') {
|
|
@@ -421,6 +450,42 @@ export function parsePColumnData(
|
|
|
421
450
|
};
|
|
422
451
|
}
|
|
423
452
|
|
|
453
|
+
case RT_PARQUET_SUPER_PARTITIONED: {
|
|
454
|
+
if (typeof meta?.superPartitionKeyLength !== 'number'
|
|
455
|
+
|| typeof meta?.partitionKeyLength !== 'number') {
|
|
456
|
+
throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${resourceType}`);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const totalKeyLength = meta.superPartitionKeyLength + meta.partitionKeyLength;
|
|
460
|
+
const parts: PColumnDataEntry<TreeNodeAccessor>[] = [];
|
|
461
|
+
|
|
462
|
+
// Process all super partitions
|
|
463
|
+
for (const supKeyStr of acc.listInputFields()) {
|
|
464
|
+
const superPartition = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });
|
|
465
|
+
if (superPartition === undefined) return undefined;
|
|
466
|
+
|
|
467
|
+
// Validate inner type
|
|
468
|
+
if (superPartition.resourceType.name !== RT_PARQUET_PARTITIONED) {
|
|
469
|
+
throw new Error(`Expected ${RT_PARQUET_PARTITIONED} inside ${resourceType}, but got ${superPartition.resourceType.name}`);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const innerResult = parsePColumnData(superPartition, JSON.parse(supKeyStr) as PColumnKey);
|
|
473
|
+
|
|
474
|
+
if (innerResult === undefined) return undefined;
|
|
475
|
+
|
|
476
|
+
if (innerResult.type !== 'ParquetPartitioned')
|
|
477
|
+
throw new Error(`Unexpected inner result type for ${resourceType}: ${innerResult.type}`);
|
|
478
|
+
|
|
479
|
+
parts.push(...innerResult.parts);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return {
|
|
483
|
+
type: 'ParquetPartitioned',
|
|
484
|
+
partitionKeyLength: totalKeyLength,
|
|
485
|
+
parts,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
424
489
|
default:
|
|
425
490
|
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
426
491
|
}
|