@loaders.gl/parquet 4.4.5 → 5.0.0-alpha.2
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/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/index.cjs +25873 -4776
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -11
- 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.map +1 -1
- package/dist/lib/arrow/convert-schema-from-parquet.js +86 -26
- 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 +396 -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 +199 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.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 +338 -0
- package/dist/lib/geo/geospatial-metadata.js.map +1 -0
- package/dist/lib/parquet-page-index.d.ts +62 -0
- package/dist/lib/parquet-page-index.d.ts.map +1 -0
- package/dist/lib/parquet-page-index.js +377 -0
- package/dist/lib/parquet-page-index.js.map +1 -0
- package/dist/lib/parquet-predicate.d.ts +17 -0
- package/dist/lib/parquet-predicate.d.ts.map +1 -0
- package/dist/lib/parquet-predicate.js +300 -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 +22 -0
- package/dist/lib/parquet-source-worker-client.js.map +1 -0
- package/dist/lib/parquet-source-worker-decoder.d.ts +4 -0
- package/dist/lib/parquet-source-worker-decoder.d.ts.map +1 -0
- package/dist/lib/parquet-source-worker-decoder.js +115 -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 +97 -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 +3 -1
- 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 +608 -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 +1 -4
- 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 +77 -26
- package/dist/lib/parsers/parse-parquet-to-json.js.map +1 -1
- 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 +261 -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 +11 -0
- package/dist/lib/utils/normalize-parquet-options.js.map +1 -0
- package/dist/parquet-dataset-source.cjs +26413 -0
- package/dist/parquet-dataset-source.cjs.map +6 -0
- package/dist/parquet-dataset-source.d.ts +54 -0
- package/dist/parquet-dataset-source.d.ts.map +1 -0
- package/dist/parquet-dataset-source.js +380 -0
- package/dist/parquet-dataset-source.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 +57 -0
- package/dist/parquet-js-loader-types.d.ts.map +1 -0
- package/dist/parquet-js-loader-types.js +33 -0
- package/dist/parquet-js-loader-types.js.map +1 -0
- package/dist/parquet-js-loader.d.ts +32 -0
- package/dist/parquet-js-loader.d.ts.map +1 -0
- package/dist/parquet-js-loader.js +58 -0
- package/dist/parquet-js-loader.js.map +1 -0
- package/dist/parquet-js-writer.d.ts +44 -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 +44 -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 +36 -0
- package/dist/parquet-source-capabilities.d.ts.map +1 -0
- package/dist/parquet-source-capabilities.js +22 -0
- package/dist/parquet-source-capabilities.js.map +1 -0
- package/dist/parquet-source-loader-types.d.ts +72 -0
- package/dist/parquet-source-loader-types.d.ts.map +1 -0
- package/dist/parquet-source-loader-types.js +74 -0
- package/dist/parquet-source-loader-types.js.map +1 -0
- package/dist/parquet-source-loader.cjs +25975 -0
- package/dist/parquet-source-loader.cjs.map +6 -0
- package/dist/parquet-source-loader.d.ts +120 -0
- package/dist/parquet-source-loader.d.ts.map +1 -0
- package/dist/parquet-source-loader.js +812 -0
- package/dist/parquet-source-loader.js.map +1 -0
- package/dist/parquet-source-types.d.ts +384 -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-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 +38491 -0
- package/dist/parquet-source-worker.js.map +7 -0
- package/dist/parquet-worker-node.cjs +54779 -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 +15 -0
- package/dist/parquet-worker-url.js.map +1 -0
- package/dist/parquet-worker.js +19920 -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 +20 -3
- package/dist/parquetjs/codecs/declare.d.ts.map +1 -1
- package/dist/parquetjs/codecs/declare.js +7 -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 +439 -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 +18 -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 +88 -76
- package/dist/parquetjs/codecs/plain.js.map +1 -1
- package/dist/parquetjs/codecs/rle.d.ts +3 -3
- package/dist/parquetjs/codecs/rle.d.ts.map +1 -1
- package/dist/parquetjs/codecs/rle.js +196 -68
- package/dist/parquetjs/codecs/rle.js.map +1 -1
- package/dist/parquetjs/compression.d.ts +7 -8
- package/dist/parquetjs/compression.d.ts.map +1 -1
- package/dist/parquetjs/compression.js +95 -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 +64 -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 +11 -4
- package/dist/parquetjs/encoder/parquet-encoder.d.ts.map +1 -1
- package/dist/parquetjs/encoder/parquet-encoder.js +259 -52
- package/dist/parquetjs/encoder/parquet-encoder.js.map +1 -1
- 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 +2 -2
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js +2 -2
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js.map +1 -1
- 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 +2 -2
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.js +2 -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/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/FileMetaData.d.ts +2 -2
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/FileMetaData.js +2 -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/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/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 +6 -2
- package/dist/parquetjs/parquet-thrift/index.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/index.js +6 -2
- package/dist/parquetjs/parquet-thrift/index.js.map +1 -1
- package/dist/parquetjs/parser/decoders.d.ts +14 -3
- package/dist/parquetjs/parser/decoders.d.ts.map +1 -1
- package/dist/parquetjs/parser/decoders.js +381 -117
- package/dist/parquetjs/parser/decoders.js.map +1 -1
- package/dist/parquetjs/parser/parquet-reader.d.ts +35 -10
- package/dist/parquetjs/parser/parquet-reader.d.ts.map +1 -1
- package/dist/parquetjs/parser/parquet-reader.js +179 -59
- package/dist/parquetjs/parser/parquet-reader.js.map +1 -1
- package/dist/parquetjs/schema/declare.d.ts +62 -8
- 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 +21 -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 +71 -23
- 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 +272 -51
- package/dist/parquetjs/schema/types.js.map +1 -1
- 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/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 +14 -6
- package/dist/parquetjs/utils/read-utils.d.ts.map +1 -1
- package/dist/parquetjs/utils/read-utils.js +46 -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 +9 -0
- package/dist/unbundled.d.ts.map +1 -0
- package/dist/unbundled.js +10 -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 +63 -33
- package/src/bundled.ts +33 -0
- package/src/geoparquet-loader-with-parser.ts +95 -0
- package/src/geoparquet-loader.ts +54 -0
- package/src/index.ts +49 -23
- package/src/lib/arrow/convert-columns-to-row-group.ts +3 -0
- package/src/lib/arrow/convert-schema-from-parquet.ts +97 -30
- package/src/lib/arrow/convert-schema-to-parquet.ts +16 -7
- package/src/lib/arrow/create-nested-arrow-vector.ts +589 -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 +261 -0
- package/src/lib/geo/geospatial-metadata.ts +457 -0
- package/src/lib/parquet-page-index.ts +581 -0
- package/src/lib/parquet-predicate.ts +374 -0
- package/src/lib/parquet-source-worker-client.ts +39 -0
- package/src/lib/parquet-source-worker-decoder.ts +156 -0
- package/src/lib/parquet-source-worker-file.ts +56 -0
- package/src/lib/parquet-source-worker-types.ts +107 -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 +3 -1
- 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 +829 -0
- package/src/lib/parsers/parse-parquet-to-arrow.ts +63 -36
- package/src/lib/parsers/parse-parquet-to-columns.ts +6 -7
- package/src/lib/parsers/parse-parquet-to-json.ts +101 -33
- package/src/lib/sources/parquet-range-file.ts +359 -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 +14 -0
- package/src/parquet-dataset-source.ts +488 -0
- package/src/parquet-format.ts +2 -0
- package/src/parquet-js-loader-types.ts +52 -0
- package/src/parquet-js-loader.ts +83 -0
- package/src/parquet-js-writer.ts +68 -0
- package/src/parquet-loader-base.ts +34 -0
- package/src/parquet-loader-options.ts +51 -0
- package/src/parquet-loader-types.ts +35 -0
- package/src/parquet-loader.ts +115 -0
- package/src/parquet-source-capabilities.ts +56 -0
- package/src/parquet-source-loader-types.ts +87 -0
- package/src/parquet-source-loader.ts +1265 -0
- package/src/parquet-source-types.ts +458 -0
- package/src/parquet-source-worker-url.ts +23 -0
- package/src/parquet-worker-url.ts +18 -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 +35 -3
- package/src/parquetjs/codecs/delta.ts +587 -0
- package/src/parquetjs/codecs/dictionary.ts +22 -4
- package/src/parquetjs/codecs/index.ts +18 -0
- package/src/parquetjs/codecs/plain.ts +149 -87
- package/src/parquetjs/codecs/rle.ts +268 -82
- package/src/parquetjs/compression.ts +110 -155
- package/src/parquetjs/encoder/dictionary-planner.ts +99 -0
- package/src/parquetjs/encoder/page-planner.ts +83 -0
- package/src/parquetjs/encoder/parquet-encoder.ts +378 -77
- package/src/parquetjs/parquet-thrift/BsonType.ts +1 -1
- package/src/parquetjs/parquet-thrift/ColumnChunk.ts +2 -2
- package/src/parquetjs/parquet-thrift/ColumnIndex.ts +13 -13
- package/src/parquetjs/parquet-thrift/ColumnMetaData.ts +2 -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/EnumType.ts +1 -1
- package/src/parquetjs/parquet-thrift/FileMetaData.ts +2 -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/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/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 +6 -4
- package/src/parquetjs/parser/decoders.ts +487 -133
- package/src/parquetjs/parser/parquet-reader.ts +297 -71
- package/src/parquetjs/schema/declare.ts +99 -7
- package/src/parquetjs/schema/schema.ts +23 -3
- package/src/parquetjs/schema/shred.ts +112 -35
- package/src/parquetjs/schema/types.ts +294 -61
- package/src/parquetjs/utils/binary-utils.ts +132 -0
- package/src/parquetjs/utils/file-utils.ts +4 -4
- package/src/parquetjs/utils/read-utils.ts +56 -55
- 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 +33 -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
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
// Forked from https://github.com/kbajalc/parquets under MIT license
|
|
6
6
|
|
|
7
7
|
/* eslint-disable camelcase */
|
|
8
|
-
import {
|
|
8
|
+
import {BSONWriter, parseBSONSync} from '@loaders.gl/bson';
|
|
9
9
|
import {OriginalType, ParquetField, ParquetType, PrimitiveType} from './declare';
|
|
10
|
+
import {
|
|
11
|
+
decodeUtf8,
|
|
12
|
+
encodeUtf8,
|
|
13
|
+
readUInt32LE,
|
|
14
|
+
toArrayBuffer,
|
|
15
|
+
toUint8Array,
|
|
16
|
+
writeUInt32LE
|
|
17
|
+
} from '../utils/binary-utils';
|
|
10
18
|
|
|
11
19
|
export interface ParquetTypeKit {
|
|
12
20
|
primitiveType: PrimitiveType;
|
|
@@ -56,6 +64,12 @@ export const PARQUET_LOGICAL_TYPES: Record<ParquetType, ParquetTypeKit> = {
|
|
|
56
64
|
toPrimitive: toPrimitive_UTF8,
|
|
57
65
|
fromPrimitive: fromPrimitive_UTF8
|
|
58
66
|
},
|
|
67
|
+
ENUM: {
|
|
68
|
+
primitiveType: 'BYTE_ARRAY',
|
|
69
|
+
originalType: 'ENUM',
|
|
70
|
+
toPrimitive: toPrimitive_UTF8,
|
|
71
|
+
fromPrimitive: fromPrimitive_UTF8
|
|
72
|
+
},
|
|
59
73
|
TIME_MILLIS: {
|
|
60
74
|
primitiveType: 'INT32',
|
|
61
75
|
originalType: 'TIME_MILLIS',
|
|
@@ -66,6 +80,11 @@ export const PARQUET_LOGICAL_TYPES: Record<ParquetType, ParquetTypeKit> = {
|
|
|
66
80
|
originalType: 'TIME_MICROS',
|
|
67
81
|
toPrimitive: toPrimitive_TIME_MICROS
|
|
68
82
|
},
|
|
83
|
+
TIME_NANOS: {
|
|
84
|
+
primitiveType: 'INT64',
|
|
85
|
+
originalType: 'TIME_NANOS',
|
|
86
|
+
toPrimitive: toPrimitive_TIME_NANOS
|
|
87
|
+
},
|
|
69
88
|
DATE: {
|
|
70
89
|
primitiveType: 'INT32',
|
|
71
90
|
originalType: 'DATE',
|
|
@@ -84,6 +103,11 @@ export const PARQUET_LOGICAL_TYPES: Record<ParquetType, ParquetTypeKit> = {
|
|
|
84
103
|
toPrimitive: toPrimitive_TIMESTAMP_MICROS,
|
|
85
104
|
fromPrimitive: fromPrimitive_TIMESTAMP_MICROS
|
|
86
105
|
},
|
|
106
|
+
TIMESTAMP_NANOS: {
|
|
107
|
+
primitiveType: 'INT64',
|
|
108
|
+
originalType: 'TIMESTAMP_NANOS',
|
|
109
|
+
toPrimitive: toPrimitive_TIMESTAMP_NANOS
|
|
110
|
+
},
|
|
87
111
|
UINT_8: {
|
|
88
112
|
primitiveType: 'INT32',
|
|
89
113
|
originalType: 'UINT_8',
|
|
@@ -136,6 +160,39 @@ export const PARQUET_LOGICAL_TYPES: Record<ParquetType, ParquetTypeKit> = {
|
|
|
136
160
|
toPrimitive: toPrimitive_BSON,
|
|
137
161
|
fromPrimitive: fromPrimitive_BSON
|
|
138
162
|
},
|
|
163
|
+
UUID: {
|
|
164
|
+
primitiveType: 'FIXED_LEN_BYTE_ARRAY',
|
|
165
|
+
originalType: 'UUID',
|
|
166
|
+
typeLength: 16,
|
|
167
|
+
toPrimitive: toPrimitive_BYTE_ARRAY
|
|
168
|
+
},
|
|
169
|
+
FLOAT16: {
|
|
170
|
+
primitiveType: 'FIXED_LEN_BYTE_ARRAY',
|
|
171
|
+
originalType: 'FLOAT16',
|
|
172
|
+
typeLength: 2,
|
|
173
|
+
toPrimitive: toPrimitive_FLOAT16,
|
|
174
|
+
fromPrimitive: fromPrimitive_FLOAT16
|
|
175
|
+
},
|
|
176
|
+
UNKNOWN: {
|
|
177
|
+
primitiveType: 'BYTE_ARRAY',
|
|
178
|
+
originalType: 'UNKNOWN',
|
|
179
|
+
toPrimitive: toPrimitive_BYTE_ARRAY
|
|
180
|
+
},
|
|
181
|
+
VARIANT: {
|
|
182
|
+
primitiveType: 'BYTE_ARRAY',
|
|
183
|
+
originalType: 'VARIANT',
|
|
184
|
+
toPrimitive: toPrimitive_BYTE_ARRAY
|
|
185
|
+
},
|
|
186
|
+
GEOMETRY: {
|
|
187
|
+
primitiveType: 'BYTE_ARRAY',
|
|
188
|
+
originalType: 'GEOMETRY',
|
|
189
|
+
toPrimitive: toPrimitive_BYTE_ARRAY
|
|
190
|
+
},
|
|
191
|
+
GEOGRAPHY: {
|
|
192
|
+
primitiveType: 'BYTE_ARRAY',
|
|
193
|
+
originalType: 'GEOGRAPHY',
|
|
194
|
+
toPrimitive: toPrimitive_BYTE_ARRAY
|
|
195
|
+
},
|
|
139
196
|
INTERVAL: {
|
|
140
197
|
primitiveType: 'FIXED_LEN_BYTE_ARRAY',
|
|
141
198
|
originalType: 'INTERVAL',
|
|
@@ -207,15 +264,82 @@ function fromPrimitive_BOOLEAN(value: any): boolean {
|
|
|
207
264
|
|
|
208
265
|
function toPrimitive_FLOAT(value: any): number {
|
|
209
266
|
const v = parseFloat(value);
|
|
210
|
-
if (isNaN(v)) {
|
|
267
|
+
if (Number.isNaN(v)) {
|
|
211
268
|
throw new Error(`invalid value for FLOAT: ${value}`);
|
|
212
269
|
}
|
|
213
270
|
return v;
|
|
214
271
|
}
|
|
215
272
|
|
|
273
|
+
/** Converts a JavaScript number to the two-byte IEEE 754 binary16 representation. */
|
|
274
|
+
function toPrimitive_FLOAT16(value: unknown): Uint8Array {
|
|
275
|
+
const numberValue = Number(value);
|
|
276
|
+
if (Number.isNaN(numberValue) && !Number.isNaN(value)) {
|
|
277
|
+
throw new Error(`invalid value for FLOAT16: ${value}`);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const float32 = new Float32Array([numberValue]);
|
|
281
|
+
const bits = new Uint32Array(float32.buffer)[0];
|
|
282
|
+
const sign = (bits >>> 16) & 0x8000;
|
|
283
|
+
const exponent = (bits >>> 23) & 0xff;
|
|
284
|
+
const mantissa = bits & 0x7fffff;
|
|
285
|
+
let half: number;
|
|
286
|
+
if (exponent === 0xff) {
|
|
287
|
+
half = sign | 0x7c00 | (mantissa ? 0x0200 : 0);
|
|
288
|
+
} else {
|
|
289
|
+
const halfExponent = exponent - 127 + 15;
|
|
290
|
+
if (halfExponent >= 0x1f) {
|
|
291
|
+
half = sign | 0x7c00;
|
|
292
|
+
} else if (halfExponent <= 0) {
|
|
293
|
+
if (halfExponent < -10) {
|
|
294
|
+
half = sign;
|
|
295
|
+
} else {
|
|
296
|
+
const normalizedMantissa = mantissa | 0x800000;
|
|
297
|
+
half = sign | roundRightShiftToNearestEven(normalizedMantissa, 14 - halfExponent);
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
const halfMantissa = roundRightShiftToNearestEven(mantissa, 13);
|
|
301
|
+
if (halfMantissa === 0x400) {
|
|
302
|
+
const roundedExponent = halfExponent + 1;
|
|
303
|
+
half = roundedExponent >= 0x1f ? sign | 0x7c00 : sign | (roundedExponent << 10);
|
|
304
|
+
} else {
|
|
305
|
+
half = sign | (halfExponent << 10) | halfMantissa;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return new Uint8Array([half & 0xff, half >>> 8]);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Rounds a non-negative integer right shift using IEEE round-to-nearest, ties-to-even. */
|
|
313
|
+
function roundRightShiftToNearestEven(value: number, shift: number): number {
|
|
314
|
+
const divisor = 2 ** shift;
|
|
315
|
+
const quotient = Math.floor(value / divisor);
|
|
316
|
+
const remainder = value - quotient * divisor;
|
|
317
|
+
const halfway = divisor / 2;
|
|
318
|
+
return quotient + (remainder > halfway || (remainder === halfway && quotient % 2 === 1) ? 1 : 0);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Converts little-endian IEEE 754 binary16 bytes to a JavaScript number. */
|
|
322
|
+
function fromPrimitive_FLOAT16(value: unknown): number {
|
|
323
|
+
const bytes = toUint8Array(value as ArrayBuffer | ArrayBufferView);
|
|
324
|
+
if (bytes.byteLength !== 2) {
|
|
325
|
+
throw new Error(`invalid FLOAT16 byte length: ${bytes.byteLength}`);
|
|
326
|
+
}
|
|
327
|
+
const half = bytes[0] | (bytes[1] << 8);
|
|
328
|
+
const sign = half & 0x8000 ? -1 : 1;
|
|
329
|
+
const exponent = (half >>> 10) & 0x1f;
|
|
330
|
+
const mantissa = half & 0x03ff;
|
|
331
|
+
if (exponent === 0x1f) {
|
|
332
|
+
return mantissa ? Number.NaN : sign * Number.POSITIVE_INFINITY;
|
|
333
|
+
}
|
|
334
|
+
if (exponent === 0) {
|
|
335
|
+
return sign * 2 ** -14 * (mantissa / 1024);
|
|
336
|
+
}
|
|
337
|
+
return sign * 2 ** (exponent - 15) * (1 + mantissa / 1024);
|
|
338
|
+
}
|
|
339
|
+
|
|
216
340
|
function toPrimitive_DOUBLE(value: any): number {
|
|
217
341
|
const v = parseFloat(value);
|
|
218
|
-
if (isNaN(v)) {
|
|
342
|
+
if (Number.isNaN(v)) {
|
|
219
343
|
throw new Error(`invalid value for DOUBLE: ${value}`);
|
|
220
344
|
}
|
|
221
345
|
return v;
|
|
@@ -223,7 +347,7 @@ function toPrimitive_DOUBLE(value: any): number {
|
|
|
223
347
|
|
|
224
348
|
function toPrimitive_INT8(value: any) {
|
|
225
349
|
const v = parseInt(value, 10);
|
|
226
|
-
if (v < -0x80 || v > 0x7f || isNaN(v)) {
|
|
350
|
+
if (v < -0x80 || v > 0x7f || Number.isNaN(v)) {
|
|
227
351
|
throw new Error(`invalid value for INT8: ${value}`);
|
|
228
352
|
}
|
|
229
353
|
|
|
@@ -232,7 +356,7 @@ function toPrimitive_INT8(value: any) {
|
|
|
232
356
|
|
|
233
357
|
function toPrimitive_UINT8(value: any) {
|
|
234
358
|
const v = parseInt(value, 10);
|
|
235
|
-
if (v < 0 || v > 0xff || isNaN(v)) {
|
|
359
|
+
if (v < 0 || v > 0xff || Number.isNaN(v)) {
|
|
236
360
|
throw new Error(`invalid value for UINT8: ${value}`);
|
|
237
361
|
}
|
|
238
362
|
|
|
@@ -241,7 +365,7 @@ function toPrimitive_UINT8(value: any) {
|
|
|
241
365
|
|
|
242
366
|
function toPrimitive_INT16(value: any) {
|
|
243
367
|
const v = parseInt(value, 10);
|
|
244
|
-
if (v < -0x8000 || v > 0x7fff || isNaN(v)) {
|
|
368
|
+
if (v < -0x8000 || v > 0x7fff || Number.isNaN(v)) {
|
|
245
369
|
throw new Error(`invalid value for INT16: ${value}`);
|
|
246
370
|
}
|
|
247
371
|
|
|
@@ -250,7 +374,7 @@ function toPrimitive_INT16(value: any) {
|
|
|
250
374
|
|
|
251
375
|
function toPrimitive_UINT16(value: any) {
|
|
252
376
|
const v = parseInt(value, 10);
|
|
253
|
-
if (v < 0 || v > 0xffff || isNaN(v)) {
|
|
377
|
+
if (v < 0 || v > 0xffff || Number.isNaN(v)) {
|
|
254
378
|
throw new Error(`invalid value for UINT16: ${value}`);
|
|
255
379
|
}
|
|
256
380
|
|
|
@@ -259,7 +383,7 @@ function toPrimitive_UINT16(value: any) {
|
|
|
259
383
|
|
|
260
384
|
function toPrimitive_INT32(value: any) {
|
|
261
385
|
const v = parseInt(value, 10);
|
|
262
|
-
if (v < -0x80000000 || v > 0x7fffffff || isNaN(v)) {
|
|
386
|
+
if (v < -0x80000000 || v > 0x7fffffff || Number.isNaN(v)) {
|
|
263
387
|
throw new Error(`invalid value for INT32: ${value}`);
|
|
264
388
|
}
|
|
265
389
|
|
|
@@ -269,7 +393,7 @@ function toPrimitive_INT32(value: any) {
|
|
|
269
393
|
function decimalToPrimitive_INT32(value: number, field: ParquetField): number {
|
|
270
394
|
const primitiveValue = value * 10 ** (field.scale || 0);
|
|
271
395
|
const v = Math.round(((primitiveValue * 10 ** -field.presision!) % 1) * 10 ** field.presision!);
|
|
272
|
-
if (v < -0x80000000 || v > 0x7fffffff || isNaN(v)) {
|
|
396
|
+
if (v < -0x80000000 || v > 0x7fffffff || Number.isNaN(v)) {
|
|
273
397
|
throw new Error(`invalid value for INT32: ${value}`);
|
|
274
398
|
}
|
|
275
399
|
return v;
|
|
@@ -277,99 +401,198 @@ function decimalToPrimitive_INT32(value: number, field: ParquetField): number {
|
|
|
277
401
|
|
|
278
402
|
function toPrimitive_UINT32(value: any): number {
|
|
279
403
|
const v = parseInt(value, 10);
|
|
280
|
-
if (v < 0 || v >
|
|
404
|
+
if (v < 0 || v > 0xffffffff || Number.isNaN(v)) {
|
|
281
405
|
throw new Error(`invalid value for UINT32: ${value}`);
|
|
282
406
|
}
|
|
283
407
|
return v;
|
|
284
408
|
}
|
|
285
409
|
|
|
286
|
-
function toPrimitive_INT64(value:
|
|
287
|
-
|
|
288
|
-
|
|
410
|
+
function toPrimitive_INT64(value: unknown): number | bigint {
|
|
411
|
+
if (typeof value === 'number') {
|
|
412
|
+
if (!Number.isSafeInteger(value)) {
|
|
413
|
+
throw new Error(`invalid value for INT64: ${value}`);
|
|
414
|
+
}
|
|
415
|
+
return value;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
let primitiveValue: bigint;
|
|
419
|
+
try {
|
|
420
|
+
primitiveValue = BigInt(value as bigint | boolean | string);
|
|
421
|
+
} catch {
|
|
289
422
|
throw new Error(`invalid value for INT64: ${value}`);
|
|
290
423
|
}
|
|
291
|
-
|
|
424
|
+
if (primitiveValue < -(2n ** 63n) || primitiveValue > 2n ** 63n - 1n) {
|
|
425
|
+
throw new Error(`invalid value for INT64: ${value}`);
|
|
426
|
+
}
|
|
427
|
+
return primitiveValue;
|
|
292
428
|
}
|
|
293
429
|
|
|
294
430
|
function decimalToPrimitive_INT64(value: number, field: ParquetField) {
|
|
295
431
|
const primitiveValue = value * 10 ** (field.scale || 0);
|
|
296
432
|
const v = Math.round(((primitiveValue * 10 ** -field.presision!) % 1) * 10 ** field.presision!);
|
|
297
|
-
if (isNaN(v)) {
|
|
433
|
+
if (Number.isNaN(v)) {
|
|
298
434
|
throw new Error(`invalid value for INT64: ${value}`);
|
|
299
435
|
}
|
|
300
436
|
|
|
301
437
|
return v;
|
|
302
438
|
}
|
|
303
439
|
|
|
304
|
-
function toPrimitive_UINT64(value:
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
440
|
+
function toPrimitive_UINT64(value: unknown): bigint {
|
|
441
|
+
const primitiveValue = BigInt(value as bigint | boolean | number | string);
|
|
442
|
+
if (primitiveValue < 0n || primitiveValue > 2n ** 64n - 1n) {
|
|
307
443
|
throw new Error(`invalid value for UINT64: ${value}`);
|
|
308
444
|
}
|
|
309
|
-
|
|
310
|
-
return v;
|
|
445
|
+
return BigInt.asIntN(64, primitiveValue);
|
|
311
446
|
}
|
|
312
447
|
|
|
313
448
|
function toPrimitive_INT96(value: any) {
|
|
314
449
|
const v = parseInt(value, 10);
|
|
315
|
-
if (isNaN(v)) {
|
|
450
|
+
if (Number.isNaN(v)) {
|
|
316
451
|
throw new Error(`invalid value for INT96: ${value}`);
|
|
317
452
|
}
|
|
318
453
|
|
|
319
454
|
return v;
|
|
320
455
|
}
|
|
321
456
|
|
|
322
|
-
function toPrimitive_BYTE_ARRAY(value: any):
|
|
323
|
-
return
|
|
457
|
+
function toPrimitive_BYTE_ARRAY(value: any): Uint8Array {
|
|
458
|
+
return typeof value === 'string' ? encodeUtf8(value) : toUint8Array(value);
|
|
324
459
|
}
|
|
325
460
|
|
|
326
|
-
function decimalToPrimitive_BYTE_ARRAY(value:
|
|
327
|
-
|
|
328
|
-
|
|
461
|
+
function decimalToPrimitive_BYTE_ARRAY(value: unknown, field: ParquetField): Uint8Array {
|
|
462
|
+
if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {
|
|
463
|
+
const bytes = toUint8Array(value);
|
|
464
|
+
if (field.typeLength !== undefined && bytes.byteLength !== field.typeLength) {
|
|
465
|
+
throw new Error(
|
|
466
|
+
`invalid DECIMAL byte width: expected ${field.typeLength}, received ${bytes.byteLength}`
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
return bytes;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const unscaledValue = getUnscaledDecimalInteger(value, field.scale || 0);
|
|
473
|
+
const precision = field.precision ?? field.presision;
|
|
474
|
+
if (precision !== undefined && getDecimalDigitCount(unscaledValue) > precision) {
|
|
475
|
+
throw new Error(`DECIMAL value ${value} exceeds precision ${precision}`);
|
|
476
|
+
}
|
|
477
|
+
const byteWidth = field.typeLength ?? getSignedBigIntByteWidth(unscaledValue);
|
|
478
|
+
const bitWidth = BigInt(byteWidth * 8);
|
|
479
|
+
const minimum = -(1n << (bitWidth - 1n));
|
|
480
|
+
const maximum = (1n << (bitWidth - 1n)) - 1n;
|
|
481
|
+
if (unscaledValue < minimum || unscaledValue > maximum) {
|
|
482
|
+
throw new Error(`DECIMAL value ${value} does not fit in ${byteWidth} bytes`);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const bytes = new Uint8Array(byteWidth);
|
|
486
|
+
let unsignedValue = BigInt.asUintN(byteWidth * 8, unscaledValue);
|
|
487
|
+
for (let byteIndex = byteWidth - 1; byteIndex >= 0; byteIndex--) {
|
|
488
|
+
bytes[byteIndex] = Number(unsignedValue & 0xffn);
|
|
489
|
+
unsignedValue >>= 8n;
|
|
490
|
+
}
|
|
491
|
+
return bytes;
|
|
329
492
|
}
|
|
330
493
|
|
|
331
|
-
|
|
332
|
-
|
|
494
|
+
/** Converts a logical decimal value to its exact scaled integer. */
|
|
495
|
+
function getUnscaledDecimalInteger(value: unknown, scale: number): bigint {
|
|
496
|
+
if (!Number.isInteger(scale) || scale < 0) {
|
|
497
|
+
throw new Error(`invalid DECIMAL scale: ${scale}`);
|
|
498
|
+
}
|
|
499
|
+
if (typeof value === 'bigint') {
|
|
500
|
+
return value * 10n ** BigInt(scale);
|
|
501
|
+
}
|
|
502
|
+
if (typeof value === 'number') {
|
|
503
|
+
const scaledValue = Math.round(value * 10 ** scale);
|
|
504
|
+
if (!Number.isFinite(value) || !Number.isSafeInteger(scaledValue)) {
|
|
505
|
+
throw new Error(`DECIMAL number ${value} cannot be represented exactly; use a string`);
|
|
506
|
+
}
|
|
507
|
+
return BigInt(scaledValue);
|
|
508
|
+
}
|
|
509
|
+
if (typeof value !== 'string') {
|
|
510
|
+
throw new Error(`invalid value for DECIMAL: ${value}`);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const match = /^([+-]?)(\d+)(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/.exec(value.trim());
|
|
514
|
+
if (!match) {
|
|
515
|
+
throw new Error(`invalid value for DECIMAL: ${value}`);
|
|
516
|
+
}
|
|
517
|
+
const sign = match[1] === '-' ? -1n : 1n;
|
|
518
|
+
const fraction = match[3] || '';
|
|
519
|
+
let unscaledValue = BigInt(`${match[2]}${fraction}` || '0');
|
|
520
|
+
const decimalShift = scale + Number(match[4] || 0) - fraction.length;
|
|
521
|
+
if (decimalShift >= 0) {
|
|
522
|
+
unscaledValue *= 10n ** BigInt(decimalShift);
|
|
523
|
+
} else {
|
|
524
|
+
const divisor = 10n ** BigInt(-decimalShift);
|
|
525
|
+
if (unscaledValue % divisor !== 0n) {
|
|
526
|
+
throw new Error(`DECIMAL value ${value} has more fractional digits than scale ${scale}`);
|
|
527
|
+
}
|
|
528
|
+
unscaledValue /= divisor;
|
|
529
|
+
}
|
|
530
|
+
return sign * unscaledValue;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** Returns the number of base-10 digits in a signed integer, treating zero as one digit. */
|
|
534
|
+
function getDecimalDigitCount(value: bigint): number {
|
|
535
|
+
return (value < 0n ? -value : value).toString().length;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** Returns the smallest two's-complement byte width that can contain a signed integer. */
|
|
539
|
+
function getSignedBigIntByteWidth(value: bigint): number {
|
|
540
|
+
let byteWidth = 1;
|
|
541
|
+
while (value < -(1n << BigInt(byteWidth * 8 - 1)) || value >= 1n << BigInt(byteWidth * 8 - 1)) {
|
|
542
|
+
byteWidth++;
|
|
543
|
+
}
|
|
544
|
+
return byteWidth;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function toPrimitive_UTF8(value: any): Uint8Array {
|
|
548
|
+
return encodeUtf8(String(value));
|
|
333
549
|
}
|
|
334
550
|
|
|
335
551
|
function fromPrimitive_UTF8(value: any): string {
|
|
336
|
-
return value
|
|
552
|
+
return decodeUtf8(toUint8Array(value));
|
|
337
553
|
}
|
|
338
554
|
|
|
339
|
-
function toPrimitive_JSON(value: any):
|
|
340
|
-
return
|
|
555
|
+
function toPrimitive_JSON(value: any): Uint8Array {
|
|
556
|
+
return encodeUtf8(JSON.stringify(value));
|
|
341
557
|
}
|
|
342
558
|
|
|
343
559
|
function fromPrimitive_JSON(value: any): unknown {
|
|
344
|
-
return JSON.parse(value);
|
|
560
|
+
return JSON.parse(decodeUtf8(toUint8Array(value)));
|
|
345
561
|
}
|
|
346
562
|
|
|
347
|
-
function toPrimitive_BSON(value: any):
|
|
563
|
+
function toPrimitive_BSON(value: any): Uint8Array {
|
|
348
564
|
// @ts-ignore
|
|
349
565
|
const arrayBuffer: ArrayBuffer = BSONWriter.encodeSync?.(value);
|
|
350
|
-
return
|
|
566
|
+
return toUint8Array(arrayBuffer);
|
|
351
567
|
}
|
|
352
568
|
|
|
353
569
|
function fromPrimitive_BSON(value: any) {
|
|
354
|
-
return
|
|
570
|
+
return parseBSONSync(toArrayBuffer(value));
|
|
355
571
|
}
|
|
356
572
|
|
|
357
573
|
function toPrimitive_TIME_MILLIS(value: any) {
|
|
358
574
|
const v = parseInt(value, 10);
|
|
359
|
-
|
|
360
|
-
if (v < 0 || v > 0xffffffffffffffff || isNaN(v)) {
|
|
575
|
+
if (v < 0 || v >= kMillisPerDay || Number.isNaN(v)) {
|
|
361
576
|
throw new Error(`invalid value for TIME_MILLIS: ${value}`);
|
|
362
577
|
}
|
|
363
578
|
|
|
364
579
|
return v;
|
|
365
580
|
}
|
|
366
581
|
|
|
367
|
-
function toPrimitive_TIME_MICROS(value:
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
582
|
+
function toPrimitive_TIME_MICROS(value: unknown): bigint {
|
|
583
|
+
const primitiveValue = BigInt(value as bigint | boolean | number | string);
|
|
584
|
+
if (primitiveValue < 0n || primitiveValue >= 86_400_000_000n) {
|
|
370
585
|
throw new Error(`invalid value for TIME_MICROS: ${value}`);
|
|
371
586
|
}
|
|
372
|
-
return
|
|
587
|
+
return primitiveValue;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function toPrimitive_TIME_NANOS(value: unknown): bigint {
|
|
591
|
+
const primitiveValue = BigInt(value as bigint | boolean | number | string);
|
|
592
|
+
if (primitiveValue < 0n || primitiveValue >= 86_400_000_000_000n) {
|
|
593
|
+
throw new Error(`invalid value for TIME_NANOS: ${value}`);
|
|
594
|
+
}
|
|
595
|
+
return primitiveValue;
|
|
373
596
|
}
|
|
374
597
|
|
|
375
598
|
const kMillisPerDay = 86400000;
|
|
@@ -383,7 +606,7 @@ function toPrimitive_DATE(value: any): number {
|
|
|
383
606
|
/* convert from integer */
|
|
384
607
|
{
|
|
385
608
|
const v = parseInt(value, 10);
|
|
386
|
-
if (v <
|
|
609
|
+
if (v < -0x80000000 || v > 0x7fffffff || Number.isNaN(v)) {
|
|
387
610
|
throw new Error(`invalid value for DATE: ${value}`);
|
|
388
611
|
}
|
|
389
612
|
|
|
@@ -404,7 +627,7 @@ function toPrimitive_TIMESTAMP_MILLIS(value: any): number {
|
|
|
404
627
|
/* convert from integer */
|
|
405
628
|
{
|
|
406
629
|
const v = parseInt(value, 10);
|
|
407
|
-
if (
|
|
630
|
+
if (!Number.isSafeInteger(v)) {
|
|
408
631
|
throw new Error(`invalid value for TIMESTAMP_MILLIS: ${value}`);
|
|
409
632
|
}
|
|
410
633
|
|
|
@@ -413,28 +636,36 @@ function toPrimitive_TIMESTAMP_MILLIS(value: any): number {
|
|
|
413
636
|
}
|
|
414
637
|
|
|
415
638
|
function fromPrimitive_TIMESTAMP_MILLIS(value: any): Date {
|
|
416
|
-
return new Date(value);
|
|
639
|
+
return new Date(Number(value));
|
|
417
640
|
}
|
|
418
641
|
|
|
419
|
-
function toPrimitive_TIMESTAMP_MICROS(value:
|
|
642
|
+
function toPrimitive_TIMESTAMP_MICROS(value: unknown): bigint {
|
|
420
643
|
/* convert from date */
|
|
421
644
|
if (value instanceof Date) {
|
|
422
|
-
return value.getTime() *
|
|
645
|
+
return BigInt(value.getTime()) * 1000n;
|
|
423
646
|
}
|
|
424
647
|
|
|
425
648
|
/* convert from integer */
|
|
426
649
|
{
|
|
427
|
-
|
|
428
|
-
|
|
650
|
+
let primitiveValue: bigint;
|
|
651
|
+
try {
|
|
652
|
+
primitiveValue = BigInt(value as bigint | boolean | number | string);
|
|
653
|
+
} catch {
|
|
429
654
|
throw new Error(`invalid value for TIMESTAMP_MICROS: ${value}`);
|
|
430
655
|
}
|
|
431
|
-
|
|
432
|
-
return v;
|
|
656
|
+
return primitiveValue;
|
|
433
657
|
}
|
|
434
658
|
}
|
|
435
659
|
|
|
436
660
|
function fromPrimitive_TIMESTAMP_MICROS(value: any) {
|
|
437
|
-
return new Date(value / 1000);
|
|
661
|
+
return new Date(Number(value) / 1000);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function toPrimitive_TIMESTAMP_NANOS(value: unknown): bigint {
|
|
665
|
+
if (value instanceof Date) {
|
|
666
|
+
return BigInt(value.getTime()) * 1_000_000n;
|
|
667
|
+
}
|
|
668
|
+
return BigInt(value as bigint | boolean | number | string);
|
|
438
669
|
}
|
|
439
670
|
|
|
440
671
|
function toPrimitive_INTERVAL(value: any) {
|
|
@@ -444,26 +675,28 @@ function toPrimitive_INTERVAL(value: any) {
|
|
|
444
675
|
);
|
|
445
676
|
}
|
|
446
677
|
|
|
447
|
-
const buf =
|
|
678
|
+
const buf = new Uint8Array(12);
|
|
448
679
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
680
|
+
writeUInt32LE(buf, value.months, 0);
|
|
681
|
+
writeUInt32LE(buf, value.days, 4);
|
|
682
|
+
writeUInt32LE(buf, value.milliseconds, 8);
|
|
452
683
|
return buf;
|
|
453
684
|
}
|
|
454
685
|
|
|
455
686
|
function fromPrimitive_INTERVAL(value: any) {
|
|
456
|
-
const
|
|
457
|
-
const months =
|
|
458
|
-
const days =
|
|
459
|
-
const millis =
|
|
687
|
+
const bytes = toUint8Array(value);
|
|
688
|
+
const months = readUInt32LE(bytes, 0);
|
|
689
|
+
const days = readUInt32LE(bytes, 4);
|
|
690
|
+
const millis = readUInt32LE(bytes, 8);
|
|
460
691
|
|
|
461
692
|
return {months, days, milliseconds: millis};
|
|
462
693
|
}
|
|
463
694
|
|
|
464
695
|
function decimalFromPrimitive_INT(value: any, field: ParquetField) {
|
|
465
|
-
const
|
|
466
|
-
|
|
696
|
+
const numberValue = Number(value);
|
|
697
|
+
const precision = field.precision ?? field.presision!;
|
|
698
|
+
const precisionInt = Math.round(((numberValue * 10 ** -precision) % 1) * 10 ** precision);
|
|
699
|
+
return precisionInt * 10 ** -(field.scale || 0);
|
|
467
700
|
}
|
|
468
701
|
|
|
469
702
|
function decimalFromPrimitive_BYTE_ARRAY(value: any, field: ParquetField) {
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
const TEXT_DECODER = new TextDecoder();
|
|
6
|
+
const TEXT_ENCODER = new TextEncoder();
|
|
7
|
+
|
|
8
|
+
/** Returns bytes as an exact Uint8Array view. */
|
|
9
|
+
export function toUint8Array(binary: ArrayBuffer | ArrayBufferView): Uint8Array {
|
|
10
|
+
if (binary instanceof Uint8Array) {
|
|
11
|
+
return binary;
|
|
12
|
+
}
|
|
13
|
+
if (ArrayBuffer.isView(binary)) {
|
|
14
|
+
return new Uint8Array(binary.buffer, binary.byteOffset, binary.byteLength);
|
|
15
|
+
}
|
|
16
|
+
return new Uint8Array(binary);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Returns bytes as a copied ArrayBuffer with no extra prefix/suffix bytes. */
|
|
20
|
+
export function toArrayBuffer(binary: ArrayBuffer | ArrayBufferView): ArrayBuffer {
|
|
21
|
+
const bytes = toUint8Array(binary);
|
|
22
|
+
return bytes.slice().buffer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Returns a copied Uint8Array. */
|
|
26
|
+
export function copyUint8Array(binary: Uint8Array): Uint8Array {
|
|
27
|
+
return binary.slice();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Decode UTF-8 bytes. */
|
|
31
|
+
export function decodeUtf8(binary: Uint8Array): string {
|
|
32
|
+
return TEXT_DECODER.decode(binary);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Encode text as UTF-8 bytes. */
|
|
36
|
+
export function encodeUtf8(text: string): Uint8Array {
|
|
37
|
+
return TEXT_ENCODER.encode(text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Decode an ASCII/UTF-8 range from bytes. */
|
|
41
|
+
export function decodeString(
|
|
42
|
+
binary: Uint8Array,
|
|
43
|
+
start: number = 0,
|
|
44
|
+
end: number = binary.length
|
|
45
|
+
): string {
|
|
46
|
+
return decodeUtf8(binary.subarray(start, end));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getDataView(binary: Uint8Array): DataView {
|
|
50
|
+
return new DataView(binary.buffer, binary.byteOffset, binary.byteLength);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Read signed little-endian 32-bit integer. */
|
|
54
|
+
export function readInt32LE(binary: Uint8Array, offset: number): number {
|
|
55
|
+
return getDataView(binary).getInt32(offset, true);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Read unsigned little-endian 32-bit integer. */
|
|
59
|
+
export function readUInt32LE(binary: Uint8Array, offset: number): number {
|
|
60
|
+
return getDataView(binary).getUint32(offset, true);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Read signed little-endian 64-bit integer without losing precision. */
|
|
64
|
+
export function readInt64LE(binary: Uint8Array, offset: number): bigint {
|
|
65
|
+
return getDataView(binary).getBigInt64(offset, true);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Read unsigned little-endian 64-bit integer without losing precision. */
|
|
69
|
+
export function readUInt64LE(binary: Uint8Array, offset: number): bigint {
|
|
70
|
+
return getDataView(binary).getBigUint64(offset, true);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Read little-endian 32-bit float. */
|
|
74
|
+
export function readFloatLE(binary: Uint8Array, offset: number): number {
|
|
75
|
+
return getDataView(binary).getFloat32(offset, true);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Read little-endian 64-bit float. */
|
|
79
|
+
export function readDoubleLE(binary: Uint8Array, offset: number): number {
|
|
80
|
+
return getDataView(binary).getFloat64(offset, true);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Concatenate bytes into one exact Uint8Array. */
|
|
84
|
+
export function concatUint8Arrays(chunks: Uint8Array[]): Uint8Array {
|
|
85
|
+
let byteLength = 0;
|
|
86
|
+
for (const chunk of chunks) {
|
|
87
|
+
byteLength += chunk.length;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const result = new Uint8Array(byteLength);
|
|
91
|
+
let offset = 0;
|
|
92
|
+
for (const chunk of chunks) {
|
|
93
|
+
result.set(chunk, offset);
|
|
94
|
+
offset += chunk.length;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Write signed little-endian 16-bit integer. */
|
|
100
|
+
export function writeInt16LE(binary: Uint8Array, value: number, offset: number): void {
|
|
101
|
+
getDataView(binary).setInt16(offset, value, true);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Write unsigned little-endian 16-bit integer. */
|
|
105
|
+
export function writeUInt16LE(binary: Uint8Array, value: number, offset: number): void {
|
|
106
|
+
getDataView(binary).setUint16(offset, value, true);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Write signed little-endian 32-bit integer. */
|
|
110
|
+
export function writeInt32LE(binary: Uint8Array, value: number, offset: number): void {
|
|
111
|
+
getDataView(binary).setInt32(offset, value, true);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Write unsigned little-endian 32-bit integer. */
|
|
115
|
+
export function writeUInt32LE(binary: Uint8Array, value: number, offset: number): void {
|
|
116
|
+
getDataView(binary).setUint32(offset, value, true);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Write signed little-endian 64-bit integer. */
|
|
120
|
+
export function writeInt64LE(binary: Uint8Array, value: number | bigint, offset: number): void {
|
|
121
|
+
getDataView(binary).setBigInt64(offset, BigInt(value), true);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Write little-endian 32-bit float. */
|
|
125
|
+
export function writeFloatLE(binary: Uint8Array, value: number, offset: number): void {
|
|
126
|
+
getDataView(binary).setFloat32(offset, value, true);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Write little-endian 64-bit float. */
|
|
130
|
+
export function writeDoubleLE(binary: Uint8Array, value: number, offset: number): void {
|
|
131
|
+
getDataView(binary).setFloat64(offset, value, true);
|
|
132
|
+
}
|