@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
|
@@ -0,0 +1,1213 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
import type {ReadableFile} from '@loaders.gl/loader-utils';
|
|
7
|
+
import type {
|
|
8
|
+
ArrayType,
|
|
9
|
+
ArrowTable,
|
|
10
|
+
ArrowTableBatch,
|
|
11
|
+
DataType,
|
|
12
|
+
Field,
|
|
13
|
+
ObjectRowTable,
|
|
14
|
+
Schema,
|
|
15
|
+
SchemaMetadata
|
|
16
|
+
} from '@loaders.gl/schema';
|
|
17
|
+
import {convertTable, deserializeArrowType} from '@loaders.gl/schema-utils';
|
|
18
|
+
|
|
19
|
+
import type {ParquetJSLoaderOptions} from '../../parquet-loader-options';
|
|
20
|
+
import {preloadCompressions} from '../../parquetjs/compression';
|
|
21
|
+
import {ParquetReader} from '../../parquetjs/parser/parquet-reader';
|
|
22
|
+
import type {
|
|
23
|
+
ParquetColumnChunk,
|
|
24
|
+
ParquetField,
|
|
25
|
+
ParquetRowGroup
|
|
26
|
+
} from '../../parquetjs/schema/declare';
|
|
27
|
+
import type {ParquetSchema} from '../../parquetjs/schema/schema';
|
|
28
|
+
import {materializeColumn, materializeRows} from '../../parquetjs/schema/shred';
|
|
29
|
+
import {createNestedArrowVector} from '../arrow/create-nested-arrow-vector';
|
|
30
|
+
import {getSchemaFromParquetReader} from './get-parquet-schema';
|
|
31
|
+
|
|
32
|
+
/** Largest byte value copied inline to avoid TypedArray#set call overhead. */
|
|
33
|
+
const MAXIMUM_INLINE_BYTE_COPY_LENGTH = 7;
|
|
34
|
+
|
|
35
|
+
/** Primitive Arrow type instances used by serialized Parquet schemas. */
|
|
36
|
+
const PARQUET_ARROW_PRIMITIVE_TYPES: Partial<Record<Extract<DataType, string>, arrow.DataType>> = {
|
|
37
|
+
binary: new arrow.Binary(),
|
|
38
|
+
bool: new arrow.Bool(),
|
|
39
|
+
float32: new arrow.Float32(),
|
|
40
|
+
float64: new arrow.Float64(),
|
|
41
|
+
int8: new arrow.Int8(),
|
|
42
|
+
int16: new arrow.Int16(),
|
|
43
|
+
int32: new arrow.Int32(),
|
|
44
|
+
int64: new arrow.Int64(),
|
|
45
|
+
uint8: new arrow.Uint8(),
|
|
46
|
+
uint16: new arrow.Uint16(),
|
|
47
|
+
uint32: new arrow.Uint32(),
|
|
48
|
+
uint64: new arrow.Uint64(),
|
|
49
|
+
utf8: new arrow.Utf8()
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Inputs accepted by Apache Arrow's overloaded `Schema.assign` method. */
|
|
53
|
+
type ArrowSchemaAssignment = arrow.Schema | arrow.Field | arrow.Field[];
|
|
54
|
+
|
|
55
|
+
/** Arrow schema that preserves identity when Apache Arrow assigns its existing fields. */
|
|
56
|
+
class ParquetArrowSchema extends arrow.Schema {
|
|
57
|
+
/** Whether the next exact field assignment may reuse this schema. */
|
|
58
|
+
private reuseIdentityAssignment = false;
|
|
59
|
+
|
|
60
|
+
/** Enables identity reuse for one synchronous Arrow RecordBatch construction. */
|
|
61
|
+
enableIdentityAssignmentReuse(): void {
|
|
62
|
+
this.reuseIdentityAssignment = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Restores Apache Arrow's normal public assignment semantics. */
|
|
66
|
+
disableIdentityAssignmentReuse(): void {
|
|
67
|
+
this.reuseIdentityAssignment = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Avoids cloning fields and merging metadata when assignment is already an exact match.
|
|
72
|
+
* @param assignments schemas or fields to merge into this schema
|
|
73
|
+
* @returns this schema for an identity assignment, otherwise Apache Arrow's assigned schema
|
|
74
|
+
*/
|
|
75
|
+
override assign(...assignments: ArrowSchemaAssignment[]): arrow.Schema {
|
|
76
|
+
const firstAssignment = assignments[0];
|
|
77
|
+
if (
|
|
78
|
+
this.reuseIdentityAssignment &&
|
|
79
|
+
assignments.length === 1 &&
|
|
80
|
+
Array.isArray(firstAssignment) &&
|
|
81
|
+
firstAssignment.length === this.fields.length &&
|
|
82
|
+
firstAssignment.every((field, index) => field === this.fields[index])
|
|
83
|
+
) {
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
const assignedSchema =
|
|
87
|
+
assignments.length === 1 && firstAssignment instanceof arrow.Schema
|
|
88
|
+
? super.assign(firstAssignment)
|
|
89
|
+
: super.assign(...(assignments as Array<arrow.Field | arrow.Field[]>));
|
|
90
|
+
return new ParquetArrowSchema(
|
|
91
|
+
assignedSchema.fields,
|
|
92
|
+
assignedSchema.metadata,
|
|
93
|
+
assignedSchema.dictionaries,
|
|
94
|
+
assignedSchema.metadataVersion
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Parses a Parquet file with the TypeScript implementation directly into Arrow batches.
|
|
101
|
+
* @param file readable Parquet file
|
|
102
|
+
* @param options loader options applied before Arrow conversion
|
|
103
|
+
* @returns Arrow table containing the decoded rows
|
|
104
|
+
*/
|
|
105
|
+
export async function parseParquetFileToArrowWithJs(
|
|
106
|
+
file: ReadableFile,
|
|
107
|
+
options?: ParquetJSLoaderOptions
|
|
108
|
+
): Promise<ArrowTable> {
|
|
109
|
+
if (
|
|
110
|
+
!options?.parquet?.offset &&
|
|
111
|
+
options?.parquet?.limit === undefined &&
|
|
112
|
+
options?.parquet?.batchSize === undefined
|
|
113
|
+
) {
|
|
114
|
+
return await parseCompleteParquetFileToArrowWithJs(file, options);
|
|
115
|
+
}
|
|
116
|
+
const recordBatches: arrow.RecordBatch[] = [];
|
|
117
|
+
let schema: Schema | undefined;
|
|
118
|
+
|
|
119
|
+
for await (const batch of parseParquetFileToArrowInBatchesWithJs(file, options)) {
|
|
120
|
+
schema ||= batch.schema;
|
|
121
|
+
recordBatches.push(...batch.data.batches);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
schema ||= await readProjectedSchema(file, options);
|
|
125
|
+
const table = recordBatches.length
|
|
126
|
+
? new arrow.Table(recordBatches)
|
|
127
|
+
: new arrow.Table(createParquetArrowSchema(schema), []);
|
|
128
|
+
return {shape: 'arrow-table', data: table, schema};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Parses complete row groups directly, bypassing batch slicing and wrapper reconstruction. */
|
|
132
|
+
async function parseCompleteParquetFileToArrowWithJs(
|
|
133
|
+
file: ReadableFile,
|
|
134
|
+
options?: ParquetJSLoaderOptions
|
|
135
|
+
): Promise<ArrowTable> {
|
|
136
|
+
await preloadCompressions(options);
|
|
137
|
+
const reader = new ParquetReader(file, {
|
|
138
|
+
preserveBinary: options?.parquet?.preserveBinary,
|
|
139
|
+
int96AsTimestamp: options?.parquet?.int96AsTimestamp ?? true,
|
|
140
|
+
retainByteArrayViews: true,
|
|
141
|
+
useTypedValueBuffers: true,
|
|
142
|
+
useTypedLevelBuffers: true,
|
|
143
|
+
useArrowByteArrayBuffers: true,
|
|
144
|
+
verifyFooterSignature: options?.parquet?.verifyFooterSignature,
|
|
145
|
+
keyRetriever: options?.parquet?.keyRetriever,
|
|
146
|
+
aadPrefix: options?.parquet?.aadPrefix
|
|
147
|
+
});
|
|
148
|
+
const schema = projectSchema(await getSchemaFromParquetReader(reader), options?.parquet?.columns);
|
|
149
|
+
const arrowSchema = createParquetArrowSchema(schema);
|
|
150
|
+
const parquetSchema = await reader.getSchema();
|
|
151
|
+
const recordBatches: arrow.RecordBatch[] = [];
|
|
152
|
+
let onlyTable: ArrowTable | undefined;
|
|
153
|
+
|
|
154
|
+
for await (const rowGroup of reader.rowGroupIterator(getParquetIterationProps(options))) {
|
|
155
|
+
const table = convertRowGroupSliceToArrow(
|
|
156
|
+
schema,
|
|
157
|
+
arrowSchema,
|
|
158
|
+
parquetSchema,
|
|
159
|
+
rowGroup,
|
|
160
|
+
0,
|
|
161
|
+
rowGroup.rowCount
|
|
162
|
+
);
|
|
163
|
+
onlyTable = recordBatches.length === 0 ? table : undefined;
|
|
164
|
+
recordBatches.push(...table.data.batches);
|
|
165
|
+
}
|
|
166
|
+
if (onlyTable && recordBatches.length === onlyTable.data.batches.length) {
|
|
167
|
+
return onlyTable;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
shape: 'arrow-table',
|
|
171
|
+
schema,
|
|
172
|
+
data: recordBatches.length
|
|
173
|
+
? new arrow.Table(recordBatches)
|
|
174
|
+
: new arrow.Table(createParquetArrowSchema(schema), [])
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Reads the projected loaders.gl schema when row selection produces no Arrow record batches. */
|
|
179
|
+
async function readProjectedSchema(
|
|
180
|
+
file: ReadableFile,
|
|
181
|
+
options?: ParquetJSLoaderOptions
|
|
182
|
+
): Promise<Schema> {
|
|
183
|
+
const reader = new ParquetReader(file, {
|
|
184
|
+
preserveBinary: options?.parquet?.preserveBinary,
|
|
185
|
+
int96AsTimestamp: options?.parquet?.int96AsTimestamp ?? true,
|
|
186
|
+
verifyFooterSignature: options?.parquet?.verifyFooterSignature,
|
|
187
|
+
keyRetriever: options?.parquet?.keyRetriever,
|
|
188
|
+
aadPrefix: options?.parquet?.aadPrefix
|
|
189
|
+
});
|
|
190
|
+
return projectSchema(await getSchemaFromParquetReader(reader), options?.parquet?.columns);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Parses a Parquet file in batches with the TypeScript implementation and materializes Arrow directly
|
|
195
|
+
* from decoded columns whenever the selected schema is flat.
|
|
196
|
+
* @param file readable Parquet file
|
|
197
|
+
* @param options loader options applied before Arrow conversion
|
|
198
|
+
* @returns asynchronous Arrow table batches
|
|
199
|
+
*/
|
|
200
|
+
export async function* parseParquetFileToArrowInBatchesWithJs(
|
|
201
|
+
file: ReadableFile,
|
|
202
|
+
options?: ParquetJSLoaderOptions
|
|
203
|
+
): AsyncIterable<ArrowTableBatch> {
|
|
204
|
+
await preloadCompressions(options);
|
|
205
|
+
|
|
206
|
+
const reader = new ParquetReader(file, {
|
|
207
|
+
preserveBinary: options?.parquet?.preserveBinary,
|
|
208
|
+
int96AsTimestamp: options?.parquet?.int96AsTimestamp ?? true,
|
|
209
|
+
retainByteArrayViews: true,
|
|
210
|
+
useTypedValueBuffers: true,
|
|
211
|
+
useTypedLevelBuffers: true,
|
|
212
|
+
useArrowByteArrayBuffers: true,
|
|
213
|
+
verifyFooterSignature: options?.parquet?.verifyFooterSignature,
|
|
214
|
+
keyRetriever: options?.parquet?.keyRetriever,
|
|
215
|
+
aadPrefix: options?.parquet?.aadPrefix
|
|
216
|
+
});
|
|
217
|
+
const schema = projectSchema(await getSchemaFromParquetReader(reader), options?.parquet?.columns);
|
|
218
|
+
const arrowSchema = createParquetArrowSchema(schema);
|
|
219
|
+
const parquetSchema = await reader.getSchema();
|
|
220
|
+
const rowGroups = reader.rowGroupIterator(getParquetIterationProps(options));
|
|
221
|
+
const rowOffset = Math.max(0, options?.parquet?.offset || 0);
|
|
222
|
+
const rowLimit = options?.parquet?.limit;
|
|
223
|
+
const requestedBatchSize = options?.parquet?.batchSize;
|
|
224
|
+
let rowsVisited = 0;
|
|
225
|
+
let rowsYielded = 0;
|
|
226
|
+
|
|
227
|
+
for await (const rowGroup of rowGroups) {
|
|
228
|
+
const selectionStart = Math.min(rowGroup.rowCount, Math.max(0, rowOffset - rowsVisited));
|
|
229
|
+
const availableRowCount = rowGroup.rowCount - selectionStart;
|
|
230
|
+
const remainingRowCount =
|
|
231
|
+
rowLimit === undefined
|
|
232
|
+
? availableRowCount
|
|
233
|
+
: Math.max(0, Math.min(availableRowCount, rowLimit - rowsYielded));
|
|
234
|
+
const selectionEnd = selectionStart + remainingRowCount;
|
|
235
|
+
rowsVisited += rowGroup.rowCount;
|
|
236
|
+
|
|
237
|
+
if (selectionEnd <= selectionStart) {
|
|
238
|
+
if (rowLimit !== undefined && rowsYielded >= rowLimit) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const arrowTable = convertRowGroupSliceToArrow(
|
|
245
|
+
schema,
|
|
246
|
+
arrowSchema,
|
|
247
|
+
parquetSchema,
|
|
248
|
+
rowGroup,
|
|
249
|
+
selectionStart,
|
|
250
|
+
selectionEnd
|
|
251
|
+
);
|
|
252
|
+
const batchSize =
|
|
253
|
+
requestedBatchSize && requestedBatchSize > 0 ? requestedBatchSize : remainingRowCount;
|
|
254
|
+
|
|
255
|
+
for (let batchStart = selectionStart; batchStart < selectionEnd; batchStart += batchSize) {
|
|
256
|
+
const batchEnd = Math.min(batchStart + batchSize, selectionEnd);
|
|
257
|
+
const batchTable = sliceArrowTable(
|
|
258
|
+
arrowTable,
|
|
259
|
+
batchStart - selectionStart,
|
|
260
|
+
batchEnd - selectionStart
|
|
261
|
+
);
|
|
262
|
+
const length = batchEnd - batchStart;
|
|
263
|
+
|
|
264
|
+
yield {
|
|
265
|
+
batchType: 'data',
|
|
266
|
+
shape: batchTable.shape,
|
|
267
|
+
schema: batchTable.schema,
|
|
268
|
+
data: batchTable.data,
|
|
269
|
+
length
|
|
270
|
+
};
|
|
271
|
+
rowsYielded += length;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (rowLimit !== undefined && rowsYielded >= rowLimit) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Converts a loaders.gl schema into the identity-aware Arrow schema used by Parquet batches. */
|
|
281
|
+
function createParquetArrowSchema(schema: Schema): ParquetArrowSchema {
|
|
282
|
+
return new ParquetArrowSchema(
|
|
283
|
+
schema.fields.map(field => createParquetArrowField(field)),
|
|
284
|
+
createParquetArrowMetadata(schema.metadata)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Hydrates one serialized Parquet field without generic Arrow conversion allocations. */
|
|
289
|
+
function createParquetArrowField(field: Field): arrow.Field {
|
|
290
|
+
return new arrow.Field(
|
|
291
|
+
field.name,
|
|
292
|
+
createParquetArrowType(field.type),
|
|
293
|
+
field.nullable,
|
|
294
|
+
createParquetArrowMetadata(field.metadata)
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Reuses immutable primitive Arrow types and falls back for composite serialized types. */
|
|
299
|
+
function createParquetArrowType(dataType: DataType): arrow.DataType {
|
|
300
|
+
const primitiveType =
|
|
301
|
+
typeof dataType === 'string' ? PARQUET_ARROW_PRIMITIVE_TYPES[dataType] : undefined;
|
|
302
|
+
return primitiveType || deserializeArrowType(dataType);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Hydrates serialized Parquet metadata without an intermediate entries array. */
|
|
306
|
+
function createParquetArrowMetadata(metadata?: SchemaMetadata): Map<string, string> {
|
|
307
|
+
const arrowMetadata = new Map<string, string>();
|
|
308
|
+
if (metadata) {
|
|
309
|
+
for (const key of Object.keys(metadata)) {
|
|
310
|
+
arrowMetadata.set(key, metadata[key]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return arrowMetadata;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Builds Arrow from one selected row-group range with per-column fallbacks. */
|
|
317
|
+
function convertRowGroupSliceToArrow(
|
|
318
|
+
schema: Schema,
|
|
319
|
+
arrowSchema: arrow.Schema,
|
|
320
|
+
parquetSchema: ParquetSchema,
|
|
321
|
+
rowGroup: ParquetRowGroup,
|
|
322
|
+
start: number,
|
|
323
|
+
end: number
|
|
324
|
+
): ArrowTable {
|
|
325
|
+
const vectors: Record<string, arrow.Vector> = {};
|
|
326
|
+
let materializedRows: Record<string, unknown>[] | undefined;
|
|
327
|
+
for (const field of arrowSchema.fields) {
|
|
328
|
+
const parquetField = parquetSchema.findField(field.name);
|
|
329
|
+
const columnData = rowGroup.columnData[field.name];
|
|
330
|
+
const nestedVector = createNestedArrowVector(field.type, parquetField, rowGroup, start, end);
|
|
331
|
+
if (nestedVector) {
|
|
332
|
+
vectors[field.name] = nestedVector;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const decimalVector = createDecimalArrowVector(
|
|
336
|
+
field.type,
|
|
337
|
+
parquetField,
|
|
338
|
+
columnData,
|
|
339
|
+
start,
|
|
340
|
+
end
|
|
341
|
+
);
|
|
342
|
+
if (decimalVector) {
|
|
343
|
+
vectors[field.name] = decimalVector;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const primitiveVector = createRawPrimitiveArrowVector(
|
|
347
|
+
field.type,
|
|
348
|
+
parquetField,
|
|
349
|
+
columnData,
|
|
350
|
+
start,
|
|
351
|
+
end
|
|
352
|
+
);
|
|
353
|
+
if (primitiveVector) {
|
|
354
|
+
vectors[field.name] = primitiveVector;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const byteVector = createRawByteArrowVector(field.type, parquetField, columnData, start, end);
|
|
358
|
+
if (byteVector) {
|
|
359
|
+
vectors[field.name] = byteVector;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
let fullColumn = materializeColumn(parquetSchema, rowGroup, field.name);
|
|
364
|
+
if (parquetField.fields && hasStandardNestedCollection(parquetField)) {
|
|
365
|
+
materializedRows ||= materializeRows(parquetSchema, rowGroup);
|
|
366
|
+
const normalizedValues = materializedRows
|
|
367
|
+
.slice(start, end)
|
|
368
|
+
.map(row => normalizeNestedParquetValue(row[field.name], parquetField));
|
|
369
|
+
vectors[field.name] = arrow.vectorFromArray(normalizedValues, field.type);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (!fullColumn && parquetField.fields) {
|
|
373
|
+
materializedRows ||= materializeRows(parquetSchema, rowGroup);
|
|
374
|
+
const fallbackTable: ObjectRowTable = {
|
|
375
|
+
shape: 'object-row-table',
|
|
376
|
+
schema: {
|
|
377
|
+
...schema,
|
|
378
|
+
fields: schema.fields.filter(schemaField => schemaField.name === field.name)
|
|
379
|
+
},
|
|
380
|
+
data: materializedRows.slice(start, end)
|
|
381
|
+
};
|
|
382
|
+
const fallbackArrowTable = convertTable(fallbackTable, 'arrow-table');
|
|
383
|
+
const fallbackVector = fallbackArrowTable.data.getChild(field.name);
|
|
384
|
+
if (!fallbackVector) {
|
|
385
|
+
throw new Error(`Failed to materialize nested Parquet column ${field.name}`);
|
|
386
|
+
}
|
|
387
|
+
vectors[field.name] = fallbackVector;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
fullColumn ||= new Array(rowGroup.rowCount).fill(null);
|
|
391
|
+
const column = sliceColumn(fullColumn, start, end);
|
|
392
|
+
vectors[field.name] = arrow.vectorFromArray(
|
|
393
|
+
normalizeArrowColumn(column, field.type),
|
|
394
|
+
field.type
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
shape: 'arrow-table',
|
|
400
|
+
schema,
|
|
401
|
+
data: createArrowTable(arrowSchema, vectors, end - start)
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Detects standard collection wrappers that need normalization before Arrow conversion. */
|
|
406
|
+
function hasStandardNestedCollection(field: ParquetField): boolean {
|
|
407
|
+
if (field.logicalType?.type === 'LIST') {
|
|
408
|
+
const element = field.fields?.list?.fields?.element;
|
|
409
|
+
if (!element) return false;
|
|
410
|
+
// Nested repeated continuation is still handled by the legacy materializer;
|
|
411
|
+
// only normalize one-level collections here until that path is fully aligned.
|
|
412
|
+
if (element.logicalType?.type === 'LIST' || element.logicalType?.type === 'MAP') return false;
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
if (field.logicalType?.type === 'MAP') {
|
|
416
|
+
return Boolean(field.fields?.key_value?.fields?.key && field.fields.key_value.fields.value);
|
|
417
|
+
}
|
|
418
|
+
return Object.values(field.fields || {}).some(hasStandardNestedCollection);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Normalizes standard Parquet LIST/MAP wrappers and absent values before Arrow conversion. */
|
|
422
|
+
function normalizeNestedParquetValue(value: unknown, field: ParquetField): unknown {
|
|
423
|
+
// Materialization omits absent optional fields; Arrow builders recognize null, not undefined.
|
|
424
|
+
if (value === undefined || value === null) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
if (!field.fields) {
|
|
428
|
+
return value;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (field.logicalType?.type === 'LIST') {
|
|
432
|
+
const listField = field.fields.list;
|
|
433
|
+
const elementField = listField?.fields?.element;
|
|
434
|
+
if (!listField || !elementField) {
|
|
435
|
+
return value;
|
|
436
|
+
}
|
|
437
|
+
const listValue = value && typeof value === 'object' ? Reflect.get(value, 'list') : undefined;
|
|
438
|
+
if (!Array.isArray(listValue)) {
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
return listValue.map(element =>
|
|
442
|
+
normalizeNestedParquetValue(
|
|
443
|
+
element && typeof element === 'object' ? Reflect.get(element, 'element') : element,
|
|
444
|
+
elementField
|
|
445
|
+
)
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (field.logicalType?.type === 'MAP') {
|
|
450
|
+
const entryField = field.fields.key_value;
|
|
451
|
+
const keyField = entryField?.fields?.key;
|
|
452
|
+
const valueField = entryField?.fields?.value;
|
|
453
|
+
if (!entryField || !keyField || !valueField) {
|
|
454
|
+
return value;
|
|
455
|
+
}
|
|
456
|
+
const entries =
|
|
457
|
+
value && typeof value === 'object' ? Reflect.get(value, 'key_value') : undefined;
|
|
458
|
+
if (!Array.isArray(entries)) {
|
|
459
|
+
return new Map();
|
|
460
|
+
}
|
|
461
|
+
return new Map(
|
|
462
|
+
entries.map(entry => [
|
|
463
|
+
Reflect.get(entry, 'key'),
|
|
464
|
+
normalizeNestedParquetValue(Reflect.get(entry, 'value'), valueField)
|
|
465
|
+
])
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (typeof value !== 'object' || Array.isArray(value) || ArrayBuffer.isView(value)) {
|
|
470
|
+
return value;
|
|
471
|
+
}
|
|
472
|
+
const normalized: Record<string, unknown> = {};
|
|
473
|
+
for (const [name, childField] of Object.entries(field.fields)) {
|
|
474
|
+
normalized[name] = normalizeNestedParquetValue(Reflect.get(value, name), childField);
|
|
475
|
+
}
|
|
476
|
+
return normalized;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** Creates an exact Arrow Decimal128/256 vector from unscaled Parquet decimal values. */
|
|
480
|
+
function createDecimalArrowVector(
|
|
481
|
+
arrowType: arrow.DataType,
|
|
482
|
+
parquetField: ParquetField,
|
|
483
|
+
columnData: ParquetColumnChunk | undefined,
|
|
484
|
+
start: number,
|
|
485
|
+
end: number
|
|
486
|
+
): arrow.Vector | undefined {
|
|
487
|
+
if (!(arrowType instanceof arrow.Decimal) || !columnData) {
|
|
488
|
+
return undefined;
|
|
489
|
+
}
|
|
490
|
+
const rowCount = end - start;
|
|
491
|
+
const wordCount = arrowType.bitWidth / 32;
|
|
492
|
+
const data = new Uint32Array(rowCount * wordCount);
|
|
493
|
+
const nullBitmap = parquetField.dLevelMax ? new Uint8Array(Math.ceil(rowCount / 8)) : undefined;
|
|
494
|
+
let nullCount = 0;
|
|
495
|
+
let valueIndex = 0;
|
|
496
|
+
|
|
497
|
+
if (nullBitmap) {
|
|
498
|
+
for (let rowIndex = 0; rowIndex < start; rowIndex++) {
|
|
499
|
+
if (columnData.dlevels[rowIndex] === parquetField.dLevelMax) valueIndex++;
|
|
500
|
+
}
|
|
501
|
+
} else {
|
|
502
|
+
valueIndex = start;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
506
|
+
const sourceRowIndex = start + rowIndex;
|
|
507
|
+
if (!nullBitmap || columnData.dlevels[sourceRowIndex] === parquetField.dLevelMax) {
|
|
508
|
+
writeArrowDecimal(
|
|
509
|
+
data,
|
|
510
|
+
rowIndex * wordCount,
|
|
511
|
+
wordCount,
|
|
512
|
+
getUnscaledDecimal(columnData.values[valueIndex++]),
|
|
513
|
+
arrowType.bitWidth
|
|
514
|
+
);
|
|
515
|
+
if (nullBitmap) nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
516
|
+
} else {
|
|
517
|
+
nullCount++;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return new arrow.Vector([
|
|
522
|
+
arrow.makeData({
|
|
523
|
+
type: arrowType,
|
|
524
|
+
data,
|
|
525
|
+
nullBitmap: nullCount ? nullBitmap : undefined,
|
|
526
|
+
nullCount
|
|
527
|
+
})
|
|
528
|
+
]);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Converts one Parquet decimal physical value to its signed unscaled integer. */
|
|
532
|
+
function getUnscaledDecimal(value: unknown): bigint {
|
|
533
|
+
if (typeof value === 'bigint') return value;
|
|
534
|
+
if (typeof value === 'number') return BigInt(value);
|
|
535
|
+
const bytes = value as Uint8Array;
|
|
536
|
+
let unsignedValue = 0n;
|
|
537
|
+
for (const byte of bytes) unsignedValue = (unsignedValue << 8n) | BigInt(byte);
|
|
538
|
+
return bytes.length && bytes[0] & 0x80
|
|
539
|
+
? unsignedValue - (1n << BigInt(bytes.length * 8))
|
|
540
|
+
: unsignedValue;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** Writes one signed bigint into Arrow's little-endian two's-complement decimal buffer. */
|
|
544
|
+
function writeArrowDecimal(
|
|
545
|
+
data: Uint32Array,
|
|
546
|
+
offset: number,
|
|
547
|
+
wordCount: number,
|
|
548
|
+
value: bigint,
|
|
549
|
+
bitWidth: number
|
|
550
|
+
): void {
|
|
551
|
+
const minimum = -(1n << BigInt(bitWidth - 1));
|
|
552
|
+
const maximum = (1n << BigInt(bitWidth - 1)) - 1n;
|
|
553
|
+
if (value < minimum || value > maximum) {
|
|
554
|
+
throw new Error(`Parquet decimal value ${value} exceeds Arrow Decimal${bitWidth}`);
|
|
555
|
+
}
|
|
556
|
+
let unsignedValue = BigInt.asUintN(bitWidth, value);
|
|
557
|
+
for (let wordIndex = 0; wordIndex < wordCount; wordIndex++) {
|
|
558
|
+
data[offset + wordIndex] = Number(unsignedValue & 0xffffffffn);
|
|
559
|
+
unsignedValue >>= 32n;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** Creates an Arrow table while retaining row counts for a schema with no projected fields. */
|
|
564
|
+
function createArrowTable(
|
|
565
|
+
schema: arrow.Schema,
|
|
566
|
+
vectors: Record<string, arrow.Vector>,
|
|
567
|
+
rowCount: number
|
|
568
|
+
): arrow.Table {
|
|
569
|
+
if (schema.fields.length) {
|
|
570
|
+
// Every vector represents one row-group slice and therefore has one data chunk. Supplying the
|
|
571
|
+
// Struct directly avoids Arrow Table's generic vector redistribution and schema reassignment.
|
|
572
|
+
const children = schema.fields.map(field => vectors[field.name].data[0]);
|
|
573
|
+
const data = arrow.makeData({
|
|
574
|
+
type: new arrow.Struct(schema.fields),
|
|
575
|
+
length: rowCount,
|
|
576
|
+
nullCount: 0,
|
|
577
|
+
children
|
|
578
|
+
});
|
|
579
|
+
const recordBatch = createParquetRecordBatch(schema, data);
|
|
580
|
+
return new arrow.Table(recordBatch);
|
|
581
|
+
}
|
|
582
|
+
if (rowCount === 0) {
|
|
583
|
+
return new arrow.Table(schema, vectors);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const recordBatch = createParquetRecordBatch(
|
|
587
|
+
schema,
|
|
588
|
+
arrow.makeData({type: new arrow.Struct([]), children: []})
|
|
589
|
+
);
|
|
590
|
+
// Apache Arrow JS derives RecordBatch length from its children and therefore resets an empty
|
|
591
|
+
// Struct to zero rows. Restore the explicit Parquet selection length after construction.
|
|
592
|
+
Object.defineProperty(recordBatch.data, 'length', {value: rowCount});
|
|
593
|
+
return new arrow.Table(schema, [recordBatch]);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Constructs a RecordBatch while restricting schema identity reuse to the synchronous call. */
|
|
597
|
+
function createParquetRecordBatch(
|
|
598
|
+
schema: arrow.Schema,
|
|
599
|
+
data: arrow.Data<arrow.Struct>
|
|
600
|
+
): arrow.RecordBatch {
|
|
601
|
+
if (!(schema instanceof ParquetArrowSchema)) {
|
|
602
|
+
return new arrow.RecordBatch(schema, data);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
schema.enableIdentityAssignmentReuse();
|
|
606
|
+
try {
|
|
607
|
+
return new arrow.RecordBatch(schema, data);
|
|
608
|
+
} finally {
|
|
609
|
+
schema.disableIdentityAssignmentReuse();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** Typed arrays accepted by the direct primitive Arrow materialization path. */
|
|
614
|
+
type RawPrimitiveArrowArray =
|
|
615
|
+
| Float32Array
|
|
616
|
+
| Float64Array
|
|
617
|
+
| Int8Array
|
|
618
|
+
| Int16Array
|
|
619
|
+
| Int32Array
|
|
620
|
+
| Uint8Array
|
|
621
|
+
| Uint16Array
|
|
622
|
+
| Uint32Array
|
|
623
|
+
| BigInt64Array
|
|
624
|
+
| BigUint64Array;
|
|
625
|
+
|
|
626
|
+
/** Creates a fixed-width Arrow vector directly from decoded primitive Parquet values. */
|
|
627
|
+
function createRawPrimitiveArrowVector(
|
|
628
|
+
arrowType: arrow.DataType,
|
|
629
|
+
parquetField: ParquetField,
|
|
630
|
+
columnData: ParquetColumnChunk | undefined,
|
|
631
|
+
start: number,
|
|
632
|
+
end: number
|
|
633
|
+
): arrow.Vector | undefined {
|
|
634
|
+
if (!columnData) {
|
|
635
|
+
return undefined;
|
|
636
|
+
}
|
|
637
|
+
const rowCount = end - start;
|
|
638
|
+
const directData = createRawPrimitiveArrowArrayView(
|
|
639
|
+
arrowType,
|
|
640
|
+
parquetField,
|
|
641
|
+
columnData,
|
|
642
|
+
start,
|
|
643
|
+
end
|
|
644
|
+
);
|
|
645
|
+
const expandedData = directData
|
|
646
|
+
? undefined
|
|
647
|
+
: createExpandedRawPrimitiveArrowArrayView(arrowType, parquetField, columnData, start, end);
|
|
648
|
+
if (expandedData) {
|
|
649
|
+
return new arrow.Vector([
|
|
650
|
+
arrow.makeData({
|
|
651
|
+
type: arrowType,
|
|
652
|
+
data: expandedData.data,
|
|
653
|
+
nullBitmap: expandedData.nullBitmap,
|
|
654
|
+
nullCount: expandedData.nullCount
|
|
655
|
+
} as any)
|
|
656
|
+
]);
|
|
657
|
+
}
|
|
658
|
+
const data = directData || createRawPrimitiveArrowArray(arrowType, parquetField, rowCount);
|
|
659
|
+
if (!data) {
|
|
660
|
+
return undefined;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const nullBitmap = parquetField.dLevelMax ? new Uint8Array(Math.ceil(rowCount / 8)) : undefined;
|
|
664
|
+
let valueIndex = 0;
|
|
665
|
+
let nullCount = 0;
|
|
666
|
+
|
|
667
|
+
if (!nullBitmap) {
|
|
668
|
+
if (!directData) {
|
|
669
|
+
valueIndex = start;
|
|
670
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
671
|
+
setRawPrimitiveArrowValue(data, rowIndex, columnData.values[valueIndex++]);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
for (let rowIndex = 0; rowIndex < start; rowIndex++) {
|
|
676
|
+
if (columnData.dlevels[rowIndex] === parquetField.dLevelMax) {
|
|
677
|
+
valueIndex++;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
681
|
+
const sourceRowIndex = start + rowIndex;
|
|
682
|
+
if (columnData.dlevels[sourceRowIndex] === parquetField.dLevelMax) {
|
|
683
|
+
setRawPrimitiveArrowValue(data, rowIndex, columnData.values[valueIndex++]);
|
|
684
|
+
nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
685
|
+
} else {
|
|
686
|
+
nullCount++;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const nulls = nullCount ? nullBitmap : undefined;
|
|
692
|
+
return new arrow.Vector([
|
|
693
|
+
arrow.makeData({type: arrowType, data, nullBitmap: nulls, nullCount} as any)
|
|
694
|
+
]);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Expands a full nullable primitive column in place into the decoder's row-capacity buffer.
|
|
699
|
+
*
|
|
700
|
+
* Parquet omits physical values for null rows, but the decoder allocates from the column's level
|
|
701
|
+
* count. Walking backwards makes the overlapping expansion safe while building Arrow validity.
|
|
702
|
+
*/
|
|
703
|
+
function createExpandedRawPrimitiveArrowArrayView(
|
|
704
|
+
arrowType: arrow.DataType,
|
|
705
|
+
parquetField: ParquetField,
|
|
706
|
+
columnData: ParquetColumnChunk,
|
|
707
|
+
start: number,
|
|
708
|
+
end: number
|
|
709
|
+
):
|
|
710
|
+
| {data: RawPrimitiveArrowArray; nullBitmap: Uint8Array | undefined; nullCount: number}
|
|
711
|
+
| undefined {
|
|
712
|
+
if (
|
|
713
|
+
parquetField.repetitionType !== 'OPTIONAL' ||
|
|
714
|
+
parquetField.rLevelMax !== 0 ||
|
|
715
|
+
start !== 0 ||
|
|
716
|
+
end !== columnData.count
|
|
717
|
+
) {
|
|
718
|
+
return undefined;
|
|
719
|
+
}
|
|
720
|
+
const compactData = getMatchingRawPrimitiveArrowArray(arrowType, parquetField, columnData.values);
|
|
721
|
+
if (!compactData) {
|
|
722
|
+
return undefined;
|
|
723
|
+
}
|
|
724
|
+
if (columnData.nullCount === 0 && compactData.length === end) {
|
|
725
|
+
return {data: compactData, nullBitmap: undefined, nullCount: 0};
|
|
726
|
+
}
|
|
727
|
+
const data = createRawPrimitiveCapacityView(compactData, end);
|
|
728
|
+
if (!data) {
|
|
729
|
+
return undefined;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const nullBitmap = new Uint8Array(Math.ceil(end / 8));
|
|
733
|
+
let valueIndex = compactData.length - 1;
|
|
734
|
+
let nullCount = 0;
|
|
735
|
+
for (let rowIndex = end - 1; rowIndex >= 0; rowIndex--) {
|
|
736
|
+
if (columnData.dlevels[rowIndex] === parquetField.dLevelMax) {
|
|
737
|
+
setRawPrimitiveArrowValue(data, rowIndex, compactData[valueIndex--]);
|
|
738
|
+
nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
739
|
+
} else {
|
|
740
|
+
nullCount++;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
if (valueIndex !== -1) {
|
|
744
|
+
throw new Error(`Parquet column ${parquetField.name} has inconsistent definition levels`);
|
|
745
|
+
}
|
|
746
|
+
return {data, nullBitmap: nullCount ? nullBitmap : undefined, nullCount};
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/** Reuses a typed decoded column as the Arrow value buffer for required primitive fields. */
|
|
750
|
+
function createRawPrimitiveArrowArrayView(
|
|
751
|
+
arrowType: arrow.DataType,
|
|
752
|
+
parquetField: ParquetField,
|
|
753
|
+
columnData: ParquetColumnChunk,
|
|
754
|
+
start: number,
|
|
755
|
+
end: number
|
|
756
|
+
): RawPrimitiveArrowArray | undefined {
|
|
757
|
+
if (parquetField.repetitionType !== 'REQUIRED') {
|
|
758
|
+
return undefined;
|
|
759
|
+
}
|
|
760
|
+
const values = getMatchingRawPrimitiveArrowArray(arrowType, parquetField, columnData.values);
|
|
761
|
+
return values?.subarray(start, end) as RawPrimitiveArrowArray | undefined;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/** Returns a decoded typed value buffer when it exactly matches the target Arrow representation. */
|
|
765
|
+
function getMatchingRawPrimitiveArrowArray(
|
|
766
|
+
arrowType: arrow.DataType,
|
|
767
|
+
parquetField: ParquetField,
|
|
768
|
+
values: ParquetColumnChunk['values']
|
|
769
|
+
): RawPrimitiveArrowArray | undefined {
|
|
770
|
+
if (
|
|
771
|
+
parquetField.primitiveType === 'FLOAT' &&
|
|
772
|
+
arrowType instanceof arrow.Float32 &&
|
|
773
|
+
values instanceof Float32Array
|
|
774
|
+
) {
|
|
775
|
+
return values;
|
|
776
|
+
}
|
|
777
|
+
if (
|
|
778
|
+
parquetField.primitiveType === 'DOUBLE' &&
|
|
779
|
+
arrowType instanceof arrow.Float64 &&
|
|
780
|
+
values instanceof Float64Array
|
|
781
|
+
) {
|
|
782
|
+
return values;
|
|
783
|
+
}
|
|
784
|
+
if (
|
|
785
|
+
parquetField.primitiveType === 'INT32' &&
|
|
786
|
+
(arrowType instanceof arrow.Int32 ||
|
|
787
|
+
arrowType instanceof arrow.DateDay ||
|
|
788
|
+
arrowType instanceof arrow.TimeMillisecond) &&
|
|
789
|
+
values instanceof Int32Array
|
|
790
|
+
) {
|
|
791
|
+
return values;
|
|
792
|
+
}
|
|
793
|
+
if (
|
|
794
|
+
parquetField.primitiveType === 'INT64' &&
|
|
795
|
+
(arrowType instanceof arrow.Int64 ||
|
|
796
|
+
arrowType instanceof arrow.TimeMicrosecond ||
|
|
797
|
+
arrowType instanceof arrow.TimeNanosecond ||
|
|
798
|
+
arrowType instanceof arrow.TimestampMillisecond ||
|
|
799
|
+
arrowType instanceof arrow.TimestampMicrosecond ||
|
|
800
|
+
arrowType instanceof arrow.TimestampNanosecond) &&
|
|
801
|
+
values instanceof BigInt64Array
|
|
802
|
+
) {
|
|
803
|
+
return values;
|
|
804
|
+
}
|
|
805
|
+
if (
|
|
806
|
+
parquetField.primitiveType === 'INT96' &&
|
|
807
|
+
arrowType instanceof arrow.TimestampNanosecond &&
|
|
808
|
+
values instanceof BigInt64Array
|
|
809
|
+
) {
|
|
810
|
+
return values;
|
|
811
|
+
}
|
|
812
|
+
return undefined;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/** Creates a larger view over the unused capacity retained by a compact decoder buffer. */
|
|
816
|
+
function createRawPrimitiveCapacityView(
|
|
817
|
+
values: RawPrimitiveArrowArray,
|
|
818
|
+
length: number
|
|
819
|
+
): RawPrimitiveArrowArray | undefined {
|
|
820
|
+
if (values.buffer.byteLength - values.byteOffset < length * values.BYTES_PER_ELEMENT) {
|
|
821
|
+
return undefined;
|
|
822
|
+
}
|
|
823
|
+
if (values instanceof Float32Array) {
|
|
824
|
+
return new Float32Array(values.buffer, values.byteOffset, length);
|
|
825
|
+
}
|
|
826
|
+
if (values instanceof Float64Array) {
|
|
827
|
+
return new Float64Array(values.buffer, values.byteOffset, length);
|
|
828
|
+
}
|
|
829
|
+
if (values instanceof Int8Array) return new Int8Array(values.buffer, values.byteOffset, length);
|
|
830
|
+
if (values instanceof Int16Array) return new Int16Array(values.buffer, values.byteOffset, length);
|
|
831
|
+
if (values instanceof Int32Array) return new Int32Array(values.buffer, values.byteOffset, length);
|
|
832
|
+
if (values instanceof Uint8Array) return new Uint8Array(values.buffer, values.byteOffset, length);
|
|
833
|
+
if (values instanceof Uint16Array)
|
|
834
|
+
return new Uint16Array(values.buffer, values.byteOffset, length);
|
|
835
|
+
if (values instanceof Uint32Array)
|
|
836
|
+
return new Uint32Array(values.buffer, values.byteOffset, length);
|
|
837
|
+
if (values instanceof BigInt64Array) {
|
|
838
|
+
return new BigInt64Array(values.buffer, values.byteOffset, length);
|
|
839
|
+
}
|
|
840
|
+
return new BigUint64Array(values.buffer, values.byteOffset, length);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/** Allocates the Arrow typed array matching an unconverted physical Parquet primitive. */
|
|
844
|
+
function createRawPrimitiveArrowArray(
|
|
845
|
+
arrowType: arrow.DataType,
|
|
846
|
+
parquetField: ParquetField,
|
|
847
|
+
rowCount: number
|
|
848
|
+
): RawPrimitiveArrowArray | undefined {
|
|
849
|
+
if (parquetField.primitiveType === 'FLOAT' && arrowType instanceof arrow.Float32) {
|
|
850
|
+
return new Float32Array(rowCount);
|
|
851
|
+
}
|
|
852
|
+
if (parquetField.primitiveType === 'DOUBLE' && arrowType instanceof arrow.Float64) {
|
|
853
|
+
return new Float64Array(rowCount);
|
|
854
|
+
}
|
|
855
|
+
if (parquetField.primitiveType === 'INT32' && arrowType instanceof arrow.Int8) {
|
|
856
|
+
return new Int8Array(rowCount);
|
|
857
|
+
}
|
|
858
|
+
if (parquetField.primitiveType === 'INT32' && arrowType instanceof arrow.Int16) {
|
|
859
|
+
return new Int16Array(rowCount);
|
|
860
|
+
}
|
|
861
|
+
if (
|
|
862
|
+
parquetField.primitiveType === 'INT32' &&
|
|
863
|
+
(arrowType instanceof arrow.Int32 ||
|
|
864
|
+
arrowType instanceof arrow.DateDay ||
|
|
865
|
+
arrowType instanceof arrow.TimeMillisecond)
|
|
866
|
+
) {
|
|
867
|
+
return new Int32Array(rowCount);
|
|
868
|
+
}
|
|
869
|
+
if (parquetField.primitiveType === 'INT32' && arrowType instanceof arrow.Uint8) {
|
|
870
|
+
return new Uint8Array(rowCount);
|
|
871
|
+
}
|
|
872
|
+
if (parquetField.primitiveType === 'INT32' && arrowType instanceof arrow.Uint16) {
|
|
873
|
+
return new Uint16Array(rowCount);
|
|
874
|
+
}
|
|
875
|
+
if (parquetField.primitiveType === 'INT32' && arrowType instanceof arrow.Uint32) {
|
|
876
|
+
return new Uint32Array(rowCount);
|
|
877
|
+
}
|
|
878
|
+
if (
|
|
879
|
+
parquetField.primitiveType === 'INT64' &&
|
|
880
|
+
(arrowType instanceof arrow.Int64 ||
|
|
881
|
+
arrowType instanceof arrow.TimeMicrosecond ||
|
|
882
|
+
arrowType instanceof arrow.TimeNanosecond ||
|
|
883
|
+
arrowType instanceof arrow.TimestampMillisecond ||
|
|
884
|
+
arrowType instanceof arrow.TimestampMicrosecond ||
|
|
885
|
+
arrowType instanceof arrow.TimestampNanosecond)
|
|
886
|
+
) {
|
|
887
|
+
return new BigInt64Array(rowCount);
|
|
888
|
+
}
|
|
889
|
+
if (parquetField.primitiveType === 'INT96' && arrowType instanceof arrow.TimestampNanosecond) {
|
|
890
|
+
return new BigInt64Array(rowCount);
|
|
891
|
+
}
|
|
892
|
+
if (parquetField.primitiveType === 'INT64' && arrowType instanceof arrow.Uint64) {
|
|
893
|
+
return new BigUint64Array(rowCount);
|
|
894
|
+
}
|
|
895
|
+
return undefined;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** Writes a decoded primitive into the exact TypedArray expected by Arrow. */
|
|
899
|
+
function setRawPrimitiveArrowValue(
|
|
900
|
+
data: RawPrimitiveArrowArray,
|
|
901
|
+
index: number,
|
|
902
|
+
value: unknown
|
|
903
|
+
): void {
|
|
904
|
+
if (data instanceof BigInt64Array) {
|
|
905
|
+
data[index] = typeof value === 'bigint' ? value : BigInt(value as number | string);
|
|
906
|
+
} else if (data instanceof BigUint64Array) {
|
|
907
|
+
data[index] = BigInt.asUintN(
|
|
908
|
+
64,
|
|
909
|
+
typeof value === 'bigint' ? value : BigInt(value as number | string)
|
|
910
|
+
);
|
|
911
|
+
} else {
|
|
912
|
+
data[index] = Number(value);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/** Creates an Arrow Utf8 or Binary vector directly from decoded Parquet byte arrays. */
|
|
917
|
+
function createRawByteArrowVector(
|
|
918
|
+
arrowType: arrow.DataType,
|
|
919
|
+
parquetField: ParquetField,
|
|
920
|
+
columnData: ParquetColumnChunk | undefined,
|
|
921
|
+
start: number,
|
|
922
|
+
end: number
|
|
923
|
+
): arrow.Vector | undefined {
|
|
924
|
+
if (!columnData || !supportsRawByteArrowVector(arrowType, parquetField)) {
|
|
925
|
+
return undefined;
|
|
926
|
+
}
|
|
927
|
+
if (columnData.byteArrayData) {
|
|
928
|
+
return createBufferedByteArrowVector(arrowType, parquetField, columnData, start, end);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
const rowCount = end - start;
|
|
932
|
+
const valueOffsets = new Int32Array(rowCount + 1);
|
|
933
|
+
const byteValues = columnData.values as Uint8Array[];
|
|
934
|
+
const nullBitmap = parquetField.dLevelMax ? new Uint8Array(Math.ceil(rowCount / 8)) : undefined;
|
|
935
|
+
let valueIndex = 0;
|
|
936
|
+
let firstValueIndex = 0;
|
|
937
|
+
let dataByteLength = 0;
|
|
938
|
+
let nullCount = 0;
|
|
939
|
+
|
|
940
|
+
if (!nullBitmap) {
|
|
941
|
+
valueIndex = start;
|
|
942
|
+
firstValueIndex = valueIndex;
|
|
943
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
944
|
+
dataByteLength += byteValues[valueIndex++].byteLength;
|
|
945
|
+
if (dataByteLength > 0x7fffffff) {
|
|
946
|
+
throw new Error('Arrow Utf8/Binary column exceeds the 32-bit offset range');
|
|
947
|
+
}
|
|
948
|
+
valueOffsets[rowIndex + 1] = dataByteLength;
|
|
949
|
+
}
|
|
950
|
+
} else {
|
|
951
|
+
for (let rowIndex = 0; rowIndex < start; rowIndex++) {
|
|
952
|
+
if (columnData.dlevels[rowIndex] === parquetField.dLevelMax) {
|
|
953
|
+
valueIndex++;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
firstValueIndex = valueIndex;
|
|
957
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
958
|
+
const sourceRowIndex = start + rowIndex;
|
|
959
|
+
if (columnData.dlevels[sourceRowIndex] === parquetField.dLevelMax) {
|
|
960
|
+
dataByteLength += byteValues[valueIndex++].byteLength;
|
|
961
|
+
nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
962
|
+
} else {
|
|
963
|
+
nullCount++;
|
|
964
|
+
}
|
|
965
|
+
if (dataByteLength > 0x7fffffff) {
|
|
966
|
+
throw new Error('Arrow Utf8/Binary column exceeds the 32-bit offset range');
|
|
967
|
+
}
|
|
968
|
+
valueOffsets[rowIndex + 1] = dataByteLength;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
const contiguousData = getContiguousFixedByteArrayData(
|
|
973
|
+
parquetField,
|
|
974
|
+
columnData,
|
|
975
|
+
byteValues,
|
|
976
|
+
firstValueIndex,
|
|
977
|
+
valueIndex,
|
|
978
|
+
dataByteLength
|
|
979
|
+
);
|
|
980
|
+
const data = contiguousData || new Uint8Array(dataByteLength);
|
|
981
|
+
if (!contiguousData) {
|
|
982
|
+
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
983
|
+
let dataOffset = 0;
|
|
984
|
+
for (let index = firstValueIndex; index < valueIndex; index++) {
|
|
985
|
+
const bytes = byteValues[index];
|
|
986
|
+
if (bytes.byteLength >= 4 && bytes.byteLength <= MAXIMUM_INLINE_BYTE_COPY_LENGTH) {
|
|
987
|
+
dataView.setUint32(
|
|
988
|
+
dataOffset,
|
|
989
|
+
bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24),
|
|
990
|
+
true
|
|
991
|
+
);
|
|
992
|
+
dataOffset += 4;
|
|
993
|
+
for (let byteIndex = 4; byteIndex < bytes.byteLength; byteIndex++) {
|
|
994
|
+
data[dataOffset++] = bytes[byteIndex];
|
|
995
|
+
}
|
|
996
|
+
} else if (bytes.byteLength <= MAXIMUM_INLINE_BYTE_COPY_LENGTH) {
|
|
997
|
+
for (let byteIndex = 0; byteIndex < bytes.byteLength; byteIndex++) {
|
|
998
|
+
data[dataOffset++] = bytes[byteIndex];
|
|
999
|
+
}
|
|
1000
|
+
} else {
|
|
1001
|
+
data.set(bytes, dataOffset);
|
|
1002
|
+
dataOffset += bytes.byteLength;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
const nulls = nullCount ? nullBitmap : undefined;
|
|
1008
|
+
if (arrowType instanceof arrow.Utf8) {
|
|
1009
|
+
return new arrow.Vector([
|
|
1010
|
+
arrow.makeData({
|
|
1011
|
+
type: arrowType,
|
|
1012
|
+
valueOffsets,
|
|
1013
|
+
data,
|
|
1014
|
+
nullBitmap: nulls,
|
|
1015
|
+
nullCount
|
|
1016
|
+
})
|
|
1017
|
+
]);
|
|
1018
|
+
}
|
|
1019
|
+
if (arrowType instanceof arrow.Binary) {
|
|
1020
|
+
return new arrow.Vector([
|
|
1021
|
+
arrow.makeData({
|
|
1022
|
+
type: arrowType,
|
|
1023
|
+
valueOffsets,
|
|
1024
|
+
data,
|
|
1025
|
+
nullBitmap: nulls,
|
|
1026
|
+
nullCount
|
|
1027
|
+
})
|
|
1028
|
+
]);
|
|
1029
|
+
}
|
|
1030
|
+
return undefined;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/** Creates a flat Arrow Utf8/Binary vector from the decoder's compact physical byte buffer. */
|
|
1034
|
+
function createBufferedByteArrowVector(
|
|
1035
|
+
arrowType: arrow.DataType,
|
|
1036
|
+
parquetField: ParquetField,
|
|
1037
|
+
columnData: ParquetColumnChunk,
|
|
1038
|
+
start: number,
|
|
1039
|
+
end: number
|
|
1040
|
+
): arrow.Vector {
|
|
1041
|
+
const byteArrayData = columnData.byteArrayData!;
|
|
1042
|
+
const rowCount = end - start;
|
|
1043
|
+
const nullBitmap = parquetField.dLevelMax ? new Uint8Array(Math.ceil(rowCount / 8)) : undefined;
|
|
1044
|
+
let sourceValueIndex = 0;
|
|
1045
|
+
let nullCount = 0;
|
|
1046
|
+
|
|
1047
|
+
if (!nullBitmap) {
|
|
1048
|
+
sourceValueIndex = start;
|
|
1049
|
+
} else {
|
|
1050
|
+
for (let rowIndex = 0; rowIndex < start; rowIndex++) {
|
|
1051
|
+
if (columnData.dlevels[rowIndex] === parquetField.dLevelMax) sourceValueIndex++;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
const firstValueIndex = sourceValueIndex;
|
|
1055
|
+
const canReuseOffsets = !nullBitmap && start === 0 && end === columnData.count;
|
|
1056
|
+
const valueOffsets = canReuseOffsets ? byteArrayData.valueOffsets : new Int32Array(rowCount + 1);
|
|
1057
|
+
let dataByteLength = 0;
|
|
1058
|
+
|
|
1059
|
+
if (!canReuseOffsets) {
|
|
1060
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
1061
|
+
const sourceRowIndex = start + rowIndex;
|
|
1062
|
+
if (!nullBitmap || columnData.dlevels[sourceRowIndex] === parquetField.dLevelMax) {
|
|
1063
|
+
dataByteLength +=
|
|
1064
|
+
byteArrayData.valueOffsets[sourceValueIndex + 1] -
|
|
1065
|
+
byteArrayData.valueOffsets[sourceValueIndex];
|
|
1066
|
+
sourceValueIndex++;
|
|
1067
|
+
if (nullBitmap) nullBitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
1068
|
+
} else {
|
|
1069
|
+
nullCount++;
|
|
1070
|
+
}
|
|
1071
|
+
valueOffsets[rowIndex + 1] = dataByteLength;
|
|
1072
|
+
}
|
|
1073
|
+
} else {
|
|
1074
|
+
sourceValueIndex = end;
|
|
1075
|
+
dataByteLength = byteArrayData.valueOffsets[sourceValueIndex];
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
const firstByteOffset = byteArrayData.valueOffsets[firstValueIndex];
|
|
1079
|
+
const lastByteOffset = byteArrayData.valueOffsets[sourceValueIndex];
|
|
1080
|
+
const data = byteArrayData.data.subarray(firstByteOffset, lastByteOffset);
|
|
1081
|
+
return new arrow.Vector([
|
|
1082
|
+
arrow.makeData({
|
|
1083
|
+
type: arrowType,
|
|
1084
|
+
valueOffsets,
|
|
1085
|
+
data,
|
|
1086
|
+
nullBitmap: nullCount ? nullBitmap : undefined,
|
|
1087
|
+
nullCount
|
|
1088
|
+
} as any)
|
|
1089
|
+
]);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Reuses one PLAIN page's contiguous fixed-width payload as Arrow Binary data.
|
|
1094
|
+
*
|
|
1095
|
+
* A single FIXED_LEN_BYTE_ARRAY page has no length prefixes between physical values. The decoder
|
|
1096
|
+
* retains each value as a view into that page, so Arrow can retain the complete span instead of
|
|
1097
|
+
* allocating and copying every value into another buffer.
|
|
1098
|
+
*/
|
|
1099
|
+
function getContiguousFixedByteArrayData(
|
|
1100
|
+
parquetField: ParquetField,
|
|
1101
|
+
columnData: ParquetColumnChunk,
|
|
1102
|
+
byteValues: Uint8Array[],
|
|
1103
|
+
firstValueIndex: number,
|
|
1104
|
+
valueEndIndex: number,
|
|
1105
|
+
dataByteLength: number
|
|
1106
|
+
): Uint8Array | undefined {
|
|
1107
|
+
const valueCount = valueEndIndex - firstValueIndex;
|
|
1108
|
+
const typeLength = parquetField.typeLength;
|
|
1109
|
+
if (
|
|
1110
|
+
parquetField.primitiveType !== 'FIXED_LEN_BYTE_ARRAY' ||
|
|
1111
|
+
!typeLength ||
|
|
1112
|
+
columnData.pageHeaders.length !== 1 ||
|
|
1113
|
+
valueCount === 0 ||
|
|
1114
|
+
dataByteLength !== valueCount * typeLength
|
|
1115
|
+
) {
|
|
1116
|
+
return undefined;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
const firstValue = byteValues[firstValueIndex];
|
|
1120
|
+
const lastValue = byteValues[valueEndIndex - 1];
|
|
1121
|
+
if (
|
|
1122
|
+
firstValue.byteLength !== typeLength ||
|
|
1123
|
+
lastValue.byteLength !== typeLength ||
|
|
1124
|
+
firstValue.buffer !== lastValue.buffer ||
|
|
1125
|
+
lastValue.byteOffset + typeLength !== firstValue.byteOffset + dataByteLength
|
|
1126
|
+
) {
|
|
1127
|
+
return undefined;
|
|
1128
|
+
}
|
|
1129
|
+
return new Uint8Array(firstValue.buffer, firstValue.byteOffset, dataByteLength);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/** Returns whether one flat Parquet byte column maps directly to Arrow Utf8 or Binary. */
|
|
1133
|
+
function supportsRawByteArrowVector(
|
|
1134
|
+
arrowType: arrow.DataType,
|
|
1135
|
+
parquetField: ParquetField
|
|
1136
|
+
): boolean {
|
|
1137
|
+
if (arrowType instanceof arrow.Utf8) {
|
|
1138
|
+
return parquetField.originalType === 'UTF8' || parquetField.originalType === 'ENUM';
|
|
1139
|
+
}
|
|
1140
|
+
if (arrowType instanceof arrow.Binary) {
|
|
1141
|
+
return (
|
|
1142
|
+
(!parquetField.originalType ||
|
|
1143
|
+
parquetField.originalType === 'JSON' ||
|
|
1144
|
+
parquetField.originalType === 'BSON' ||
|
|
1145
|
+
parquetField.originalType === 'INTERVAL' ||
|
|
1146
|
+
parquetField.originalType === 'VARIANT' ||
|
|
1147
|
+
parquetField.originalType === 'GEOMETRY' ||
|
|
1148
|
+
parquetField.originalType === 'GEOGRAPHY') &&
|
|
1149
|
+
(parquetField.primitiveType === 'BYTE_ARRAY' ||
|
|
1150
|
+
parquetField.primitiveType === 'FIXED_LEN_BYTE_ARRAY')
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/** Normalizes JavaScript values that Apache Arrow's 64-bit integer builders require as bigints. */
|
|
1157
|
+
function normalizeArrowColumn(
|
|
1158
|
+
column: ArrayLike<unknown>,
|
|
1159
|
+
type: arrow.DataType
|
|
1160
|
+
): readonly unknown[] {
|
|
1161
|
+
if (!(type instanceof arrow.Int) || type.bitWidth !== 64) {
|
|
1162
|
+
return column as readonly unknown[];
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
return Array.from(column, value => {
|
|
1166
|
+
if (value === null || value === undefined || typeof value === 'bigint') {
|
|
1167
|
+
return value;
|
|
1168
|
+
}
|
|
1169
|
+
if (value instanceof Date) {
|
|
1170
|
+
return BigInt(value.getTime());
|
|
1171
|
+
}
|
|
1172
|
+
return BigInt(value as number | string);
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/** Slices one Arrow table while preserving the loaders.gl schema wrapper. */
|
|
1177
|
+
function sliceArrowTable(table: ArrowTable, start: number, end: number): ArrowTable {
|
|
1178
|
+
if (start === 0 && end === table.data.numRows) {
|
|
1179
|
+
return table;
|
|
1180
|
+
}
|
|
1181
|
+
if (table.data.numCols === 0) {
|
|
1182
|
+
return {...table, data: createArrowTable(table.data.schema, {}, end - start)};
|
|
1183
|
+
}
|
|
1184
|
+
return {...table, data: table.data.slice(start, end)};
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/** Slices an arbitrary column while preserving efficient native slice implementations. */
|
|
1188
|
+
function sliceColumn(column: ArrayLike<unknown>, start: number, end: number): ArrayLike<unknown> {
|
|
1189
|
+
if ('slice' in column && typeof column.slice === 'function') {
|
|
1190
|
+
return (column.slice as (start: number, end: number) => ArrayType)(start, end);
|
|
1191
|
+
}
|
|
1192
|
+
return Array.from(column).slice(start, end);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/** Creates row-group projection properties from public loader options. */
|
|
1196
|
+
function getParquetIterationProps(
|
|
1197
|
+
options?: ParquetJSLoaderOptions
|
|
1198
|
+
): {columnList?: string[] | string[][]} | undefined {
|
|
1199
|
+
const columnList = options?.parquet?.columns;
|
|
1200
|
+
return columnList?.length ? {columnList} : undefined;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** Restricts the loaders.gl schema to explicitly selected top-level columns. */
|
|
1204
|
+
function projectSchema(schema: Schema, columns?: string[]): Schema {
|
|
1205
|
+
if (!columns?.length) {
|
|
1206
|
+
return schema;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
return {
|
|
1210
|
+
...schema,
|
|
1211
|
+
fields: schema.fields.filter(field => columns.includes(field.name))
|
|
1212
|
+
};
|
|
1213
|
+
}
|