@loaders.gl/parquet 4.2.0-alpha.3 → 4.2.0-alpha.5
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 +269 -616
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/lib/arrow/convert-columns-to-row-group.js +1 -2
- package/dist/lib/arrow/convert-row-group-to-columns.js +8 -6
- package/dist/lib/arrow/convert-schema-from-parquet.d.ts +3 -3
- package/dist/lib/arrow/convert-schema-from-parquet.d.ts.map +1 -1
- package/dist/lib/arrow/convert-schema-from-parquet.js +71 -82
- package/dist/lib/arrow/convert-schema-to-parquet.d.ts +1 -1
- package/dist/lib/arrow/convert-schema-to-parquet.d.ts.map +1 -1
- package/dist/lib/arrow/convert-schema-to-parquet.js +65 -35
- package/dist/lib/constants.js +15 -2
- package/dist/lib/parsers/get-parquet-schema.d.ts +1 -1
- package/dist/lib/parsers/get-parquet-schema.d.ts.map +1 -1
- package/dist/lib/parsers/get-parquet-schema.js +9 -7
- package/dist/lib/parsers/parse-geoparquet.d.ts +1 -1
- package/dist/lib/parsers/parse-geoparquet.d.ts.map +1 -1
- package/dist/lib/parsers/parse-geoparquet.js +47 -45
- package/dist/lib/parsers/parse-parquet-to-columns.d.ts +1 -1
- package/dist/lib/parsers/parse-parquet-to-columns.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-columns.js +36 -25
- package/dist/lib/parsers/parse-parquet.d.ts +1 -1
- package/dist/lib/parsers/parse-parquet.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet.js +62 -50
- package/dist/lib/wasm/encode-parquet-wasm.d.ts +1 -1
- package/dist/lib/wasm/encode-parquet-wasm.d.ts.map +1 -1
- package/dist/lib/wasm/encode-parquet-wasm.js +49 -12
- package/dist/lib/wasm/load-wasm.js +13 -10
- package/dist/lib/wasm/parse-parquet-wasm.d.ts +1 -1
- package/dist/lib/wasm/parse-parquet-wasm.d.ts.map +1 -1
- package/dist/lib/wasm/parse-parquet-wasm.js +19 -15
- package/dist/parquet-loader.d.ts +1 -1
- package/dist/parquet-loader.d.ts.map +1 -1
- package/dist/parquet-loader.js +78 -65
- package/dist/parquet-wasm-loader.js +25 -28
- package/dist/parquet-wasm-writer.js +19 -23
- package/dist/parquet-writer.js +17 -13
- package/dist/parquetjs/codecs/declare.d.ts +1 -1
- package/dist/parquetjs/codecs/declare.d.ts.map +1 -1
- package/dist/parquetjs/codecs/declare.js +0 -1
- package/dist/parquetjs/codecs/dictionary.js +4 -8
- package/dist/parquetjs/codecs/index.d.ts +3 -3
- package/dist/parquetjs/codecs/index.d.ts.map +1 -1
- package/dist/parquetjs/codecs/index.js +20 -17
- package/dist/parquetjs/codecs/plain.d.ts +2 -2
- package/dist/parquetjs/codecs/plain.d.ts.map +1 -1
- package/dist/parquetjs/codecs/plain.js +166 -162
- package/dist/parquetjs/codecs/rle.d.ts +2 -2
- package/dist/parquetjs/codecs/rle.d.ts.map +1 -1
- package/dist/parquetjs/codecs/rle.js +124 -105
- package/dist/parquetjs/compression.d.ts +1 -1
- package/dist/parquetjs/compression.d.ts.map +1 -1
- package/dist/parquetjs/compression.js +157 -43
- package/dist/parquetjs/encoder/parquet-encoder.d.ts +3 -3
- package/dist/parquetjs/encoder/parquet-encoder.d.ts.map +1 -1
- package/dist/parquetjs/encoder/parquet-encoder.js +406 -275
- package/dist/parquetjs/parquet-thrift/BoundaryOrder.js +12 -7
- package/dist/parquetjs/parquet-thrift/BsonType.js +31 -27
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js +175 -166
- package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js +178 -166
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts +6 -6
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.js +359 -333
- package/dist/parquetjs/parquet-thrift/ColumnOrder.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnOrder.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnOrder.js +73 -68
- package/dist/parquetjs/parquet-thrift/CompressionCodec.js +17 -12
- package/dist/parquetjs/parquet-thrift/ConvertedType.js +31 -26
- package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeader.js +136 -124
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js +198 -181
- package/dist/parquetjs/parquet-thrift/DateType.js +31 -27
- package/dist/parquetjs/parquet-thrift/DecimalType.js +76 -69
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js +93 -86
- package/dist/parquetjs/parquet-thrift/Encoding.js +17 -12
- package/dist/parquetjs/parquet-thrift/EnumType.js +31 -27
- package/dist/parquetjs/parquet-thrift/FieldRepetitionType.js +12 -7
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts +4 -4
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/FileMetaData.js +217 -205
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.js +31 -27
- package/dist/parquetjs/parquet-thrift/IntType.js +76 -69
- package/dist/parquetjs/parquet-thrift/JsonType.js +31 -27
- package/dist/parquetjs/parquet-thrift/KeyValue.js +73 -67
- package/dist/parquetjs/parquet-thrift/ListType.js +31 -27
- package/dist/parquetjs/parquet-thrift/LogicalType.d.ts +13 -13
- package/dist/parquetjs/parquet-thrift/LogicalType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/LogicalType.js +325 -344
- package/dist/parquetjs/parquet-thrift/MapType.js +31 -27
- package/dist/parquetjs/parquet-thrift/MicroSeconds.js +31 -27
- package/dist/parquetjs/parquet-thrift/MilliSeconds.js +31 -27
- package/dist/parquetjs/parquet-thrift/NullType.js +31 -27
- package/dist/parquetjs/parquet-thrift/OffsetIndex.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/OffsetIndex.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/OffsetIndex.js +66 -60
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.js +98 -88
- package/dist/parquetjs/parquet-thrift/PageHeader.d.ts +5 -5
- package/dist/parquetjs/parquet-thrift/PageHeader.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageHeader.js +185 -175
- package/dist/parquetjs/parquet-thrift/PageLocation.js +108 -96
- package/dist/parquetjs/parquet-thrift/PageType.js +13 -8
- package/dist/parquetjs/parquet-thrift/RowGroup.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/RowGroup.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/RowGroup.js +145 -133
- package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts +4 -4
- package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/SchemaElement.js +211 -205
- package/dist/parquetjs/parquet-thrift/SortingColumn.js +98 -88
- package/dist/parquetjs/parquet-thrift/Statistics.js +143 -137
- package/dist/parquetjs/parquet-thrift/StringType.js +31 -27
- package/dist/parquetjs/parquet-thrift/TimeType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/TimeType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/TimeType.js +76 -69
- package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/TimeUnit.js +94 -91
- package/dist/parquetjs/parquet-thrift/TimestampType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/TimestampType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/TimestampType.js +76 -69
- package/dist/parquetjs/parquet-thrift/Type.js +17 -12
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js +31 -27
- package/dist/parquetjs/parquet-thrift/UUIDType.js +31 -27
- package/dist/parquetjs/parquet-thrift/index.d.ts +44 -44
- package/dist/parquetjs/parquet-thrift/index.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/index.js +6 -1
- package/dist/parquetjs/parser/decoders.d.ts +3 -3
- package/dist/parquetjs/parser/decoders.d.ts.map +1 -1
- package/dist/parquetjs/parser/decoders.js +306 -242
- package/dist/parquetjs/parser/parquet-reader.d.ts +3 -3
- package/dist/parquetjs/parser/parquet-reader.d.ts.map +1 -1
- package/dist/parquetjs/parser/parquet-reader.js +179 -157
- package/dist/parquetjs/schema/declare.d.ts +1 -1
- package/dist/parquetjs/schema/declare.d.ts.map +1 -1
- package/dist/parquetjs/schema/declare.js +6 -9
- package/dist/parquetjs/schema/schema.d.ts +1 -1
- package/dist/parquetjs/schema/schema.d.ts.map +1 -1
- package/dist/parquetjs/schema/schema.js +139 -120
- package/dist/parquetjs/schema/shred.d.ts +2 -2
- package/dist/parquetjs/schema/shred.d.ts.map +1 -1
- package/dist/parquetjs/schema/shred.js +301 -204
- package/dist/parquetjs/schema/types.d.ts +1 -1
- package/dist/parquetjs/schema/types.d.ts.map +1 -1
- package/dist/parquetjs/schema/types.js +328 -314
- package/dist/parquetjs/utils/file-utils.js +24 -23
- package/dist/parquetjs/utils/read-utils.d.ts +1 -1
- package/dist/parquetjs/utils/read-utils.d.ts.map +1 -1
- package/dist/parquetjs/utils/read-utils.js +79 -69
- package/dist/polyfills/buffer/buffer-polyfill.browser.js +8 -3
- package/dist/polyfills/buffer/buffer-polyfill.node.js +13 -8
- package/dist/polyfills/buffer/buffer.js +1750 -1367
- package/dist/polyfills/buffer/index.d.ts +3 -3
- package/dist/polyfills/buffer/index.d.ts.map +1 -1
- package/dist/polyfills/buffer/index.js +5 -1
- package/dist/polyfills/buffer/install-buffer-polyfill.js +2 -1
- package/dist/polyfills/util.js +4 -1
- package/dist/workers/parquet-worker.js +3 -1
- package/package.json +15 -13
- package/src/index.ts +1 -1
- package/src/lib/parsers/parse-parquet-to-columns.ts +1 -1
- package/src/lib/parsers/parse-parquet.ts +1 -1
- package/src/parquetjs/encoder/parquet-encoder.ts +2 -2
- package/src/parquetjs/parser/decoders.ts +2 -2
- package/src/parquetjs/parser/parquet-reader.ts +1 -1
- package/src/parquetjs/schema/schema.ts +1 -1
- package/src/parquetjs/utils/read-utils.ts +2 -2
- package/dist/index.js.map +0 -1
- package/dist/lib/arrow/convert-columns-to-row-group.js.map +0 -1
- package/dist/lib/arrow/convert-row-group-to-columns.js.map +0 -1
- package/dist/lib/arrow/convert-schema-from-parquet.js.map +0 -1
- package/dist/lib/arrow/convert-schema-to-parquet.js.map +0 -1
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/parsers/get-parquet-schema.js.map +0 -1
- package/dist/lib/parsers/parse-geoparquet.js.map +0 -1
- package/dist/lib/parsers/parse-parquet-to-columns.js.map +0 -1
- package/dist/lib/parsers/parse-parquet.js.map +0 -1
- package/dist/lib/wasm/encode-parquet-wasm.js.map +0 -1
- package/dist/lib/wasm/load-wasm.js.map +0 -1
- package/dist/lib/wasm/parse-parquet-wasm.js.map +0 -1
- package/dist/lib/wip/convert-schema-deep.java.disabled +0 -910
- package/dist/lib/wip/convert-schema-deep.rs.disabled +0 -976
- package/dist/parquet-loader.js.map +0 -1
- package/dist/parquet-wasm-loader.js.map +0 -1
- package/dist/parquet-wasm-writer.js.map +0 -1
- package/dist/parquet-writer.js.map +0 -1
- package/dist/parquetjs/LICENSE +0 -20
- package/dist/parquetjs/codecs/declare.js.map +0 -1
- package/dist/parquetjs/codecs/dictionary.js.map +0 -1
- package/dist/parquetjs/codecs/index.js.map +0 -1
- package/dist/parquetjs/codecs/plain.js.map +0 -1
- package/dist/parquetjs/codecs/rle.js.map +0 -1
- package/dist/parquetjs/compression.js.map +0 -1
- package/dist/parquetjs/encoder/parquet-encoder.js.map +0 -1
- package/dist/parquetjs/modules.d.ts +0 -21
- package/dist/parquetjs/parquet-thrift/BoundaryOrder.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/BsonType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/ColumnOrder.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/CompressionCodec.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/ConvertedType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeader.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/DateType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/DecimalType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/Encoding.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/EnumType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/FieldRepetitionType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/FileMetaData.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/IntType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/JsonType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/KeyValue.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/ListType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/LogicalType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/MapType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/MicroSeconds.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/MilliSeconds.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/NullType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/OffsetIndex.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/PageHeader.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/PageLocation.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/PageType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/RowGroup.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/SchemaElement.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/SortingColumn.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/Statistics.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/StringType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/TimeType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/TimeUnit.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/TimestampType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/Type.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/UUIDType.js.map +0 -1
- package/dist/parquetjs/parquet-thrift/index.js.map +0 -1
- package/dist/parquetjs/parser/decoders.js.map +0 -1
- package/dist/parquetjs/parser/parquet-reader.js.map +0 -1
- package/dist/parquetjs/schema/declare.js.map +0 -1
- package/dist/parquetjs/schema/schema.js.map +0 -1
- package/dist/parquetjs/schema/shred.js.map +0 -1
- package/dist/parquetjs/schema/types.js.map +0 -1
- package/dist/parquetjs/utils/file-utils.js.map +0 -1
- package/dist/parquetjs/utils/read-utils.js.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.browser.js.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.node.js.map +0 -1
- package/dist/polyfills/buffer/buffer.js.map +0 -1
- package/dist/polyfills/buffer/index.js.map +0 -1
- package/dist/polyfills/buffer/install-buffer-polyfill.js.map +0 -1
- package/dist/polyfills/util.js.map +0 -1
- package/dist/workers/parquet-worker.js.map +0 -1
|
@@ -1,139 +1,158 @@
|
|
|
1
|
+
// Forked from https://github.com/kbajalc/parquets under MIT license (Copyright (c) 2017 ironSource Ltd.)
|
|
1
2
|
import { PARQUET_CODECS } from "../codecs/index.js";
|
|
2
3
|
import { PARQUET_COMPRESSION_METHODS } from "../compression.js";
|
|
3
4
|
import { materializeRows, shredBuffer, shredRecord } from "./shred.js";
|
|
4
5
|
import { PARQUET_LOGICAL_TYPES } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* A parquet file schema
|
|
8
|
+
*/
|
|
5
9
|
export class ParquetSchema {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
findField(path) {
|
|
15
|
-
if (typeof path === 'string') {
|
|
16
|
-
path = path.split(',');
|
|
17
|
-
} else {
|
|
18
|
-
path = path.slice(0);
|
|
10
|
+
/**
|
|
11
|
+
* Create a new schema from a JSON schema definition
|
|
12
|
+
*/
|
|
13
|
+
constructor(schema) {
|
|
14
|
+
this.schema = schema;
|
|
15
|
+
this.fields = buildFields(schema, 0, 0, []);
|
|
16
|
+
this.fieldList = listFields(this.fields);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve a field definition
|
|
20
|
+
*/
|
|
21
|
+
findField(path) {
|
|
22
|
+
if (typeof path === 'string') {
|
|
23
|
+
// tslint:disable-next-line:no-parameter-reassignment
|
|
24
|
+
path = path.split(',');
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// tslint:disable-next-line:no-parameter-reassignment
|
|
28
|
+
path = path.slice(0); // clone array
|
|
29
|
+
}
|
|
30
|
+
let n = this.fields;
|
|
31
|
+
for (; path.length > 1; path.shift()) {
|
|
32
|
+
n = n[path[0]].fields;
|
|
33
|
+
}
|
|
34
|
+
return n[path[0]];
|
|
23
35
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve a field definition and all the field's ancestors
|
|
38
|
+
*/
|
|
39
|
+
findFieldBranch(path) {
|
|
40
|
+
if (typeof path === 'string') {
|
|
41
|
+
// tslint:disable-next-line:no-parameter-reassignment
|
|
42
|
+
path = path.split(',');
|
|
43
|
+
}
|
|
44
|
+
const branch = [];
|
|
45
|
+
let n = this.fields;
|
|
46
|
+
for (; path.length > 0; path.shift()) {
|
|
47
|
+
branch.push(n[path[0]]);
|
|
48
|
+
if (path.length > 1) {
|
|
49
|
+
n = n[path[0]].fields;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return branch;
|
|
29
53
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
54
|
+
shredRecord(row, rowGroup) {
|
|
55
|
+
shredRecord(this, row, rowGroup);
|
|
56
|
+
}
|
|
57
|
+
materializeRows(rowGroup) {
|
|
58
|
+
return materializeRows(this, rowGroup);
|
|
59
|
+
}
|
|
60
|
+
compress(type) {
|
|
61
|
+
setCompress(this.schema, type);
|
|
62
|
+
setCompress(this.fields, type);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
rowGroup() {
|
|
66
|
+
return shredBuffer(this);
|
|
37
67
|
}
|
|
38
|
-
return branch;
|
|
39
|
-
}
|
|
40
|
-
shredRecord(row, rowGroup) {
|
|
41
|
-
shredRecord(this, row, rowGroup);
|
|
42
|
-
}
|
|
43
|
-
materializeRows(rowGroup) {
|
|
44
|
-
return materializeRows(this, rowGroup);
|
|
45
|
-
}
|
|
46
|
-
compress(type) {
|
|
47
|
-
setCompress(this.schema, type);
|
|
48
|
-
setCompress(this.fields, type);
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
rowGroup() {
|
|
52
|
-
return shredBuffer(this);
|
|
53
|
-
}
|
|
54
68
|
}
|
|
55
69
|
function setCompress(schema, type) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
for (const name in schema) {
|
|
71
|
+
const node = schema[name];
|
|
72
|
+
if (node.fields) {
|
|
73
|
+
setCompress(node.fields, type);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
node.compression = type;
|
|
77
|
+
}
|
|
62
78
|
}
|
|
63
|
-
}
|
|
64
79
|
}
|
|
80
|
+
// eslint-disable-next-line max-statements, complexity
|
|
65
81
|
function buildFields(schema, rLevelParentMax, dLevelParentMax, path) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
82
|
+
const fieldList = {};
|
|
83
|
+
for (const name in schema) {
|
|
84
|
+
const opts = schema[name];
|
|
85
|
+
/* field repetition type */
|
|
86
|
+
const required = !opts.optional;
|
|
87
|
+
const repeated = Boolean(opts.repeated);
|
|
88
|
+
let rLevelMax = rLevelParentMax;
|
|
89
|
+
let dLevelMax = dLevelParentMax;
|
|
90
|
+
let repetitionType = 'REQUIRED';
|
|
91
|
+
if (!required) {
|
|
92
|
+
repetitionType = 'OPTIONAL';
|
|
93
|
+
dLevelMax++;
|
|
94
|
+
}
|
|
95
|
+
if (repeated) {
|
|
96
|
+
repetitionType = 'REPEATED';
|
|
97
|
+
rLevelMax++;
|
|
98
|
+
if (required)
|
|
99
|
+
dLevelMax++;
|
|
100
|
+
}
|
|
101
|
+
/* nested field */
|
|
102
|
+
if (opts.fields) {
|
|
103
|
+
const cpath = path.concat([name]);
|
|
104
|
+
fieldList[name] = {
|
|
105
|
+
name,
|
|
106
|
+
path: cpath,
|
|
107
|
+
key: cpath.join(),
|
|
108
|
+
repetitionType,
|
|
109
|
+
rLevelMax,
|
|
110
|
+
dLevelMax,
|
|
111
|
+
isNested: true,
|
|
112
|
+
fieldCount: Object.keys(opts.fields).length,
|
|
113
|
+
fields: buildFields(opts.fields, rLevelMax, dLevelMax, cpath)
|
|
114
|
+
};
|
|
115
|
+
continue; // eslint-disable-line no-continue
|
|
116
|
+
}
|
|
117
|
+
const typeDef = PARQUET_LOGICAL_TYPES[opts.type];
|
|
118
|
+
if (!typeDef) {
|
|
119
|
+
throw new Error(`invalid parquet type: ${opts.type}`);
|
|
120
|
+
}
|
|
121
|
+
opts.encoding = opts.encoding || 'PLAIN';
|
|
122
|
+
if (!(opts.encoding in PARQUET_CODECS)) {
|
|
123
|
+
throw new Error(`unsupported parquet encoding: ${opts.encoding}`);
|
|
124
|
+
}
|
|
125
|
+
opts.compression = opts.compression || 'UNCOMPRESSED';
|
|
126
|
+
if (!(opts.compression in PARQUET_COMPRESSION_METHODS)) {
|
|
127
|
+
throw new Error(`unsupported compression method: ${opts.compression}`);
|
|
128
|
+
}
|
|
129
|
+
/* add to schema */
|
|
130
|
+
const cpath = path.concat([name]);
|
|
131
|
+
fieldList[name] = {
|
|
132
|
+
name,
|
|
133
|
+
primitiveType: typeDef.primitiveType,
|
|
134
|
+
originalType: typeDef.originalType,
|
|
135
|
+
path: cpath,
|
|
136
|
+
key: cpath.join(),
|
|
137
|
+
repetitionType,
|
|
138
|
+
encoding: opts.encoding,
|
|
139
|
+
compression: opts.compression,
|
|
140
|
+
typeLength: opts.typeLength || typeDef.typeLength,
|
|
141
|
+
presision: opts.presision,
|
|
142
|
+
scale: opts.scale,
|
|
143
|
+
rLevelMax,
|
|
144
|
+
dLevelMax
|
|
145
|
+
};
|
|
109
146
|
}
|
|
110
|
-
|
|
111
|
-
fieldList[name] = {
|
|
112
|
-
name,
|
|
113
|
-
primitiveType: typeDef.primitiveType,
|
|
114
|
-
originalType: typeDef.originalType,
|
|
115
|
-
path: cpath,
|
|
116
|
-
key: cpath.join(),
|
|
117
|
-
repetitionType,
|
|
118
|
-
encoding: opts.encoding,
|
|
119
|
-
compression: opts.compression,
|
|
120
|
-
typeLength: opts.typeLength || typeDef.typeLength,
|
|
121
|
-
presision: opts.presision,
|
|
122
|
-
scale: opts.scale,
|
|
123
|
-
rLevelMax,
|
|
124
|
-
dLevelMax
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
return fieldList;
|
|
147
|
+
return fieldList;
|
|
128
148
|
}
|
|
129
149
|
function listFields(fields) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
let list = [];
|
|
151
|
+
for (const k in fields) {
|
|
152
|
+
list.push(fields[k]);
|
|
153
|
+
if (fields[k].isNested) {
|
|
154
|
+
list = list.concat(listFields(fields[k].fields));
|
|
155
|
+
}
|
|
135
156
|
}
|
|
136
|
-
|
|
137
|
-
return list;
|
|
157
|
+
return list;
|
|
138
158
|
}
|
|
139
|
-
//# sourceMappingURL=schema.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArrayType } from '@loaders.gl/schema';
|
|
2
|
-
import { ParquetRowGroup, ParquetRow } from
|
|
3
|
-
import { ParquetSchema } from
|
|
2
|
+
import { ParquetRowGroup, ParquetRow } from "./declare.js";
|
|
3
|
+
import { ParquetSchema } from "./schema.js";
|
|
4
4
|
export { ParquetRowGroup };
|
|
5
5
|
export declare function shredBuffer(schema: ParquetSchema): ParquetRowGroup;
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shred.d.ts","sourceRoot":"","sources":["../../../src/parquetjs/schema/shred.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAoC,UAAU,EAAC,
|
|
1
|
+
{"version":3,"file":"shred.d.ts","sourceRoot":"","sources":["../../../src/parquetjs/schema/shred.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAoC,UAAU,EAAC,qBAAkB;AACxF,OAAO,EAAC,aAAa,EAAC,oBAAiB;AAGvC,OAAO,EAAC,eAAe,EAAC,CAAC;AAEzB,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAYlE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,eAAe,GACxB,IAAI,CAmBN;AAgED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,GAAG,UAAU,EAAE,CAa9F;AAoFD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,eAAe,GACxB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAS3B"}
|