@loaders.gl/parquet 4.5.3 → 5.0.0-alpha.10
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/LICENSE +14 -3
- package/dist/bundled.d.ts +9 -0
- package/dist/bundled.d.ts.map +1 -0
- package/dist/bundled.js +10 -0
- package/dist/bundled.js.map +1 -0
- package/dist/delta-format.d.ts +9 -0
- package/dist/delta-format.d.ts.map +1 -0
- package/dist/delta-format.js +12 -0
- package/dist/delta-format.js.map +1 -0
- package/dist/delta-source-loader-types.d.ts +27 -0
- package/dist/delta-source-loader-types.d.ts.map +1 -0
- package/dist/delta-source-loader-types.js +28 -0
- package/dist/delta-source-loader-types.js.map +1 -0
- package/dist/delta-source.d.ts +48 -0
- package/dist/delta-source.d.ts.map +1 -0
- package/dist/delta-source.js +222 -0
- package/dist/delta-source.js.map +1 -0
- package/dist/delta-types.d.ts +38 -0
- package/dist/delta-types.d.ts.map +1 -0
- package/dist/delta-types.js +5 -0
- package/dist/delta-types.js.map +1 -0
- package/dist/geoparquet-loader-with-parser.d.ts +33 -0
- package/dist/geoparquet-loader-with-parser.d.ts.map +1 -0
- package/dist/geoparquet-loader-with-parser.js +52 -0
- package/dist/geoparquet-loader-with-parser.js.map +1 -0
- package/dist/geoparquet-loader.d.ts +59 -0
- package/dist/geoparquet-loader.d.ts.map +1 -0
- package/dist/geoparquet-loader.js +30 -0
- package/dist/geoparquet-loader.js.map +1 -0
- package/dist/iceberg-rest-catalog.d.ts +49 -0
- package/dist/iceberg-rest-catalog.d.ts.map +1 -0
- package/dist/iceberg-rest-catalog.js +78 -0
- package/dist/iceberg-rest-catalog.js.map +1 -0
- package/dist/iceberg-table-source.d.ts +63 -0
- package/dist/iceberg-table-source.d.ts.map +1 -0
- package/dist/iceberg-table-source.js +797 -0
- package/dist/iceberg-table-source.js.map +1 -0
- package/dist/iceberg-types.d.ts +150 -0
- package/dist/iceberg-types.d.ts.map +1 -0
- package/dist/iceberg-types.js +5 -0
- package/dist/iceberg-types.js.map +1 -0
- package/dist/index.cjs +41568 -6781
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/arrow/convert-columns-to-row-group.js +3 -0
- package/dist/lib/arrow/convert-columns-to-row-group.js.map +1 -1
- package/dist/lib/arrow/convert-schema-from-parquet.d.ts +3 -1
- package/dist/lib/arrow/convert-schema-from-parquet.d.ts.map +1 -1
- package/dist/lib/arrow/convert-schema-from-parquet.js +164 -29
- package/dist/lib/arrow/convert-schema-from-parquet.js.map +1 -1
- package/dist/lib/arrow/convert-schema-to-parquet.d.ts.map +1 -1
- package/dist/lib/arrow/convert-schema-to-parquet.js +16 -7
- package/dist/lib/arrow/convert-schema-to-parquet.js.map +1 -1
- package/dist/lib/arrow/create-nested-arrow-vector.d.ts +8 -0
- package/dist/lib/arrow/create-nested-arrow-vector.d.ts.map +1 -0
- package/dist/lib/arrow/create-nested-arrow-vector.js +485 -0
- package/dist/lib/arrow/create-nested-arrow-vector.js.map +1 -0
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +1 -2
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/encoders/encode-arrow-to-parquet.d.ts +2 -2
- package/dist/lib/encoders/encode-arrow-to-parquet.d.ts.map +1 -1
- package/dist/lib/encoders/encode-arrow-to-parquet.js +3 -10
- package/dist/lib/encoders/encode-arrow-to-parquet.js.map +1 -1
- package/dist/lib/encoders/encode-table-to-parquet-js.d.ts +5 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.d.ts.map +1 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.js +394 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.js.map +1 -0
- package/dist/lib/geo/geoparquet-covering.d.ts +19 -0
- package/dist/lib/geo/geoparquet-covering.d.ts.map +1 -0
- package/dist/lib/geo/geoparquet-covering.js +137 -0
- package/dist/lib/geo/geoparquet-covering.js.map +1 -0
- package/dist/lib/geo/geospatial-metadata.d.ts +67 -0
- package/dist/lib/geo/geospatial-metadata.d.ts.map +1 -0
- package/dist/lib/geo/geospatial-metadata.js +412 -0
- package/dist/lib/geo/geospatial-metadata.js.map +1 -0
- package/dist/lib/parquet-bloom-filter-planner.d.ts +16 -0
- package/dist/lib/parquet-bloom-filter-planner.d.ts.map +1 -0
- package/dist/lib/parquet-bloom-filter-planner.js +57 -0
- package/dist/lib/parquet-bloom-filter-planner.js.map +1 -0
- package/dist/lib/parquet-bloom-filter.d.ts +30 -0
- package/dist/lib/parquet-bloom-filter.d.ts.map +1 -0
- package/dist/lib/parquet-bloom-filter.js +289 -0
- package/dist/lib/parquet-bloom-filter.js.map +1 -0
- package/dist/lib/parquet-encryption.d.ts +80 -0
- package/dist/lib/parquet-encryption.d.ts.map +1 -0
- package/dist/lib/parquet-encryption.js +190 -0
- package/dist/lib/parquet-encryption.js.map +1 -0
- package/dist/lib/parquet-page-index.d.ts +91 -0
- package/dist/lib/parquet-page-index.d.ts.map +1 -0
- package/dist/lib/parquet-page-index.js +463 -0
- package/dist/lib/parquet-page-index.js.map +1 -0
- package/dist/lib/parquet-predicate.d.ts +21 -0
- package/dist/lib/parquet-predicate.d.ts.map +1 -0
- package/dist/lib/parquet-predicate.js +328 -0
- package/dist/lib/parquet-predicate.js.map +1 -0
- package/dist/lib/parquet-source-worker-client.d.ts +6 -0
- package/dist/lib/parquet-source-worker-client.d.ts.map +1 -0
- package/dist/lib/parquet-source-worker-client.js +24 -0
- package/dist/lib/parquet-source-worker-client.js.map +1 -0
- package/dist/lib/parquet-source-worker-decoder.d.ts +7 -0
- package/dist/lib/parquet-source-worker-decoder.d.ts.map +1 -0
- package/dist/lib/parquet-source-worker-decoder.js +181 -0
- package/dist/lib/parquet-source-worker-decoder.js.map +1 -0
- package/dist/lib/parquet-source-worker-file.d.ts +24 -0
- package/dist/lib/parquet-source-worker-file.d.ts.map +1 -0
- package/dist/lib/parquet-source-worker-file.js +40 -0
- package/dist/lib/parquet-source-worker-file.js.map +1 -0
- package/dist/lib/parquet-source-worker-types.d.ts +121 -0
- package/dist/lib/parquet-source-worker-types.d.ts.map +1 -0
- package/dist/lib/parquet-source-worker-types.js +5 -0
- package/dist/lib/parquet-source-worker-types.js.map +1 -0
- package/dist/lib/parquet-worker-transport.d.ts +8 -0
- package/dist/lib/parquet-worker-transport.d.ts.map +1 -0
- package/dist/lib/parquet-worker-transport.js +40 -0
- package/dist/lib/parquet-worker-transport.js.map +1 -0
- package/dist/lib/parsers/convert-parquet-tables.d.ts +16 -0
- package/dist/lib/parsers/convert-parquet-tables.d.ts.map +1 -0
- package/dist/lib/parsers/convert-parquet-tables.js +30 -0
- package/dist/lib/parsers/convert-parquet-tables.js.map +1 -0
- package/dist/lib/parsers/get-parquet-schema.d.ts.map +1 -1
- package/dist/lib/parsers/get-parquet-schema.js +6 -2
- package/dist/lib/parsers/get-parquet-schema.js.map +1 -1
- package/dist/lib/parsers/parse-geoparquet-to-geojson.d.ts +4 -4
- package/dist/lib/parsers/parse-geoparquet-to-geojson.d.ts.map +1 -1
- package/dist/lib/parsers/parse-geoparquet-to-geojson.js +19 -6
- package/dist/lib/parsers/parse-geoparquet-to-geojson.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-tables.d.ts +37 -0
- package/dist/lib/parsers/parse-parquet-tables.d.ts.map +1 -0
- package/dist/lib/parsers/parse-parquet-tables.js +50 -0
- package/dist/lib/parsers/parse-parquet-tables.js.map +1 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.d.ts +19 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.d.ts.map +1 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.js +921 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.js.map +1 -0
- package/dist/lib/parsers/parse-parquet-to-arrow.d.ts +7 -7
- package/dist/lib/parsers/parse-parquet-to-arrow.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-arrow.js +45 -32
- package/dist/lib/parsers/parse-parquet-to-arrow.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-columns.d.ts +3 -3
- package/dist/lib/parsers/parse-parquet-to-columns.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-columns.js +4 -5
- package/dist/lib/parsers/parse-parquet-to-columns.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-json.d.ts +3 -3
- package/dist/lib/parsers/parse-parquet-to-json.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-json.js +95 -28
- package/dist/lib/parsers/parse-parquet-to-json.js.map +1 -1
- package/dist/lib/slice-parquet-batch.d.ts +9 -0
- package/dist/lib/slice-parquet-batch.d.ts.map +1 -0
- package/dist/lib/slice-parquet-batch.js +28 -0
- package/dist/lib/slice-parquet-batch.js.map +1 -0
- package/dist/lib/sources/parquet-range-file.d.ts +80 -0
- package/dist/lib/sources/parquet-range-file.d.ts.map +1 -0
- package/dist/lib/sources/parquet-range-file.js +267 -0
- package/dist/lib/sources/parquet-range-file.js.map +1 -0
- package/dist/lib/sources/single-batch-queue.d.ts +24 -0
- package/dist/lib/sources/single-batch-queue.d.ts.map +1 -0
- package/dist/lib/sources/single-batch-queue.js +91 -0
- package/dist/lib/sources/single-batch-queue.js.map +1 -0
- package/dist/lib/utils/load-wasm-node.d.ts +3 -0
- package/dist/lib/utils/load-wasm-node.d.ts.map +1 -0
- package/dist/lib/utils/load-wasm-node.js +23 -0
- package/dist/lib/utils/load-wasm-node.js.map +1 -0
- package/dist/lib/utils/load-wasm.d.ts +2 -2
- package/dist/lib/utils/load-wasm.d.ts.map +1 -1
- package/dist/lib/utils/load-wasm.js +28 -12
- package/dist/lib/utils/load-wasm.js.map +1 -1
- package/dist/lib/utils/make-stream-iterator.d.ts +2 -0
- package/dist/lib/utils/make-stream-iterator.d.ts.map +1 -1
- package/dist/lib/utils/make-stream-iterator.js +123 -14
- package/dist/lib/utils/make-stream-iterator.js.map +1 -1
- package/dist/lib/utils/normalize-parquet-options.d.ts +5 -0
- package/dist/lib/utils/normalize-parquet-options.d.ts.map +1 -0
- package/dist/lib/utils/normalize-parquet-options.js +25 -0
- package/dist/lib/utils/normalize-parquet-options.js.map +1 -0
- package/dist/parquet-dataset-source.cjs +38974 -0
- package/dist/parquet-dataset-source.cjs.map +6 -0
- package/dist/parquet-dataset-source.d.ts +81 -0
- package/dist/parquet-dataset-source.d.ts.map +1 -0
- package/dist/parquet-dataset-source.js +602 -0
- package/dist/parquet-dataset-source.js.map +1 -0
- package/dist/parquet-encoded-page-types.d.ts +108 -0
- package/dist/parquet-encoded-page-types.d.ts.map +1 -0
- package/dist/parquet-encoded-page-types.js +5 -0
- package/dist/parquet-encoded-page-types.js.map +1 -0
- package/dist/parquet-format.d.ts +2 -0
- package/dist/parquet-format.d.ts.map +1 -1
- package/dist/parquet-format.js +2 -0
- package/dist/parquet-format.js.map +1 -1
- package/dist/parquet-js-loader-types.d.ts +59 -0
- package/dist/parquet-js-loader-types.d.ts.map +1 -0
- package/dist/parquet-js-loader-types.js +34 -0
- package/dist/parquet-js-loader-types.js.map +1 -0
- package/dist/parquet-js-loader.d.ts +18 -22
- package/dist/parquet-js-loader.d.ts.map +1 -1
- package/dist/parquet-js-loader.js +53 -14
- package/dist/parquet-js-loader.js.map +1 -1
- package/dist/parquet-js-writer.d.ts +65 -0
- package/dist/parquet-js-writer.d.ts.map +1 -0
- package/dist/parquet-js-writer.js +28 -0
- package/dist/parquet-js-writer.js.map +1 -0
- package/dist/parquet-loader-base.d.ts +25 -0
- package/dist/parquet-loader-base.d.ts.map +1 -0
- package/dist/parquet-loader-base.js +23 -0
- package/dist/parquet-loader-base.js.map +1 -0
- package/dist/parquet-loader-options.d.ts +55 -0
- package/dist/parquet-loader-options.d.ts.map +1 -0
- package/dist/parquet-loader-options.js +10 -0
- package/dist/parquet-loader-options.js.map +1 -0
- package/dist/parquet-loader-types.d.ts +61 -0
- package/dist/parquet-loader-types.d.ts.map +1 -0
- package/dist/parquet-loader-types.js +17 -0
- package/dist/parquet-loader-types.js.map +1 -0
- package/dist/parquet-loader.d.ts +42 -0
- package/dist/parquet-loader.d.ts.map +1 -0
- package/dist/parquet-loader.js +68 -0
- package/dist/parquet-loader.js.map +1 -0
- package/dist/parquet-source-capabilities.d.ts +43 -0
- package/dist/parquet-source-capabilities.d.ts.map +1 -0
- package/dist/parquet-source-capabilities.js +32 -0
- package/dist/parquet-source-capabilities.js.map +1 -0
- package/dist/parquet-source-loader-types.d.ts +82 -0
- package/dist/parquet-source-loader-types.d.ts.map +1 -0
- package/dist/parquet-source-loader-types.js +84 -0
- package/dist/parquet-source-loader-types.js.map +1 -0
- package/dist/parquet-source-loader.cjs +38261 -0
- package/dist/parquet-source-loader.cjs.map +6 -0
- package/dist/parquet-source-loader.d.ts +167 -0
- package/dist/parquet-source-loader.d.ts.map +1 -0
- package/dist/parquet-source-loader.js +1438 -0
- package/dist/parquet-source-loader.js.map +1 -0
- package/dist/parquet-source-types.d.ts +534 -0
- package/dist/parquet-source-types.d.ts.map +1 -0
- package/dist/parquet-source-types.js +5 -0
- package/dist/parquet-source-types.js.map +1 -0
- package/dist/parquet-source-worker-factory.d.ts +4 -0
- package/dist/parquet-source-worker-factory.d.ts.map +1 -0
- package/dist/parquet-source-worker-factory.js +6 -0
- package/dist/parquet-source-worker-factory.js.map +1 -0
- package/dist/parquet-source-worker-url.d.ts +3 -0
- package/dist/parquet-source-worker-url.d.ts.map +1 -0
- package/dist/parquet-source-worker-url.js +22 -0
- package/dist/parquet-source-worker-url.js.map +1 -0
- package/dist/parquet-source-worker.js +38871 -0
- package/dist/parquet-source-worker.js.map +7 -0
- package/dist/parquet-worker-node.cjs +78507 -0
- package/dist/parquet-worker-node.cjs.map +7 -0
- package/dist/parquet-worker-url.d.ts +3 -0
- package/dist/parquet-worker-url.d.ts.map +1 -0
- package/dist/parquet-worker-url.js +19 -0
- package/dist/parquet-worker-url.js.map +1 -0
- package/dist/parquet-worker.js +20094 -0
- package/dist/parquet-worker.js.map +7 -0
- package/dist/parquet-writer.d.ts +10 -0
- package/dist/parquet-writer.d.ts.map +1 -0
- package/dist/parquet-writer.js +27 -0
- package/dist/parquet-writer.js.map +1 -0
- package/dist/parquet_wasm_bg.wasm +0 -0
- package/dist/parquetjs/codecs/byte-stream-split.d.ts +9 -0
- package/dist/parquetjs/codecs/byte-stream-split.d.ts.map +1 -0
- package/dist/parquetjs/codecs/byte-stream-split.js +159 -0
- package/dist/parquetjs/codecs/byte-stream-split.js.map +1 -0
- package/dist/parquetjs/codecs/declare.d.ts +35 -3
- package/dist/parquetjs/codecs/declare.d.ts.map +1 -1
- package/dist/parquetjs/codecs/declare.js +17 -1
- package/dist/parquetjs/codecs/declare.js.map +1 -1
- package/dist/parquetjs/codecs/delta.d.ts +17 -0
- package/dist/parquetjs/codecs/delta.d.ts.map +1 -0
- package/dist/parquetjs/codecs/delta.js +788 -0
- package/dist/parquetjs/codecs/delta.js.map +1 -0
- package/dist/parquetjs/codecs/dictionary.d.ts +5 -2
- package/dist/parquetjs/codecs/dictionary.d.ts.map +1 -1
- package/dist/parquetjs/codecs/dictionary.js +16 -4
- package/dist/parquetjs/codecs/dictionary.js.map +1 -1
- package/dist/parquetjs/codecs/index.d.ts.map +1 -1
- package/dist/parquetjs/codecs/index.js +22 -0
- package/dist/parquetjs/codecs/index.js.map +1 -1
- package/dist/parquetjs/codecs/plain.d.ts +3 -3
- package/dist/parquetjs/codecs/plain.d.ts.map +1 -1
- package/dist/parquetjs/codecs/plain.js +231 -78
- package/dist/parquetjs/codecs/plain.js.map +1 -1
- package/dist/parquetjs/codecs/rle.d.ts +7 -3
- package/dist/parquetjs/codecs/rle.d.ts.map +1 -1
- package/dist/parquetjs/codecs/rle.js +613 -69
- package/dist/parquetjs/codecs/rle.js.map +1 -1
- package/dist/parquetjs/compression.d.ts +16 -8
- package/dist/parquetjs/compression.d.ts.map +1 -1
- package/dist/parquetjs/compression.js +114 -141
- package/dist/parquetjs/compression.js.map +1 -1
- package/dist/parquetjs/encoder/dictionary-planner.d.ts +17 -0
- package/dist/parquetjs/encoder/dictionary-planner.d.ts.map +1 -0
- package/dist/parquetjs/encoder/dictionary-planner.js +67 -0
- package/dist/parquetjs/encoder/dictionary-planner.js.map +1 -0
- package/dist/parquetjs/encoder/page-planner.d.ts +11 -0
- package/dist/parquetjs/encoder/page-planner.d.ts.map +1 -0
- package/dist/parquetjs/encoder/page-planner.js +60 -0
- package/dist/parquetjs/encoder/page-planner.js.map +1 -0
- package/dist/parquetjs/encoder/parquet-encoder.d.ts +54 -5
- package/dist/parquetjs/encoder/parquet-encoder.d.ts.map +1 -1
- package/dist/parquetjs/encoder/parquet-encoder.js +930 -66
- package/dist/parquetjs/encoder/parquet-encoder.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/BoundingBox.d.ts +29 -0
- package/dist/parquetjs/parquet-thrift/BoundingBox.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/BoundingBox.js +85 -0
- package/dist/parquetjs/parquet-thrift/BoundingBox.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/BsonType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/BsonType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/BsonType.js +1 -1
- package/dist/parquetjs/parquet-thrift/BsonType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts +7 -2
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js +37 -2
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnCryptoMetaData.d.ts +35 -0
- package/dist/parquetjs/parquet-thrift/ColumnCryptoMetaData.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnCryptoMetaData.js +135 -0
- package/dist/parquetjs/parquet-thrift/ColumnCryptoMetaData.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts +6 -6
- package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js +3 -3
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts +12 -2
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.js +75 -2
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.js.map +1 -1
- 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 +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnOrder.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeader.js +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeader.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js +1 -1
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/DateType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/DateType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DateType.js +1 -1
- package/dist/parquetjs/parquet-thrift/DateType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/DecimalType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/DecimalType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/DecimalType.js +1 -1
- package/dist/parquetjs/parquet-thrift/DecimalType.js.map +1 -1
- 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 +1 -1
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.d.ts +8 -0
- package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.js +14 -0
- package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/Encoding.d.ts +2 -1
- package/dist/parquetjs/parquet-thrift/Encoding.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/Encoding.js +1 -0
- package/dist/parquetjs/parquet-thrift/Encoding.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/EncryptionAlgorithm.d.ts +22 -0
- package/dist/parquetjs/parquet-thrift/EncryptionAlgorithm.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/EncryptionAlgorithm.js +111 -0
- package/dist/parquetjs/parquet-thrift/EncryptionAlgorithm.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/EnumType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/EnumType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/EnumType.js +1 -1
- package/dist/parquetjs/parquet-thrift/EnumType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/FileCryptoMetaData.d.ts +16 -0
- package/dist/parquetjs/parquet-thrift/FileCryptoMetaData.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/FileCryptoMetaData.js +57 -0
- package/dist/parquetjs/parquet-thrift/FileCryptoMetaData.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts +7 -2
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/FileMetaData.js +37 -2
- package/dist/parquetjs/parquet-thrift/FileMetaData.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/Float16Type.d.ts +9 -0
- package/dist/parquetjs/parquet-thrift/Float16Type.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/Float16Type.js +27 -0
- package/dist/parquetjs/parquet-thrift/Float16Type.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/GeographyType.d.ts +14 -0
- package/dist/parquetjs/parquet-thrift/GeographyType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/GeographyType.js +51 -0
- package/dist/parquetjs/parquet-thrift/GeographyType.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/GeometryType.d.ts +11 -0
- package/dist/parquetjs/parquet-thrift/GeometryType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/GeometryType.js +41 -0
- package/dist/parquetjs/parquet-thrift/GeometryType.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/GeospatialStatistics.d.ts +18 -0
- package/dist/parquetjs/parquet-thrift/GeospatialStatistics.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/GeospatialStatistics.js +62 -0
- package/dist/parquetjs/parquet-thrift/GeospatialStatistics.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.js +1 -1
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/IntType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/IntType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/IntType.js +1 -1
- package/dist/parquetjs/parquet-thrift/IntType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/JsonType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/JsonType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/JsonType.js +1 -1
- package/dist/parquetjs/parquet-thrift/JsonType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/KeyValue.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/KeyValue.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/KeyValue.js +1 -1
- package/dist/parquetjs/parquet-thrift/KeyValue.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/ListType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/ListType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ListType.js +1 -1
- package/dist/parquetjs/parquet-thrift/ListType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/LogicalType.d.ts +17 -1
- package/dist/parquetjs/parquet-thrift/LogicalType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/LogicalType.js +97 -1
- package/dist/parquetjs/parquet-thrift/LogicalType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/MapType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/MapType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/MapType.js +1 -1
- package/dist/parquetjs/parquet-thrift/MapType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/MicroSeconds.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/MicroSeconds.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/MicroSeconds.js +1 -1
- package/dist/parquetjs/parquet-thrift/MicroSeconds.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/MilliSeconds.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/MilliSeconds.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/MilliSeconds.js +1 -1
- package/dist/parquetjs/parquet-thrift/MilliSeconds.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/NanoSeconds.d.ts +9 -0
- package/dist/parquetjs/parquet-thrift/NanoSeconds.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/NanoSeconds.js +27 -0
- package/dist/parquetjs/parquet-thrift/NanoSeconds.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/NullType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/NullType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/NullType.js +1 -1
- package/dist/parquetjs/parquet-thrift/NullType.js.map +1 -1
- 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 +1 -1
- package/dist/parquetjs/parquet-thrift/OffsetIndex.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.js +1 -1
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageHeader.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/PageHeader.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageHeader.js +1 -1
- package/dist/parquetjs/parquet-thrift/PageHeader.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageLocation.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/PageLocation.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/PageLocation.js +2 -2
- package/dist/parquetjs/parquet-thrift/PageLocation.js.map +1 -1
- 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 +2 -2
- package/dist/parquetjs/parquet-thrift/RowGroup.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/SchemaElement.js +1 -1
- package/dist/parquetjs/parquet-thrift/SchemaElement.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/SizeStatistics.d.ts +26 -0
- package/dist/parquetjs/parquet-thrift/SizeStatistics.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/SizeStatistics.js +85 -0
- package/dist/parquetjs/parquet-thrift/SizeStatistics.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/SortingColumn.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/SortingColumn.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/SortingColumn.js +1 -1
- package/dist/parquetjs/parquet-thrift/SortingColumn.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/Statistics.d.ts +14 -10
- package/dist/parquetjs/parquet-thrift/Statistics.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/Statistics.js +38 -2
- package/dist/parquetjs/parquet-thrift/Statistics.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/StringType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/StringType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/StringType.js +1 -1
- package/dist/parquetjs/parquet-thrift/StringType.js.map +1 -1
- 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 +1 -1
- package/dist/parquetjs/parquet-thrift/TimeType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts +5 -1
- package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/TimeUnit.js +25 -1
- package/dist/parquetjs/parquet-thrift/TimeUnit.js.map +1 -1
- 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 +1 -1
- package/dist/parquetjs/parquet-thrift/TimestampType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js +1 -1
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/UUIDType.d.ts +1 -1
- package/dist/parquetjs/parquet-thrift/UUIDType.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/UUIDType.js +1 -1
- package/dist/parquetjs/parquet-thrift/UUIDType.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/VariantType.d.ts +11 -0
- package/dist/parquetjs/parquet-thrift/VariantType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/VariantType.js +41 -0
- package/dist/parquetjs/parquet-thrift/VariantType.js.map +1 -0
- package/dist/parquetjs/parquet-thrift/index.d.ts +12 -2
- package/dist/parquetjs/parquet-thrift/index.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/index.js +12 -2
- package/dist/parquetjs/parquet-thrift/index.js.map +1 -1
- package/dist/parquetjs/parser/decoders.d.ts +23 -3
- package/dist/parquetjs/parser/decoders.d.ts.map +1 -1
- package/dist/parquetjs/parser/decoders.js +687 -119
- package/dist/parquetjs/parser/decoders.js.map +1 -1
- package/dist/parquetjs/parser/encoded-pages.d.ts +24 -0
- package/dist/parquetjs/parser/encoded-pages.d.ts.map +1 -0
- package/dist/parquetjs/parser/encoded-pages.js +206 -0
- package/dist/parquetjs/parser/encoded-pages.js.map +1 -0
- package/dist/parquetjs/parser/parquet-reader.d.ts +111 -10
- package/dist/parquetjs/parser/parquet-reader.d.ts.map +1 -1
- package/dist/parquetjs/parser/parquet-reader.js +836 -69
- package/dist/parquetjs/parser/parquet-reader.js.map +1 -1
- package/dist/parquetjs/schema/declare.d.ts +83 -10
- package/dist/parquetjs/schema/declare.d.ts.map +1 -1
- package/dist/parquetjs/schema/declare.js.map +1 -1
- package/dist/parquetjs/schema/schema.d.ts +3 -0
- package/dist/parquetjs/schema/schema.d.ts.map +1 -1
- package/dist/parquetjs/schema/schema.js +31 -3
- package/dist/parquetjs/schema/schema.js.map +1 -1
- package/dist/parquetjs/schema/shred.d.ts +2 -0
- package/dist/parquetjs/schema/shred.d.ts.map +1 -1
- package/dist/parquetjs/schema/shred.js +285 -29
- package/dist/parquetjs/schema/shred.js.map +1 -1
- package/dist/parquetjs/schema/types.d.ts.map +1 -1
- package/dist/parquetjs/schema/types.js +290 -71
- package/dist/parquetjs/schema/types.js.map +1 -1
- package/dist/parquetjs/schema/variant.d.ts +3 -0
- package/dist/parquetjs/schema/variant.d.ts.map +1 -0
- package/dist/parquetjs/schema/variant.js +248 -0
- package/dist/parquetjs/schema/variant.js.map +1 -0
- package/dist/parquetjs/utils/binary-utils.d.ts +41 -0
- package/dist/parquetjs/utils/binary-utils.d.ts.map +1 -0
- package/dist/parquetjs/utils/binary-utils.js +106 -0
- package/dist/parquetjs/utils/binary-utils.js.map +1 -0
- package/dist/parquetjs/utils/crc32.d.ts +3 -0
- package/dist/parquetjs/utils/crc32.d.ts.map +1 -0
- package/dist/parquetjs/utils/crc32.js +15 -0
- package/dist/parquetjs/utils/crc32.js.map +1 -0
- package/dist/parquetjs/utils/file-utils.d.ts +1 -1
- package/dist/parquetjs/utils/file-utils.d.ts.map +1 -1
- package/dist/parquetjs/utils/file-utils.js +3 -3
- package/dist/parquetjs/utils/file-utils.js.map +1 -1
- package/dist/parquetjs/utils/read-utils.d.ts +25 -7
- package/dist/parquetjs/utils/read-utils.d.ts.map +1 -1
- package/dist/parquetjs/utils/read-utils.js +66 -39
- package/dist/parquetjs/utils/read-utils.js.map +1 -1
- package/dist/parquetjs/utils/thrift-runtime.d.ts +106 -0
- package/dist/parquetjs/utils/thrift-runtime.d.ts.map +1 -0
- package/dist/parquetjs/utils/thrift-runtime.js +50 -0
- package/dist/parquetjs/utils/thrift-runtime.js.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.d.ts +78 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.d.ts.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.js +213 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.js.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.d.ts +80 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.d.ts.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.js +276 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.js.map +1 -0
- package/dist/parquetjs/utils/uint8-array-transport.d.ts +25 -0
- package/dist/parquetjs/utils/uint8-array-transport.d.ts.map +1 -0
- package/dist/parquetjs/utils/uint8-array-transport.js +62 -0
- package/dist/parquetjs/utils/uint8-array-transport.js.map +1 -0
- package/dist/polyfills/process.d.ts +12 -0
- package/dist/polyfills/process.d.ts.map +1 -0
- package/dist/polyfills/process.js +17 -0
- package/dist/polyfills/process.js.map +1 -0
- package/dist/unbundled.d.ts +10 -0
- package/dist/unbundled.d.ts.map +1 -0
- package/dist/unbundled.js +11 -0
- package/dist/unbundled.js.map +1 -0
- package/dist/wasm.d.ts +3 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +6 -0
- package/dist/wasm.js.map +1 -0
- package/dist/workers/parquet-source-worker.d.ts +2 -0
- package/dist/workers/parquet-source-worker.d.ts.map +1 -0
- package/dist/workers/parquet-source-worker.js +17 -0
- package/dist/workers/parquet-source-worker.js.map +1 -0
- package/dist/workers/parquet-worker-node.d.ts +2 -0
- package/dist/workers/parquet-worker-node.d.ts.map +1 -0
- package/dist/workers/parquet-worker-node.js +5 -0
- package/dist/workers/parquet-worker-node.js.map +1 -0
- package/dist/workers/parquet-worker.d.ts +2 -0
- package/dist/workers/parquet-worker.d.ts.map +1 -0
- package/dist/workers/parquet-worker.js +27 -0
- package/dist/workers/parquet-worker.js.map +1 -0
- package/package.json +84 -40
- package/src/bundled.ts +43 -0
- package/src/delta-format.ts +12 -0
- package/src/delta-source-loader-types.ts +40 -0
- package/src/delta-source.ts +305 -0
- package/src/delta-types.ts +40 -0
- package/src/geoparquet-loader-with-parser.ts +95 -0
- package/src/geoparquet-loader.ts +54 -0
- package/src/iceberg-rest-catalog.ts +122 -0
- package/src/iceberg-table-source.ts +1037 -0
- package/src/iceberg-types.ts +165 -0
- package/src/index.ts +105 -26
- package/src/lib/arrow/convert-columns-to-row-group.ts +3 -0
- package/src/lib/arrow/convert-schema-from-parquet.ts +193 -32
- package/src/lib/arrow/convert-schema-to-parquet.ts +16 -7
- package/src/lib/arrow/create-nested-arrow-vector.ts +705 -0
- package/src/lib/constants.ts +0 -2
- package/src/lib/encoders/encode-arrow-to-parquet.ts +10 -16
- package/src/lib/encoders/encode-table-to-parquet-js.ts +526 -0
- package/src/lib/geo/geoparquet-covering.ts +201 -0
- package/src/lib/geo/geospatial-metadata.ts +547 -0
- package/src/lib/parquet-bloom-filter-planner.ts +86 -0
- package/src/lib/parquet-bloom-filter.ts +345 -0
- package/src/lib/parquet-encryption.ts +344 -0
- package/src/lib/parquet-page-index.ts +727 -0
- package/src/lib/parquet-predicate.ts +410 -0
- package/src/lib/parquet-source-worker-client.ts +41 -0
- package/src/lib/parquet-source-worker-decoder.ts +252 -0
- package/src/lib/parquet-source-worker-file.ts +56 -0
- package/src/lib/parquet-source-worker-types.ts +132 -0
- package/src/lib/parquet-worker-transport.ts +57 -0
- package/src/lib/parsers/convert-parquet-tables.ts +39 -0
- package/src/lib/parsers/get-parquet-schema.ts +6 -2
- package/src/lib/parsers/parse-geoparquet-to-geojson.ts +27 -14
- package/src/lib/parsers/parse-parquet-tables.ts +82 -0
- package/src/lib/parsers/parse-parquet-to-arrow-js.ts +1213 -0
- package/src/lib/parsers/parse-parquet-to-arrow.ts +62 -36
- package/src/lib/parsers/parse-parquet-to-columns.ts +9 -8
- package/src/lib/parsers/parse-parquet-to-json.ts +119 -35
- package/src/lib/slice-parquet-batch.ts +32 -0
- package/src/lib/sources/parquet-range-file.ts +365 -0
- package/src/lib/sources/single-batch-queue.ts +95 -0
- package/src/lib/utils/load-wasm-node.ts +25 -0
- package/src/lib/utils/load-wasm.ts +36 -13
- package/src/lib/utils/make-stream-iterator.ts +126 -14
- package/src/lib/utils/normalize-parquet-options.ts +30 -0
- package/src/parquet-dataset-source.ts +800 -0
- package/src/parquet-encoded-page-types.ts +122 -0
- package/src/parquet-format.ts +2 -0
- package/src/parquet-js-loader-types.ts +53 -0
- package/src/parquet-js-loader.ts +76 -19
- package/src/parquet-js-writer.ts +98 -0
- package/src/parquet-loader-base.ts +34 -0
- package/src/parquet-loader-options.ts +62 -0
- package/src/parquet-loader-types.ts +35 -0
- package/src/parquet-loader.ts +115 -0
- package/src/parquet-source-capabilities.ts +73 -0
- package/src/parquet-source-loader-types.ts +97 -0
- package/src/parquet-source-loader.ts +2254 -0
- package/src/parquet-source-types.ts +627 -0
- package/src/parquet-source-worker-factory.ts +8 -0
- package/src/parquet-source-worker-url.ts +23 -0
- package/src/parquet-worker-url.ts +23 -0
- package/src/parquet-writer.ts +42 -0
- package/src/parquetjs/LICENSE +23 -1
- package/src/parquetjs/codecs/byte-stream-split.ts +221 -0
- package/src/parquetjs/codecs/declare.ts +62 -3
- package/src/parquetjs/codecs/delta.ts +1047 -0
- package/src/parquetjs/codecs/dictionary.ts +22 -4
- package/src/parquetjs/codecs/index.ts +22 -0
- package/src/parquetjs/codecs/plain.ts +317 -89
- package/src/parquetjs/codecs/rle.ts +852 -82
- package/src/parquetjs/compression.ts +137 -156
- package/src/parquetjs/encoder/dictionary-planner.ts +104 -0
- package/src/parquetjs/encoder/page-planner.ts +83 -0
- package/src/parquetjs/encoder/parquet-encoder.ts +1374 -95
- package/src/parquetjs/parquet-thrift/BoundingBox.ts +108 -0
- package/src/parquetjs/parquet-thrift/BsonType.ts +1 -1
- package/src/parquetjs/parquet-thrift/ColumnChunk.ts +37 -2
- package/src/parquetjs/parquet-thrift/ColumnCryptoMetaData.ts +139 -0
- package/src/parquetjs/parquet-thrift/ColumnIndex.ts +13 -13
- package/src/parquetjs/parquet-thrift/ColumnMetaData.ts +75 -2
- package/src/parquetjs/parquet-thrift/ColumnOrder.ts +1 -1
- package/src/parquetjs/parquet-thrift/DataPageHeader.ts +1 -1
- package/src/parquetjs/parquet-thrift/DataPageHeaderV2.ts +1 -1
- package/src/parquetjs/parquet-thrift/DateType.ts +1 -1
- package/src/parquetjs/parquet-thrift/DecimalType.ts +1 -1
- package/src/parquetjs/parquet-thrift/DictionaryPageHeader.ts +1 -1
- package/src/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.ts +13 -0
- package/src/parquetjs/parquet-thrift/Encoding.ts +2 -1
- package/src/parquetjs/parquet-thrift/EncryptionAlgorithm.ts +127 -0
- package/src/parquetjs/parquet-thrift/EnumType.ts +1 -1
- package/src/parquetjs/parquet-thrift/FileCryptoMetaData.ts +60 -0
- package/src/parquetjs/parquet-thrift/FileMetaData.ts +37 -2
- package/src/parquetjs/parquet-thrift/Float16Type.ts +28 -0
- package/src/parquetjs/parquet-thrift/GeographyType.ts +54 -0
- package/src/parquetjs/parquet-thrift/GeometryType.ts +43 -0
- package/src/parquetjs/parquet-thrift/GeospatialStatistics.ts +68 -0
- package/src/parquetjs/parquet-thrift/IndexPageHeader.ts +1 -1
- package/src/parquetjs/parquet-thrift/IntType.ts +1 -1
- package/src/parquetjs/parquet-thrift/JsonType.ts +1 -1
- package/src/parquetjs/parquet-thrift/KeyValue.ts +1 -1
- package/src/parquetjs/parquet-thrift/ListType.ts +1 -1
- package/src/parquetjs/parquet-thrift/LogicalType.ts +97 -1
- package/src/parquetjs/parquet-thrift/MapType.ts +1 -1
- package/src/parquetjs/parquet-thrift/MicroSeconds.ts +1 -1
- package/src/parquetjs/parquet-thrift/MilliSeconds.ts +1 -1
- package/src/parquetjs/parquet-thrift/NanoSeconds.ts +28 -0
- package/src/parquetjs/parquet-thrift/NullType.ts +1 -1
- package/src/parquetjs/parquet-thrift/OffsetIndex.ts +1 -1
- package/src/parquetjs/parquet-thrift/PageEncodingStats.ts +1 -1
- package/src/parquetjs/parquet-thrift/PageHeader.ts +1 -1
- package/src/parquetjs/parquet-thrift/PageLocation.ts +2 -2
- package/src/parquetjs/parquet-thrift/RowGroup.ts +2 -2
- package/src/parquetjs/parquet-thrift/SchemaElement.ts +1 -1
- package/src/parquetjs/parquet-thrift/SizeStatistics.ts +98 -0
- package/src/parquetjs/parquet-thrift/SortingColumn.ts +1 -1
- package/src/parquetjs/parquet-thrift/Statistics.ts +50 -14
- package/src/parquetjs/parquet-thrift/StringType.ts +1 -1
- package/src/parquetjs/parquet-thrift/TimeType.ts +1 -1
- package/src/parquetjs/parquet-thrift/TimeUnit.ts +25 -1
- package/src/parquetjs/parquet-thrift/TimestampType.ts +1 -1
- package/src/parquetjs/parquet-thrift/TypeDefinedOrder.ts +1 -1
- package/src/parquetjs/parquet-thrift/UUIDType.ts +1 -1
- package/src/parquetjs/parquet-thrift/VariantType.ts +43 -0
- package/src/parquetjs/parquet-thrift/index.ts +12 -4
- package/src/parquetjs/parser/decoders.ts +922 -143
- package/src/parquetjs/parser/encoded-pages.ts +278 -0
- package/src/parquetjs/parser/parquet-reader.ts +1334 -83
- package/src/parquetjs/schema/declare.ts +121 -9
- package/src/parquetjs/schema/schema.ts +33 -3
- package/src/parquetjs/schema/shred.ts +345 -41
- package/src/parquetjs/schema/types.ts +308 -84
- package/src/parquetjs/schema/variant.ts +313 -0
- package/src/parquetjs/utils/binary-utils.ts +132 -0
- package/src/parquetjs/utils/crc32.ts +15 -0
- package/src/parquetjs/utils/file-utils.ts +4 -4
- package/src/parquetjs/utils/read-utils.ts +77 -51
- package/src/parquetjs/utils/thrift-runtime.ts +109 -0
- package/src/parquetjs/utils/uint8-array-compact-protocol-writer.ts +254 -0
- package/src/parquetjs/utils/uint8-array-compact-protocol.ts +322 -0
- package/src/parquetjs/utils/uint8-array-transport.ts +79 -0
- package/src/polyfills/process.ts +17 -0
- package/src/unbundled.ts +47 -0
- package/src/wasm.ts +6 -0
- package/src/workers/parquet-source-worker.ts +21 -0
- package/src/workers/parquet-worker-node.ts +5 -0
- package/src/workers/parquet-worker.ts +31 -0
- package/dist/parquet-arrow-loader.d.ts +0 -43
- package/dist/parquet-arrow-loader.d.ts.map +0 -1
- package/dist/parquet-arrow-loader.js +0 -49
- package/dist/parquet-arrow-loader.js.map +0 -1
- package/dist/parquet-arrow-writer.d.ts +0 -9
- package/dist/parquet-arrow-writer.d.ts.map +0 -1
- package/dist/parquet-arrow-writer.js +0 -23
- package/dist/parquet-arrow-writer.js.map +0 -1
- package/dist/parquet-json-loader.d.ts +0 -148
- package/dist/parquet-json-loader.d.ts.map +0 -1
- package/dist/parquet-json-loader.js +0 -106
- package/dist/parquet-json-loader.js.map +0 -1
- package/dist/parquet-json-writer.d.ts +0 -19
- package/dist/parquet-json-writer.d.ts.map +0 -1
- package/dist/parquet-json-writer.js +0 -20
- package/dist/parquet-json-writer.js.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.browser.d.ts +0 -3
- package/dist/polyfills/buffer/buffer-polyfill.browser.d.ts.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.browser.js +0 -12
- package/dist/polyfills/buffer/buffer-polyfill.browser.js.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.node.d.ts +0 -3
- package/dist/polyfills/buffer/buffer-polyfill.node.d.ts.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.node.js +0 -17
- package/dist/polyfills/buffer/buffer-polyfill.node.js.map +0 -1
- package/dist/polyfills/buffer/buffer.d.ts +0 -222
- package/dist/polyfills/buffer/buffer.d.ts.map +0 -1
- package/dist/polyfills/buffer/buffer.js +0 -1868
- package/dist/polyfills/buffer/buffer.js.map +0 -1
- package/dist/polyfills/buffer/index.d.ts +0 -4
- package/dist/polyfills/buffer/index.d.ts.map +0 -1
- package/dist/polyfills/buffer/index.js +0 -9
- package/dist/polyfills/buffer/index.js.map +0 -1
- package/dist/polyfills/buffer/install-buffer-polyfill.d.ts +0 -2
- package/dist/polyfills/buffer/install-buffer-polyfill.d.ts.map +0 -1
- package/dist/polyfills/buffer/install-buffer-polyfill.js +0 -10
- package/dist/polyfills/buffer/install-buffer-polyfill.js.map +0 -1
- package/dist/workers/parquet-json-worker.d.ts +0 -2
- package/dist/workers/parquet-json-worker.d.ts.map +0 -1
- package/dist/workers/parquet-json-worker.js +0 -7
- package/dist/workers/parquet-json-worker.js.map +0 -1
- package/src/parquet-arrow-loader.ts +0 -74
- package/src/parquet-arrow-writer.ts +0 -33
- package/src/parquet-json-loader.ts +0 -160
- package/src/parquet-json-writer.ts +0 -27
- package/src/parquetjs/modules.d.ts +0 -25
- package/src/polyfills/buffer/buffer-polyfill.browser.ts +0 -14
- package/src/polyfills/buffer/buffer-polyfill.node.ts +0 -19
- package/src/polyfills/buffer/buffer.ts +0 -2205
- package/src/polyfills/buffer/index.ts +0 -11
- package/src/polyfills/buffer/install-buffer-polyfill.ts +0 -12
- package/src/workers/parquet-json-worker.ts +0 -8
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
// Copyright (c) 2017 ironSource Ltd.
|
|
5
5
|
// Forked from https://github.com/kbajalc/parquets under MIT license
|
|
6
6
|
import { PARQUET_CODECS } from "../codecs/index.js";
|
|
7
|
-
import { ConvertedType, Encoding, FieldRepetitionType, PageType, Type } from "../parquet-thrift/index.js";
|
|
7
|
+
import { ConvertedType, EdgeInterpolationAlgorithm, Encoding, FieldRepetitionType, PageType, Type } from "../parquet-thrift/index.js";
|
|
8
8
|
import { decompress } from "../compression.js";
|
|
9
9
|
import { PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING } from "../../lib/constants.js";
|
|
10
10
|
import { decodePageHeader, getThriftEnum, getBitWidth } from "../utils/read-utils.js";
|
|
11
|
+
import { crc32 } from "../utils/crc32.js";
|
|
12
|
+
/** Shared empty level storage for required flat columns, whose levels are implicit. */
|
|
13
|
+
const EMPTY_PARQUET_LEVEL_BUFFER = new Uint8Array(0);
|
|
11
14
|
/**
|
|
12
15
|
* Decode data pages
|
|
13
16
|
* @param buffer - input data
|
|
@@ -21,61 +24,174 @@ export async function decodeDataPages(buffer, context) {
|
|
|
21
24
|
offset: 0,
|
|
22
25
|
size: buffer.length
|
|
23
26
|
};
|
|
27
|
+
const expectedLevelCount = context.numValues === undefined ? undefined : Number(context.numValues);
|
|
28
|
+
if (expectedLevelCount !== undefined &&
|
|
29
|
+
(!Number.isSafeInteger(expectedLevelCount) || expectedLevelCount < 0)) {
|
|
30
|
+
throw new Error(`Invalid Parquet column value count ${expectedLevelCount}`);
|
|
31
|
+
}
|
|
32
|
+
const outputCapacity = expectedLevelCount ?? 0;
|
|
33
|
+
const byteArrayOutput = createArrowByteArrayOutput(buffer, context, outputCapacity);
|
|
24
34
|
const data = {
|
|
25
|
-
rlevels:
|
|
26
|
-
dlevels:
|
|
27
|
-
values: [],
|
|
35
|
+
rlevels: createParquetLevelBuffer(context, outputCapacity, context.rLevelMax),
|
|
36
|
+
dlevels: createParquetLevelBuffer(context, outputCapacity, context.dLevelMax),
|
|
37
|
+
values: byteArrayOutput ? [] : createParquetColumnValueBuffer(context, outputCapacity),
|
|
28
38
|
pageHeaders: [],
|
|
29
|
-
count: 0
|
|
39
|
+
count: 0,
|
|
40
|
+
nullCount: 0
|
|
30
41
|
};
|
|
31
42
|
let dictionary = context.dictionary || [];
|
|
43
|
+
let levelOffset = 0;
|
|
44
|
+
let valueOffset = 0;
|
|
32
45
|
while (
|
|
33
46
|
// @ts-ignore size can be undefined
|
|
34
47
|
cursor.offset < cursor.size &&
|
|
35
|
-
(
|
|
48
|
+
(expectedLevelCount === undefined || levelOffset < expectedLevelCount)) {
|
|
36
49
|
// Looks like we have to decode these in sequence due to cursor updates?
|
|
37
|
-
const
|
|
50
|
+
const target = {
|
|
51
|
+
values: data.values,
|
|
52
|
+
valueOffset,
|
|
53
|
+
byteArrayOutput,
|
|
54
|
+
dictionary,
|
|
55
|
+
rlevels: data.rlevels,
|
|
56
|
+
dlevels: data.dlevels,
|
|
57
|
+
levelOffset
|
|
58
|
+
};
|
|
59
|
+
const page = context.compression === 'UNCOMPRESSED'
|
|
60
|
+
? decodeUncompressedPage(cursor, context, target)
|
|
61
|
+
: await decodePage(cursor, context, target);
|
|
38
62
|
if (page.dictionary) {
|
|
39
63
|
dictionary = page.dictionary;
|
|
40
64
|
// eslint-disable-next-line no-continue
|
|
41
65
|
continue;
|
|
42
66
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line no-loop-func
|
|
48
|
-
page.values = page.values.map((value) => dictionary[value]);
|
|
67
|
+
levelOffset += page.count;
|
|
68
|
+
if (page.directValuesWritten !== undefined) {
|
|
69
|
+
valueOffset += page.directValuesWritten;
|
|
70
|
+
data.nullCount += page.count - page.directValuesWritten;
|
|
49
71
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
else {
|
|
73
|
+
const valueEncoding = getThriftEnum(Encoding, page.pageHeader.data_page_header?.encoding ?? page.pageHeader.data_page_header_v2?.encoding);
|
|
74
|
+
const usesDictionary = dictionary.length &&
|
|
75
|
+
(valueEncoding === 'PLAIN_DICTIONARY' || valueEncoding === 'RLE_DICTIONARY');
|
|
76
|
+
for (let index = 0; index < page.values.length; index++) {
|
|
77
|
+
const value = usesDictionary ? dictionary[Number(page.values[index])] : page.values[index];
|
|
78
|
+
if (value !== undefined) {
|
|
79
|
+
data.values[valueOffset++] = value;
|
|
80
|
+
}
|
|
56
81
|
}
|
|
57
82
|
}
|
|
58
83
|
data.count += page.count;
|
|
59
84
|
data.pageHeaders.push(page.pageHeader);
|
|
60
85
|
}
|
|
86
|
+
data.rlevels = trimParquetLevelBuffer(data.rlevels, levelOffset);
|
|
87
|
+
data.dlevels = trimParquetLevelBuffer(data.dlevels, levelOffset);
|
|
88
|
+
if (byteArrayOutput) {
|
|
89
|
+
data.values = [];
|
|
90
|
+
data.byteArrayData = {
|
|
91
|
+
data: byteArrayOutput.data.subarray(0, byteArrayOutput.byteLength),
|
|
92
|
+
valueOffsets: byteArrayOutput.valueOffsets.subarray(0, valueOffset + 1)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
data.values = trimParquetValueBuffer(data.values, valueOffset);
|
|
97
|
+
}
|
|
61
98
|
return data;
|
|
62
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Decodes an uncompressed column chunk synchronously.
|
|
102
|
+
*
|
|
103
|
+
* In-memory Parquet reads use this entry point to avoid one resolved Promise per selected column.
|
|
104
|
+
*/
|
|
105
|
+
export function decodeUncompressedDataPages(buffer, context) {
|
|
106
|
+
const cursor = { buffer, offset: 0, size: buffer.length };
|
|
107
|
+
const expectedLevelCount = context.numValues === undefined ? undefined : Number(context.numValues);
|
|
108
|
+
if (expectedLevelCount !== undefined &&
|
|
109
|
+
(!Number.isSafeInteger(expectedLevelCount) || expectedLevelCount < 0)) {
|
|
110
|
+
throw new Error(`Invalid Parquet column value count ${expectedLevelCount}`);
|
|
111
|
+
}
|
|
112
|
+
const outputCapacity = expectedLevelCount ?? 0;
|
|
113
|
+
const byteArrayOutput = createArrowByteArrayOutput(buffer, context, outputCapacity);
|
|
114
|
+
const data = {
|
|
115
|
+
rlevels: createParquetLevelBuffer(context, outputCapacity, context.rLevelMax),
|
|
116
|
+
dlevels: createParquetLevelBuffer(context, outputCapacity, context.dLevelMax),
|
|
117
|
+
values: byteArrayOutput ? [] : createParquetColumnValueBuffer(context, outputCapacity),
|
|
118
|
+
pageHeaders: [],
|
|
119
|
+
count: 0,
|
|
120
|
+
nullCount: 0
|
|
121
|
+
};
|
|
122
|
+
let dictionary = context.dictionary || [];
|
|
123
|
+
let levelOffset = 0;
|
|
124
|
+
let valueOffset = 0;
|
|
125
|
+
while (cursor.offset < (cursor.size ?? cursor.buffer.length) &&
|
|
126
|
+
(expectedLevelCount === undefined || levelOffset < expectedLevelCount)) {
|
|
127
|
+
const page = decodeUncompressedPage(cursor, context, {
|
|
128
|
+
values: data.values,
|
|
129
|
+
valueOffset,
|
|
130
|
+
byteArrayOutput,
|
|
131
|
+
dictionary,
|
|
132
|
+
rlevels: data.rlevels,
|
|
133
|
+
dlevels: data.dlevels,
|
|
134
|
+
levelOffset
|
|
135
|
+
});
|
|
136
|
+
if (page.dictionary) {
|
|
137
|
+
dictionary = page.dictionary;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
levelOffset += page.count;
|
|
141
|
+
if (page.directValuesWritten !== undefined) {
|
|
142
|
+
valueOffset += page.directValuesWritten;
|
|
143
|
+
data.nullCount += page.count - page.directValuesWritten;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const valueEncoding = getThriftEnum(Encoding, page.pageHeader.data_page_header?.encoding ?? page.pageHeader.data_page_header_v2?.encoding);
|
|
147
|
+
const usesDictionary = dictionary.length &&
|
|
148
|
+
(valueEncoding === 'PLAIN_DICTIONARY' || valueEncoding === 'RLE_DICTIONARY');
|
|
149
|
+
for (let index = 0; index < page.values.length; index++) {
|
|
150
|
+
const value = usesDictionary ? dictionary[Number(page.values[index])] : page.values[index];
|
|
151
|
+
if (value !== undefined)
|
|
152
|
+
data.values[valueOffset++] = value;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
data.count += page.count;
|
|
156
|
+
data.pageHeaders.push(page.pageHeader);
|
|
157
|
+
}
|
|
158
|
+
data.rlevels = trimParquetLevelBuffer(data.rlevels, levelOffset);
|
|
159
|
+
data.dlevels = trimParquetLevelBuffer(data.dlevels, levelOffset);
|
|
160
|
+
if (byteArrayOutput) {
|
|
161
|
+
data.values = [];
|
|
162
|
+
data.byteArrayData = {
|
|
163
|
+
data: byteArrayOutput.data.subarray(0, byteArrayOutput.byteLength),
|
|
164
|
+
valueOffsets: byteArrayOutput.valueOffsets.subarray(0, valueOffset + 1)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
data.values = trimParquetValueBuffer(data.values, valueOffset);
|
|
169
|
+
}
|
|
170
|
+
return data;
|
|
171
|
+
}
|
|
172
|
+
/** Decodes a dictionary page from an uncompressed in-memory column chunk. */
|
|
173
|
+
export function decodeUncompressedDictionaryBuffer(buffer, context) {
|
|
174
|
+
const cursor = { buffer, offset: 0, size: buffer.length };
|
|
175
|
+
return decodeUncompressedPage(cursor, context).dictionary;
|
|
176
|
+
}
|
|
63
177
|
/**
|
|
64
178
|
* Decode parquet page based on page type
|
|
65
179
|
* @param cursor
|
|
66
180
|
* @param context
|
|
67
181
|
*/
|
|
68
|
-
export async function decodePage(cursor, context) {
|
|
182
|
+
export async function decodePage(cursor, context, target) {
|
|
69
183
|
let page;
|
|
70
184
|
const { pageHeader, length } = decodePageHeader(cursor.buffer, cursor.offset);
|
|
71
185
|
cursor.offset += length;
|
|
72
186
|
const pageType = getThriftEnum(PageType, pageHeader.type);
|
|
187
|
+
const pageEnd = cursor.offset + pageHeader.compressed_page_size;
|
|
188
|
+
verifyPageChecksum(cursor, pageHeader, pageEnd, context);
|
|
73
189
|
switch (pageType) {
|
|
74
190
|
case 'DATA_PAGE':
|
|
75
|
-
page = await decodeDataPage(cursor, pageHeader, context);
|
|
191
|
+
page = await decodeDataPage(cursor, pageHeader, context, target);
|
|
76
192
|
break;
|
|
77
193
|
case 'DATA_PAGE_V2':
|
|
78
|
-
page = await decodeDataPageV2(cursor, pageHeader, context);
|
|
194
|
+
page = await decodeDataPageV2(cursor, pageHeader, context, target);
|
|
79
195
|
break;
|
|
80
196
|
case 'DICTIONARY_PAGE':
|
|
81
197
|
page = {
|
|
@@ -88,6 +204,46 @@ export async function decodePage(cursor, context) {
|
|
|
88
204
|
}
|
|
89
205
|
return page;
|
|
90
206
|
}
|
|
207
|
+
/** Decodes one uncompressed page without introducing a Promise/microtask boundary. */
|
|
208
|
+
function decodeUncompressedPage(cursor, context, target) {
|
|
209
|
+
const { pageHeader, length } = decodePageHeader(cursor.buffer, cursor.offset);
|
|
210
|
+
cursor.offset += length;
|
|
211
|
+
const pageEnd = cursor.offset + pageHeader.compressed_page_size;
|
|
212
|
+
verifyPageChecksum(cursor, pageHeader, pageEnd, context);
|
|
213
|
+
const pageType = getThriftEnum(PageType, pageHeader.type);
|
|
214
|
+
switch (pageType) {
|
|
215
|
+
case 'DATA_PAGE':
|
|
216
|
+
return decodeDataPageValues(cursor, pageHeader, context, target);
|
|
217
|
+
case 'DATA_PAGE_V2':
|
|
218
|
+
return decodeUncompressedDataPageV2(cursor, pageHeader, context, target);
|
|
219
|
+
case 'DICTIONARY_PAGE':
|
|
220
|
+
return {
|
|
221
|
+
dictionary: decodeUncompressedDictionaryPage(cursor, pageHeader, context),
|
|
222
|
+
dlevels: EMPTY_PARQUET_LEVEL_BUFFER,
|
|
223
|
+
rlevels: EMPTY_PARQUET_LEVEL_BUFFER,
|
|
224
|
+
values: [],
|
|
225
|
+
count: 0,
|
|
226
|
+
pageHeader
|
|
227
|
+
};
|
|
228
|
+
default:
|
|
229
|
+
throw new Error(`invalid page type: ${pageType}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Verifies a page checksum before either the synchronous or asynchronous decode path consumes it. */
|
|
233
|
+
function verifyPageChecksum(cursor, pageHeader, pageEnd, context) {
|
|
234
|
+
if (!context.verifyPageChecksums)
|
|
235
|
+
return;
|
|
236
|
+
if (pageEnd > (cursor.size ?? cursor.buffer.length)) {
|
|
237
|
+
throw new Error('Parquet page extends beyond the available buffer');
|
|
238
|
+
}
|
|
239
|
+
if (pageHeader.crc === undefined)
|
|
240
|
+
return;
|
|
241
|
+
const expected = pageHeader.crc >>> 0;
|
|
242
|
+
const actual = crc32(cursor.buffer.subarray(cursor.offset, pageEnd));
|
|
243
|
+
if (actual !== expected) {
|
|
244
|
+
throw new Error(`Parquet page checksum mismatch: expected ${expected}, calculated ${actual}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
91
247
|
/**
|
|
92
248
|
* Decode parquet schema
|
|
93
249
|
* @param schemaElements input schema elements data
|
|
@@ -122,29 +278,28 @@ export function decodeSchema(schemaElements, offset, len) {
|
|
|
122
278
|
const res = decodeSchema(schemaElements, next + 1, schemaElement.num_children);
|
|
123
279
|
next = res.next;
|
|
124
280
|
schema[schemaElement.name] = {
|
|
125
|
-
// type: undefined,
|
|
126
281
|
optional,
|
|
127
282
|
repeated,
|
|
283
|
+
logicalType: decodeSchemaLogicalType(schemaElement),
|
|
284
|
+
fieldId: schemaElement.field_id,
|
|
128
285
|
fields: res.schema
|
|
129
286
|
};
|
|
130
287
|
}
|
|
131
288
|
else {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
switch (logicalType) {
|
|
138
|
-
case 'DECIMAL':
|
|
139
|
-
logicalType = `${logicalType}_${type}`;
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
}
|
|
289
|
+
const physicalType = getThriftEnum(Type, schemaElement.type);
|
|
290
|
+
const logicalType = decodeSchemaLogicalType(schemaElement);
|
|
291
|
+
const parquetType = getSchemaParquetType(schemaElement, physicalType, logicalType);
|
|
292
|
+
const precision = logicalType?.precision ?? schemaElement.precision;
|
|
293
|
+
const scale = logicalType?.scale ?? schemaElement.scale;
|
|
143
294
|
schema[schemaElement.name] = {
|
|
144
|
-
type:
|
|
295
|
+
type: parquetType,
|
|
296
|
+
physicalType,
|
|
145
297
|
typeLength: schemaElement.type_length,
|
|
146
|
-
presision:
|
|
147
|
-
|
|
298
|
+
presision: precision,
|
|
299
|
+
precision,
|
|
300
|
+
scale,
|
|
301
|
+
logicalType,
|
|
302
|
+
fieldId: schemaElement.field_id,
|
|
148
303
|
optional,
|
|
149
304
|
repeated
|
|
150
305
|
};
|
|
@@ -153,6 +308,171 @@ export function decodeSchema(schemaElements, offset, len) {
|
|
|
153
308
|
}
|
|
154
309
|
return { schema, offset, next };
|
|
155
310
|
}
|
|
311
|
+
/** Decodes the parameterized Parquet LogicalType union, falling back to ConvertedType metadata. */
|
|
312
|
+
function decodeSchemaLogicalType(schemaElement) {
|
|
313
|
+
const logicalType = schemaElement.logicalType;
|
|
314
|
+
if (logicalType?.STRING)
|
|
315
|
+
return { type: 'STRING' };
|
|
316
|
+
if (logicalType?.MAP)
|
|
317
|
+
return { type: 'MAP' };
|
|
318
|
+
if (logicalType?.LIST)
|
|
319
|
+
return { type: 'LIST' };
|
|
320
|
+
if (logicalType?.ENUM)
|
|
321
|
+
return { type: 'ENUM' };
|
|
322
|
+
if (logicalType?.DECIMAL) {
|
|
323
|
+
return {
|
|
324
|
+
type: 'DECIMAL',
|
|
325
|
+
precision: logicalType.DECIMAL.precision,
|
|
326
|
+
scale: logicalType.DECIMAL.scale
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
if (logicalType?.DATE)
|
|
330
|
+
return { type: 'DATE' };
|
|
331
|
+
if (logicalType?.TIME) {
|
|
332
|
+
return {
|
|
333
|
+
type: 'TIME',
|
|
334
|
+
unit: decodeTimeUnit(logicalType.TIME.unit),
|
|
335
|
+
isAdjustedToUTC: logicalType.TIME.isAdjustedToUTC
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
if (logicalType?.TIMESTAMP) {
|
|
339
|
+
return {
|
|
340
|
+
type: 'TIMESTAMP',
|
|
341
|
+
unit: decodeTimeUnit(logicalType.TIMESTAMP.unit),
|
|
342
|
+
isAdjustedToUTC: logicalType.TIMESTAMP.isAdjustedToUTC
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
if (logicalType?.INTEGER) {
|
|
346
|
+
const bitWidth = logicalType.INTEGER.bitWidth;
|
|
347
|
+
if (bitWidth !== 8 && bitWidth !== 16 && bitWidth !== 32 && bitWidth !== 64) {
|
|
348
|
+
throw new Error(`parquet: invalid INTEGER bit width ${bitWidth}`);
|
|
349
|
+
}
|
|
350
|
+
return { type: 'INTEGER', bitWidth, isSigned: logicalType.INTEGER.isSigned };
|
|
351
|
+
}
|
|
352
|
+
if (logicalType?.UNKNOWN)
|
|
353
|
+
return { type: 'UNKNOWN' };
|
|
354
|
+
if (logicalType?.JSON)
|
|
355
|
+
return { type: 'JSON' };
|
|
356
|
+
if (logicalType?.BSON)
|
|
357
|
+
return { type: 'BSON' };
|
|
358
|
+
if (logicalType?.UUID)
|
|
359
|
+
return { type: 'UUID' };
|
|
360
|
+
if (logicalType?.FLOAT16)
|
|
361
|
+
return { type: 'FLOAT16' };
|
|
362
|
+
if (logicalType?.VARIANT) {
|
|
363
|
+
return { type: 'VARIANT', specificationVersion: logicalType.VARIANT.specification_version };
|
|
364
|
+
}
|
|
365
|
+
if (logicalType?.GEOMETRY)
|
|
366
|
+
return { type: 'GEOMETRY', crs: logicalType.GEOMETRY.crs };
|
|
367
|
+
if (logicalType?.GEOGRAPHY) {
|
|
368
|
+
return {
|
|
369
|
+
type: 'GEOGRAPHY',
|
|
370
|
+
crs: logicalType.GEOGRAPHY.crs,
|
|
371
|
+
algorithm: logicalType.GEOGRAPHY.algorithm === undefined
|
|
372
|
+
? undefined
|
|
373
|
+
: getThriftEnum(EdgeInterpolationAlgorithm, logicalType.GEOGRAPHY.algorithm)
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
if (schemaElement.converted_type === undefined || schemaElement.converted_type === null) {
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
const convertedType = getThriftEnum(ConvertedType, schemaElement.converted_type);
|
|
380
|
+
switch (convertedType) {
|
|
381
|
+
case 'UTF8':
|
|
382
|
+
return { type: 'STRING' };
|
|
383
|
+
case 'MAP':
|
|
384
|
+
case 'MAP_KEY_VALUE':
|
|
385
|
+
return { type: 'MAP' };
|
|
386
|
+
case 'LIST':
|
|
387
|
+
return { type: 'LIST' };
|
|
388
|
+
case 'ENUM':
|
|
389
|
+
return { type: 'ENUM' };
|
|
390
|
+
case 'DECIMAL':
|
|
391
|
+
return { type: 'DECIMAL', precision: schemaElement.precision, scale: schemaElement.scale };
|
|
392
|
+
case 'DATE':
|
|
393
|
+
return { type: 'DATE' };
|
|
394
|
+
case 'TIME_MILLIS':
|
|
395
|
+
return { type: 'TIME', unit: 'MILLIS', isAdjustedToUTC: true };
|
|
396
|
+
case 'TIME_MICROS':
|
|
397
|
+
return { type: 'TIME', unit: 'MICROS', isAdjustedToUTC: true };
|
|
398
|
+
case 'TIMESTAMP_MILLIS':
|
|
399
|
+
return { type: 'TIMESTAMP', unit: 'MILLIS', isAdjustedToUTC: true };
|
|
400
|
+
case 'TIMESTAMP_MICROS':
|
|
401
|
+
return { type: 'TIMESTAMP', unit: 'MICROS', isAdjustedToUTC: true };
|
|
402
|
+
case 'UINT_8':
|
|
403
|
+
case 'UINT_16':
|
|
404
|
+
case 'UINT_32':
|
|
405
|
+
case 'UINT_64':
|
|
406
|
+
return {
|
|
407
|
+
type: 'INTEGER',
|
|
408
|
+
bitWidth: Number(convertedType.slice(5)),
|
|
409
|
+
isSigned: false
|
|
410
|
+
};
|
|
411
|
+
case 'INT_8':
|
|
412
|
+
case 'INT_16':
|
|
413
|
+
case 'INT_32':
|
|
414
|
+
case 'INT_64':
|
|
415
|
+
return {
|
|
416
|
+
type: 'INTEGER',
|
|
417
|
+
bitWidth: Number(convertedType.slice(4)),
|
|
418
|
+
isSigned: true
|
|
419
|
+
};
|
|
420
|
+
case 'JSON':
|
|
421
|
+
return { type: 'JSON' };
|
|
422
|
+
case 'BSON':
|
|
423
|
+
return { type: 'BSON' };
|
|
424
|
+
default:
|
|
425
|
+
return undefined;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/** Resolves one physical/logical pair to the internal Parquet value converter. */
|
|
429
|
+
function getSchemaParquetType(schemaElement, physicalType, logicalType) {
|
|
430
|
+
if (!logicalType) {
|
|
431
|
+
return schemaElement.converted_type === undefined || schemaElement.converted_type === null
|
|
432
|
+
? physicalType
|
|
433
|
+
: getThriftEnum(ConvertedType, schemaElement.converted_type);
|
|
434
|
+
}
|
|
435
|
+
switch (logicalType.type) {
|
|
436
|
+
case 'STRING':
|
|
437
|
+
return 'UTF8';
|
|
438
|
+
case 'ENUM':
|
|
439
|
+
return 'ENUM';
|
|
440
|
+
case 'DECIMAL':
|
|
441
|
+
return `DECIMAL_${physicalType}`;
|
|
442
|
+
case 'DATE':
|
|
443
|
+
return 'DATE';
|
|
444
|
+
case 'TIME':
|
|
445
|
+
return `TIME_${logicalType.unit}`;
|
|
446
|
+
case 'TIMESTAMP':
|
|
447
|
+
return `TIMESTAMP_${logicalType.unit}`;
|
|
448
|
+
case 'INTEGER':
|
|
449
|
+
return `${logicalType.isSigned ? 'INT' : 'UINT'}_${logicalType.bitWidth}`;
|
|
450
|
+
case 'UNKNOWN':
|
|
451
|
+
case 'JSON':
|
|
452
|
+
case 'BSON':
|
|
453
|
+
case 'UUID':
|
|
454
|
+
case 'FLOAT16':
|
|
455
|
+
case 'VARIANT':
|
|
456
|
+
case 'GEOMETRY':
|
|
457
|
+
case 'GEOGRAPHY':
|
|
458
|
+
return logicalType.type;
|
|
459
|
+
default:
|
|
460
|
+
if (schemaElement.converted_type !== undefined && schemaElement.converted_type !== null) {
|
|
461
|
+
return getThriftEnum(ConvertedType, schemaElement.converted_type);
|
|
462
|
+
}
|
|
463
|
+
return physicalType;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/** Returns the selected member of the Parquet TimeUnit union. */
|
|
467
|
+
function decodeTimeUnit(timeUnit) {
|
|
468
|
+
if (timeUnit?.MILLIS)
|
|
469
|
+
return 'MILLIS';
|
|
470
|
+
if (timeUnit?.MICROS)
|
|
471
|
+
return 'MICROS';
|
|
472
|
+
if (timeUnit?.NANOS)
|
|
473
|
+
return 'NANOS';
|
|
474
|
+
throw new Error('parquet: TIME or TIMESTAMP logical type is missing its unit');
|
|
475
|
+
}
|
|
156
476
|
/**
|
|
157
477
|
* Decode a consecutive array of data using one of the parquet encodings
|
|
158
478
|
*/
|
|
@@ -168,13 +488,15 @@ function decodeValues(type, encoding, cursor, count, opts) {
|
|
|
168
488
|
* @param header
|
|
169
489
|
* @param options
|
|
170
490
|
*/
|
|
171
|
-
async function decodeDataPage(cursor, header, context) {
|
|
491
|
+
async function decodeDataPage(cursor, header, context, target) {
|
|
172
492
|
const cursorEnd = cursor.offset + header.compressed_page_size;
|
|
173
|
-
const valueCount = header.data_page_header?.num_values;
|
|
174
493
|
/* uncompress page */
|
|
175
494
|
let dataCursor = cursor;
|
|
176
495
|
if (context.compression !== 'UNCOMPRESSED') {
|
|
177
|
-
const
|
|
496
|
+
const compressedValues = cursor.buffer.slice(cursor.offset, cursorEnd);
|
|
497
|
+
const valuesBuf = context.decompressPage
|
|
498
|
+
? await context.decompressPage(compressedValues, header.uncompressed_page_size)
|
|
499
|
+
: await decompress(context.compression, compressedValues, header.uncompressed_page_size);
|
|
178
500
|
dataCursor = {
|
|
179
501
|
buffer: valuesBuf,
|
|
180
502
|
offset: 0,
|
|
@@ -182,51 +504,47 @@ async function decodeDataPage(cursor, header, context) {
|
|
|
182
504
|
};
|
|
183
505
|
cursor.offset = cursorEnd;
|
|
184
506
|
}
|
|
507
|
+
return decodeDataPageValues(dataCursor, header, context, target);
|
|
508
|
+
}
|
|
509
|
+
/** Decodes one uncompressed Data Page V1 body without introducing an asynchronous boundary. */
|
|
510
|
+
function decodeDataPageValues(dataCursor, header, context, target) {
|
|
511
|
+
const valueCount = header.data_page_header?.num_values;
|
|
185
512
|
/* read repetition levels */
|
|
186
513
|
const rLevelEncoding = getThriftEnum(Encoding, header.data_page_header?.repetition_level_encoding);
|
|
187
|
-
|
|
188
|
-
let rLevels = new Array(valueCount);
|
|
189
|
-
if (context.column.rLevelMax > 0) {
|
|
190
|
-
rLevels = decodeValues(PARQUET_RDLVL_TYPE, rLevelEncoding, dataCursor, valueCount, {
|
|
191
|
-
bitWidth: getBitWidth(context.column.rLevelMax),
|
|
192
|
-
disableEnvelope: false
|
|
193
|
-
// column: opts.column
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
rLevels.fill(0);
|
|
198
|
-
}
|
|
514
|
+
const rLevels = decodeLevels(dataCursor, valueCount, context.column.rLevelMax, rLevelEncoding, false, target?.rlevels, target?.levelOffset);
|
|
199
515
|
/* read definition levels */
|
|
200
516
|
const dLevelEncoding = getThriftEnum(Encoding, header.data_page_header?.definition_level_encoding);
|
|
201
|
-
|
|
202
|
-
let
|
|
517
|
+
const dLevels = decodeLevels(dataCursor, valueCount, context.column.dLevelMax, dLevelEncoding, false, target?.dlevels, target?.levelOffset);
|
|
518
|
+
let valueCountNonNull = valueCount;
|
|
203
519
|
if (context.column.dLevelMax > 0) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
dLevels.fill(0);
|
|
212
|
-
}
|
|
213
|
-
let valueCountNonNull = 0;
|
|
214
|
-
for (const dlvl of dLevels) {
|
|
215
|
-
if (dlvl === context.column.dLevelMax) {
|
|
216
|
-
valueCountNonNull++;
|
|
520
|
+
valueCountNonNull = 0;
|
|
521
|
+
const decodedDefinitionLevels = target?.dlevels || dLevels;
|
|
522
|
+
const definitionLevelOffset = target?.levelOffset || 0;
|
|
523
|
+
for (let index = 0; index < valueCount; index++) {
|
|
524
|
+
if (decodedDefinitionLevels[definitionLevelOffset + index] === context.column.dLevelMax) {
|
|
525
|
+
valueCountNonNull++;
|
|
526
|
+
}
|
|
217
527
|
}
|
|
218
528
|
}
|
|
219
529
|
/* read values */
|
|
220
530
|
const valueEncoding = getThriftEnum(Encoding, header.data_page_header?.encoding);
|
|
221
531
|
const decodeOptions = {
|
|
222
532
|
typeLength: context.column.typeLength,
|
|
223
|
-
bitWidth: context
|
|
533
|
+
bitWidth: getValueBitWidth(context, valueEncoding),
|
|
534
|
+
retainByteArrayViews: context.retainByteArrayViews,
|
|
535
|
+
output: target?.values,
|
|
536
|
+
outputOffset: target?.valueOffset,
|
|
537
|
+
dictionary: isDictionaryEncoding(valueEncoding) ? target?.dictionary : undefined,
|
|
538
|
+
byteArrayOutput: target?.byteArrayOutput,
|
|
539
|
+
int64AsBigInt: shouldDecodeInt64AsBigInt(context),
|
|
540
|
+
int96AsTimestamp: context.int96AsTimestamp
|
|
224
541
|
};
|
|
225
542
|
const values = decodeValues(context.column.primitiveType, valueEncoding, dataCursor, valueCountNonNull, decodeOptions);
|
|
226
543
|
return {
|
|
227
544
|
dlevels: dLevels,
|
|
228
545
|
rlevels: rLevels,
|
|
229
546
|
values,
|
|
547
|
+
directValuesWritten: target ? valueCountNonNull : undefined,
|
|
230
548
|
count: valueCount,
|
|
231
549
|
pageHeader: header
|
|
232
550
|
};
|
|
@@ -238,60 +556,298 @@ async function decodeDataPage(cursor, header, context) {
|
|
|
238
556
|
* @param opts
|
|
239
557
|
* @returns
|
|
240
558
|
*/
|
|
241
|
-
async function decodeDataPageV2(cursor, header, context) {
|
|
559
|
+
async function decodeDataPageV2(cursor, header, context, target) {
|
|
560
|
+
const dataPageHeader = header.data_page_header_v2;
|
|
561
|
+
if (!dataPageHeader) {
|
|
562
|
+
throw new Error('Missing Parquet data page v2 header');
|
|
563
|
+
}
|
|
242
564
|
const cursorEnd = cursor.offset + header.compressed_page_size;
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
const valueCountNonNull = valueCount -
|
|
246
|
-
const valueEncoding = getThriftEnum(Encoding,
|
|
565
|
+
const levelsOffset = cursor.offset;
|
|
566
|
+
const valueCount = dataPageHeader.num_values;
|
|
567
|
+
const valueCountNonNull = valueCount - dataPageHeader.num_nulls;
|
|
568
|
+
const valueEncoding = getThriftEnum(Encoding, dataPageHeader.encoding);
|
|
569
|
+
if (header.compressed_page_size < 0 ||
|
|
570
|
+
cursorEnd > (cursor.size ?? cursor.buffer.length) ||
|
|
571
|
+
valueCountNonNull < 0) {
|
|
572
|
+
throw new Error('Invalid Parquet data page v2 header');
|
|
573
|
+
}
|
|
247
574
|
/* read repetition levels */
|
|
248
|
-
|
|
249
|
-
let rLevels = new Array(valueCount);
|
|
575
|
+
let rLevels = [];
|
|
250
576
|
if (context.column.rLevelMax > 0) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
disableEnvelope: true
|
|
254
|
-
});
|
|
577
|
+
const repetitionLevelCursor = createPageSliceCursor(cursor, levelsOffset, dataPageHeader.repetition_levels_byte_length);
|
|
578
|
+
rLevels = decodeLevels(repetitionLevelCursor, valueCount, context.column.rLevelMax, PARQUET_RDLVL_ENCODING, true, target?.rlevels, target?.levelOffset);
|
|
255
579
|
}
|
|
256
|
-
else {
|
|
580
|
+
else if (!target) {
|
|
581
|
+
rLevels = new Array(valueCount);
|
|
257
582
|
rLevels.fill(0);
|
|
258
583
|
}
|
|
584
|
+
const definitionLevelsOffset = levelsOffset + dataPageHeader.repetition_levels_byte_length;
|
|
259
585
|
/* read definition levels */
|
|
260
|
-
|
|
261
|
-
let dLevels = new Array(valueCount);
|
|
586
|
+
let dLevels = [];
|
|
262
587
|
if (context.column.dLevelMax > 0) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
disableEnvelope: true
|
|
266
|
-
});
|
|
588
|
+
const definitionLevelCursor = createPageSliceCursor(cursor, definitionLevelsOffset, dataPageHeader.definition_levels_byte_length);
|
|
589
|
+
dLevels = decodeLevels(definitionLevelCursor, valueCount, context.column.dLevelMax, PARQUET_RDLVL_ENCODING, true, target?.dlevels, target?.levelOffset);
|
|
267
590
|
}
|
|
268
|
-
else {
|
|
591
|
+
else if (!target) {
|
|
592
|
+
dLevels = new Array(valueCount);
|
|
269
593
|
dLevels.fill(0);
|
|
270
594
|
}
|
|
271
595
|
/* read values */
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
596
|
+
const valuesOffset = definitionLevelsOffset + dataPageHeader.definition_levels_byte_length;
|
|
597
|
+
const valuesCompressedByteLength = cursorEnd - valuesOffset;
|
|
598
|
+
const valuesUncompressedByteLength = header.uncompressed_page_size -
|
|
599
|
+
dataPageHeader.repetition_levels_byte_length -
|
|
600
|
+
dataPageHeader.definition_levels_byte_length;
|
|
601
|
+
if (valuesCompressedByteLength < 0 || valuesUncompressedByteLength < 0) {
|
|
602
|
+
throw new Error('Invalid Parquet data page v2 level lengths');
|
|
603
|
+
}
|
|
604
|
+
let valuesBuffer = cursor.buffer.subarray(valuesOffset, cursorEnd);
|
|
605
|
+
if (dataPageHeader.is_compressed !== false && context.compression !== 'UNCOMPRESSED') {
|
|
606
|
+
valuesBuffer = context.decompressPage
|
|
607
|
+
? await context.decompressPage(valuesBuffer, valuesUncompressedByteLength)
|
|
608
|
+
: await decompress(context.compression, valuesBuffer, valuesUncompressedByteLength);
|
|
281
609
|
}
|
|
610
|
+
cursor.offset = cursorEnd;
|
|
611
|
+
return decodeDataPageV2Values(valuesBuffer, header, context, target, rLevels, dLevels, valueCount, valueCountNonNull, valueEncoding);
|
|
612
|
+
}
|
|
613
|
+
/** Decodes one uncompressed Data Page V2 without awaiting an unused decompressor. */
|
|
614
|
+
function decodeUncompressedDataPageV2(cursor, header, context, target) {
|
|
615
|
+
const dataPageHeader = header.data_page_header_v2;
|
|
616
|
+
if (!dataPageHeader) {
|
|
617
|
+
throw new Error('Missing Parquet data page v2 header');
|
|
618
|
+
}
|
|
619
|
+
const cursorEnd = cursor.offset + header.compressed_page_size;
|
|
620
|
+
const levelsOffset = cursor.offset;
|
|
621
|
+
const valueCount = dataPageHeader.num_values;
|
|
622
|
+
const valueCountNonNull = valueCount - dataPageHeader.num_nulls;
|
|
623
|
+
const valueEncoding = getThriftEnum(Encoding, dataPageHeader.encoding);
|
|
624
|
+
if (header.compressed_page_size < 0 ||
|
|
625
|
+
cursorEnd > (cursor.size ?? cursor.buffer.length) ||
|
|
626
|
+
valueCountNonNull < 0) {
|
|
627
|
+
throw new Error('Invalid Parquet data page v2 header');
|
|
628
|
+
}
|
|
629
|
+
let rLevels = [];
|
|
630
|
+
if (context.column.rLevelMax > 0) {
|
|
631
|
+
const repetitionLevelCursor = createPageSliceCursor(cursor, levelsOffset, dataPageHeader.repetition_levels_byte_length);
|
|
632
|
+
rLevels = decodeLevels(repetitionLevelCursor, valueCount, context.column.rLevelMax, PARQUET_RDLVL_ENCODING, true, target?.rlevels, target?.levelOffset);
|
|
633
|
+
}
|
|
634
|
+
else if (!target) {
|
|
635
|
+
rLevels = new Array(valueCount).fill(0);
|
|
636
|
+
}
|
|
637
|
+
const definitionLevelsOffset = levelsOffset + dataPageHeader.repetition_levels_byte_length;
|
|
638
|
+
let dLevels = [];
|
|
639
|
+
if (context.column.dLevelMax > 0) {
|
|
640
|
+
const definitionLevelCursor = createPageSliceCursor(cursor, definitionLevelsOffset, dataPageHeader.definition_levels_byte_length);
|
|
641
|
+
dLevels = decodeLevels(definitionLevelCursor, valueCount, context.column.dLevelMax, PARQUET_RDLVL_ENCODING, true, target?.dlevels, target?.levelOffset);
|
|
642
|
+
}
|
|
643
|
+
else if (!target) {
|
|
644
|
+
dLevels = new Array(valueCount).fill(0);
|
|
645
|
+
}
|
|
646
|
+
const valuesOffset = definitionLevelsOffset + dataPageHeader.definition_levels_byte_length;
|
|
647
|
+
const valuesUncompressedByteLength = header.uncompressed_page_size -
|
|
648
|
+
dataPageHeader.repetition_levels_byte_length -
|
|
649
|
+
dataPageHeader.definition_levels_byte_length;
|
|
650
|
+
if (valuesOffset > cursorEnd || valuesUncompressedByteLength < 0) {
|
|
651
|
+
throw new Error('Invalid Parquet data page v2 level lengths');
|
|
652
|
+
}
|
|
653
|
+
const valuesBuffer = cursor.buffer.subarray(valuesOffset, cursorEnd);
|
|
654
|
+
cursor.offset = cursorEnd;
|
|
655
|
+
return decodeDataPageV2Values(valuesBuffer, header, context, target, rLevels, dLevels, valueCount, valueCountNonNull, valueEncoding);
|
|
656
|
+
}
|
|
657
|
+
/** Decodes a prepared Data Page V2 value section without an asynchronous boundary. */
|
|
658
|
+
function decodeDataPageV2Values(valuesBuffer, header, context, target, rLevels, dLevels, valueCount, valueCountNonNull, valueEncoding) {
|
|
659
|
+
const valuesBufCursor = { buffer: valuesBuffer, offset: 0, size: valuesBuffer.length };
|
|
282
660
|
const decodeOptions = {
|
|
283
661
|
typeLength: context.column.typeLength,
|
|
284
|
-
bitWidth: context
|
|
662
|
+
bitWidth: getValueBitWidth(context, valueEncoding),
|
|
663
|
+
retainByteArrayViews: context.retainByteArrayViews,
|
|
664
|
+
output: target?.values,
|
|
665
|
+
outputOffset: target?.valueOffset,
|
|
666
|
+
dictionary: isDictionaryEncoding(valueEncoding) ? target?.dictionary : undefined,
|
|
667
|
+
byteArrayOutput: target?.byteArrayOutput,
|
|
668
|
+
int64AsBigInt: shouldDecodeInt64AsBigInt(context),
|
|
669
|
+
int96AsTimestamp: context.int96AsTimestamp
|
|
285
670
|
};
|
|
286
671
|
const values = decodeValues(context.column.primitiveType, valueEncoding, valuesBufCursor, valueCountNonNull, decodeOptions);
|
|
287
672
|
return {
|
|
288
673
|
dlevels: dLevels,
|
|
289
674
|
rlevels: rLevels,
|
|
290
675
|
values,
|
|
676
|
+
directValuesWritten: target ? valueCountNonNull : undefined,
|
|
291
677
|
count: valueCount,
|
|
292
678
|
pageHeader: header
|
|
293
679
|
};
|
|
294
680
|
}
|
|
681
|
+
/** Decodes repetition or definition levels into an optional column-level destination. */
|
|
682
|
+
function decodeLevels(cursor, count, levelMax, encoding, disableEnvelope, output, outputOffset = 0) {
|
|
683
|
+
if (levelMax === 0) {
|
|
684
|
+
return output ? [] : new Array(count).fill(0);
|
|
685
|
+
}
|
|
686
|
+
const levels = decodeValues(PARQUET_RDLVL_TYPE, encoding, cursor, count, {
|
|
687
|
+
bitWidth: getBitWidth(levelMax),
|
|
688
|
+
disableEnvelope,
|
|
689
|
+
output,
|
|
690
|
+
outputOffset
|
|
691
|
+
});
|
|
692
|
+
return output ? [] : levels;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Allocates a compact Arrow-compatible destination for supported uncompressed byte pages.
|
|
696
|
+
*
|
|
697
|
+
* Scanning only the small Thrift page headers avoids committing to the fast path when a column
|
|
698
|
+
* mixes in an encoding that still requires materialized values. The page buffer is a useful
|
|
699
|
+
* initial capacity; the destination grows for prefix-reconstructed delta values when necessary.
|
|
700
|
+
*/
|
|
701
|
+
function createArrowByteArrayOutput(buffer, context, valueCapacity) {
|
|
702
|
+
if (!context.useArrowByteArrayBuffers ||
|
|
703
|
+
context.compression !== 'UNCOMPRESSED' ||
|
|
704
|
+
!supportsArrowByteArrayOutput(context.column) ||
|
|
705
|
+
valueCapacity === 0) {
|
|
706
|
+
return undefined;
|
|
707
|
+
}
|
|
708
|
+
if (!context.hasOnlyArrowByteArrayDataPages &&
|
|
709
|
+
!hasOnlyArrowByteArrayDataPages(buffer, valueCapacity)) {
|
|
710
|
+
return undefined;
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
data: context.column.primitiveType === 'FIXED_LEN_BYTE_ARRAY'
|
|
714
|
+
? new Uint8Array(0)
|
|
715
|
+
: new Uint8Array(Math.max(1, buffer.byteLength)),
|
|
716
|
+
valueOffsets: new Int32Array(valueCapacity + 1),
|
|
717
|
+
byteLength: 0
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
/** Returns whether a BYTE_ARRAY field maps directly to Arrow Utf8 or Binary without conversion. */
|
|
721
|
+
function supportsArrowByteArrayOutput(column) {
|
|
722
|
+
if (column.primitiveType !== 'BYTE_ARRAY' && column.primitiveType !== 'FIXED_LEN_BYTE_ARRAY') {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
if (column.logicalType) {
|
|
726
|
+
return (column.logicalType.type === 'STRING' ||
|
|
727
|
+
column.logicalType.type === 'ENUM' ||
|
|
728
|
+
column.logicalType.type === 'JSON' ||
|
|
729
|
+
column.logicalType.type === 'BSON' ||
|
|
730
|
+
column.logicalType.type === 'VARIANT' ||
|
|
731
|
+
column.logicalType.type === 'GEOMETRY' ||
|
|
732
|
+
column.logicalType.type === 'GEOGRAPHY');
|
|
733
|
+
}
|
|
734
|
+
return (!column.originalType ||
|
|
735
|
+
column.originalType === 'UTF8' ||
|
|
736
|
+
column.originalType === 'ENUM' ||
|
|
737
|
+
column.originalType === 'JSON' ||
|
|
738
|
+
column.originalType === 'BSON' ||
|
|
739
|
+
column.originalType === 'INTERVAL');
|
|
740
|
+
}
|
|
741
|
+
/** Returns whether a complete column buffer contains only direct Arrow byte-array data pages. */
|
|
742
|
+
function hasOnlyArrowByteArrayDataPages(buffer, expectedLevelCount) {
|
|
743
|
+
let offset = 0;
|
|
744
|
+
let levelCount = 0;
|
|
745
|
+
while (offset < buffer.byteLength && levelCount < expectedLevelCount) {
|
|
746
|
+
const { pageHeader, length } = decodePageHeader(buffer, offset);
|
|
747
|
+
const pageType = getThriftEnum(PageType, pageHeader.type);
|
|
748
|
+
if (pageType !== 'DATA_PAGE' && pageType !== 'DATA_PAGE_V2') {
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
const encoding = getThriftEnum(Encoding, pageHeader.data_page_header?.encoding ?? pageHeader.data_page_header_v2?.encoding);
|
|
752
|
+
if (encoding !== 'PLAIN' &&
|
|
753
|
+
encoding !== 'DELTA_LENGTH_BYTE_ARRAY' &&
|
|
754
|
+
encoding !== 'DELTA_BYTE_ARRAY') {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
const valueCount = pageHeader.data_page_header?.num_values ?? pageHeader.data_page_header_v2?.num_values;
|
|
758
|
+
if (valueCount === undefined || valueCount < 0) {
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
levelCount += valueCount;
|
|
762
|
+
offset += length + pageHeader.compressed_page_size;
|
|
763
|
+
if (offset > buffer.byteLength) {
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return levelCount === expectedLevelCount;
|
|
768
|
+
}
|
|
769
|
+
/** Allocates compact unsigned storage for repetition and definition levels. */
|
|
770
|
+
function createParquetLevelBuffer(context, capacity, levelMax) {
|
|
771
|
+
if (context.useTypedLevelBuffers && levelMax === 0) {
|
|
772
|
+
// Required flat columns have no encoded levels. Avoid allocating two row-sized zero buffers
|
|
773
|
+
// that neither direct Arrow construction nor level decoding will inspect.
|
|
774
|
+
return EMPTY_PARQUET_LEVEL_BUFFER;
|
|
775
|
+
}
|
|
776
|
+
if (!context.useTypedLevelBuffers || capacity === 0) {
|
|
777
|
+
return levelMax > 0 ? new Array(capacity) : new Array(capacity).fill(0);
|
|
778
|
+
}
|
|
779
|
+
if (levelMax <= 0xff) {
|
|
780
|
+
return new Uint8Array(capacity);
|
|
781
|
+
}
|
|
782
|
+
if (levelMax <= 0xffff) {
|
|
783
|
+
return new Uint16Array(capacity);
|
|
784
|
+
}
|
|
785
|
+
return new Uint32Array(capacity);
|
|
786
|
+
}
|
|
787
|
+
/** Restricts an overallocated level buffer to the number of decoded levels. */
|
|
788
|
+
function trimParquetLevelBuffer(levels, length) {
|
|
789
|
+
if (Array.isArray(levels)) {
|
|
790
|
+
levels.length = length;
|
|
791
|
+
return levels;
|
|
792
|
+
}
|
|
793
|
+
if (levels.length === 0 || levels.length === length)
|
|
794
|
+
return levels;
|
|
795
|
+
return levels.subarray(0, length);
|
|
796
|
+
}
|
|
797
|
+
/** Returns whether an encoding stores RLE dictionary indices instead of physical values. */
|
|
798
|
+
function isDictionaryEncoding(encoding) {
|
|
799
|
+
return encoding === 'PLAIN_DICTIONARY' || encoding === 'RLE_DICTIONARY';
|
|
800
|
+
}
|
|
801
|
+
/** Preserves exact physical signed INT64 values in every output shape. */
|
|
802
|
+
function shouldDecodeInt64AsBigInt(context) {
|
|
803
|
+
return context.column.primitiveType === 'INT64';
|
|
804
|
+
}
|
|
805
|
+
/** Allocates the narrowest lossless column buffer supported by the current JavaScript decoder. */
|
|
806
|
+
function createParquetColumnValueBuffer(context, capacity) {
|
|
807
|
+
if (!context.useTypedValueBuffers || capacity === 0) {
|
|
808
|
+
return new Array(capacity);
|
|
809
|
+
}
|
|
810
|
+
switch (context.column.primitiveType) {
|
|
811
|
+
case 'BOOLEAN':
|
|
812
|
+
return new Uint8Array(capacity);
|
|
813
|
+
case 'INT32':
|
|
814
|
+
return new Int32Array(capacity);
|
|
815
|
+
case 'INT64':
|
|
816
|
+
return new BigInt64Array(capacity);
|
|
817
|
+
case 'INT96':
|
|
818
|
+
return context.int96AsTimestamp ? new BigInt64Array(capacity) : new Float64Array(capacity);
|
|
819
|
+
case 'DOUBLE':
|
|
820
|
+
return new Float64Array(capacity);
|
|
821
|
+
case 'FLOAT':
|
|
822
|
+
return new Float32Array(capacity);
|
|
823
|
+
default:
|
|
824
|
+
return new Array(capacity);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
/** Restricts an overallocated typed column buffer to its decoded non-null values. */
|
|
828
|
+
function trimParquetValueBuffer(values, length) {
|
|
829
|
+
if (Array.isArray(values)) {
|
|
830
|
+
values.length = length;
|
|
831
|
+
return values;
|
|
832
|
+
}
|
|
833
|
+
return values.subarray(0, length);
|
|
834
|
+
}
|
|
835
|
+
/** Returns the physical value bit width required by encodings such as RLE BOOLEAN. */
|
|
836
|
+
function getValueBitWidth(context, encoding) {
|
|
837
|
+
if (encoding === 'RLE' && context.column.primitiveType === 'BOOLEAN') {
|
|
838
|
+
return 1;
|
|
839
|
+
}
|
|
840
|
+
return context.column.typeLength;
|
|
841
|
+
}
|
|
842
|
+
/** Creates a bounded cursor over one uncompressed data page v2 level section. */
|
|
843
|
+
function createPageSliceCursor(cursor, offset, byteLength) {
|
|
844
|
+
const end = offset + byteLength;
|
|
845
|
+
if (byteLength < 0 || end > (cursor.size ?? cursor.buffer.length)) {
|
|
846
|
+
throw new Error('Invalid Parquet data page v2 level lengths');
|
|
847
|
+
}
|
|
848
|
+
const buffer = cursor.buffer.subarray(offset, end);
|
|
849
|
+
return { buffer, offset: 0, size: buffer.length };
|
|
850
|
+
}
|
|
295
851
|
/**
|
|
296
852
|
* Do decoding of dictionary page which helps to iterate over all indexes and get dataPage values.
|
|
297
853
|
* @param cursor
|
|
@@ -307,7 +863,10 @@ async function decodeDictionaryPage(cursor, pageHeader, context) {
|
|
|
307
863
|
};
|
|
308
864
|
cursor.offset = cursorEnd;
|
|
309
865
|
if (context.compression !== 'UNCOMPRESSED') {
|
|
310
|
-
const
|
|
866
|
+
const compressedValues = dictCursor.buffer.subarray(dictCursor.offset);
|
|
867
|
+
const valuesBuf = context.decompressPage
|
|
868
|
+
? await context.decompressPage(compressedValues, pageHeader.uncompressed_page_size)
|
|
869
|
+
: await decompress(context.compression, compressedValues, pageHeader.uncompressed_page_size);
|
|
311
870
|
dictCursor = {
|
|
312
871
|
buffer: valuesBuf,
|
|
313
872
|
offset: 0,
|
|
@@ -315,28 +874,37 @@ async function decodeDictionaryPage(cursor, pageHeader, context) {
|
|
|
315
874
|
};
|
|
316
875
|
cursor.offset = cursorEnd;
|
|
317
876
|
}
|
|
318
|
-
|
|
319
|
-
const decodedDictionaryValues = decodeValues(context.column.primitiveType, context.column.encoding, dictCursor, numValues,
|
|
320
|
-
// TODO - this looks wrong?
|
|
321
|
-
context);
|
|
322
|
-
// Makes it look a little easier
|
|
323
|
-
let values;
|
|
324
|
-
if (context?.preserveBinary) {
|
|
325
|
-
values = decodedDictionaryValues.map((d) => preserveBinary(d));
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
values = decodedDictionaryValues.map((d) => d.toString());
|
|
329
|
-
}
|
|
330
|
-
return values;
|
|
877
|
+
return decodeDictionaryValues(dictCursor, pageHeader, context);
|
|
331
878
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (Buffer.isBuffer(d)) {
|
|
338
|
-
return new Uint8Array(d.buffer, d.byteOffset, d.byteLength).slice().buffer;
|
|
879
|
+
/** Decodes an uncompressed dictionary page directly from a view of the column chunk. */
|
|
880
|
+
function decodeUncompressedDictionaryPage(cursor, pageHeader, context) {
|
|
881
|
+
const cursorEnd = cursor.offset + pageHeader.compressed_page_size;
|
|
882
|
+
if (cursorEnd > (cursor.size ?? cursor.buffer.length)) {
|
|
883
|
+
throw new Error('Parquet dictionary page exceeds the available buffer');
|
|
339
884
|
}
|
|
340
|
-
|
|
885
|
+
const dictionaryCursor = {
|
|
886
|
+
buffer: cursor.buffer.subarray(cursor.offset, cursorEnd),
|
|
887
|
+
offset: 0,
|
|
888
|
+
size: pageHeader.compressed_page_size
|
|
889
|
+
};
|
|
890
|
+
cursor.offset = cursorEnd;
|
|
891
|
+
return decodeDictionaryValues(dictionaryCursor, pageHeader, context);
|
|
892
|
+
}
|
|
893
|
+
/** Decodes one dictionary body from its current cursor without copying uncompressed page bytes. */
|
|
894
|
+
function decodeDictionaryValues(dictionaryCursor, pageHeader, context) {
|
|
895
|
+
const numValues = pageHeader?.dictionary_page_header?.num_values || 0;
|
|
896
|
+
const declaredEncoding = getThriftEnum(Encoding, pageHeader.dictionary_page_header?.encoding);
|
|
897
|
+
// Some established writers put the data-page dictionary encoding in this field even though
|
|
898
|
+
// dictionary values themselves use PLAIN. Preserve compatibility with those files.
|
|
899
|
+
const dictionaryValueEncoding = declaredEncoding === 'PLAIN_DICTIONARY' || declaredEncoding === 'RLE_DICTIONARY'
|
|
900
|
+
? 'PLAIN'
|
|
901
|
+
: declaredEncoding;
|
|
902
|
+
const decodedDictionaryValues = decodeValues(context.column.primitiveType, dictionaryValueEncoding, dictionaryCursor, numValues, {
|
|
903
|
+
...context,
|
|
904
|
+
typeLength: context.column.typeLength,
|
|
905
|
+
int64AsBigInt: shouldDecodeInt64AsBigInt(context),
|
|
906
|
+
int96AsTimestamp: context.int96AsTimestamp
|
|
907
|
+
});
|
|
908
|
+
return decodedDictionaryValues;
|
|
341
909
|
}
|
|
342
910
|
//# sourceMappingURL=decoders.js.map
|