@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
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {DataType, Field, ObjectRowTable, Schema, Table} from '@loaders.gl/schema';
|
|
6
|
+
import {concatUint8Arrays} from '../../parquetjs/utils/binary-utils';
|
|
7
|
+
import {ParquetEncoder} from '../../parquetjs/encoder/parquet-encoder';
|
|
8
|
+
import {ParquetSchema} from '../../parquetjs/schema/schema';
|
|
9
|
+
import type {FieldDefinition, SchemaDefinition} from '../../parquetjs/schema/declare';
|
|
10
|
+
import type {ParquetJSWriterOptions} from '../../parquet-js-writer';
|
|
11
|
+
|
|
12
|
+
/** Encode a plain loaders.gl table with the parquetjs implementation. */
|
|
13
|
+
export async function encodeTableToParquetJs(
|
|
14
|
+
table: Table,
|
|
15
|
+
objectRowTable: ObjectRowTable,
|
|
16
|
+
options: ParquetJSWriterOptions
|
|
17
|
+
): Promise<ArrayBuffer> {
|
|
18
|
+
const parquetSchema = new ParquetSchema(
|
|
19
|
+
convertSchemaToParquetSchema(table.schema!, objectRowTable, options)
|
|
20
|
+
);
|
|
21
|
+
const chunks: Uint8Array[] = [];
|
|
22
|
+
const outputStream = {
|
|
23
|
+
write(chunk: Uint8Array, callback: (error?: Error) => void) {
|
|
24
|
+
chunks.push(chunk.slice());
|
|
25
|
+
callback();
|
|
26
|
+
},
|
|
27
|
+
close(callback: (error?: Error) => void) {
|
|
28
|
+
callback();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const encoder = await ParquetEncoder.openStream(
|
|
33
|
+
parquetSchema,
|
|
34
|
+
outputStream as any,
|
|
35
|
+
options.parquet
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
for (const [key, value] of Object.entries(table.schema?.metadata || {})) {
|
|
39
|
+
encoder.setMetadata(key, value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const row of objectRowTable.data) {
|
|
43
|
+
await encoder.appendRow(row);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await encoder.close();
|
|
47
|
+
|
|
48
|
+
return concatUint8Arrays(chunks).slice().buffer;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Converts a loaders.gl schema into a parquetjs schema definition.
|
|
53
|
+
* @param schema table schema
|
|
54
|
+
* @param objectRowTable table data in object-row form
|
|
55
|
+
* @returns parquetjs schema definition
|
|
56
|
+
*/
|
|
57
|
+
function convertSchemaToParquetSchema(
|
|
58
|
+
schema: Schema,
|
|
59
|
+
objectRowTable: ObjectRowTable,
|
|
60
|
+
options: ParquetJSWriterOptions
|
|
61
|
+
): SchemaDefinition {
|
|
62
|
+
const parquetFields: SchemaDefinition = {};
|
|
63
|
+
const columnEncodings = options.parquet?.columnEncodings || {};
|
|
64
|
+
const columnDictionaries = options.parquet?.columnDictionaries || {};
|
|
65
|
+
const fieldNames = new Set(schema.fields.map(field => field.name));
|
|
66
|
+
for (const columnName of Object.keys(columnEncodings)) {
|
|
67
|
+
if (!fieldNames.has(columnName)) {
|
|
68
|
+
throw new Error(`ParquetJSWriter: Unknown column encoding override "${columnName}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const columnName of Object.keys(columnDictionaries)) {
|
|
72
|
+
if (!fieldNames.has(columnName)) {
|
|
73
|
+
throw new Error(`ParquetJSWriter: Unknown column dictionary override "${columnName}"`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
for (const field of schema.fields) {
|
|
78
|
+
parquetFields[field.name] = {
|
|
79
|
+
...convertFieldToParquetFieldDefinition(field, objectRowTable.data),
|
|
80
|
+
encoding: columnEncodings[field.name]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return parquetFields;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Converts one loaders.gl field to the closest parquetjs field definition.
|
|
89
|
+
* @param field table field metadata
|
|
90
|
+
* @param rows object rows used for nullability and fallback inference
|
|
91
|
+
* @returns parquetjs field definition
|
|
92
|
+
*/
|
|
93
|
+
function convertFieldToParquetFieldDefinition(
|
|
94
|
+
field: Field,
|
|
95
|
+
rows: Array<Record<string, unknown>>
|
|
96
|
+
): FieldDefinition {
|
|
97
|
+
const sampleValue = getFirstDefinedValue(rows, field.name);
|
|
98
|
+
const nullable = field.nullable ?? sampleValue === undefined;
|
|
99
|
+
const dataType = field.type === 'null' ? getDataTypeFromValue(sampleValue) : field.type;
|
|
100
|
+
|
|
101
|
+
switch (dataType) {
|
|
102
|
+
case 'bool':
|
|
103
|
+
return {type: 'BOOLEAN', optional: nullable};
|
|
104
|
+
|
|
105
|
+
case 'int':
|
|
106
|
+
case 'int32':
|
|
107
|
+
return {type: 'INT_32', optional: nullable};
|
|
108
|
+
|
|
109
|
+
case 'int8':
|
|
110
|
+
return {type: 'INT_8', optional: nullable};
|
|
111
|
+
|
|
112
|
+
case 'int16':
|
|
113
|
+
return {type: 'INT_16', optional: nullable};
|
|
114
|
+
|
|
115
|
+
case 'uint8':
|
|
116
|
+
return {type: 'UINT_8', optional: nullable};
|
|
117
|
+
|
|
118
|
+
case 'uint16':
|
|
119
|
+
return {type: 'UINT_16', optional: nullable};
|
|
120
|
+
|
|
121
|
+
case 'uint32':
|
|
122
|
+
return {type: 'UINT_32', optional: nullable};
|
|
123
|
+
|
|
124
|
+
case 'int64':
|
|
125
|
+
return {type: 'INT_64', optional: nullable};
|
|
126
|
+
|
|
127
|
+
case 'uint64':
|
|
128
|
+
return {type: 'UINT_64', optional: nullable};
|
|
129
|
+
|
|
130
|
+
case 'float':
|
|
131
|
+
case 'float32':
|
|
132
|
+
return {type: 'FLOAT', optional: nullable};
|
|
133
|
+
|
|
134
|
+
case 'float16':
|
|
135
|
+
return {type: 'FLOAT16', optional: nullable};
|
|
136
|
+
|
|
137
|
+
case 'float64':
|
|
138
|
+
return {type: 'DOUBLE', optional: nullable};
|
|
139
|
+
|
|
140
|
+
case 'utf8':
|
|
141
|
+
return {type: 'UTF8', optional: nullable};
|
|
142
|
+
|
|
143
|
+
case 'binary':
|
|
144
|
+
return {type: 'BYTE_ARRAY', optional: nullable};
|
|
145
|
+
|
|
146
|
+
case 'date-day':
|
|
147
|
+
return {type: 'DATE', optional: nullable};
|
|
148
|
+
|
|
149
|
+
case 'date-millisecond':
|
|
150
|
+
case 'timestamp-second':
|
|
151
|
+
case 'timestamp-millisecond':
|
|
152
|
+
return {type: 'TIMESTAMP_MILLIS', optional: nullable};
|
|
153
|
+
|
|
154
|
+
case 'timestamp-microsecond':
|
|
155
|
+
return {type: 'TIMESTAMP_MICROS', optional: nullable};
|
|
156
|
+
|
|
157
|
+
case 'timestamp-nanosecond':
|
|
158
|
+
return {type: 'TIMESTAMP_NANOS', optional: nullable};
|
|
159
|
+
|
|
160
|
+
case 'time-second':
|
|
161
|
+
case 'time-millisecond':
|
|
162
|
+
return {type: 'TIME_MILLIS', optional: nullable};
|
|
163
|
+
|
|
164
|
+
case 'time-microsecond':
|
|
165
|
+
return {type: 'TIME_MICROS', optional: nullable};
|
|
166
|
+
|
|
167
|
+
case 'time-nanosecond':
|
|
168
|
+
return {type: 'TIME_NANOS', optional: nullable};
|
|
169
|
+
|
|
170
|
+
default:
|
|
171
|
+
if (typeof dataType === 'object' && dataType.type === 'decimal') {
|
|
172
|
+
const physicalType =
|
|
173
|
+
dataType.precision <= 9
|
|
174
|
+
? 'DECIMAL_INT32'
|
|
175
|
+
: dataType.precision <= 18
|
|
176
|
+
? 'DECIMAL_INT64'
|
|
177
|
+
: 'DECIMAL_FIXED_LEN_BYTE_ARRAY';
|
|
178
|
+
return {
|
|
179
|
+
type: physicalType,
|
|
180
|
+
typeLength:
|
|
181
|
+
physicalType === 'DECIMAL_FIXED_LEN_BYTE_ARRAY'
|
|
182
|
+
? getDecimalByteWidth(dataType.precision)
|
|
183
|
+
: undefined,
|
|
184
|
+
precision: dataType.precision,
|
|
185
|
+
scale: dataType.scale,
|
|
186
|
+
optional: nullable
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (typeof dataType === 'object' && dataType.type === 'fixed-size-binary') {
|
|
190
|
+
return {
|
|
191
|
+
type: 'FIXED_LEN_BYTE_ARRAY',
|
|
192
|
+
typeLength: dataType.byteWidth,
|
|
193
|
+
optional: nullable
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
throw new Error(
|
|
198
|
+
`ParquetJSWriter: Unsupported field "${field.name}" with type ${formatDataType(dataType)}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Returns the minimum fixed byte width required by one decimal precision. */
|
|
204
|
+
function getDecimalByteWidth(precision: number): number {
|
|
205
|
+
for (let byteWidth = 1; byteWidth <= 32; byteWidth++) {
|
|
206
|
+
const maximumPrecision = Math.floor(Math.log10(2 ** (8 * byteWidth - 1) - 1));
|
|
207
|
+
if (precision <= maximumPrecision) return byteWidth;
|
|
208
|
+
}
|
|
209
|
+
throw new Error(`ParquetJSWriter: Decimal precision ${precision} exceeds 32 bytes`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Finds the first non-nullish value in a column.
|
|
214
|
+
* @param rows table rows
|
|
215
|
+
* @param columnName column name
|
|
216
|
+
* @returns first defined value, if any
|
|
217
|
+
*/
|
|
218
|
+
function getFirstDefinedValue(rows: Array<Record<string, unknown>>, columnName: string): unknown {
|
|
219
|
+
for (const row of rows) {
|
|
220
|
+
const value = row[columnName];
|
|
221
|
+
if (value !== null && value !== undefined) {
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Infers a loaders.gl data type from a JavaScript value.
|
|
231
|
+
* @param value sample value
|
|
232
|
+
* @returns inferred data type
|
|
233
|
+
*/
|
|
234
|
+
function getDataTypeFromValue(value: unknown): DataType {
|
|
235
|
+
if (typeof value === 'boolean') {
|
|
236
|
+
return 'bool';
|
|
237
|
+
}
|
|
238
|
+
if (typeof value === 'number') {
|
|
239
|
+
return Number.isInteger(value) ? 'int32' : 'float64';
|
|
240
|
+
}
|
|
241
|
+
if (typeof value === 'string') {
|
|
242
|
+
return 'utf8';
|
|
243
|
+
}
|
|
244
|
+
if (value instanceof Date) {
|
|
245
|
+
return 'timestamp-millisecond';
|
|
246
|
+
}
|
|
247
|
+
if (value instanceof Uint8Array) {
|
|
248
|
+
return 'binary';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
throw new Error('ParquetJSWriter: Unable to infer a Parquet type from the provided row data');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Formats a loaders.gl data type for error messages.
|
|
256
|
+
* @param dataType input data type
|
|
257
|
+
* @returns human-readable type string
|
|
258
|
+
*/
|
|
259
|
+
function formatDataType(dataType: DataType): string {
|
|
260
|
+
return typeof dataType === 'string' ? dataType : dataType.type;
|
|
261
|
+
}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
|
|
7
|
+
import type {Field, Schema} from '@loaders.gl/schema';
|
|
8
|
+
import {
|
|
9
|
+
getGeoMetadata,
|
|
10
|
+
getMetadataValue,
|
|
11
|
+
setGeoMetadata,
|
|
12
|
+
setMetadataValue,
|
|
13
|
+
type GeoArrowEncoding,
|
|
14
|
+
type GeoArrowMetadata,
|
|
15
|
+
type GeoColumnMetadata,
|
|
16
|
+
type GeoMetadata,
|
|
17
|
+
type GeoParquetGeometryType
|
|
18
|
+
} from '@loaders.gl/gis';
|
|
19
|
+
import {
|
|
20
|
+
GeoArrowMetadataSchema,
|
|
21
|
+
GeoParquetMetadataSchema
|
|
22
|
+
} from '@loaders.gl/gis/geospatial-metadata-zod-schema';
|
|
23
|
+
import {convertArrowToSchema} from '@loaders.gl/schema-utils';
|
|
24
|
+
|
|
25
|
+
const GEOARROW_EXTENSION_NAME_KEY = 'ARROW:extension:name';
|
|
26
|
+
const GEOARROW_EXTENSION_METADATA_KEY = 'ARROW:extension:metadata';
|
|
27
|
+
const GEOPARQUET_VERSION = '1.1.0';
|
|
28
|
+
|
|
29
|
+
const GEOARROW_ENCODINGS = [
|
|
30
|
+
'geoarrow.geometry',
|
|
31
|
+
'geoarrow.geometrycollection',
|
|
32
|
+
'geoarrow.multipolygon',
|
|
33
|
+
'geoarrow.polygon',
|
|
34
|
+
'geoarrow.multilinestring',
|
|
35
|
+
'geoarrow.linestring',
|
|
36
|
+
'geoarrow.multipoint',
|
|
37
|
+
'geoarrow.point',
|
|
38
|
+
'geoarrow.box',
|
|
39
|
+
'geoarrow.wkb',
|
|
40
|
+
'geoarrow.wkt'
|
|
41
|
+
] as const satisfies GeoArrowEncoding[];
|
|
42
|
+
|
|
43
|
+
const GEOPARQUET_TO_GEOARROW_ENCODINGS = {
|
|
44
|
+
wkb: 'geoarrow.wkb',
|
|
45
|
+
point: 'geoarrow.point',
|
|
46
|
+
linestring: 'geoarrow.linestring',
|
|
47
|
+
polygon: 'geoarrow.polygon',
|
|
48
|
+
multipoint: 'geoarrow.multipoint',
|
|
49
|
+
multilinestring: 'geoarrow.multilinestring',
|
|
50
|
+
multipolygon: 'geoarrow.multipolygon'
|
|
51
|
+
} as const satisfies Record<string, GeoArrowEncoding>;
|
|
52
|
+
|
|
53
|
+
const GEOARROW_TO_GEOPARQUET_ENCODINGS = {
|
|
54
|
+
'geoarrow.wkb': 'wkb',
|
|
55
|
+
'geoarrow.point': 'point',
|
|
56
|
+
'geoarrow.linestring': 'linestring',
|
|
57
|
+
'geoarrow.polygon': 'polygon',
|
|
58
|
+
'geoarrow.multipoint': 'multipoint',
|
|
59
|
+
'geoarrow.multilinestring': 'multilinestring',
|
|
60
|
+
'geoarrow.multipolygon': 'multipolygon'
|
|
61
|
+
} as const;
|
|
62
|
+
|
|
63
|
+
const GEOARROW_TO_GEOMETRY_TYPE = {
|
|
64
|
+
'geoarrow.point': 'Point',
|
|
65
|
+
'geoarrow.linestring': 'LineString',
|
|
66
|
+
'geoarrow.polygon': 'Polygon',
|
|
67
|
+
'geoarrow.multipoint': 'MultiPoint',
|
|
68
|
+
'geoarrow.multilinestring': 'MultiLineString',
|
|
69
|
+
'geoarrow.multipolygon': 'MultiPolygon'
|
|
70
|
+
} as const satisfies Record<string, GeoParquetGeometryType>;
|
|
71
|
+
|
|
72
|
+
/** Returns GeoArrow geometry field metadata keyed by column name. */
|
|
73
|
+
function getGeometryColumnsFromSchema(schema: Schema): Record<string, GeoArrowMetadata> {
|
|
74
|
+
const geometryColumns: Record<string, GeoArrowMetadata> = {};
|
|
75
|
+
for (const field of schema.fields || []) {
|
|
76
|
+
const metadata = getGeometryMetadataForField(field.metadata || {});
|
|
77
|
+
if (metadata) {
|
|
78
|
+
geometryColumns[field.name] = metadata;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return geometryColumns;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Extracts GeoArrow metadata from one schema field metadata object. */
|
|
85
|
+
function getGeometryMetadataForField(
|
|
86
|
+
fieldMetadata: Record<string, string>
|
|
87
|
+
): GeoArrowMetadata | null {
|
|
88
|
+
let metadata: GeoArrowMetadata | null = null;
|
|
89
|
+
let geoEncoding = getMetadataValue(fieldMetadata, GEOARROW_EXTENSION_NAME_KEY);
|
|
90
|
+
if (geoEncoding) {
|
|
91
|
+
geoEncoding = geoEncoding.toLowerCase();
|
|
92
|
+
if (geoEncoding === 'wkb') {
|
|
93
|
+
geoEncoding = 'geoarrow.wkb';
|
|
94
|
+
}
|
|
95
|
+
if (geoEncoding === 'wkt') {
|
|
96
|
+
geoEncoding = 'geoarrow.wkt';
|
|
97
|
+
}
|
|
98
|
+
if (GEOARROW_ENCODINGS.includes(geoEncoding as GeoArrowEncoding)) {
|
|
99
|
+
metadata ||= {};
|
|
100
|
+
metadata.encoding = geoEncoding as GeoArrowEncoding;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const columnMetadata = getMetadataValue(fieldMetadata, GEOARROW_EXTENSION_METADATA_KEY);
|
|
105
|
+
if (columnMetadata) {
|
|
106
|
+
try {
|
|
107
|
+
const parsedMetadata = GeoArrowMetadataSchema.parse(JSON.parse(columnMetadata));
|
|
108
|
+
metadata = {
|
|
109
|
+
...(metadata || {}),
|
|
110
|
+
...parsedMetadata
|
|
111
|
+
};
|
|
112
|
+
} catch {
|
|
113
|
+
return metadata;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return metadata;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Applies GeoParquet schema metadata to matching geometry fields as GeoArrow field metadata.
|
|
122
|
+
*
|
|
123
|
+
* @param schema - Schema to annotate.
|
|
124
|
+
* @returns The same schema reference.
|
|
125
|
+
*/
|
|
126
|
+
export function applyGeoParquetToFieldMetadata(schema: Schema): Schema {
|
|
127
|
+
const geoMetadata = getGeoMetadata(schema.metadata);
|
|
128
|
+
if (!geoMetadata) {
|
|
129
|
+
return schema;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
for (const field of schema.fields) {
|
|
133
|
+
const columnMetadata = geoMetadata.columns?.[field.name];
|
|
134
|
+
if (!columnMetadata) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const fieldMetadata = getGeoArrowMetadataFromGeoParquetField(field, columnMetadata);
|
|
139
|
+
if (!fieldMetadata) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
field.metadata ||= {};
|
|
144
|
+
setMetadataValue(field.metadata, GEOARROW_EXTENSION_NAME_KEY, fieldMetadata.extensionName);
|
|
145
|
+
|
|
146
|
+
if (fieldMetadata.extensionMetadata) {
|
|
147
|
+
setMetadataValue(
|
|
148
|
+
field.metadata,
|
|
149
|
+
GEOARROW_EXTENSION_METADATA_KEY,
|
|
150
|
+
JSON.stringify(fieldMetadata.extensionMetadata)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return schema;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Creates an Arrow JS table whose schema metadata matches a loaders.gl schema.
|
|
160
|
+
*
|
|
161
|
+
* @param table - Arrow JS table to rewrap.
|
|
162
|
+
* @param schema - loaders.gl schema containing desired field/schema metadata.
|
|
163
|
+
* @returns Table using the updated Arrow JS schema.
|
|
164
|
+
*/
|
|
165
|
+
export function applyLoadersSchemaToArrowTable(table: arrow.Table, schema: Schema): arrow.Table {
|
|
166
|
+
const arrowSchema = createArrowJsSchema(table.schema, schema);
|
|
167
|
+
return new arrow.Table(arrowSchema, table.batches);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Normalizes an Arrow wrapper so GeoParquet metadata is preserved and GeoArrow field metadata is attached.
|
|
172
|
+
*
|
|
173
|
+
* @param arrowTable - loaders.gl Arrow table wrapper.
|
|
174
|
+
* @param schemaMetadata - Optional schema metadata override from the Parquet footer.
|
|
175
|
+
* @returns Arrow table wrapper with synchronized schema metadata.
|
|
176
|
+
*/
|
|
177
|
+
export function normalizeArrowTableGeoMetadata(
|
|
178
|
+
arrowTable: {shape: 'arrow-table'; data: arrow.Table; schema?: Schema},
|
|
179
|
+
schemaMetadata?: Map<string, string> | Record<string, string>
|
|
180
|
+
): {shape: 'arrow-table'; data: arrow.Table; schema: Schema} {
|
|
181
|
+
const schema = convertArrowToSchema(arrowTable.data.schema);
|
|
182
|
+
mergeSchemaMetadata(schema, schemaMetadata);
|
|
183
|
+
applyGeoParquetToFieldMetadata(schema);
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
shape: 'arrow-table',
|
|
187
|
+
data: applyLoadersSchemaToArrowTable(arrowTable.data, schema),
|
|
188
|
+
schema
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Synthesizes GeoParquet schema metadata from GeoArrow field metadata when needed.
|
|
194
|
+
*
|
|
195
|
+
* @param schema - Schema to inspect and update.
|
|
196
|
+
* @returns The same schema reference.
|
|
197
|
+
*/
|
|
198
|
+
export function ensureGeoParquetMetadata(schema: Schema): Schema {
|
|
199
|
+
schema.metadata ||= {};
|
|
200
|
+
const rawExistingGeoMetadata = getGeoMetadata(schema.metadata);
|
|
201
|
+
if (isValidGeoParquetMetadata(rawExistingGeoMetadata)) {
|
|
202
|
+
return schema;
|
|
203
|
+
}
|
|
204
|
+
const existingGeoMetadata: GeoMetadata | undefined = rawExistingGeoMetadata || undefined;
|
|
205
|
+
|
|
206
|
+
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
207
|
+
const geometryColumnNames = Object.keys(geometryColumns);
|
|
208
|
+
if (geometryColumnNames.length === 0) {
|
|
209
|
+
return schema;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const geoMetadata: GeoMetadata = {
|
|
213
|
+
version: GEOPARQUET_VERSION,
|
|
214
|
+
primary_column: geometryColumnNames[0],
|
|
215
|
+
columns: {}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
for (const geometryColumnName of geometryColumnNames) {
|
|
219
|
+
const geometryMetadata = geometryColumns[geometryColumnName];
|
|
220
|
+
const synthesizedColumnMetadata = synthesizeGeoParquetColumnMetadata(geometryMetadata);
|
|
221
|
+
if (!synthesizedColumnMetadata) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const existingColumnMetadata = existingGeoMetadata?.columns?.[geometryColumnName];
|
|
226
|
+
geoMetadata.columns[geometryColumnName] = {
|
|
227
|
+
...pickValidOptionalGeoParquetColumnMetadata(existingColumnMetadata),
|
|
228
|
+
...synthesizedColumnMetadata
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (Object.keys(geoMetadata.columns).length === 0) {
|
|
233
|
+
return schema;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
setGeoMetadata(schema.metadata, geoMetadata);
|
|
237
|
+
return schema;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Ensures an Arrow table wrapper carries valid GeoParquet schema metadata when GeoArrow fields are present.
|
|
242
|
+
*
|
|
243
|
+
* @param arrowTable - Arrow table wrapper to inspect and update.
|
|
244
|
+
* @returns Updated Arrow table wrapper.
|
|
245
|
+
*/
|
|
246
|
+
export function ensureGeoParquetMetadataOnArrowTable(arrowTable: {
|
|
247
|
+
shape: 'arrow-table';
|
|
248
|
+
data: arrow.Table;
|
|
249
|
+
schema?: Schema;
|
|
250
|
+
}): {shape: 'arrow-table'; data: arrow.Table; schema: Schema} {
|
|
251
|
+
const schema = arrowTable.schema || convertArrowToSchema(arrowTable.data.schema);
|
|
252
|
+
ensureGeoParquetMetadata(schema);
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
shape: 'arrow-table',
|
|
256
|
+
data: applyLoadersSchemaToArrowTable(arrowTable.data, schema),
|
|
257
|
+
schema
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns Parquet file key/value metadata as a plain map.
|
|
263
|
+
*
|
|
264
|
+
* @param parquetMetadata - parquet-wasm metadata object.
|
|
265
|
+
* @returns Metadata map.
|
|
266
|
+
*/
|
|
267
|
+
export function getParquetFileMetadataMap(parquetMetadata: {
|
|
268
|
+
fileMetadata(): {keyValueMetadata(): Map<string, string>};
|
|
269
|
+
}): Map<string, string> {
|
|
270
|
+
return parquetMetadata.fileMetadata().keyValueMetadata();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function mergeSchemaMetadata(
|
|
274
|
+
schema: Schema,
|
|
275
|
+
schemaMetadata?: Map<string, string> | Record<string, string>
|
|
276
|
+
): void {
|
|
277
|
+
if (!schemaMetadata) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
schema.metadata ||= {};
|
|
282
|
+
for (const [metadataKey, metadataValue] of getMetadataEntries(schemaMetadata)) {
|
|
283
|
+
setMetadataValue(schema.metadata, metadataKey, metadataValue);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function createArrowJsSchema(baseSchema: arrow.Schema, schema: Schema): arrow.Schema {
|
|
288
|
+
const fields = baseSchema.fields.map(baseField => {
|
|
289
|
+
const nextField = schema.fields.find(field => field.name === baseField.name);
|
|
290
|
+
if (!nextField?.metadata) {
|
|
291
|
+
return baseField;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return baseField.clone({
|
|
295
|
+
metadata: createMetadataMap(nextField.metadata)
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
return new arrow.Schema(
|
|
300
|
+
fields,
|
|
301
|
+
createMetadataMap(schema.metadata),
|
|
302
|
+
baseSchema.dictionaries,
|
|
303
|
+
baseSchema.metadataVersion
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function getGeoArrowMetadataFromGeoParquetField(
|
|
308
|
+
field: Field,
|
|
309
|
+
columnMetadata: GeoColumnMetadata
|
|
310
|
+
): {extensionName: GeoArrowEncoding; extensionMetadata?: Record<string, unknown>} | null {
|
|
311
|
+
const normalizedEncoding = String(columnMetadata.encoding || '').toLowerCase();
|
|
312
|
+
const extensionName =
|
|
313
|
+
GEOPARQUET_TO_GEOARROW_ENCODINGS[
|
|
314
|
+
normalizedEncoding as keyof typeof GEOPARQUET_TO_GEOARROW_ENCODINGS
|
|
315
|
+
];
|
|
316
|
+
|
|
317
|
+
if (!extensionName) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (normalizedEncoding === 'wkb' && field.type !== 'binary') {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (normalizedEncoding !== 'wkb' && (field.type === 'binary' || field.type === 'utf8')) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const extensionMetadata: Record<string, unknown> = {};
|
|
330
|
+
if (columnMetadata.crs !== undefined) {
|
|
331
|
+
extensionMetadata.crs = columnMetadata.crs;
|
|
332
|
+
}
|
|
333
|
+
if (columnMetadata.crs_type !== undefined) {
|
|
334
|
+
extensionMetadata.crs_type = columnMetadata.crs_type;
|
|
335
|
+
}
|
|
336
|
+
if (columnMetadata.edges === 'spherical') {
|
|
337
|
+
extensionMetadata.edges = 'spherical';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return Object.keys(extensionMetadata).length > 0
|
|
341
|
+
? {extensionName, extensionMetadata}
|
|
342
|
+
: {extensionName};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function isValidGeoParquetMetadata(geoMetadata: GeoMetadata | null): boolean {
|
|
346
|
+
return GeoParquetMetadataSchema.safeParse(geoMetadata).success;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function synthesizeGeoParquetColumnMetadata(
|
|
350
|
+
geometryMetadata: GeoArrowMetadata
|
|
351
|
+
): GeoColumnMetadata | null {
|
|
352
|
+
const encoding = geometryMetadata.encoding
|
|
353
|
+
? GEOARROW_TO_GEOPARQUET_ENCODINGS[
|
|
354
|
+
geometryMetadata.encoding as keyof typeof GEOARROW_TO_GEOPARQUET_ENCODINGS
|
|
355
|
+
]
|
|
356
|
+
: null;
|
|
357
|
+
|
|
358
|
+
if (!encoding) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const geometryTypes = Array.isArray(geometryMetadata.geometry_types)
|
|
363
|
+
? geometryMetadata.geometry_types
|
|
364
|
+
: inferGeometryTypesFromGeoArrowEncoding(geometryMetadata.encoding);
|
|
365
|
+
|
|
366
|
+
const columnMetadata: GeoColumnMetadata = {
|
|
367
|
+
encoding,
|
|
368
|
+
geometry_types: geometryTypes
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
if (geometryMetadata.crs !== undefined && typeof geometryMetadata.crs !== 'string') {
|
|
372
|
+
columnMetadata.crs = geometryMetadata.crs;
|
|
373
|
+
}
|
|
374
|
+
if (geometryMetadata.crs_type === 'projjson' || geometryMetadata.crs_type === 'wkt2:2019') {
|
|
375
|
+
columnMetadata.crs_type = geometryMetadata.crs_type;
|
|
376
|
+
}
|
|
377
|
+
if (geometryMetadata.edges === 'spherical') {
|
|
378
|
+
columnMetadata.edges = 'spherical';
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return columnMetadata;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function inferGeometryTypesFromGeoArrowEncoding(
|
|
385
|
+
encoding?: GeoArrowEncoding
|
|
386
|
+
): GeoParquetGeometryType[] {
|
|
387
|
+
const geometryType = encoding
|
|
388
|
+
? GEOARROW_TO_GEOMETRY_TYPE[encoding as keyof typeof GEOARROW_TO_GEOMETRY_TYPE]
|
|
389
|
+
: null;
|
|
390
|
+
return geometryType ? [geometryType] : [];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function pickValidOptionalGeoParquetColumnMetadata(
|
|
394
|
+
columnMetadata: GeoColumnMetadata | undefined
|
|
395
|
+
): Partial<GeoColumnMetadata> {
|
|
396
|
+
if (!columnMetadata) {
|
|
397
|
+
return {};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const nextColumnMetadata: Partial<GeoColumnMetadata> = {};
|
|
401
|
+
|
|
402
|
+
if (columnMetadata.orientation === 'counterclockwise') {
|
|
403
|
+
nextColumnMetadata.orientation = columnMetadata.orientation;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (isValidBBox(columnMetadata.bbox)) {
|
|
407
|
+
nextColumnMetadata.bbox = columnMetadata.bbox;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (typeof columnMetadata.epoch === 'number' && Number.isFinite(columnMetadata.epoch)) {
|
|
411
|
+
nextColumnMetadata.epoch = columnMetadata.epoch;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (columnMetadata.covering && typeof columnMetadata.covering === 'object') {
|
|
415
|
+
nextColumnMetadata.covering = columnMetadata.covering;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return nextColumnMetadata;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function isValidBBox(
|
|
422
|
+
bbox: GeoColumnMetadata['bbox']
|
|
423
|
+
): bbox is [number, number, number, number] | [number, number, number, number, number, number] {
|
|
424
|
+
if (!Array.isArray(bbox) || (bbox.length !== 4 && bbox.length !== 6)) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return bbox.every(value => typeof value === 'number' && Number.isFinite(value));
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function getMetadataEntries(
|
|
432
|
+
metadata: Map<string, string> | Record<string, string>
|
|
433
|
+
): [string, string][] {
|
|
434
|
+
if (metadata instanceof Map) {
|
|
435
|
+
return [...metadata.entries()];
|
|
436
|
+
}
|
|
437
|
+
return Object.entries(metadata);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function createMetadataMap(
|
|
441
|
+
metadata: Map<string, string> | Record<string, string> | undefined
|
|
442
|
+
): Map<string, string> {
|
|
443
|
+
if (!metadata) {
|
|
444
|
+
return new Map();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (metadata instanceof Map) {
|
|
448
|
+
return new Map(metadata);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return new Map(
|
|
452
|
+
Object.entries(metadata).map(([metadataKey, metadataValue]) => [
|
|
453
|
+
metadataKey,
|
|
454
|
+
String(metadataValue)
|
|
455
|
+
])
|
|
456
|
+
);
|
|
457
|
+
}
|