@loaders.gl/core 5.0.0-beta.1 → 5.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GEOARROW-README.md +1 -1
- package/README.md +4 -2
- package/SCAN-README.md +1 -1
- package/SCHEMA-UTILS-README.md +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.js +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.js.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs +5 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +5 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +6 -2
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +6 -2
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +295 -18
- package/dist/arrow-geometry/geojson-table.cjs.map +3 -3
- package/dist/arrow-geometry/geojson-table.d.ts +10 -3
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +23 -13
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.cjs +6 -6
- package/dist/arrow-geometry/geometry-codecs.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-codecs.js +1 -1
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.cjs +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.js +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.js.map +1 -1
- package/dist/arrow-geometry/index.cjs +0 -11
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +0 -1
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +0 -1
- package/dist/arrow-geometry/index.js.map +1 -1
- package/dist/arrow-geometry/wkb-builder.cjs +3 -3
- package/dist/arrow-geometry/wkb-builder.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-builder.d.ts +1 -1
- package/dist/arrow-geometry/wkb-builder.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-builder.js +1 -1
- package/dist/arrow-geometry/wkb-builder.js.map +1 -1
- package/dist/arrow-geometry/wkb-statistics.cjs +2 -2
- package/dist/arrow-geometry/wkb-statistics.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-statistics.js +1 -1
- package/dist/arrow-geometry/wkb-statistics.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +173 -0
- package/dist/arrow-worker-transport.cjs.map +6 -0
- package/dist/arrow-worker-transport.d.ts +15 -0
- package/dist/arrow-worker-transport.d.ts.map +1 -0
- package/dist/arrow-worker-transport.js +151 -0
- package/dist/arrow-worker-transport.js.map +1 -0
- package/dist/cluster-source.cjs +6874 -0
- package/dist/cluster-source.cjs.map +6 -0
- package/dist/cluster-source.d.ts +2 -0
- package/dist/cluster-source.d.ts.map +1 -0
- package/dist/cluster-source.js +2 -0
- package/dist/cluster-source.js.map +1 -0
- package/dist/dist.dev.js +3035 -823
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +2447 -0
- package/dist/federated-table-scan-source.cjs.map +6 -0
- package/dist/federated-table-scan-source.d.ts +2 -0
- package/dist/federated-table-scan-source.d.ts.map +1 -0
- package/dist/federated-table-scan-source.js +2 -0
- package/dist/federated-table-scan-source.js.map +1 -0
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.cjs +4 -7
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +1 -4
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +1 -0
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +2 -0
- package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-bounds.cjs +7 -7
- package/dist/geoarrow/geoarrow-bounds.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-bounds.js +3 -3
- package/dist/geoarrow/geoarrow-bounds.js.map +1 -1
- package/dist/geoarrow/geoarrow-capabilities.cjs +2 -2
- package/dist/geoarrow/geoarrow-capabilities.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-capabilities.js +1 -1
- package/dist/geoarrow/geoarrow-capabilities.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +8 -8
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +6 -4
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +9 -4
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +6 -4
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +6 -4
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
- package/dist/geoarrow/geoarrow-inspection.cjs +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-inspection.js +1 -1
- package/dist/geoarrow/geoarrow-inspection.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.js +1 -1
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.js +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs +4 -4
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -3
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs +3 -3
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs +0 -6
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +2 -3
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js +0 -6
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +738 -1372
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +20 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +15 -19
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +17 -67
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +61 -6
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +47 -53
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +2 -2
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +16 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +84 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.d.ts +3 -2
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +9 -10
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts +0 -6
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +31 -114
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/format-types.d.ts +3 -0
- package/dist/loader-utils/format-types.d.ts.map +1 -1
- package/dist/loader-utils/index.cjs +838 -1284
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +16 -7
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +8 -4
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.d.ts +4 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.js +45 -1
- package/dist/loader-utils/lib/files/http-file-transport.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-types.d.ts +2 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/read-range-response.d.ts +3 -0
- package/dist/loader-utils/lib/files/read-range-response.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/read-range-response.js +62 -0
- package/dist/loader-utils/lib/files/read-range-response.js.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.d.ts +23 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/pace-batch-iterator.d.ts +14 -0
- package/dist/loader-utils/lib/pace-batch-iterator.d.ts.map +1 -0
- package/dist/loader-utils/lib/pace-batch-iterator.js +51 -0
- package/dist/loader-utils/lib/pace-batch-iterator.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.js +1 -1
- package/dist/loader-utils/lib/request-utils/request-credentials.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +43 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +104 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.d.ts → query-options.d.ts} +5 -8
- package/dist/loader-utils/lib/scan-utils/query-options.d.ts.map +1 -0
- package/dist/{schema-utils/lib/table/batch-builder/table-batch-aggregator.js → loader-utils/lib/scan-utils/query-options.js} +1 -1
- package/dist/loader-utils/lib/scan-utils/query-options.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +54 -18
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +16 -6
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +54 -3
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -3
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +33 -18
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +53 -14
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/sources/image-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +30 -0
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -0
- package/dist/loader-utils/lib/{scan-utils/experimental-scan-options.js → sources/table-source-collection.js} +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.js.map +1 -0
- package/dist/loader-utils/lib/sources/utils/utils.js +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.js.map +1 -1
- package/dist/loader-utils/lib/sources/vector-source.d.ts +4 -3
- package/dist/loader-utils/lib/sources/vector-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -2
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js +2 -5
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +40 -21
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +120 -91
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/source-types.d.ts +7 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +9 -1
- package/dist/loader-utils/source-types.js.map +1 -1
- package/dist/null-loader.d.ts +0 -18
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +1 -19
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +771 -82
- package/dist/null-worker.js +742 -81
- package/dist/polyfills/images/encode-image-node.d.ts +18 -15
- package/dist/polyfills/images/encode-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/encode-image-node.js +19 -33
- package/dist/polyfills/images/encode-image-node.js.map +1 -1
- package/dist/polyfills/images/image-codecs-node.d.ts +2 -6
- package/dist/polyfills/images/image-codecs-node.d.ts.map +1 -1
- package/dist/polyfills/images/image-codecs-node.js +2 -24
- package/dist/polyfills/images/image-codecs-node.js.map +1 -1
- package/dist/polyfills/images/load-sharp.d.ts +3 -0
- package/dist/polyfills/images/load-sharp.d.ts.map +1 -0
- package/dist/polyfills/images/load-sharp.js +11 -0
- package/dist/polyfills/images/load-sharp.js.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts +1 -1
- package/dist/polyfills/images/node-image-bitmap.js +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts.map +1 -1
- package/dist/polyfills/images/node-image-formats.js +10 -4
- package/dist/polyfills/images/node-image-formats.js.map +1 -1
- package/dist/polyfills/images/parse-image-node.d.ts +10 -2
- package/dist/polyfills/images/parse-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/parse-image-node.js +20 -32
- package/dist/polyfills/images/parse-image-node.js.map +1 -1
- package/dist/polyfills/index.cjs +76 -151
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +134 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +11 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +86 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +255 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +18 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js +224 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs +70 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +8 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.js +39 -0
- package/dist/scan/arrow-execution/project-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution.cjs +34 -0
- package/dist/scan/arrow-execution.cjs.map +7 -0
- package/dist/scan/arrow-execution.d.ts +4 -0
- package/dist/scan/arrow-execution.d.ts.map +1 -0
- package/dist/scan/arrow-execution.js +6 -0
- package/dist/scan/arrow-execution.js.map +1 -0
- package/dist/scan/arrow-query.cjs.map +1 -1
- package/dist/scan/arrow-query.d.ts +1 -1
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/catalog-query-source.cjs +122 -0
- package/dist/scan/catalog-query-source.cjs.map +7 -0
- package/dist/scan/catalog-query-source.d.ts +6 -0
- package/dist/scan/catalog-query-source.d.ts.map +1 -0
- package/dist/scan/catalog-query-source.js +115 -0
- package/dist/scan/catalog-query-source.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +38 -38
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts +6 -10
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +35 -35
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +208 -4
- package/dist/scan/index.cjs.map +4 -4
- package/dist/scan/index.d.ts +13 -3
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +6 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +6 -9
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -314
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.cjs +75 -0
- package/dist/scan/query-arrow-table-in-batches.cjs.map +7 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts +8 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.js +54 -0
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -0
- package/dist/scan/query-arrow-table.cjs +65 -202
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +7 -40
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +51 -211
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query-open-source.cjs +52 -0
- package/dist/scan/query-open-source.cjs.map +7 -0
- package/dist/scan/query-open-source.d.ts +4 -0
- package/dist/scan/query-open-source.d.ts.map +1 -0
- package/dist/scan/query-open-source.js +26 -0
- package/dist/scan/query-open-source.js.map +1 -0
- package/dist/scan/query-progressive.cjs +190 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +173 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query-pushdown.cjs +140 -0
- package/dist/scan/query-pushdown.cjs.map +7 -0
- package/dist/scan/query-pushdown.d.ts +14 -0
- package/dist/scan/query-pushdown.d.ts.map +1 -0
- package/dist/scan/query-pushdown.js +136 -0
- package/dist/scan/query-pushdown.js.map +1 -0
- package/dist/scan/query.cjs +381 -0
- package/dist/scan/query.cjs.map +7 -0
- package/dist/scan/query.d.ts +64 -0
- package/dist/scan/query.d.ts.map +1 -0
- package/dist/scan/query.js +419 -0
- package/dist/scan/query.js.map +1 -0
- package/dist/scan/resolve-query-source.cjs +59 -0
- package/dist/scan/resolve-query-source.cjs.map +7 -0
- package/dist/scan/resolve-query-source.d.ts +6 -0
- package/dist/scan/resolve-query-source.d.ts.map +1 -0
- package/dist/scan/resolve-query-source.js +37 -0
- package/dist/scan/resolve-query-source.js.map +1 -0
- package/dist/scan/rows-to-arrow.cjs +1 -28
- package/dist/scan/rows-to-arrow.cjs.map +2 -2
- package/dist/scan/rows-to-arrow.d.ts +3 -3
- package/dist/scan/rows-to-arrow.d.ts.map +1 -1
- package/dist/scan/rows-to-arrow.js +2 -32
- package/dist/scan/rows-to-arrow.js.map +1 -1
- package/dist/scan/scan-engine.cjs.map +2 -2
- package/dist/scan/scan-engine.d.ts +5 -5
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/sql-catalog.cjs +110 -0
- package/dist/scan/sql-catalog.cjs.map +7 -0
- package/dist/scan/sql-catalog.d.ts +47 -0
- package/dist/scan/sql-catalog.d.ts.map +1 -0
- package/dist/scan/sql-catalog.js +97 -0
- package/dist/scan/sql-catalog.js.map +1 -0
- package/dist/scan/table-query.cjs.map +2 -2
- package/dist/scan/table-query.d.ts +4 -1
- package/dist/scan/table-query.d.ts.map +1 -1
- package/dist/scan/table-query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +14 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +6 -5
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +17 -14
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/geometry/geoarrow.d.ts +3 -6
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/schema/index.cjs +11 -7
- package/dist/schema/index.cjs.map +2 -2
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/schema/index.js.map +1 -1
- package/dist/schema-utils/index.cjs +690 -823
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +6 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +6 -4
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +17 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +106 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -0
- package/dist/schema-utils/lib/converters/convert.js +9 -2
- package/dist/schema-utils/lib/converters/convert.js.map +1 -1
- package/dist/schema-utils/lib/converters/types.d.ts +2 -0
- package/dist/schema-utils/lib/converters/types.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +4 -3
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +4 -4
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -3
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +9 -2
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.d.ts +14 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.js +39 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.js.map +1 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts +2 -14
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/mesh-utils.js +1 -35
- package/dist/schema-utils/lib/mesh/mesh-utils.js.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +6 -5
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts +9 -9
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js +13 -46
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts +9 -20
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js +61 -73
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts +4 -3
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +30 -9
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +6 -9
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +26 -15
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +4 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +33 -9
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts +3 -3
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/query-arrow-table.js +9 -23
- package/dist/schema-utils/lib/table/query-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +27 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +23 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +12 -10
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +15 -26
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts +6 -36
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-table.js +5 -42
- package/dist/schema-utils/lib/table/tables/convert-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.d.ts +3 -55
- package/dist/schema-utils/lib/table/tables/make-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +3 -59
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts +18 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +42 -31
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts +6 -5
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +3 -3
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +7 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +1760 -0
- package/dist/vector-table-scan-source.cjs.map +6 -0
- package/dist/vector-table-scan-source.d.ts +2 -0
- package/dist/vector-table-scan-source.d.ts.map +1 -0
- package/dist/vector-table-scan-source.js +2 -0
- package/dist/vector-table-scan-source.js.map +1 -0
- package/dist/worker-utils/index.cjs +407 -1184
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/index.d.ts +2 -8
- package/dist/worker-utils/index.d.ts.map +1 -1
- package/dist/worker-utils/index.js +1 -10
- package/dist/worker-utils/index.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +3 -2
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts +5 -7
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.js +76 -146
- package/dist/worker-utils/lib/worker-api/create-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +17 -45
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +214 -312
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts +36 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.js +23 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.js.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts +1 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js +3 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +836 -147
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +804 -143
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +55 -72
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +126 -35
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -1
- package/src/arrow-geometry/feature-table.ts +6 -2
- package/src/arrow-geometry/geojson-table.ts +32 -21
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/index.ts +0 -9
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +225 -0
- package/src/cluster-source.ts +1 -0
- package/src/federated-table-scan-source.ts +1 -0
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/clustering/cluster-source.ts +4 -7
- package/src/geoarrow/convert-table-to-geoarrow.ts +3 -1
- package/src/geoarrow/geoarrow-bounds.ts +3 -3
- package/src/geoarrow/geoarrow-capabilities.ts +1 -1
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +3 -3
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +14 -9
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +9 -6
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +1 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- package/src/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +2 -2
- package/src/geoarrow/lib/kernels/encode-geoarrow-box.ts +1 -1
- package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +8 -10
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -5
- package/src/lib/api/create-data-source.ts +148 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +22 -21
- package/src/lib/api/load.ts +61 -127
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +122 -17
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +54 -69
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/get-fetch-function.ts +2 -2
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +109 -0
- package/src/lib/loader-utils/option-defaults.ts +9 -10
- package/src/lib/loader-utils/option-utils.ts +33 -122
- package/src/loader-utils/format-types.ts +4 -0
- package/src/loader-utils/index.ts +50 -9
- package/src/loader-utils/lib/files/http-file-transport.ts +65 -1
- package/src/loader-utils/lib/files/http-file-types.ts +2 -0
- package/src/loader-utils/lib/files/read-range-response.ts +66 -0
- package/src/loader-utils/lib/log-utils/log.ts +36 -1
- package/src/loader-utils/lib/pace-batch-iterator.ts +66 -0
- package/src/loader-utils/lib/request-utils/request-credentials.ts +1 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +174 -0
- package/src/loader-utils/lib/scan-utils/query-options.ts +44 -0
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +80 -28
- package/src/loader-utils/lib/scan-utils/table-query.ts +76 -8
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +54 -29
- package/src/loader-utils/lib/sources/data-source.ts +57 -16
- package/src/loader-utils/lib/sources/image-source.ts +1 -1
- package/src/loader-utils/lib/sources/table-source-collection.ts +38 -0
- package/src/loader-utils/lib/sources/utils/utils.ts +1 -1
- package/src/loader-utils/lib/sources/vector-source.ts +3 -3
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -2
- package/src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts +5 -6
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +41 -24
- package/src/loader-utils/loader-types.ts +190 -111
- package/src/loader-utils/source-types.ts +17 -6
- package/src/null-loader.ts +1 -20
- package/src/polyfills/README.md +2 -2
- package/src/polyfills/images/encode-image-node.ts +44 -37
- package/src/polyfills/images/image-codecs-node.ts +2 -37
- package/src/polyfills/images/load-sharp.ts +13 -0
- package/src/polyfills/images/node-image-bitmap.ts +1 -1
- package/src/polyfills/images/node-image-formats.ts +10 -4
- package/src/polyfills/images/parse-image-node.ts +31 -40
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +116 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +298 -0
- package/src/scan/arrow-execution/project-arrow-table.ts +53 -0
- package/src/scan/arrow-execution.ts +7 -0
- package/src/scan/arrow-query.ts +3 -0
- package/src/scan/catalog-query-source.ts +132 -0
- package/src/scan/federated-table-scan-source.ts +64 -72
- package/src/scan/index.ts +57 -5
- package/src/scan/parse-sql-predicate.ts +14 -367
- package/src/scan/query-arrow-table-in-batches.ts +55 -0
- package/src/scan/query-arrow-table.ts +81 -271
- package/src/scan/query-open-source.ts +39 -0
- package/src/scan/query-progressive.ts +229 -0
- package/src/scan/query-pushdown.ts +184 -0
- package/src/scan/query.ts +597 -0
- package/src/scan/resolve-query-source.ts +47 -0
- package/src/scan/rows-to-arrow.ts +3 -39
- package/src/scan/scan-engine.ts +6 -6
- package/src/scan/sql-catalog.ts +167 -0
- package/src/scan/table-query.ts +6 -1
- package/src/scan/vector-table-scan-source.ts +22 -18
- package/src/schema/geometry/geoarrow.ts +8 -19
- package/src/schema/index.ts +3 -2
- package/src/schema-utils/index.ts +23 -8
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +136 -0
- package/src/schema-utils/lib/converters/convert.ts +7 -2
- package/src/schema-utils/lib/converters/types.ts +2 -0
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +7 -9
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +10 -4
- package/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts +52 -0
- package/src/schema-utils/lib/mesh/mesh-utils.ts +3 -49
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +18 -8
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts +21 -51
- package/src/schema-utils/lib/table/batch-builder/table-batch-builder.ts +68 -83
- package/src/schema-utils/lib/table/batches/convert-batches.ts +41 -21
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +33 -19
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +48 -7
- package/src/schema-utils/lib/table/query-arrow-table.ts +14 -32
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +54 -0
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +30 -35
- package/src/schema-utils/lib/table/tables/convert-table.ts +11 -57
- package/src/schema-utils/lib/table/tables/make-table.ts +6 -70
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +66 -49
- package/src/schema-utils/lib/table/tables/table-converter/convert-tables.ts +12 -14
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +13 -10
- package/src/vector-table-scan-source.ts +1 -0
- package/src/worker-utils/index.ts +2 -18
- package/src/worker-utils/lib/library-utils/library-utils.ts +3 -2
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/create-worker.ts +89 -188
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +246 -402
- package/src/worker-utils/lib/worker-api/task-runtime.ts +66 -0
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
- package/src/worker-utils/lib/worker-utils/get-transfer-list.ts +2 -0
- package/src/worker-utils/types.ts +74 -109
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs +0 -477
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts +0 -29
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js +0 -434
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs +0 -39
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts +0 -2
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js +0 -5
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts +0 -40
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/data-view-file.js +0 -68
- package/dist/loader-utils/lib/file-provider/data-view-file.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts +0 -54
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-handle-file.js +0 -102
- package/dist/loader-utils/lib/file-provider/file-handle-file.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts +0 -45
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js +0 -13
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts +0 -57
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider.js +0 -114
- package/dist/loader-utils/lib/file-provider/file-provider.js.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js.map +0 -1
- package/dist/schema/deprecated/mesh-utils.d.ts +0 -12
- package/dist/schema/deprecated/mesh-utils.d.ts.map +0 -1
- package/dist/schema/deprecated/mesh-utils.js +0 -37
- package/dist/schema/deprecated/mesh-utils.js.map +0 -1
- package/dist/schema-utils/arrow-transport.cjs +0 -691
- package/dist/schema-utils/arrow-transport.cjs.map +0 -6
- package/dist/schema-utils/arrow-transport.d.ts +0 -4
- package/dist/schema-utils/arrow-transport.d.ts.map +0 -1
- package/dist/schema-utils/arrow-transport.js +0 -7
- package/dist/schema-utils/arrow-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts +0 -76
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js +0 -182
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts +0 -33
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js +0 -134
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts +0 -10
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js +0 -71
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts +0 -19
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js +0 -64
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts +0 -20
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js +0 -83
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts +0 -21
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js +0 -86
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts +0 -24
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.js.map +0 -1
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts +0 -32
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts.map +0 -1
- package/dist/worker-utils/lib/async-queue/async-queue.js +0 -91
- package/dist/worker-utils/lib/async-queue/async-queue.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts +0 -20
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.js +0 -131
- package/dist/worker-utils/lib/worker-farm/worker-body.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts +0 -58
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.js +0 -116
- package/dist/worker-utils/lib/worker-farm/worker-farm.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts +0 -34
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.js +0 -74
- package/dist/worker-utils/lib/worker-farm/worker-job.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts +0 -94
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.js +0 -246
- package/dist/worker-utils/lib/worker-farm/worker-pool.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts +0 -67
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.js +0 -175
- package/dist/worker-utils/lib/worker-farm/worker-thread.js.map +0 -1
- package/src/arrow-geometry/arrow-geoarrow-adapter.ts +0 -568
- package/src/geoarrow/lib/arrow-geoarrow-adapter.ts +0 -12
- package/src/loader-utils/lib/file-provider/data-view-file.ts +0 -83
- package/src/loader-utils/lib/file-provider/file-handle-file.ts +0 -114
- package/src/loader-utils/lib/file-provider/file-provider-interface.ts +0 -60
- package/src/loader-utils/lib/file-provider/file-provider.ts +0 -130
- package/src/loader-utils/lib/scan-utils/experimental-scan-options.ts +0 -46
- package/src/polyfills/images/encode-image.node.ts.disabled +0 -41
- package/src/polyfills/images/parse-image.node.ts.disabled +0 -55
- package/src/schema/deprecated/mesh-utils.ts +0 -46
- package/src/schema-utils/arrow-transport.ts +0 -7
- package/src/schema-utils/lib/arrow/arrow-table-transport.ts +0 -282
- package/src/schema-utils/lib/arrow/split-arrow-buffers.ts +0 -247
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator-builders.ts.disabled +0 -190
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.ts +0 -85
- package/src/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.ts +0 -82
- package/src/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.ts +0 -103
- package/src/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.ts +0 -108
- package/src/schema-utils/lib/table/batch-builder/table-batch-aggregator.ts +0 -28
- package/src/worker-utils/lib/async-queue/async-queue.ts +0 -100
- package/src/worker-utils/lib/worker-farm/worker-body.ts +0 -145
- package/src/worker-utils/lib/worker-farm/worker-farm.ts +0 -144
- package/src/worker-utils/lib/worker-farm/worker-job.ts +0 -85
- package/src/worker-utils/lib/worker-farm/worker-pool.ts +0 -316
- package/src/worker-utils/lib/worker-farm/worker-thread.ts +0 -206
|
@@ -36,17 +36,18 @@ __export(index_exports, {
|
|
|
36
36
|
ArrowLikeTable: () => ArrowLikeTable,
|
|
37
37
|
ArrowTableBuilder: () => ArrowTableBuilder,
|
|
38
38
|
AsyncQueue: () => AsyncQueue,
|
|
39
|
-
ColumnarTableBatchAggregator: () => ColumnarTableBatchAggregator,
|
|
40
39
|
PointCloudTiler: () => PointCloudTiler,
|
|
41
|
-
RowTableBatchAggregator: () => RowTableBatchAggregator,
|
|
42
40
|
TABLE_CONVERTERS: () => TABLE_CONVERTERS,
|
|
43
41
|
TableBatchBuilder: () => TableBatchBuilder,
|
|
44
42
|
TableConverter: () => TableConverter,
|
|
45
43
|
convert: () => convert,
|
|
44
|
+
convertArrowTable: () => convertArrowTable,
|
|
45
|
+
convertArrowTableBatch: () => convertArrowTableBatch,
|
|
46
46
|
convertArrowToSchema: () => convertArrowToSchema,
|
|
47
47
|
convertArrowToTable: () => convertArrowToTable2,
|
|
48
48
|
convertBatch: () => convertBatch,
|
|
49
49
|
convertBatches: () => convertBatches,
|
|
50
|
+
convertMeshToArrowTableWrapper: () => convertMeshToArrowTableWrapper,
|
|
50
51
|
convertMeshToTable: () => convertMeshToTable,
|
|
51
52
|
convertSchemaToArrow: () => convertSchemaToArrow,
|
|
52
53
|
convertTable: () => convertTable2,
|
|
@@ -80,11 +81,14 @@ __export(index_exports, {
|
|
|
80
81
|
isArrowTable: () => isArrowTable,
|
|
81
82
|
isColumnarTable: () => isColumnarTable,
|
|
82
83
|
isGeoJSONTable: () => isGeoJSONTable,
|
|
84
|
+
isNativeArrowRecordBatch: () => isNativeArrowRecordBatch,
|
|
85
|
+
isNativeArrowTable: () => isNativeArrowTable,
|
|
83
86
|
isObjectRowTable: () => isObjectRowTable,
|
|
84
87
|
isTable: () => isTable,
|
|
85
88
|
makeArrayRowIterator: () => makeArrayRowIterator,
|
|
89
|
+
makeArrowMetadataBatch: () => makeArrowMetadataBatch,
|
|
86
90
|
makeArrowRecordBatchIterator: () => makeArrowRecordBatchIterator,
|
|
87
|
-
|
|
91
|
+
makeArrowTableFromBatches: () => makeArrowTableFromBatches,
|
|
88
92
|
makeBatchFromTable: () => makeBatchFromTable,
|
|
89
93
|
makeMeshArrowTable: () => makeMeshArrowTable,
|
|
90
94
|
makeMeshAttributeMetadata: () => makeMeshAttributeMetadata,
|
|
@@ -93,12 +97,17 @@ __export(index_exports, {
|
|
|
93
97
|
makeTableBatchIterator: () => makeTableBatchIterator,
|
|
94
98
|
makeTableFromBatches: () => makeTableFromBatches,
|
|
95
99
|
makeTableFromData: () => makeTableFromData,
|
|
100
|
+
mergeArrowSchemas: () => mergeArrowSchemas,
|
|
96
101
|
queryArrowTable: () => queryArrowTable,
|
|
102
|
+
refineArrowTableBatches: () => refineArrowTableBatches,
|
|
97
103
|
selectArrowTableRows: () => selectArrowTableRows,
|
|
98
104
|
serializeArrowField: () => serializeArrowField,
|
|
99
105
|
serializeArrowMetadata: () => serializeArrowMetadata,
|
|
100
106
|
serializeArrowSchema: () => serializeArrowSchema,
|
|
101
|
-
serializeArrowType: () => serializeArrowType
|
|
107
|
+
serializeArrowType: () => serializeArrowType,
|
|
108
|
+
snapshotArrowSchema: () => snapshotArrowSchema,
|
|
109
|
+
updateArrowTableMetadata: () => updateArrowTableMetadata,
|
|
110
|
+
updateArrowTableSchema: () => updateArrowTableSchema
|
|
102
111
|
});
|
|
103
112
|
module.exports = __toCommonJS(index_exports);
|
|
104
113
|
|
|
@@ -228,11 +237,16 @@ function detectSourceShape(input, converters) {
|
|
|
228
237
|
if (fallbackShape !== null) {
|
|
229
238
|
detectedShapes.add(fallbackShape);
|
|
230
239
|
}
|
|
240
|
+
let detectionPriority = 0;
|
|
231
241
|
for (const converter of converters) {
|
|
232
242
|
const detectedShape = converter.detectInputShape?.(input);
|
|
233
|
-
if (detectedShape)
|
|
234
|
-
|
|
243
|
+
if (!detectedShape) continue;
|
|
244
|
+
const priority = converter.inputShapePriority ?? 0;
|
|
245
|
+
if (priority > detectionPriority) {
|
|
246
|
+
detectedShapes.clear();
|
|
247
|
+
detectionPriority = priority;
|
|
235
248
|
}
|
|
249
|
+
if (priority === detectionPriority) detectedShapes.add(detectedShape);
|
|
236
250
|
}
|
|
237
251
|
if (detectedShapes.size === 0) {
|
|
238
252
|
throw new Error("Could not detect source shape for conversion input");
|
|
@@ -718,130 +732,24 @@ function deserializeArrowDictionaryKeyType(keyType) {
|
|
|
718
732
|
}
|
|
719
733
|
}
|
|
720
734
|
|
|
721
|
-
// src/schema-utils/lib/
|
|
722
|
-
|
|
723
|
-
switch (table.shape) {
|
|
724
|
-
case "array-row-table":
|
|
725
|
-
case "object-row-table":
|
|
726
|
-
return deduceSchemaFromRows(table.data);
|
|
727
|
-
case "geojson-table":
|
|
728
|
-
return deduceSchemaFromGeoJSON(table.features);
|
|
729
|
-
case "columnar-table":
|
|
730
|
-
return deduceSchemaFromColumns(table.data);
|
|
731
|
-
case "arrow-table":
|
|
732
|
-
default:
|
|
733
|
-
throw new Error("Deduce schema");
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
function deduceSchemaFromColumns(columnarTable) {
|
|
737
|
-
const fields = [];
|
|
738
|
-
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
739
|
-
const field = deduceFieldFromColumn(column, columnName);
|
|
740
|
-
fields.push(field);
|
|
741
|
-
}
|
|
742
|
-
return { fields, metadata: {} };
|
|
743
|
-
}
|
|
744
|
-
function deduceSchemaFromRows(rowTable) {
|
|
745
|
-
if (!rowTable.length) {
|
|
746
|
-
throw new Error("deduce from empty table");
|
|
747
|
-
}
|
|
748
|
-
const fields = [];
|
|
749
|
-
const row0 = rowTable[0];
|
|
750
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
751
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
752
|
-
}
|
|
753
|
-
return { fields, metadata: {} };
|
|
754
|
-
}
|
|
755
|
-
function deduceSchemaFromGeoJSON(features) {
|
|
756
|
-
if (!features.length) {
|
|
757
|
-
throw new Error("deduce from empty table");
|
|
758
|
-
}
|
|
759
|
-
const fields = [];
|
|
760
|
-
const row0 = features[0].properties || {};
|
|
761
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
762
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
763
|
-
}
|
|
764
|
-
return { fields, metadata: {} };
|
|
765
|
-
}
|
|
766
|
-
function deduceFieldFromColumn(column, name) {
|
|
767
|
-
if (ArrayBuffer.isView(column)) {
|
|
768
|
-
const type = getDataTypeFromArray(column);
|
|
769
|
-
return {
|
|
770
|
-
name,
|
|
771
|
-
type: type.type || "null",
|
|
772
|
-
nullable: type.nullable
|
|
773
|
-
// metadata: {}
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
if (Array.isArray(column) && column.length > 0) {
|
|
777
|
-
const value = column[0];
|
|
778
|
-
const type = getDataTypeFromValue(value);
|
|
779
|
-
return {
|
|
780
|
-
name,
|
|
781
|
-
type,
|
|
782
|
-
nullable: true
|
|
783
|
-
// metadata: {},
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
throw new Error("empty table");
|
|
787
|
-
}
|
|
788
|
-
function deduceFieldFromValue(value, name) {
|
|
789
|
-
const type = getDataTypeFromValue(value);
|
|
790
|
-
return {
|
|
791
|
-
name,
|
|
792
|
-
type,
|
|
793
|
-
nullable: true
|
|
794
|
-
// metadata: {}
|
|
795
|
-
};
|
|
796
|
-
}
|
|
735
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
736
|
+
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
797
737
|
|
|
798
|
-
// src/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
case "array-row-table":
|
|
804
|
-
table = { shape: "array-row-table", data };
|
|
805
|
-
break;
|
|
806
|
-
case "object-row-table":
|
|
807
|
-
table = { shape: "object-row-table", data };
|
|
808
|
-
break;
|
|
809
|
-
case "columnar-table":
|
|
810
|
-
table = { shape: "columnar-table", data };
|
|
811
|
-
break;
|
|
812
|
-
case "arrow-table":
|
|
813
|
-
table = { shape: "arrow-table", data };
|
|
814
|
-
break;
|
|
815
|
-
default:
|
|
816
|
-
throw new Error("table");
|
|
817
|
-
}
|
|
818
|
-
const schema = deduceTableSchema(table);
|
|
819
|
-
return { ...table, schema };
|
|
738
|
+
// src/lib/loader-utils/native-arrow.ts
|
|
739
|
+
function isNativeArrowTable(value) {
|
|
740
|
+
return Boolean(
|
|
741
|
+
value && typeof value === "object" && "schema" in value && "batches" in value && Array.isArray(value.batches) && "numRows" in value && typeof value.numRows === "number" && "getChildAt" in value && typeof value.getChildAt === "function"
|
|
742
|
+
);
|
|
820
743
|
}
|
|
821
|
-
function
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
if (Array.isArray(data)) {
|
|
826
|
-
if (data.length === 0) {
|
|
827
|
-
throw new Error("cannot deduce type of empty table");
|
|
828
|
-
}
|
|
829
|
-
const firstRow = data[0];
|
|
830
|
-
if (Array.isArray(firstRow)) {
|
|
831
|
-
return "array-row-table";
|
|
832
|
-
}
|
|
833
|
-
if (firstRow && typeof firstRow === "object") {
|
|
834
|
-
return "object-row-table";
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
if (data && typeof data === "object") {
|
|
838
|
-
return "columnar-table";
|
|
839
|
-
}
|
|
840
|
-
throw new Error("invalid table");
|
|
744
|
+
function isNativeArrowRecordBatch(value) {
|
|
745
|
+
return Boolean(
|
|
746
|
+
value && typeof value === "object" && value[/* @__PURE__ */ Symbol.for("apache-arrow/RecordBatch")] === true
|
|
747
|
+
);
|
|
841
748
|
}
|
|
842
749
|
|
|
843
750
|
// src/schema-utils/lib/table/tables/table-accessors.ts
|
|
844
751
|
function isTable(table) {
|
|
752
|
+
if (isNativeArrowTable(table)) return true;
|
|
845
753
|
const shape = typeof table === "object" && table?.shape;
|
|
846
754
|
switch (shape) {
|
|
847
755
|
case "array-row-table":
|
|
@@ -858,6 +766,7 @@ function isTable(table) {
|
|
|
858
766
|
}
|
|
859
767
|
}
|
|
860
768
|
function getTableLength(table) {
|
|
769
|
+
if (!("shape" in table)) return table.numRows;
|
|
861
770
|
switch (table.shape) {
|
|
862
771
|
case "array-row-table":
|
|
863
772
|
case "object-row-table":
|
|
@@ -865,8 +774,7 @@ function getTableLength(table) {
|
|
|
865
774
|
case "geojson-table":
|
|
866
775
|
return table.features.length;
|
|
867
776
|
case "arrow-table":
|
|
868
|
-
|
|
869
|
-
return arrowTable.numRows;
|
|
777
|
+
return getTableLength(table.data);
|
|
870
778
|
case "columnar-table":
|
|
871
779
|
for (const column of Object.values(table.data)) {
|
|
872
780
|
return column.length || 0;
|
|
@@ -877,6 +785,7 @@ function getTableLength(table) {
|
|
|
877
785
|
}
|
|
878
786
|
}
|
|
879
787
|
function getTableNumCols(table) {
|
|
788
|
+
if (!("shape" in table)) return table.numCols;
|
|
880
789
|
if (table.schema) {
|
|
881
790
|
return table.schema.fields.length;
|
|
882
791
|
}
|
|
@@ -893,13 +802,13 @@ function getTableNumCols(table) {
|
|
|
893
802
|
case "columnar-table":
|
|
894
803
|
return Object.keys(table.data).length;
|
|
895
804
|
case "arrow-table":
|
|
896
|
-
|
|
897
|
-
return arrowTable.numCols;
|
|
805
|
+
return getTableNumCols(table.data);
|
|
898
806
|
default:
|
|
899
807
|
throw new Error("table");
|
|
900
808
|
}
|
|
901
809
|
}
|
|
902
810
|
function getTableCell(table, rowIndex, columnName) {
|
|
811
|
+
if (!("shape" in table)) return table.getChild(columnName)?.get(rowIndex);
|
|
903
812
|
switch (table.shape) {
|
|
904
813
|
case "array-row-table":
|
|
905
814
|
const columnIndex = getTableColumnIndex(table, columnName);
|
|
@@ -912,16 +821,13 @@ function getTableCell(table, rowIndex, columnName) {
|
|
|
912
821
|
const column = table.data[columnName];
|
|
913
822
|
return column[rowIndex];
|
|
914
823
|
case "arrow-table":
|
|
915
|
-
|
|
916
|
-
const arrowColumnIndex = arrowTable.schema.fields.findIndex(
|
|
917
|
-
(field) => field.name === columnName
|
|
918
|
-
);
|
|
919
|
-
return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);
|
|
824
|
+
return getTableCell(table.data, rowIndex, columnName);
|
|
920
825
|
default:
|
|
921
826
|
throw new Error("todo");
|
|
922
827
|
}
|
|
923
828
|
}
|
|
924
829
|
function getTableCellAt(table, rowIndex, columnIndex) {
|
|
830
|
+
if (!("shape" in table)) return table.getChildAt(columnIndex)?.get(rowIndex);
|
|
925
831
|
switch (table.shape) {
|
|
926
832
|
case "array-row-table":
|
|
927
833
|
return table.data[rowIndex][columnIndex];
|
|
@@ -936,13 +842,13 @@ function getTableCellAt(table, rowIndex, columnIndex) {
|
|
|
936
842
|
const column = table.data[columnName3];
|
|
937
843
|
return column[rowIndex];
|
|
938
844
|
case "arrow-table":
|
|
939
|
-
|
|
940
|
-
return arrowTable.getChildAt(columnIndex)?.get(rowIndex);
|
|
845
|
+
return getTableCellAt(table.data, rowIndex, columnIndex);
|
|
941
846
|
default:
|
|
942
847
|
throw new Error("todo");
|
|
943
848
|
}
|
|
944
849
|
}
|
|
945
850
|
function getTableRowShape(table) {
|
|
851
|
+
if (!("shape" in table)) throw new Error("Not a row table");
|
|
946
852
|
switch (table.shape) {
|
|
947
853
|
case "array-row-table":
|
|
948
854
|
case "object-row-table":
|
|
@@ -969,101 +875,101 @@ function getTableColumnName(table, columnIndex) {
|
|
|
969
875
|
return columnName;
|
|
970
876
|
}
|
|
971
877
|
function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
878
|
+
if (!("shape" in table)) {
|
|
879
|
+
const objectRow = target || {};
|
|
880
|
+
const row = table.get(rowIndex);
|
|
881
|
+
for (const field of table.schema.fields) objectRow[field.name] = row?.[field.name];
|
|
882
|
+
return objectRow;
|
|
883
|
+
}
|
|
972
884
|
switch (table.shape) {
|
|
973
885
|
case "object-row-table":
|
|
974
886
|
return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];
|
|
975
887
|
case "array-row-table":
|
|
976
888
|
if (table.schema) {
|
|
977
|
-
const
|
|
889
|
+
const objectRow = target || {};
|
|
978
890
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
979
|
-
|
|
891
|
+
objectRow[table.schema.fields[i].name] = table.data[rowIndex][i];
|
|
980
892
|
}
|
|
981
|
-
return
|
|
893
|
+
return objectRow;
|
|
982
894
|
}
|
|
983
895
|
throw new Error("no schema");
|
|
984
896
|
case "geojson-table":
|
|
985
897
|
if (table.schema) {
|
|
986
|
-
const
|
|
898
|
+
const objectRow = target || {};
|
|
987
899
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
988
|
-
|
|
900
|
+
objectRow[table.schema.fields[i].name] = table.features[rowIndex][table.schema.fields[i].name];
|
|
989
901
|
}
|
|
990
|
-
return
|
|
902
|
+
return objectRow;
|
|
991
903
|
}
|
|
992
904
|
throw new Error("no schema");
|
|
993
905
|
case "columnar-table":
|
|
994
906
|
if (table.schema) {
|
|
995
|
-
const
|
|
907
|
+
const objectRow = target || {};
|
|
996
908
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
997
|
-
|
|
909
|
+
objectRow[table.schema.fields[i].name] = table.data[table.schema.fields[i].name][rowIndex];
|
|
998
910
|
}
|
|
999
|
-
return
|
|
911
|
+
return objectRow;
|
|
1000
912
|
} else {
|
|
1001
|
-
const
|
|
913
|
+
const objectRow = target || {};
|
|
1002
914
|
for (const [name, column] of Object.entries(table.data)) {
|
|
1003
|
-
|
|
915
|
+
objectRow[name] = column[rowIndex];
|
|
1004
916
|
}
|
|
1005
|
-
return
|
|
917
|
+
return objectRow;
|
|
1006
918
|
}
|
|
1007
919
|
case "arrow-table":
|
|
1008
|
-
|
|
1009
|
-
const objectRow = target || {};
|
|
1010
|
-
const row = arrowTable.get(rowIndex);
|
|
1011
|
-
const schema = arrowTable.schema;
|
|
1012
|
-
for (let i = 0; i < schema.fields.length; i++) {
|
|
1013
|
-
objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];
|
|
1014
|
-
}
|
|
1015
|
-
return objectRow;
|
|
920
|
+
return getTableRowAsObject(table.data, rowIndex, target, copy);
|
|
1016
921
|
default:
|
|
1017
922
|
throw new Error("shape");
|
|
1018
923
|
}
|
|
1019
924
|
}
|
|
1020
925
|
function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
926
|
+
if (!("shape" in table)) {
|
|
927
|
+
const arrayRow = target || [];
|
|
928
|
+
const row = table.get(rowIndex);
|
|
929
|
+
table.schema.fields.forEach((field, columnIndex) => {
|
|
930
|
+
arrayRow[columnIndex] = row?.[field.name];
|
|
931
|
+
});
|
|
932
|
+
return arrayRow;
|
|
933
|
+
}
|
|
1021
934
|
switch (table.shape) {
|
|
1022
935
|
case "array-row-table":
|
|
1023
936
|
return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];
|
|
1024
937
|
case "object-row-table":
|
|
1025
938
|
if (table.schema) {
|
|
1026
|
-
const
|
|
939
|
+
const arrayRow = target || [];
|
|
1027
940
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
1028
|
-
|
|
941
|
+
arrayRow[i] = table.data[rowIndex][table.schema.fields[i].name];
|
|
1029
942
|
}
|
|
1030
|
-
return
|
|
943
|
+
return arrayRow;
|
|
1031
944
|
}
|
|
1032
945
|
return Object.values(table.data[rowIndex]);
|
|
1033
946
|
case "geojson-table":
|
|
1034
947
|
if (table.schema) {
|
|
1035
|
-
const
|
|
948
|
+
const arrayRow = target || [];
|
|
1036
949
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
1037
|
-
|
|
950
|
+
arrayRow[i] = table.features[rowIndex][table.schema.fields[i].name];
|
|
1038
951
|
}
|
|
1039
|
-
return
|
|
952
|
+
return arrayRow;
|
|
1040
953
|
}
|
|
1041
954
|
return Object.values(table.features[rowIndex]);
|
|
1042
955
|
case "columnar-table":
|
|
1043
956
|
if (table.schema) {
|
|
1044
|
-
const
|
|
957
|
+
const arrayRow = target || [];
|
|
1045
958
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
1046
|
-
|
|
959
|
+
arrayRow[i] = table.data[table.schema.fields[i].name][rowIndex];
|
|
1047
960
|
}
|
|
1048
|
-
return
|
|
961
|
+
return arrayRow;
|
|
1049
962
|
} else {
|
|
1050
|
-
const
|
|
963
|
+
const arrayRow = target || [];
|
|
1051
964
|
let i = 0;
|
|
1052
965
|
for (const column of Object.values(table.data)) {
|
|
1053
|
-
|
|
966
|
+
arrayRow[i] = column[rowIndex];
|
|
1054
967
|
i++;
|
|
1055
968
|
}
|
|
1056
|
-
return
|
|
969
|
+
return arrayRow;
|
|
1057
970
|
}
|
|
1058
971
|
case "arrow-table":
|
|
1059
|
-
|
|
1060
|
-
const arrayRow = target || [];
|
|
1061
|
-
const row = arrowTable.get(rowIndex);
|
|
1062
|
-
const schema = arrowTable.schema;
|
|
1063
|
-
for (let i = 0; i < schema.fields.length; i++) {
|
|
1064
|
-
arrayRow[i] = row?.[schema.fields[i].name];
|
|
1065
|
-
}
|
|
1066
|
-
return arrayRow;
|
|
972
|
+
return getTableRowAsArray(table.data, rowIndex, target, copy);
|
|
1067
973
|
default:
|
|
1068
974
|
throw new Error("shape");
|
|
1069
975
|
}
|
|
@@ -1093,57 +999,82 @@ function* makeObjectRowIterator(table, target = {}) {
|
|
|
1093
999
|
}
|
|
1094
1000
|
}
|
|
1095
1001
|
|
|
1096
|
-
// src/schema-utils/lib/
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
let objectRows;
|
|
1100
|
-
let features;
|
|
1101
|
-
let shape = null;
|
|
1102
|
-
let schema;
|
|
1103
|
-
for await (const batch of batchIterator) {
|
|
1104
|
-
shape = shape || batch.shape;
|
|
1105
|
-
schema = schema || batch.schema;
|
|
1106
|
-
switch (batch.shape) {
|
|
1107
|
-
case "array-row-table":
|
|
1108
|
-
arrayRows = arrayRows || [];
|
|
1109
|
-
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1110
|
-
const row = batch.data[rowIndex];
|
|
1111
|
-
arrayRows.push(row);
|
|
1112
|
-
}
|
|
1113
|
-
break;
|
|
1114
|
-
case "object-row-table":
|
|
1115
|
-
objectRows = objectRows || [];
|
|
1116
|
-
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1117
|
-
const row = batch.data[rowIndex];
|
|
1118
|
-
objectRows.push(row);
|
|
1119
|
-
}
|
|
1120
|
-
break;
|
|
1121
|
-
case "geojson-table":
|
|
1122
|
-
features = features || [];
|
|
1123
|
-
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1124
|
-
const row = batch.features[rowIndex];
|
|
1125
|
-
features.push(row);
|
|
1126
|
-
}
|
|
1127
|
-
break;
|
|
1128
|
-
case "columnar-table":
|
|
1129
|
-
case "arrow-table":
|
|
1130
|
-
default:
|
|
1131
|
-
throw new Error("shape");
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
if (!shape) {
|
|
1135
|
-
return null;
|
|
1136
|
-
}
|
|
1137
|
-
switch (shape) {
|
|
1002
|
+
// src/schema-utils/lib/schema/deduce-table-schema.ts
|
|
1003
|
+
function deduceTableSchema(table) {
|
|
1004
|
+
switch (table.shape) {
|
|
1138
1005
|
case "array-row-table":
|
|
1139
|
-
return { shape: "array-row-table", data: arrayRows, schema };
|
|
1140
1006
|
case "object-row-table":
|
|
1141
|
-
return
|
|
1007
|
+
return deduceSchemaFromRows(table.data);
|
|
1142
1008
|
case "geojson-table":
|
|
1143
|
-
return
|
|
1009
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
1010
|
+
case "columnar-table":
|
|
1011
|
+
return deduceSchemaFromColumns(table.data);
|
|
1012
|
+
case "arrow-table":
|
|
1144
1013
|
default:
|
|
1145
|
-
|
|
1014
|
+
throw new Error("Deduce schema");
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
1018
|
+
const fields = [];
|
|
1019
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
1020
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
1021
|
+
fields.push(field);
|
|
1022
|
+
}
|
|
1023
|
+
return { fields, metadata: {} };
|
|
1024
|
+
}
|
|
1025
|
+
function deduceSchemaFromRows(rowTable) {
|
|
1026
|
+
if (!rowTable.length) {
|
|
1027
|
+
throw new Error("deduce from empty table");
|
|
1028
|
+
}
|
|
1029
|
+
const fields = [];
|
|
1030
|
+
const row0 = rowTable[0];
|
|
1031
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
1032
|
+
const name = Array.isArray(row0) ? `column${Number(columnName) + 1}` : columnName;
|
|
1033
|
+
fields.push(deduceFieldFromValue(value, name));
|
|
1034
|
+
}
|
|
1035
|
+
return { fields, metadata: {} };
|
|
1036
|
+
}
|
|
1037
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
1038
|
+
if (!features.length) {
|
|
1039
|
+
throw new Error("deduce from empty table");
|
|
1040
|
+
}
|
|
1041
|
+
const fields = [];
|
|
1042
|
+
const row0 = features[0].properties || {};
|
|
1043
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
1044
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
1146
1045
|
}
|
|
1046
|
+
return { fields, metadata: {} };
|
|
1047
|
+
}
|
|
1048
|
+
function deduceFieldFromColumn(column, name) {
|
|
1049
|
+
if (ArrayBuffer.isView(column)) {
|
|
1050
|
+
const type = getDataTypeFromArray(column);
|
|
1051
|
+
return {
|
|
1052
|
+
name,
|
|
1053
|
+
type: type.type || "null",
|
|
1054
|
+
nullable: type.nullable
|
|
1055
|
+
// metadata: {}
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
1059
|
+
const value = column[0];
|
|
1060
|
+
const type = getDataTypeFromValue(value);
|
|
1061
|
+
return {
|
|
1062
|
+
name,
|
|
1063
|
+
type,
|
|
1064
|
+
nullable: true
|
|
1065
|
+
// metadata: {},
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
throw new Error("empty table");
|
|
1069
|
+
}
|
|
1070
|
+
function deduceFieldFromValue(value, name) {
|
|
1071
|
+
const type = getDataTypeFromValue(value);
|
|
1072
|
+
return {
|
|
1073
|
+
name,
|
|
1074
|
+
type,
|
|
1075
|
+
nullable: true
|
|
1076
|
+
// metadata: {}
|
|
1077
|
+
};
|
|
1147
1078
|
}
|
|
1148
1079
|
|
|
1149
1080
|
// src/schema-utils/lib/table/tables/table-column.ts
|
|
@@ -1152,36 +1083,112 @@ function makeColumnFromField(field, length) {
|
|
|
1152
1083
|
return new ArrayType(length);
|
|
1153
1084
|
}
|
|
1154
1085
|
|
|
1155
|
-
// src/schema-utils/lib/table/tables/convert-
|
|
1156
|
-
|
|
1086
|
+
// src/schema-utils/lib/table/tables/convert-table.ts
|
|
1087
|
+
function convertTable(table, shape) {
|
|
1088
|
+
if (shape === "arrow") return convertTableToArrow(table);
|
|
1089
|
+
if (!("shape" in table)) return convertArrowToTable(table, shape);
|
|
1090
|
+
switch (shape) {
|
|
1091
|
+
case "object-row-table":
|
|
1092
|
+
return convertToObjectRowTable(table);
|
|
1093
|
+
case "array-row-table":
|
|
1094
|
+
return convertToArrayRowTable(table);
|
|
1095
|
+
case "columnar-table":
|
|
1096
|
+
return convertToColumnarTable(table);
|
|
1097
|
+
default:
|
|
1098
|
+
throw new Error(shape);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
function convertToColumnarTable(table) {
|
|
1102
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
1103
|
+
const fields = schema.fields;
|
|
1104
|
+
if (table.shape === "columnar-table") {
|
|
1105
|
+
return { ...table, schema };
|
|
1106
|
+
}
|
|
1107
|
+
const length = getTableLength(table);
|
|
1108
|
+
const columns = {};
|
|
1109
|
+
for (const field of fields) {
|
|
1110
|
+
const column = makeColumnFromField(field, length);
|
|
1111
|
+
columns[field.name] = column;
|
|
1112
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1113
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
return {
|
|
1117
|
+
shape: "columnar-table",
|
|
1118
|
+
schema,
|
|
1119
|
+
data: columns
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
function convertToArrayRowTable(table) {
|
|
1123
|
+
if (table.shape === "array-row-table") {
|
|
1124
|
+
return table;
|
|
1125
|
+
}
|
|
1126
|
+
const length = getTableLength(table);
|
|
1127
|
+
const data = new Array(length);
|
|
1128
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1129
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
1130
|
+
}
|
|
1131
|
+
return {
|
|
1132
|
+
shape: "array-row-table",
|
|
1133
|
+
schema: table.schema,
|
|
1134
|
+
data
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function convertToObjectRowTable(table) {
|
|
1138
|
+
if (table.shape === "object-row-table") {
|
|
1139
|
+
return table;
|
|
1140
|
+
}
|
|
1141
|
+
const length = getTableLength(table);
|
|
1142
|
+
const data = new Array(length);
|
|
1143
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1144
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
1145
|
+
}
|
|
1146
|
+
return {
|
|
1147
|
+
shape: "object-row-table",
|
|
1148
|
+
schema: table.schema,
|
|
1149
|
+
data
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1157
1152
|
|
|
1158
1153
|
// src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts
|
|
1159
|
-
var
|
|
1160
|
-
function*
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1154
|
+
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
1155
|
+
function* sliceNativeArrowBatches(table, batchSize) {
|
|
1156
|
+
if (batchSize !== void 0 && (!Number.isSafeInteger(batchSize) || batchSize < 1)) {
|
|
1157
|
+
throw new RangeError("batchSize must be a positive integer");
|
|
1158
|
+
}
|
|
1159
|
+
for (const batch of table.batches) {
|
|
1160
|
+
if (batchSize === void 0 || batch.numRows <= batchSize) {
|
|
1161
|
+
yield batch;
|
|
1162
|
+
} else {
|
|
1163
|
+
for (let offset = 0; offset < batch.numRows; offset += batchSize) {
|
|
1164
|
+
yield batch.slice(offset, offset + batchSize);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1171
1167
|
}
|
|
1172
1168
|
}
|
|
1173
1169
|
function* makeArrowRecordBatchIterator(table, options) {
|
|
1170
|
+
if (!("shape" in table)) {
|
|
1171
|
+
yield* sliceNativeArrowBatches(table, options?.batchSize);
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
yield* makeWrappedTableRecordBatchIterator(table, options);
|
|
1175
|
+
}
|
|
1176
|
+
function* makeWrappedTableRecordBatchIterator(table, options) {
|
|
1177
|
+
if (table.shape === "arrow-table") {
|
|
1178
|
+
yield* sliceNativeArrowBatches(table.data, options?.batchSize);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1174
1181
|
const arrowSchema = convertSchemaToArrow(table.schema);
|
|
1175
1182
|
const length = getTableLength(table);
|
|
1176
1183
|
const numColumns = getTableNumCols(table);
|
|
1177
1184
|
const batchSize = options?.batchSize || length;
|
|
1178
1185
|
const builders = arrowSchema?.fields.map(
|
|
1179
|
-
(arrowField) =>
|
|
1186
|
+
(arrowField) => arrow2.makeBuilder({
|
|
1180
1187
|
type: arrowField.type,
|
|
1181
1188
|
nullValues: [null, void 0]
|
|
1182
1189
|
})
|
|
1183
1190
|
);
|
|
1184
|
-
const structField = new
|
|
1191
|
+
const structField = new arrow2.Struct(arrowSchema.fields);
|
|
1185
1192
|
let batchLength = 0;
|
|
1186
1193
|
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1187
1194
|
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
@@ -1192,15 +1199,15 @@ function* makeArrowRecordBatchIterator(table, options) {
|
|
|
1192
1199
|
batchLength++;
|
|
1193
1200
|
if (batchLength >= batchSize) {
|
|
1194
1201
|
const datas = builders.map((builder) => builder.flush());
|
|
1195
|
-
const structData = new
|
|
1196
|
-
yield new
|
|
1202
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1203
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
1197
1204
|
batchLength = 0;
|
|
1198
1205
|
}
|
|
1199
1206
|
}
|
|
1200
1207
|
if (batchLength > 0) {
|
|
1201
1208
|
const datas = builders.map((builder) => builder.flush());
|
|
1202
|
-
const structData = new
|
|
1203
|
-
yield new
|
|
1209
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1210
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
1204
1211
|
batchLength = 0;
|
|
1205
1212
|
}
|
|
1206
1213
|
builders.map((builder) => builder.finish());
|
|
@@ -1208,6 +1215,7 @@ function* makeArrowRecordBatchIterator(table, options) {
|
|
|
1208
1215
|
|
|
1209
1216
|
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
1210
1217
|
function convertTableToArrow(table, options) {
|
|
1218
|
+
if (!("shape" in table)) return table;
|
|
1211
1219
|
switch (table.shape) {
|
|
1212
1220
|
case "arrow-table":
|
|
1213
1221
|
return table.data;
|
|
@@ -1216,14 +1224,16 @@ function convertTableToArrow(table, options) {
|
|
|
1216
1224
|
// return convertColumnarTableToArrow(table, options);
|
|
1217
1225
|
// fall through
|
|
1218
1226
|
default:
|
|
1219
|
-
const
|
|
1220
|
-
return new
|
|
1227
|
+
const schema = table.schema ?? deduceTableSchema(table);
|
|
1228
|
+
return new arrow3.Table(convertSchemaToArrow(schema), [
|
|
1229
|
+
...makeWrappedTableRecordBatchIterator({ ...table, schema }, options)
|
|
1230
|
+
]);
|
|
1221
1231
|
}
|
|
1222
1232
|
}
|
|
1223
1233
|
function convertArrowToTable(arrowTable, shape) {
|
|
1224
1234
|
switch (shape) {
|
|
1225
|
-
case "arrow
|
|
1226
|
-
return
|
|
1235
|
+
case "arrow":
|
|
1236
|
+
return arrowTable;
|
|
1227
1237
|
case "array-row-table":
|
|
1228
1238
|
return convertArrowToArrayRowTable(arrowTable);
|
|
1229
1239
|
case "object-row-table":
|
|
@@ -1236,13 +1246,6 @@ function convertArrowToTable(arrowTable, shape) {
|
|
|
1236
1246
|
throw new Error(shape);
|
|
1237
1247
|
}
|
|
1238
1248
|
}
|
|
1239
|
-
function convertArrowToArrowTable(arrowTable) {
|
|
1240
|
-
return {
|
|
1241
|
-
shape: "arrow-table",
|
|
1242
|
-
schema: convertArrowToSchema(arrowTable.schema),
|
|
1243
|
-
data: arrowTable
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
1249
|
function convertArrowToArrayRowTable(arrowTable) {
|
|
1247
1250
|
const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
1248
1251
|
return convertTable(columnarTable, "array-row-table");
|
|
@@ -1280,80 +1283,236 @@ function convertArrowToGeoJSONTable(arrowTable) {
|
|
|
1280
1283
|
};
|
|
1281
1284
|
}
|
|
1282
1285
|
|
|
1283
|
-
// src/schema-utils/lib/table/tables/convert-table.ts
|
|
1284
|
-
function
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1286
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts
|
|
1287
|
+
function convertArrowTable(table, shape) {
|
|
1288
|
+
const converted = convertArrowToTable(table.data, shape);
|
|
1289
|
+
return {
|
|
1290
|
+
...table,
|
|
1291
|
+
...converted,
|
|
1292
|
+
schema: table.schema ?? converted.schema
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
function convertArrowTableBatch(batch, shape) {
|
|
1296
|
+
return convertArrowTable(batch, shape);
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// src/schema-utils/lib/table/tables/make-table.ts
|
|
1300
|
+
function makeTableFromData(data) {
|
|
1301
|
+
if (isNativeArrowTable(data)) return data;
|
|
1302
|
+
let table;
|
|
1303
|
+
switch (getTableShapeFromData(data)) {
|
|
1288
1304
|
case "array-row-table":
|
|
1289
|
-
|
|
1305
|
+
table = { shape: "array-row-table", data };
|
|
1306
|
+
break;
|
|
1307
|
+
case "object-row-table":
|
|
1308
|
+
table = { shape: "object-row-table", data };
|
|
1309
|
+
break;
|
|
1290
1310
|
case "columnar-table":
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
return convertToArrowTable(table);
|
|
1311
|
+
table = { shape: "columnar-table", data };
|
|
1312
|
+
break;
|
|
1294
1313
|
default:
|
|
1295
|
-
throw new Error(
|
|
1314
|
+
throw new Error("table");
|
|
1296
1315
|
}
|
|
1316
|
+
const schema = deduceTableSchema(table);
|
|
1317
|
+
return { ...table, schema };
|
|
1297
1318
|
}
|
|
1298
|
-
function
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1310
|
-
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
1319
|
+
function getTableShapeFromData(data) {
|
|
1320
|
+
if (Array.isArray(data)) {
|
|
1321
|
+
if (data.length === 0) {
|
|
1322
|
+
throw new Error("cannot deduce type of empty table");
|
|
1323
|
+
}
|
|
1324
|
+
const firstRow = data[0];
|
|
1325
|
+
if (Array.isArray(firstRow)) {
|
|
1326
|
+
return "array-row-table";
|
|
1327
|
+
}
|
|
1328
|
+
if (firstRow && typeof firstRow === "object") {
|
|
1329
|
+
return "object-row-table";
|
|
1311
1330
|
}
|
|
1312
1331
|
}
|
|
1332
|
+
if (data && typeof data === "object") {
|
|
1333
|
+
return "columnar-table";
|
|
1334
|
+
}
|
|
1335
|
+
throw new Error("invalid table");
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// src/schema-utils/lib/table/batches/make-table-from-batches.ts
|
|
1339
|
+
var arrow5 = __toESM(require("apache-arrow"), 1);
|
|
1340
|
+
|
|
1341
|
+
// src/schema-utils/lib/arrow/arrow-metadata.ts
|
|
1342
|
+
var arrow4 = __toESM(require("apache-arrow"), 1);
|
|
1343
|
+
function snapshotArrowSchema(schema) {
|
|
1344
|
+
return deserializeArrowSchema(serializeArrowSchema(schema));
|
|
1345
|
+
}
|
|
1346
|
+
function mergeArrowSchemas(previous, next) {
|
|
1347
|
+
if (!previous) return snapshotArrowSchema(next);
|
|
1348
|
+
new arrow4.Table(previous, [new arrow4.RecordBatch(next, void 0)]);
|
|
1349
|
+
const earlier = serializeArrowSchema(previous);
|
|
1350
|
+
const later = serializeArrowSchema(next);
|
|
1351
|
+
return deserializeArrowSchema({
|
|
1352
|
+
...later,
|
|
1353
|
+
fields: later.fields.map((field, index) => mergeFieldMetadata(earlier.fields[index], field)),
|
|
1354
|
+
metadata: { ...earlier.metadata, ...later.metadata }
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
function mergeFieldMetadata(previous, next) {
|
|
1313
1358
|
return {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1359
|
+
...next,
|
|
1360
|
+
type: mergeTypeMetadata(previous.type, next.type),
|
|
1361
|
+
metadata: { ...previous.metadata, ...next.metadata }
|
|
1317
1362
|
};
|
|
1318
1363
|
}
|
|
1319
|
-
function
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1364
|
+
function mergeTypeMetadata(previous, next) {
|
|
1365
|
+
if (typeof previous !== "object" || typeof next !== "object") return next;
|
|
1366
|
+
if ("children" in previous && "children" in next) {
|
|
1367
|
+
const previousChildren = previous.children;
|
|
1368
|
+
return {
|
|
1369
|
+
...next,
|
|
1370
|
+
children: next.children.map(
|
|
1371
|
+
(field, index) => mergeFieldMetadata(previousChildren[index], field)
|
|
1372
|
+
)
|
|
1373
|
+
};
|
|
1322
1374
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1326
|
-
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
1375
|
+
if (previous.type === "dictionary" && next.type === "dictionary") {
|
|
1376
|
+
return { ...next, dictionary: mergeTypeMetadata(previous.dictionary, next.dictionary) };
|
|
1327
1377
|
}
|
|
1328
|
-
return
|
|
1329
|
-
shape: "array-row-table",
|
|
1330
|
-
schema: table.schema,
|
|
1331
|
-
data
|
|
1332
|
-
};
|
|
1378
|
+
return next;
|
|
1333
1379
|
}
|
|
1334
|
-
function
|
|
1335
|
-
|
|
1336
|
-
|
|
1380
|
+
function updateArrowTableSchema(table, schema) {
|
|
1381
|
+
const snapshot = snapshotArrowSchema(schema);
|
|
1382
|
+
const batches = table.batches.map(
|
|
1383
|
+
(batch) => new arrow4.RecordBatch(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
|
|
1384
|
+
);
|
|
1385
|
+
return new arrow4.Table(
|
|
1386
|
+
snapshot,
|
|
1387
|
+
batches.length ? batches : [new arrow4.RecordBatch(snapshotArrowSchema(snapshot), void 0)]
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
function updateArrowTableMetadata(table, metadata) {
|
|
1391
|
+
const schema = new arrow4.Schema(
|
|
1392
|
+
table.data.schema.fields,
|
|
1393
|
+
new Map([...table.data.schema.metadata, ...Object.entries(metadata)])
|
|
1394
|
+
);
|
|
1395
|
+
const data = updateArrowTableSchema(table.data, schema);
|
|
1396
|
+
return { ...table, data, schema: serializeArrowSchema(data.schema) };
|
|
1397
|
+
}
|
|
1398
|
+
function makeArrowMetadataBatch(schema) {
|
|
1399
|
+
return new arrow4.RecordBatch(snapshotArrowSchema(schema), void 0);
|
|
1400
|
+
}
|
|
1401
|
+
async function makeArrowTableFromBatches(batches) {
|
|
1402
|
+
let schema;
|
|
1403
|
+
const collected = [];
|
|
1404
|
+
for await (const batch of batches) {
|
|
1405
|
+
schema = mergeArrowSchemas(schema, batch.schema);
|
|
1406
|
+
collected.push(
|
|
1407
|
+
new arrow4.RecordBatch(snapshotArrowSchema(batch.schema), batch.data, new Map(batch.metadata))
|
|
1408
|
+
);
|
|
1337
1409
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1410
|
+
return schema ? new arrow4.Table(schema, collected) : null;
|
|
1411
|
+
}
|
|
1412
|
+
async function* refineArrowTableBatches(batches) {
|
|
1413
|
+
let schema;
|
|
1414
|
+
let bounds;
|
|
1415
|
+
for await (const batch of batches) {
|
|
1416
|
+
const table = batch;
|
|
1417
|
+
if (table?.shape !== "arrow-table") {
|
|
1418
|
+
yield batch;
|
|
1419
|
+
continue;
|
|
1420
|
+
}
|
|
1421
|
+
const localBounds = table.data.schema.metadata.get("boundingBox");
|
|
1422
|
+
const nextSchema = snapshotArrowSchema(table.data.schema);
|
|
1423
|
+
if (localBounds) {
|
|
1424
|
+
const nextBounds = JSON.parse(localBounds);
|
|
1425
|
+
bounds = bounds ? [
|
|
1426
|
+
nextBounds[0].map((value, index) => Math.min(bounds[0][index], value)),
|
|
1427
|
+
nextBounds[1].map((value, index) => Math.max(bounds[1][index], value))
|
|
1428
|
+
] : nextBounds;
|
|
1429
|
+
nextSchema.metadata.set("boundingBox", JSON.stringify(bounds));
|
|
1430
|
+
}
|
|
1431
|
+
schema = mergeArrowSchemas(schema, nextSchema);
|
|
1432
|
+
const data = updateArrowTableSchema(table.data, schema);
|
|
1433
|
+
if (localBounds) {
|
|
1434
|
+
for (const recordBatch of data.batches) recordBatch.metadata.set("boundingBox", localBounds);
|
|
1435
|
+
}
|
|
1436
|
+
yield { ...table, data, schema: serializeArrowSchema(data.schema) };
|
|
1342
1437
|
}
|
|
1343
|
-
return {
|
|
1344
|
-
shape: "object-row-table",
|
|
1345
|
-
schema: table.schema,
|
|
1346
|
-
data
|
|
1347
|
-
};
|
|
1348
1438
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1439
|
+
|
|
1440
|
+
// src/schema-utils/lib/table/batches/make-table-from-batches.ts
|
|
1441
|
+
async function makeTableFromBatches(batchIterator) {
|
|
1442
|
+
let arrayRows;
|
|
1443
|
+
let objectRows;
|
|
1444
|
+
let features;
|
|
1445
|
+
let shape = null;
|
|
1446
|
+
let schema;
|
|
1447
|
+
const arrowBatches = [];
|
|
1448
|
+
let arrowSchema;
|
|
1449
|
+
for await (const batch of batchIterator) {
|
|
1450
|
+
const batchShape = isNativeArrowRecordBatch(batch) ? "arrow" : batch.shape;
|
|
1451
|
+
shape ??= batchShape;
|
|
1452
|
+
if (shape !== batchShape) throw new Error("Batches must have the same shape");
|
|
1453
|
+
if (isNativeArrowRecordBatch(batch)) {
|
|
1454
|
+
arrowBatches.push(batch);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
schema = schema || batch.schema;
|
|
1458
|
+
switch (batch.shape) {
|
|
1459
|
+
case "array-row-table":
|
|
1460
|
+
arrayRows = arrayRows || [];
|
|
1461
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1462
|
+
const row = batch.data[rowIndex];
|
|
1463
|
+
arrayRows.push(row);
|
|
1464
|
+
}
|
|
1465
|
+
break;
|
|
1466
|
+
case "object-row-table":
|
|
1467
|
+
objectRows = objectRows || [];
|
|
1468
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1469
|
+
const row = batch.data[rowIndex];
|
|
1470
|
+
objectRows.push(row);
|
|
1471
|
+
}
|
|
1472
|
+
break;
|
|
1473
|
+
case "geojson-table":
|
|
1474
|
+
features = features || [];
|
|
1475
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1476
|
+
const row = batch.features[rowIndex];
|
|
1477
|
+
features.push(row);
|
|
1478
|
+
}
|
|
1479
|
+
break;
|
|
1480
|
+
case "arrow-table": {
|
|
1481
|
+
for (const recordBatch of batch.data.batches) {
|
|
1482
|
+
arrowSchema = mergeArrowSchemas(arrowSchema, recordBatch.schema);
|
|
1483
|
+
arrowBatches.push(recordBatch);
|
|
1484
|
+
}
|
|
1485
|
+
arrowSchema = mergeArrowSchemas(arrowSchema, batch.data.schema);
|
|
1486
|
+
if (batch.schema)
|
|
1487
|
+
arrowSchema = mergeArrowSchemas(arrowSchema, convertSchemaToArrow(batch.schema));
|
|
1488
|
+
if (batch.data.batches.length === 0) arrowBatches.push(makeArrowMetadataBatch(arrowSchema));
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
case "columnar-table":
|
|
1492
|
+
default:
|
|
1493
|
+
throw new Error("shape");
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
if (!shape) {
|
|
1497
|
+
return null;
|
|
1498
|
+
}
|
|
1499
|
+
switch (shape) {
|
|
1500
|
+
case "arrow":
|
|
1501
|
+
return makeArrowTableFromBatches(arrowBatches);
|
|
1502
|
+
case "arrow-table": {
|
|
1503
|
+
const collected = await makeArrowTableFromBatches(arrowBatches);
|
|
1504
|
+
const data = collected && new arrow5.Table(arrowSchema || collected.schema, collected.batches);
|
|
1505
|
+
return data ? { shape: "arrow-table", data, schema: serializeArrowSchema(data.schema) } : null;
|
|
1506
|
+
}
|
|
1507
|
+
case "array-row-table":
|
|
1508
|
+
return { shape: "array-row-table", data: arrayRows, schema };
|
|
1509
|
+
case "object-row-table":
|
|
1510
|
+
return { shape: "object-row-table", data: objectRows, schema };
|
|
1511
|
+
case "geojson-table":
|
|
1512
|
+
return { shape: "geojson-table", type: "FeatureCollection", features, schema };
|
|
1513
|
+
default:
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1357
1516
|
}
|
|
1358
1517
|
|
|
1359
1518
|
// src/schema-utils/lib/table/tables/table-converter/convert-tables.ts
|
|
@@ -1365,8 +1524,8 @@ function convertTables(table, shape) {
|
|
|
1365
1524
|
return convertTable(table, "array-row-table");
|
|
1366
1525
|
case "columnar-table":
|
|
1367
1526
|
return convertTable(table, "columnar-table");
|
|
1368
|
-
case "arrow
|
|
1369
|
-
return convertTable(table, "arrow
|
|
1527
|
+
case "arrow":
|
|
1528
|
+
return convertTable(table, "arrow");
|
|
1370
1529
|
default:
|
|
1371
1530
|
throw new Error(`Unsupported table conversion target: ${shape}`);
|
|
1372
1531
|
}
|
|
@@ -1375,12 +1534,13 @@ function convertTables(table, shape) {
|
|
|
1375
1534
|
// src/schema-utils/lib/table/tables/table-converter/table-converter.ts
|
|
1376
1535
|
var TableConverter = {
|
|
1377
1536
|
id: "table",
|
|
1378
|
-
from: ["object-row-table", "array-row-table", "columnar-table", "arrow-table"],
|
|
1379
|
-
to: ["object-row-table", "array-row-table", "columnar-table", "arrow
|
|
1537
|
+
from: ["object-row-table", "array-row-table", "columnar-table", "arrow-table", "arrow"],
|
|
1538
|
+
to: ["object-row-table", "array-row-table", "columnar-table", "arrow"],
|
|
1380
1539
|
canConvert(sourceShape, targetShape) {
|
|
1381
1540
|
return sourceShape !== targetShape;
|
|
1382
1541
|
},
|
|
1383
1542
|
detectInputShape(input) {
|
|
1543
|
+
if (isNativeArrowTable(input)) return "arrow";
|
|
1384
1544
|
if (typeof input === "object" && input !== null && "shape" in input && typeof input.shape === "string" && ["object-row-table", "array-row-table", "columnar-table", "arrow-table"].includes(input.shape)) {
|
|
1385
1545
|
return input.shape;
|
|
1386
1546
|
}
|
|
@@ -1394,8 +1554,8 @@ var TableConverter = {
|
|
|
1394
1554
|
return convertTables(input, "array-row-table");
|
|
1395
1555
|
case "columnar-table":
|
|
1396
1556
|
return convertTables(input, "columnar-table");
|
|
1397
|
-
case "arrow
|
|
1398
|
-
return convertTables(input, "arrow
|
|
1557
|
+
case "arrow":
|
|
1558
|
+
return convertTables(input, "arrow");
|
|
1399
1559
|
default:
|
|
1400
1560
|
throw new Error(`Unsupported table conversion target: ${targetShape}`);
|
|
1401
1561
|
}
|
|
@@ -1415,7 +1575,7 @@ function convertToObjectRow(arrayRow, headers) {
|
|
|
1415
1575
|
}
|
|
1416
1576
|
} else {
|
|
1417
1577
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
1418
|
-
const columnName = `column
|
|
1578
|
+
const columnName = `column${i + 1}`;
|
|
1419
1579
|
objectRow[columnName] = arrayRow[i];
|
|
1420
1580
|
}
|
|
1421
1581
|
}
|
|
@@ -1437,7 +1597,7 @@ function convertToArrayRow(objectRow, headers) {
|
|
|
1437
1597
|
function inferHeadersFromArrayRow(arrayRow) {
|
|
1438
1598
|
const headers = [];
|
|
1439
1599
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
1440
|
-
const columnName = `column
|
|
1600
|
+
const columnName = `column${i + 1}`;
|
|
1441
1601
|
headers.push(columnName);
|
|
1442
1602
|
}
|
|
1443
1603
|
return headers;
|
|
@@ -1472,9 +1632,9 @@ function makeBatchFromTable(table) {
|
|
|
1472
1632
|
}
|
|
1473
1633
|
|
|
1474
1634
|
// src/schema-utils/lib/table/query-arrow-table.ts
|
|
1475
|
-
var
|
|
1635
|
+
var arrow6 = __toESM(require("apache-arrow"), 1);
|
|
1476
1636
|
function queryArrowTable(table, options = {}, filterRows) {
|
|
1477
|
-
const availableColumns = table.
|
|
1637
|
+
const availableColumns = table.schema.fields.map((field) => field.name);
|
|
1478
1638
|
const selectedColumns = options.columns ? [...options.columns] : availableColumns;
|
|
1479
1639
|
for (const columnName of selectedColumns) {
|
|
1480
1640
|
if (!availableColumns.includes(columnName)) {
|
|
@@ -1485,22 +1645,15 @@ function queryArrowTable(table, options = {}, filterRows) {
|
|
|
1485
1645
|
if (options.predicate !== void 0) {
|
|
1486
1646
|
if (!filterRows) throw new Error("Arrow table query requires a predicate evaluator.");
|
|
1487
1647
|
const columns = Object.fromEntries(
|
|
1488
|
-
availableColumns.map((name) => [name, [...table.
|
|
1648
|
+
availableColumns.map((name) => [name, [...table.getChild(name) || []]])
|
|
1489
1649
|
);
|
|
1490
|
-
rowIndices = filterRows(options.predicate, columns, table.
|
|
1650
|
+
rowIndices = filterRows(options.predicate, columns, table.numRows);
|
|
1491
1651
|
}
|
|
1492
1652
|
const limitedRowIndices = rowIndices ? rowIndices.slice(0, options.limit ?? Number.POSITIVE_INFINITY) : void 0;
|
|
1493
|
-
|
|
1494
|
-
const schema = table.schema ? {
|
|
1495
|
-
...table.schema,
|
|
1496
|
-
fields: selectedColumns.flatMap(
|
|
1497
|
-
(columnName) => table.schema?.fields.filter((field) => field.name === columnName) || []
|
|
1498
|
-
)
|
|
1499
|
-
} : void 0;
|
|
1500
|
-
return schema ? { shape: "arrow-table", schema, data } : { shape: "arrow-table", data };
|
|
1653
|
+
return limitedRowIndices ? createArrowTableFromRowIndices(table, selectedColumns, limitedRowIndices) : table.select(selectedColumns).slice(0, options.limit ?? Number.POSITIVE_INFINITY);
|
|
1501
1654
|
}
|
|
1502
1655
|
function selectArrowTableRows(table, rowIndices, columns, limit) {
|
|
1503
|
-
const availableColumns = table.
|
|
1656
|
+
const availableColumns = table.schema.fields.map((field) => field.name);
|
|
1504
1657
|
const selectedColumns = columns ? [...columns] : availableColumns;
|
|
1505
1658
|
for (const columnName of selectedColumns) {
|
|
1506
1659
|
if (!availableColumns.includes(columnName)) {
|
|
@@ -1508,27 +1661,21 @@ function selectArrowTableRows(table, rowIndices, columns, limit) {
|
|
|
1508
1661
|
}
|
|
1509
1662
|
}
|
|
1510
1663
|
const limitedRowIndices = rowIndices.slice(0, limit ?? Number.POSITIVE_INFINITY);
|
|
1511
|
-
|
|
1512
|
-
const schema = table.schema ? {
|
|
1513
|
-
...table.schema,
|
|
1514
|
-
fields: selectedColumns.flatMap(
|
|
1515
|
-
(columnName) => table.schema?.fields.filter((field) => field.name === columnName) || []
|
|
1516
|
-
)
|
|
1517
|
-
} : void 0;
|
|
1518
|
-
return schema ? { shape: "arrow-table", schema, data } : { shape: "arrow-table", data };
|
|
1664
|
+
return createArrowTableFromRowIndices(table, selectedColumns, limitedRowIndices);
|
|
1519
1665
|
}
|
|
1520
1666
|
function createArrowTableFromRowIndices(sourceData, selectedColumns, rowIndices) {
|
|
1521
|
-
const schema = new
|
|
1667
|
+
const schema = new arrow6.Schema(
|
|
1522
1668
|
selectedColumns.map(
|
|
1523
1669
|
(columnName) => sourceData.schema.fields.find((field) => field.name === columnName)
|
|
1524
|
-
)
|
|
1670
|
+
),
|
|
1671
|
+
sourceData.schema.metadata
|
|
1525
1672
|
);
|
|
1526
1673
|
const vectors = Object.fromEntries(
|
|
1527
1674
|
selectedColumns.map((columnName) => {
|
|
1528
1675
|
const sourceVector = sourceData.getChild(columnName);
|
|
1529
1676
|
return [
|
|
1530
1677
|
columnName,
|
|
1531
|
-
|
|
1678
|
+
arrow6.vectorFromArray(
|
|
1532
1679
|
rowIndices.map((rowIndex) => sourceVector?.get(rowIndex)),
|
|
1533
1680
|
sourceVector?.type
|
|
1534
1681
|
)
|
|
@@ -1536,19 +1683,23 @@ function createArrowTableFromRowIndices(sourceData, selectedColumns, rowIndices)
|
|
|
1536
1683
|
})
|
|
1537
1684
|
);
|
|
1538
1685
|
const children = selectedColumns.map((columnName) => vectors[columnName].data[0]);
|
|
1539
|
-
const data = new
|
|
1540
|
-
new
|
|
1686
|
+
const data = new arrow6.Data(
|
|
1687
|
+
new arrow6.Struct(schema.fields),
|
|
1541
1688
|
0,
|
|
1542
1689
|
rowIndices.length,
|
|
1543
1690
|
0,
|
|
1544
1691
|
void 0,
|
|
1545
1692
|
children
|
|
1546
1693
|
);
|
|
1547
|
-
return new
|
|
1694
|
+
return new arrow6.Table(schema, new arrow6.RecordBatch(schema, data));
|
|
1548
1695
|
}
|
|
1549
1696
|
|
|
1550
1697
|
// src/schema-utils/lib/table/batches/convert-batches.ts
|
|
1551
1698
|
function convertBatch(batch, shape) {
|
|
1699
|
+
if (isNativeArrowRecordBatch(batch)) {
|
|
1700
|
+
if (shape === "arrow") return batch;
|
|
1701
|
+
throw new Error("Convert a native RecordBatch as a table to select a row or column layout");
|
|
1702
|
+
}
|
|
1552
1703
|
switch (shape) {
|
|
1553
1704
|
case "object-row-table":
|
|
1554
1705
|
return { ...batch, ...convertTable(batch, "object-row-table") };
|
|
@@ -1556,14 +1707,24 @@ function convertBatch(batch, shape) {
|
|
|
1556
1707
|
return { ...batch, ...convertTable(batch, "array-row-table") };
|
|
1557
1708
|
case "columnar-table":
|
|
1558
1709
|
return { ...batch, ...convertTable(batch, "columnar-table") };
|
|
1559
|
-
case "arrow
|
|
1560
|
-
|
|
1710
|
+
case "arrow": {
|
|
1711
|
+
const table = convertTable(batch, "arrow");
|
|
1712
|
+
if (table.batches.length > 1) {
|
|
1713
|
+
throw new Error("Use convertBatches to expand multiple Arrow record batches");
|
|
1714
|
+
}
|
|
1715
|
+
return table.batches[0] ?? makeArrowMetadataBatch(table.schema);
|
|
1716
|
+
}
|
|
1561
1717
|
default:
|
|
1562
1718
|
throw new Error(shape);
|
|
1563
1719
|
}
|
|
1564
1720
|
}
|
|
1565
1721
|
async function* convertBatches(batches, shape) {
|
|
1566
1722
|
for await (const batch of batches) {
|
|
1723
|
+
if (isNativeArrowRecordBatch(batch)) {
|
|
1724
|
+
if (shape !== "arrow") throw new Error("Expected a loaders.gl table batch");
|
|
1725
|
+
yield batch;
|
|
1726
|
+
continue;
|
|
1727
|
+
}
|
|
1567
1728
|
switch (shape) {
|
|
1568
1729
|
case "object-row-table":
|
|
1569
1730
|
yield convertBatch(batch, "object-row-table");
|
|
@@ -1574,9 +1735,12 @@ async function* convertBatches(batches, shape) {
|
|
|
1574
1735
|
case "columnar-table":
|
|
1575
1736
|
yield convertBatch(batch, "columnar-table");
|
|
1576
1737
|
break;
|
|
1577
|
-
case "arrow
|
|
1578
|
-
|
|
1738
|
+
case "arrow": {
|
|
1739
|
+
const table = convertTable(batch, "arrow");
|
|
1740
|
+
if (table.batches.length) yield* table.batches;
|
|
1741
|
+
else yield makeArrowMetadataBatch(table.schema);
|
|
1579
1742
|
break;
|
|
1743
|
+
}
|
|
1580
1744
|
default:
|
|
1581
1745
|
throw new Error(shape);
|
|
1582
1746
|
}
|
|
@@ -1600,339 +1764,106 @@ function isArrowTable(table) {
|
|
|
1600
1764
|
return table.shape === "arrow-table";
|
|
1601
1765
|
}
|
|
1602
1766
|
|
|
1603
|
-
// src/schema-utils/lib/table/batch-builder/
|
|
1604
|
-
var
|
|
1605
|
-
var BaseTableBatchAggregator = class {
|
|
1606
|
-
schema;
|
|
1607
|
-
options;
|
|
1608
|
-
shape;
|
|
1609
|
-
length = 0;
|
|
1610
|
-
rows = null;
|
|
1611
|
-
cursor = 0;
|
|
1612
|
-
_headers = [];
|
|
1613
|
-
constructor(schema, options) {
|
|
1614
|
-
this.options = options;
|
|
1615
|
-
this.schema = schema;
|
|
1616
|
-
if (!Array.isArray(schema)) {
|
|
1617
|
-
this._headers = [];
|
|
1618
|
-
for (const key in schema) {
|
|
1619
|
-
this._headers[schema[key].index] = schema[key].name;
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
rowCount() {
|
|
1624
|
-
return this.length;
|
|
1625
|
-
}
|
|
1626
|
-
addArrayRow(row, cursor) {
|
|
1627
|
-
if (Number.isFinite(cursor)) {
|
|
1628
|
-
this.cursor = cursor;
|
|
1629
|
-
}
|
|
1630
|
-
this.shape = "array-row-table";
|
|
1631
|
-
this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
|
|
1632
|
-
this.rows[this.length] = row;
|
|
1633
|
-
this.length++;
|
|
1634
|
-
}
|
|
1635
|
-
addObjectRow(row, cursor) {
|
|
1636
|
-
if (Number.isFinite(cursor)) {
|
|
1637
|
-
this.cursor = cursor;
|
|
1638
|
-
}
|
|
1639
|
-
this.shape = "object-row-table";
|
|
1640
|
-
this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
|
|
1641
|
-
this.rows[this.length] = row;
|
|
1642
|
-
this.length++;
|
|
1643
|
-
}
|
|
1644
|
-
getBatch() {
|
|
1645
|
-
let rows = this.rows;
|
|
1646
|
-
if (!rows) {
|
|
1647
|
-
return null;
|
|
1648
|
-
}
|
|
1649
|
-
rows = rows.slice(0, this.length);
|
|
1650
|
-
this.rows = null;
|
|
1651
|
-
const batch = {
|
|
1652
|
-
shape: this.shape || "array-row-table",
|
|
1653
|
-
batchType: "data",
|
|
1654
|
-
data: rows,
|
|
1655
|
-
length: this.length,
|
|
1656
|
-
schema: this.schema,
|
|
1657
|
-
cursor: this.cursor
|
|
1658
|
-
};
|
|
1659
|
-
return batch;
|
|
1660
|
-
}
|
|
1661
|
-
};
|
|
1662
|
-
|
|
1663
|
-
// src/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.ts
|
|
1664
|
-
var DEFAULT_ROW_COUNT2 = 100;
|
|
1665
|
-
var RowTableBatchAggregator = class {
|
|
1666
|
-
schema;
|
|
1667
|
-
options;
|
|
1668
|
-
length = 0;
|
|
1669
|
-
objectRows = null;
|
|
1670
|
-
arrayRows = null;
|
|
1671
|
-
cursor = 0;
|
|
1672
|
-
_headers = null;
|
|
1673
|
-
constructor(schema, options) {
|
|
1674
|
-
this.options = options;
|
|
1675
|
-
this.schema = schema;
|
|
1676
|
-
if (schema) {
|
|
1677
|
-
this._headers = [];
|
|
1678
|
-
for (let i = 0; i < schema.fields.length; i++) {
|
|
1679
|
-
this._headers[i] = schema.fields[i].name;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
rowCount() {
|
|
1684
|
-
return this.length;
|
|
1685
|
-
}
|
|
1686
|
-
addArrayRow(row, cursor) {
|
|
1687
|
-
if (Number.isFinite(cursor)) {
|
|
1688
|
-
this.cursor = cursor;
|
|
1689
|
-
}
|
|
1690
|
-
this._headers ||= inferHeadersFromArrayRow(row);
|
|
1691
|
-
switch (this.options.shape) {
|
|
1692
|
-
case "object-row-table":
|
|
1693
|
-
const rowObject = convertToObjectRow(row, this._headers);
|
|
1694
|
-
this.addObjectRow(rowObject, cursor);
|
|
1695
|
-
break;
|
|
1696
|
-
case "array-row-table":
|
|
1697
|
-
this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT2);
|
|
1698
|
-
this.arrayRows[this.length] = row;
|
|
1699
|
-
this.length++;
|
|
1700
|
-
break;
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
addObjectRow(row, cursor) {
|
|
1704
|
-
if (Number.isFinite(cursor)) {
|
|
1705
|
-
this.cursor = cursor;
|
|
1706
|
-
}
|
|
1707
|
-
this._headers ||= inferHeadersFromObjectRow(row);
|
|
1708
|
-
switch (this.options.shape) {
|
|
1709
|
-
case "array-row-table":
|
|
1710
|
-
const rowArray = convertToArrayRow(row, this._headers);
|
|
1711
|
-
this.addArrayRow(rowArray, cursor);
|
|
1712
|
-
break;
|
|
1713
|
-
case "object-row-table":
|
|
1714
|
-
this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT2);
|
|
1715
|
-
this.objectRows[this.length] = row;
|
|
1716
|
-
this.length++;
|
|
1717
|
-
break;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
getBatch() {
|
|
1721
|
-
let rows = this.arrayRows || this.objectRows;
|
|
1722
|
-
if (!rows) {
|
|
1723
|
-
return null;
|
|
1724
|
-
}
|
|
1725
|
-
rows = rows.slice(0, this.length);
|
|
1726
|
-
this.arrayRows = null;
|
|
1727
|
-
this.objectRows = null;
|
|
1728
|
-
return {
|
|
1729
|
-
shape: this.options.shape,
|
|
1730
|
-
batchType: "data",
|
|
1731
|
-
data: rows,
|
|
1732
|
-
length: this.length,
|
|
1733
|
-
// @ts-expect-error we should infer a schema
|
|
1734
|
-
schema: this.schema,
|
|
1735
|
-
cursor: this.cursor
|
|
1736
|
-
};
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1767
|
+
// src/schema-utils/lib/table/batch-builder/table-batch-builder.ts
|
|
1768
|
+
var import_apache_arrow = require("apache-arrow");
|
|
1739
1769
|
|
|
1740
|
-
// src/schema-utils/lib/table/batch-builder/
|
|
1741
|
-
var
|
|
1742
|
-
var
|
|
1770
|
+
// src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts
|
|
1771
|
+
var arrow7 = __toESM(require("apache-arrow"), 1);
|
|
1772
|
+
var ArrowTableBuilder = class {
|
|
1743
1773
|
schema;
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1774
|
+
arrowSchema;
|
|
1775
|
+
arrowBuilders;
|
|
1776
|
+
length;
|
|
1747
1777
|
constructor(schema, options) {
|
|
1748
|
-
this.
|
|
1749
|
-
this.
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
addArrayRow(row) {
|
|
1755
|
-
this._reallocateColumns();
|
|
1756
|
-
let i = 0;
|
|
1757
|
-
for (const fieldName in this.columns) {
|
|
1758
|
-
this.columns[fieldName][this.length] = row[i++];
|
|
1759
|
-
}
|
|
1760
|
-
this.length++;
|
|
1778
|
+
this.arrowSchema = convertSchemaToArrow(schema, options);
|
|
1779
|
+
this.schema = options?.viewTypes && options.viewTypes !== "never" ? convertArrowToSchema(this.arrowSchema) : schema;
|
|
1780
|
+
this.arrowBuilders = this.arrowSchema.fields.map(
|
|
1781
|
+
(field) => arrow7.makeBuilder({ type: field.type, nullValues: [null, void 0] })
|
|
1782
|
+
);
|
|
1783
|
+
this.length = 0;
|
|
1761
1784
|
}
|
|
1762
1785
|
addObjectRow(row) {
|
|
1763
|
-
this.
|
|
1764
|
-
|
|
1765
|
-
|
|
1786
|
+
for (let i = 0; i < this.arrowBuilders.length; i++) {
|
|
1787
|
+
const columnName = this.schema.fields[i].name;
|
|
1788
|
+
const value = row[columnName];
|
|
1789
|
+
this.arrowBuilders[i].append(value);
|
|
1766
1790
|
}
|
|
1767
1791
|
this.length++;
|
|
1768
1792
|
}
|
|
1769
|
-
|
|
1770
|
-
this.
|
|
1771
|
-
|
|
1772
|
-
shape: "columnar-table",
|
|
1773
|
-
batchType: "data",
|
|
1774
|
-
data: this.columns,
|
|
1775
|
-
schema: this.schema,
|
|
1776
|
-
length: this.length
|
|
1777
|
-
};
|
|
1778
|
-
return batch;
|
|
1779
|
-
}
|
|
1780
|
-
// HELPERS
|
|
1781
|
-
_reallocateColumns() {
|
|
1782
|
-
if (this.length < this.allocated) {
|
|
1783
|
-
return;
|
|
1784
|
-
}
|
|
1785
|
-
this.allocated = this.allocated > 0 ? this.allocated * 2 : DEFAULT_ROW_COUNT3;
|
|
1786
|
-
this.columns = {};
|
|
1787
|
-
for (const field of this.schema.fields) {
|
|
1788
|
-
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
1789
|
-
const oldColumn = this.columns[field.name];
|
|
1790
|
-
if (!oldColumn) {
|
|
1791
|
-
this.columns[field.name] = new ArrayType(this.allocated);
|
|
1792
|
-
} else if (Array.isArray(oldColumn)) {
|
|
1793
|
-
oldColumn.length = this.allocated;
|
|
1794
|
-
} else if (ArrayBuffer.isView(oldColumn) && !(oldColumn instanceof DataView)) {
|
|
1795
|
-
const typedArray = new ArrayType(this.allocated);
|
|
1796
|
-
typedArray.set(oldColumn);
|
|
1797
|
-
this.columns[field.name] = typedArray;
|
|
1798
|
-
} else {
|
|
1799
|
-
throw new Error("Invalid column type");
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
_pruneColumns() {
|
|
1804
|
-
for (const [columnName, column] of Object.entries(this.columns)) {
|
|
1805
|
-
this.columns[columnName] = column.slice(0, this.length);
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
// src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.ts
|
|
1811
|
-
var arrow6 = __toESM(require("apache-arrow"), 1);
|
|
1812
|
-
var ArrowTableBatchAggregator = class extends ColumnarTableBatchAggregator {
|
|
1813
|
-
arrowSchema;
|
|
1814
|
-
constructor(schema, options) {
|
|
1815
|
-
super(schema, options);
|
|
1816
|
-
this.arrowSchema = null;
|
|
1817
|
-
}
|
|
1818
|
-
getBatch() {
|
|
1819
|
-
const batch = super.getBatch();
|
|
1820
|
-
if (batch) {
|
|
1821
|
-
this.arrowSchema = this.arrowSchema || getArrowSchema(batch.schema);
|
|
1822
|
-
const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);
|
|
1823
|
-
const recordBatch = new arrow6.RecordBatch(
|
|
1824
|
-
this.arrowSchema,
|
|
1825
|
-
arrow6.makeData({
|
|
1826
|
-
type: new arrow6.Struct(this.arrowSchema.fields),
|
|
1827
|
-
children: arrowVectors.map(({ data }) => data[0])
|
|
1828
|
-
})
|
|
1829
|
-
);
|
|
1830
|
-
return {
|
|
1831
|
-
shape: "arrow-table",
|
|
1832
|
-
batchType: "data",
|
|
1833
|
-
data: new arrow6.Table([recordBatch]),
|
|
1834
|
-
length: batch.length
|
|
1835
|
-
};
|
|
1793
|
+
addArrayRow(row) {
|
|
1794
|
+
for (let i = 0; i < this.arrowBuilders.length; i++) {
|
|
1795
|
+
this.arrowBuilders[i].append(row[i]);
|
|
1836
1796
|
}
|
|
1837
|
-
|
|
1797
|
+
this.length++;
|
|
1838
1798
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
const fields = Array.isArray(schema.fields) ? schema.fields : Object.values(schema);
|
|
1843
|
-
for (const field of fields) {
|
|
1844
|
-
if (field.type === "float32" || field.type === Float32Array) {
|
|
1845
|
-
const metadata = /* @__PURE__ */ new Map();
|
|
1846
|
-
const arrowField = new arrow6.Field(field.name, new arrow6.Float32(), field.nullable, metadata);
|
|
1847
|
-
arrowFields.push(arrowField);
|
|
1848
|
-
}
|
|
1799
|
+
/** Emits the declared schema before any rows are buffered. */
|
|
1800
|
+
firstBatch() {
|
|
1801
|
+
return this.length === 0 ? this._getArrowRecordBatch() : null;
|
|
1849
1802
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1803
|
+
/** Flushes the buffered rows as a native record batch. */
|
|
1804
|
+
flushBatch() {
|
|
1805
|
+
return this.length === 0 ? null : this._getArrowRecordBatch();
|
|
1852
1806
|
}
|
|
1853
|
-
|
|
1854
|
-
|
|
1807
|
+
/** Finishes the builders and returns the final native batch when it has rows or fields. */
|
|
1808
|
+
finishBatch() {
|
|
1809
|
+
const batch = this._getArrowRecordBatch();
|
|
1810
|
+
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
1811
|
+
return batch.numCols || batch.numRows ? batch : null;
|
|
1855
1812
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
const vector = data[field.name];
|
|
1862
|
-
if (vector instanceof Float32Array) {
|
|
1863
|
-
const arrowVector = arrow6.makeVector(vector);
|
|
1864
|
-
arrowVectors.push(arrowVector);
|
|
1865
|
-
}
|
|
1813
|
+
/** Finishes the builders and returns a native Arrow table. */
|
|
1814
|
+
finishTable() {
|
|
1815
|
+
const batch = this._getArrowRecordBatch();
|
|
1816
|
+
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
1817
|
+
return new arrow7.Table(batch);
|
|
1866
1818
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1819
|
+
/** Extract a record batch flushing the currently accumulated data in the builders */
|
|
1820
|
+
_getArrowRecordBatch() {
|
|
1821
|
+
const { arrowBuilders, arrowSchema } = this;
|
|
1822
|
+
const arrowDatas = arrowBuilders.map((builder) => builder.flush());
|
|
1823
|
+
const length = arrowDatas[0]?.length || this.length;
|
|
1824
|
+
this.length = 0;
|
|
1825
|
+
const structField = new arrow7.Struct(arrowSchema.fields);
|
|
1826
|
+
const arrowStructData = new arrow7.Data(structField, 0, length, 0, void 0, arrowDatas);
|
|
1827
|
+
const arrowRecordBatch = new arrow7.RecordBatch(
|
|
1828
|
+
snapshotArrowSchema(arrowSchema),
|
|
1829
|
+
arrowStructData
|
|
1830
|
+
);
|
|
1831
|
+
return arrowRecordBatch;
|
|
1869
1832
|
}
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1833
|
+
};
|
|
1872
1834
|
|
|
1873
1835
|
// src/schema-utils/lib/table/batch-builder/table-batch-builder.ts
|
|
1874
1836
|
var DEFAULT_OPTIONS = {
|
|
1875
1837
|
shape: void 0,
|
|
1876
|
-
batchSize: "auto"
|
|
1877
|
-
batchDebounceMs: 0,
|
|
1878
|
-
limit: 0,
|
|
1879
|
-
_limitMB: 0
|
|
1838
|
+
batchSize: "auto"
|
|
1880
1839
|
};
|
|
1881
1840
|
var TableBatchBuilder = class {
|
|
1882
1841
|
schema;
|
|
1883
1842
|
options;
|
|
1884
|
-
|
|
1843
|
+
/** Persistent Arrow builders for typed output. */
|
|
1844
|
+
arrowBuilder = null;
|
|
1845
|
+
/** Rows retained for explicit raw output, including schema-less JSON. */
|
|
1846
|
+
rows = [];
|
|
1885
1847
|
batchCount = 0;
|
|
1886
1848
|
bytesUsed = 0;
|
|
1887
1849
|
isChunkComplete = false;
|
|
1888
|
-
lastBatchEmittedMs = Date.now();
|
|
1889
|
-
totalLength = 0;
|
|
1890
|
-
totalBytes = 0;
|
|
1891
|
-
rowBytes = 0;
|
|
1892
|
-
static ArrowBatch;
|
|
1893
1850
|
constructor(schema, options) {
|
|
1894
1851
|
this.schema = schema;
|
|
1895
1852
|
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
1896
1853
|
}
|
|
1897
|
-
limitReached() {
|
|
1898
|
-
if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
|
|
1899
|
-
return true;
|
|
1900
|
-
}
|
|
1901
|
-
if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
|
|
1902
|
-
return true;
|
|
1903
|
-
}
|
|
1904
|
-
return false;
|
|
1905
|
-
}
|
|
1906
1854
|
/** @deprecated Use addArrayRow or addObjectRow */
|
|
1907
1855
|
addRow(row) {
|
|
1908
|
-
if (this.
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
this.addArrayRow(row);
|
|
1856
|
+
if (this.options.shape === "columnar-table") {
|
|
1857
|
+
this.arrowBuilder ??= new ArrowTableBuilder(this.schema);
|
|
1858
|
+
if (Array.isArray(row)) {
|
|
1859
|
+
this.arrowBuilder.addArrayRow(row);
|
|
1860
|
+
} else {
|
|
1861
|
+
this.arrowBuilder.addObjectRow(row);
|
|
1862
|
+
}
|
|
1916
1863
|
} else {
|
|
1917
|
-
this.
|
|
1864
|
+
this.rows.push(row);
|
|
1918
1865
|
}
|
|
1919
1866
|
}
|
|
1920
|
-
/** Add one row to the batch */
|
|
1921
|
-
addArrayRow(row) {
|
|
1922
|
-
if (!this.aggregator) {
|
|
1923
|
-
const TableBatchType = this._getTableBatchType();
|
|
1924
|
-
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
1925
|
-
}
|
|
1926
|
-
this.aggregator.addArrayRow(row);
|
|
1927
|
-
}
|
|
1928
|
-
/** Add one row to the batch */
|
|
1929
|
-
addObjectRow(row) {
|
|
1930
|
-
if (!this.aggregator) {
|
|
1931
|
-
const TableBatchType = this._getTableBatchType();
|
|
1932
|
-
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
1933
|
-
}
|
|
1934
|
-
this.aggregator.addObjectRow(row);
|
|
1935
|
-
}
|
|
1936
1867
|
/** Mark an incoming raw memory chunk has completed */
|
|
1937
1868
|
chunkComplete(chunk) {
|
|
1938
1869
|
if (chunk instanceof ArrayBuffer) {
|
|
@@ -1950,57 +1881,73 @@ var TableBatchBuilder = class {
|
|
|
1950
1881
|
return this._getBatch(options);
|
|
1951
1882
|
}
|
|
1952
1883
|
// INTERNAL
|
|
1953
|
-
_estimateRowMB(row) {
|
|
1954
|
-
return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
|
|
1955
|
-
}
|
|
1956
1884
|
_isFull() {
|
|
1957
|
-
if (
|
|
1885
|
+
if (this.rowCount() === 0) {
|
|
1958
1886
|
return false;
|
|
1959
1887
|
}
|
|
1960
1888
|
if (this.options.batchSize === "auto") {
|
|
1961
1889
|
if (!this.isChunkComplete) {
|
|
1962
1890
|
return false;
|
|
1963
1891
|
}
|
|
1964
|
-
} else if (this.options.batchSize > this.
|
|
1965
|
-
return false;
|
|
1966
|
-
}
|
|
1967
|
-
if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
|
|
1892
|
+
} else if (this.options.batchSize > this.rowCount()) {
|
|
1968
1893
|
return false;
|
|
1969
1894
|
}
|
|
1970
1895
|
this.isChunkComplete = false;
|
|
1971
|
-
this.lastBatchEmittedMs = Date.now();
|
|
1972
1896
|
return true;
|
|
1973
1897
|
}
|
|
1974
1898
|
/**
|
|
1975
1899
|
* bytesUsed can be set via chunkComplete or via getBatch*
|
|
1976
1900
|
*/
|
|
1977
1901
|
_getBatch(options) {
|
|
1978
|
-
if (
|
|
1902
|
+
if (this.rowCount() === 0) {
|
|
1979
1903
|
return null;
|
|
1980
1904
|
}
|
|
1981
1905
|
if (options?.bytesUsed) {
|
|
1982
1906
|
this.bytesUsed = options.bytesUsed;
|
|
1983
1907
|
}
|
|
1984
|
-
const normalizedBatch = this.
|
|
1908
|
+
const normalizedBatch = this.takeBatch();
|
|
1985
1909
|
normalizedBatch.count = this.batchCount;
|
|
1986
1910
|
normalizedBatch.bytesUsed = this.bytesUsed;
|
|
1987
1911
|
Object.assign(normalizedBatch, options);
|
|
1988
1912
|
this.batchCount++;
|
|
1989
|
-
this.aggregator = null;
|
|
1990
1913
|
return normalizedBatch;
|
|
1991
1914
|
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
1915
|
+
/** Returns the number of rows buffered for the next batch. */
|
|
1916
|
+
rowCount() {
|
|
1917
|
+
return this.arrowBuilder?.length ?? this.rows.length;
|
|
1918
|
+
}
|
|
1919
|
+
/** Flushes typed output or takes ownership of the buffered raw rows. */
|
|
1920
|
+
takeBatch() {
|
|
1921
|
+
if (this.arrowBuilder) {
|
|
1922
|
+
const batch = this.arrowBuilder.flushBatch();
|
|
1923
|
+
return {
|
|
1924
|
+
...convertArrowToTable(new import_apache_arrow.Table(batch), "columnar-table"),
|
|
1925
|
+
schema: structuredClone(this.schema),
|
|
1926
|
+
batchType: "data",
|
|
1927
|
+
length: batch.numRows
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
const rows = this.rows;
|
|
1931
|
+
this.rows = [];
|
|
1932
|
+
const shape = this.options.shape ?? (Array.isArray(rows[0]) ? "array-row-table" : "object-row-table");
|
|
1933
|
+
const firstRow = rows[0];
|
|
1934
|
+
const fieldNames = this.schema?.fields.map((field) => field.name) ?? (Array.isArray(firstRow) ? inferHeadersFromArrayRow(firstRow) : inferHeadersFromObjectRow(firstRow));
|
|
1935
|
+
if (shape === "array-row-table") {
|
|
1936
|
+
return {
|
|
1937
|
+
shape,
|
|
1938
|
+
batchType: "data",
|
|
1939
|
+
data: rows.map((row) => Array.isArray(row) ? row : convertToArrayRow(row, fieldNames)),
|
|
1940
|
+
schema: this.schema,
|
|
1941
|
+
length: rows.length
|
|
1942
|
+
};
|
|
2003
1943
|
}
|
|
1944
|
+
return {
|
|
1945
|
+
shape: "object-row-table",
|
|
1946
|
+
batchType: "data",
|
|
1947
|
+
data: rows.map((row) => Array.isArray(row) ? convertToObjectRow(row, fieldNames) : row),
|
|
1948
|
+
schema: this.schema,
|
|
1949
|
+
length: rows.length
|
|
1950
|
+
};
|
|
2004
1951
|
}
|
|
2005
1952
|
};
|
|
2006
1953
|
|
|
@@ -2143,17 +2090,7 @@ var ArrowLikeTable = class {
|
|
|
2143
2090
|
// }
|
|
2144
2091
|
};
|
|
2145
2092
|
|
|
2146
|
-
// src/schema-utils/lib/mesh/mesh-
|
|
2147
|
-
function getMeshSize(attributes) {
|
|
2148
|
-
let size = 0;
|
|
2149
|
-
for (const attributeName in attributes) {
|
|
2150
|
-
const attribute = attributes[attributeName];
|
|
2151
|
-
if (ArrayBuffer.isView(attribute)) {
|
|
2152
|
-
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
return size;
|
|
2156
|
-
}
|
|
2093
|
+
// src/schema-utils/lib/mesh/get-mesh-bounding-box.ts
|
|
2157
2094
|
function getMeshBoundingBox(attributes) {
|
|
2158
2095
|
const positionAttribute = attributes?.POSITION;
|
|
2159
2096
|
if (!positionAttribute || !("value" in positionAttribute) || !positionAttribute.value.length) {
|
|
@@ -2184,6 +2121,18 @@ function getMeshBoundingBox(attributes) {
|
|
|
2184
2121
|
];
|
|
2185
2122
|
}
|
|
2186
2123
|
|
|
2124
|
+
// src/schema-utils/lib/mesh/mesh-utils.ts
|
|
2125
|
+
function getMeshSize(attributes) {
|
|
2126
|
+
let size = 0;
|
|
2127
|
+
for (const attributeName in attributes) {
|
|
2128
|
+
const attribute = attributes[attributeName];
|
|
2129
|
+
if (ArrayBuffer.isView(attribute)) {
|
|
2130
|
+
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
return size;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2187
2136
|
// src/schema/float16.ts
|
|
2188
2137
|
var import_core2 = require("@math.gl/core");
|
|
2189
2138
|
function createFloat16Array(length) {
|
|
@@ -2249,34 +2198,34 @@ function decodeFloat16(value) {
|
|
|
2249
2198
|
}
|
|
2250
2199
|
|
|
2251
2200
|
// src/schema/categories/category-mesh.ts
|
|
2252
|
-
var
|
|
2253
|
-
var meshArrowSchema = new
|
|
2254
|
-
new
|
|
2201
|
+
var arrow8 = __toESM(require("apache-arrow"), 1);
|
|
2202
|
+
var meshArrowSchema = new arrow8.Schema([
|
|
2203
|
+
new arrow8.Field(
|
|
2255
2204
|
"POSITION",
|
|
2256
|
-
new
|
|
2205
|
+
new arrow8.FixedSizeList(3, new arrow8.Field("value", new arrow8.Float32(), false)),
|
|
2257
2206
|
false
|
|
2258
2207
|
)
|
|
2259
2208
|
]);
|
|
2260
|
-
var indexedMeshArrowSchema = new
|
|
2209
|
+
var indexedMeshArrowSchema = new arrow8.Schema([
|
|
2261
2210
|
...meshArrowSchema.fields,
|
|
2262
|
-
new
|
|
2211
|
+
new arrow8.Field(
|
|
2263
2212
|
"indices",
|
|
2264
|
-
new
|
|
2213
|
+
new arrow8.List(new arrow8.Field("item", new arrow8.Uint32(), false)),
|
|
2265
2214
|
true
|
|
2266
2215
|
)
|
|
2267
2216
|
]);
|
|
2268
2217
|
|
|
2269
2218
|
// src/schema-utils/lib/mesh/convert-mesh-to-table.ts
|
|
2270
|
-
var
|
|
2219
|
+
var arrow10 = __toESM(require("apache-arrow"), 1);
|
|
2271
2220
|
|
|
2272
2221
|
// src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts
|
|
2273
|
-
var
|
|
2222
|
+
var arrow9 = __toESM(require("apache-arrow"), 1);
|
|
2274
2223
|
function getFixedSizeListSize(vector) {
|
|
2275
|
-
return vector.type instanceof
|
|
2224
|
+
return vector.type instanceof arrow9.FixedSizeList ? vector.type.listSize : 1;
|
|
2276
2225
|
}
|
|
2277
2226
|
function getFixedSizeListVector(typedArray, stride, logicalType) {
|
|
2278
2227
|
const data = getFixedSizeListData(typedArray, stride, logicalType);
|
|
2279
|
-
return new
|
|
2228
|
+
return new arrow9.Vector([data]);
|
|
2280
2229
|
}
|
|
2281
2230
|
function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
2282
2231
|
const listType = getFixedSizeListType(typedArray, stride, logicalType);
|
|
@@ -2284,13 +2233,13 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
2284
2233
|
const storage = logicalType === "float16" && isNativeFloat16Array(typedArray) ? getFloat16Storage(typedArray) : typedArray;
|
|
2285
2234
|
const buffers = {
|
|
2286
2235
|
// valueOffsets: undefined,
|
|
2287
|
-
[
|
|
2236
|
+
[arrow9.BufferType.DATA]: storage
|
|
2288
2237
|
// values
|
|
2289
2238
|
// nullBitmap: undefined,
|
|
2290
2239
|
// typeIds: undefined
|
|
2291
2240
|
};
|
|
2292
|
-
const nestedData = new
|
|
2293
|
-
const data = new
|
|
2241
|
+
const nestedData = new arrow9.Data(nestedType, 0, storage.length, 0, buffers);
|
|
2242
|
+
const data = new arrow9.Data(
|
|
2294
2243
|
listType,
|
|
2295
2244
|
0,
|
|
2296
2245
|
storage.length / stride,
|
|
@@ -2303,7 +2252,7 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
2303
2252
|
function getFixedSizeListType(typedArray, stride, logicalType) {
|
|
2304
2253
|
const type = logicalType || getDataTypeFromArray(typedArray).type;
|
|
2305
2254
|
const arrowType = deserializeArrowType(type);
|
|
2306
|
-
const listType = new
|
|
2255
|
+
const listType = new arrow9.FixedSizeList(stride, new arrow9.Field("value", arrowType, false));
|
|
2307
2256
|
return listType;
|
|
2308
2257
|
}
|
|
2309
2258
|
|
|
@@ -2313,8 +2262,8 @@ function convertMeshToTable(mesh, shape) {
|
|
|
2313
2262
|
switch (shape) {
|
|
2314
2263
|
case "columnar-table":
|
|
2315
2264
|
return convertMeshToColumnarTable(mesh);
|
|
2316
|
-
case "arrow
|
|
2317
|
-
return
|
|
2265
|
+
case "arrow":
|
|
2266
|
+
return convertMeshToArrowTableWrapper(mesh).data;
|
|
2318
2267
|
default:
|
|
2319
2268
|
throw new Error(shape);
|
|
2320
2269
|
}
|
|
@@ -2333,7 +2282,7 @@ function convertMeshToColumnarTable(mesh) {
|
|
|
2333
2282
|
indices: hasIndices ? mesh.indices : void 0
|
|
2334
2283
|
};
|
|
2335
2284
|
}
|
|
2336
|
-
function
|
|
2285
|
+
function convertMeshToArrowTableWrapper(mesh, batchSize) {
|
|
2337
2286
|
return makeMeshArrowTable(mesh.attributes, {
|
|
2338
2287
|
schema: mesh.schema,
|
|
2339
2288
|
topology: mesh.topology,
|
|
@@ -2360,8 +2309,8 @@ function makeMeshArrowTable(attributes, options = {}) {
|
|
|
2360
2309
|
fields.push(indicesField);
|
|
2361
2310
|
}
|
|
2362
2311
|
}
|
|
2363
|
-
const arrowSchema = new
|
|
2364
|
-
const table = columns[attributeNames[0]]?.length === 0 ? new
|
|
2312
|
+
const arrowSchema = new arrow10.Schema(fields, getMeshArrowMetadata(options));
|
|
2313
|
+
const table = columns[attributeNames[0]]?.length === 0 ? new arrow10.Table(arrowSchema) : new arrow10.Table(arrowSchema, columns);
|
|
2365
2314
|
const schema = serializeArrowSchema(table.schema);
|
|
2366
2315
|
return {
|
|
2367
2316
|
shape: "arrow-table",
|
|
@@ -2375,14 +2324,14 @@ function getAttributeArrowVector(value, size, componentType) {
|
|
|
2375
2324
|
if (componentType === "float16") {
|
|
2376
2325
|
const storage = isNativeFloat16Array(value) ? getFloat16Storage(value) : value;
|
|
2377
2326
|
if (size === 1) {
|
|
2378
|
-
const data = new
|
|
2379
|
-
[
|
|
2327
|
+
const data = new arrow10.Data(new arrow10.Float16(), 0, storage.length, 0, {
|
|
2328
|
+
[arrow10.BufferType.DATA]: storage
|
|
2380
2329
|
});
|
|
2381
|
-
return new
|
|
2330
|
+
return new arrow10.Vector([data]);
|
|
2382
2331
|
}
|
|
2383
2332
|
return getFixedSizeListVector(value, size, componentType);
|
|
2384
2333
|
}
|
|
2385
|
-
return size === 1 ?
|
|
2334
|
+
return size === 1 ? arrow10.makeVector(value) : getFixedSizeListVector(value, size);
|
|
2386
2335
|
}
|
|
2387
2336
|
function getOrderedAttributeNames(attributes) {
|
|
2388
2337
|
const attributeNames = Object.keys(attributes);
|
|
@@ -2408,7 +2357,7 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
|
|
|
2408
2357
|
for (const [key, value] of Object.entries(suppliedField.metadata)) {
|
|
2409
2358
|
metadata.set(key, value);
|
|
2410
2359
|
}
|
|
2411
|
-
return new
|
|
2360
|
+
return new arrow10.Field(
|
|
2412
2361
|
canonicalField.name,
|
|
2413
2362
|
canonicalField.type,
|
|
2414
2363
|
canonicalField.nullable,
|
|
@@ -2419,21 +2368,21 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
|
|
|
2419
2368
|
if (componentType === "float16") {
|
|
2420
2369
|
const metadata = new Map(Object.entries(field?.metadata || {}));
|
|
2421
2370
|
metadata.set("componentType", "float16");
|
|
2422
|
-
return new
|
|
2371
|
+
return new arrow10.Field(attributeName, column.type, false, metadata);
|
|
2423
2372
|
}
|
|
2424
2373
|
if (field && field.type.toString() !== column.type.toString()) {
|
|
2425
2374
|
const deserializedField = deserializeArrowField(field);
|
|
2426
|
-
return new
|
|
2375
|
+
return new arrow10.Field(
|
|
2427
2376
|
attributeName,
|
|
2428
2377
|
column.type,
|
|
2429
2378
|
deserializedField.nullable,
|
|
2430
2379
|
deserializedField.metadata
|
|
2431
2380
|
);
|
|
2432
2381
|
}
|
|
2433
|
-
return field ? deserializeArrowField(field) : new
|
|
2382
|
+
return field ? deserializeArrowField(field) : new arrow10.Field(attributeName, column.type, false);
|
|
2434
2383
|
}
|
|
2435
2384
|
function isMeshPositionColumn(column) {
|
|
2436
|
-
return column.type instanceof
|
|
2385
|
+
return column.type instanceof arrow10.FixedSizeList && column.type.listSize === 3 && column.type.children[0].type instanceof arrow10.Float32;
|
|
2437
2386
|
}
|
|
2438
2387
|
function getIndicesVector(indices, vertexCount, type) {
|
|
2439
2388
|
const indicesType = type;
|
|
@@ -2446,25 +2395,25 @@ function getIndicesVector(indices, vertexCount, type) {
|
|
|
2446
2395
|
if (vertexCount > 0) {
|
|
2447
2396
|
nullBitmap[0] = 1;
|
|
2448
2397
|
}
|
|
2449
|
-
const valuesData = new
|
|
2398
|
+
const valuesData = new arrow10.Data(
|
|
2450
2399
|
indicesType.children[0].type,
|
|
2451
2400
|
0,
|
|
2452
2401
|
values.length,
|
|
2453
2402
|
0,
|
|
2454
|
-
{ [
|
|
2403
|
+
{ [arrow10.BufferType.DATA]: values }
|
|
2455
2404
|
);
|
|
2456
|
-
const indicesData = new
|
|
2405
|
+
const indicesData = new arrow10.Data(
|
|
2457
2406
|
indicesType,
|
|
2458
2407
|
0,
|
|
2459
2408
|
vertexCount,
|
|
2460
2409
|
Math.max(0, vertexCount - 1),
|
|
2461
2410
|
{
|
|
2462
|
-
[
|
|
2463
|
-
[
|
|
2411
|
+
[arrow10.BufferType.OFFSET]: valueOffsets,
|
|
2412
|
+
[arrow10.BufferType.VALIDITY]: nullBitmap
|
|
2464
2413
|
},
|
|
2465
2414
|
[valuesData]
|
|
2466
2415
|
);
|
|
2467
|
-
return new
|
|
2416
|
+
return new arrow10.Vector([indicesData]);
|
|
2468
2417
|
}
|
|
2469
2418
|
function getMeshArrowMetadata(options) {
|
|
2470
2419
|
const metadata = { ...options.schema?.metadata };
|
|
@@ -2481,8 +2430,9 @@ function getMeshArrowMetadata(options) {
|
|
|
2481
2430
|
}
|
|
2482
2431
|
|
|
2483
2432
|
// src/schema-utils/lib/mesh/convert-table-to-mesh.ts
|
|
2484
|
-
var
|
|
2433
|
+
var arrow11 = __toESM(require("apache-arrow"), 1);
|
|
2485
2434
|
function convertTableToMesh(table) {
|
|
2435
|
+
if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
|
|
2486
2436
|
switch (table.shape) {
|
|
2487
2437
|
// case 'columnar-table':
|
|
2488
2438
|
// return convertColumnarTableToMesh(table);
|
|
@@ -2493,8 +2443,10 @@ function convertTableToMesh(table) {
|
|
|
2493
2443
|
}
|
|
2494
2444
|
}
|
|
2495
2445
|
function convertArrowTableToMesh(table) {
|
|
2496
|
-
const arrowTable = table.data;
|
|
2446
|
+
const arrowTable = isNativeArrowTable(table) ? table : table.data;
|
|
2497
2447
|
const schema = serializeArrowSchema(arrowTable.schema);
|
|
2448
|
+
const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
|
|
2449
|
+
if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
|
|
2498
2450
|
const fields = schema.fields;
|
|
2499
2451
|
const attributes = {};
|
|
2500
2452
|
const columns = [];
|
|
@@ -2592,7 +2544,7 @@ function fixMetadata(schema) {
|
|
|
2592
2544
|
schema.metadata.mode ||= "0";
|
|
2593
2545
|
}
|
|
2594
2546
|
function getAttributeTypedArray(attributeData, size) {
|
|
2595
|
-
if (!(attributeData.type instanceof
|
|
2547
|
+
if (!(attributeData.type instanceof arrow11.FixedSizeList)) {
|
|
2596
2548
|
return attributeData.toArray();
|
|
2597
2549
|
}
|
|
2598
2550
|
const values = attributeData.data[0].children[0].values;
|
|
@@ -2804,101 +2756,6 @@ var DataType3 = class {
|
|
|
2804
2756
|
}
|
|
2805
2757
|
};
|
|
2806
2758
|
|
|
2807
|
-
// src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts
|
|
2808
|
-
var arrow11 = __toESM(require("apache-arrow"), 1);
|
|
2809
|
-
var ArrowTableBuilder = class {
|
|
2810
|
-
schema;
|
|
2811
|
-
arrowSchema;
|
|
2812
|
-
arrowBuilders;
|
|
2813
|
-
length;
|
|
2814
|
-
constructor(schema, options) {
|
|
2815
|
-
this.arrowSchema = convertSchemaToArrow(schema, options);
|
|
2816
|
-
this.schema = options?.viewTypes && options.viewTypes !== "never" ? convertArrowToSchema(this.arrowSchema) : schema;
|
|
2817
|
-
this.arrowBuilders = this.arrowSchema.fields.map(
|
|
2818
|
-
(field) => arrow11.makeBuilder({ type: field.type, nullValues: [null] })
|
|
2819
|
-
);
|
|
2820
|
-
this.length = 0;
|
|
2821
|
-
}
|
|
2822
|
-
addObjectRow(row) {
|
|
2823
|
-
for (let i = 0; i < this.arrowBuilders.length; i++) {
|
|
2824
|
-
const columnName = this.schema.fields[i].name;
|
|
2825
|
-
const value = row[columnName];
|
|
2826
|
-
this.arrowBuilders[i].append(value);
|
|
2827
|
-
}
|
|
2828
|
-
this.length++;
|
|
2829
|
-
}
|
|
2830
|
-
addArrayRow(row) {
|
|
2831
|
-
for (let i = 0; i < this.arrowBuilders.length; i++) {
|
|
2832
|
-
this.arrowBuilders[i].append(row[i]);
|
|
2833
|
-
}
|
|
2834
|
-
this.length++;
|
|
2835
|
-
}
|
|
2836
|
-
/** Makes sure that a first batch with schema is sent even if no rows */
|
|
2837
|
-
firstBatch() {
|
|
2838
|
-
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
2839
|
-
if (arrowRecordBatch.numCols !== 0) {
|
|
2840
|
-
return null;
|
|
2841
|
-
}
|
|
2842
|
-
return {
|
|
2843
|
-
shape: "arrow-table",
|
|
2844
|
-
batchType: "data",
|
|
2845
|
-
length: arrowRecordBatch.numRows,
|
|
2846
|
-
schema: this.schema,
|
|
2847
|
-
data: new arrow11.Table(arrowRecordBatch)
|
|
2848
|
-
};
|
|
2849
|
-
}
|
|
2850
|
-
/** Flush the current batch if conditions are right */
|
|
2851
|
-
flushBatch() {
|
|
2852
|
-
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
2853
|
-
if (arrowRecordBatch.numCols === 0) {
|
|
2854
|
-
return null;
|
|
2855
|
-
}
|
|
2856
|
-
return {
|
|
2857
|
-
shape: "arrow-table",
|
|
2858
|
-
batchType: "data",
|
|
2859
|
-
length: arrowRecordBatch.numRows,
|
|
2860
|
-
schema: this.schema,
|
|
2861
|
-
data: new arrow11.Table(arrowRecordBatch)
|
|
2862
|
-
};
|
|
2863
|
-
}
|
|
2864
|
-
/** Get a last batch if any data is left */
|
|
2865
|
-
finishBatch() {
|
|
2866
|
-
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
2867
|
-
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
2868
|
-
if (arrowRecordBatch.numCols === 0 && arrowRecordBatch.numRows === 0) {
|
|
2869
|
-
return null;
|
|
2870
|
-
}
|
|
2871
|
-
return {
|
|
2872
|
-
shape: "arrow-table",
|
|
2873
|
-
batchType: "data",
|
|
2874
|
-
length: arrowRecordBatch.numRows,
|
|
2875
|
-
schema: this.schema,
|
|
2876
|
-
data: new arrow11.Table(arrowRecordBatch)
|
|
2877
|
-
};
|
|
2878
|
-
}
|
|
2879
|
-
/** Return a table with all the accumulated data */
|
|
2880
|
-
finishTable() {
|
|
2881
|
-
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
2882
|
-
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
2883
|
-
return {
|
|
2884
|
-
shape: "arrow-table",
|
|
2885
|
-
schema: this.schema,
|
|
2886
|
-
data: new arrow11.Table(arrowRecordBatch)
|
|
2887
|
-
};
|
|
2888
|
-
}
|
|
2889
|
-
/** Extract a record batch flushing the currently accumulated data in the builders */
|
|
2890
|
-
_getArrowRecordBatch() {
|
|
2891
|
-
const { arrowBuilders, arrowSchema } = this;
|
|
2892
|
-
const arrowDatas = arrowBuilders.map((builder) => builder.flush());
|
|
2893
|
-
const length = arrowDatas[0]?.length || this.length;
|
|
2894
|
-
this.length = 0;
|
|
2895
|
-
const structField = new arrow11.Struct(arrowSchema.fields);
|
|
2896
|
-
const arrowStructData = new arrow11.Data(structField, 0, length, 0, void 0, arrowDatas);
|
|
2897
|
-
const arrowRecordBatch = new arrow11.RecordBatch(arrowSchema, arrowStructData);
|
|
2898
|
-
return arrowRecordBatch;
|
|
2899
|
-
}
|
|
2900
|
-
};
|
|
2901
|
-
|
|
2902
2759
|
// src/schema-utils/lib/table/arrow-api/get-type-info.ts
|
|
2903
2760
|
function getTypeInfo(arrowTypeLike) {
|
|
2904
2761
|
return {
|
|
@@ -3154,7 +3011,8 @@ var PointCloudTiler = class {
|
|
|
3154
3011
|
/** Validates the decoded profile and creates a root cube from finite native coordinates. */
|
|
3155
3012
|
async initialize(input) {
|
|
3156
3013
|
this.signal.throwIfAborted();
|
|
3157
|
-
if ("
|
|
3014
|
+
if (!("attributes" in input)) {
|
|
3015
|
+
const table = "shape" in input ? input.data : input;
|
|
3158
3016
|
const buffers2 = /* @__PURE__ */ new Set();
|
|
3159
3017
|
let arrowBytes = 0;
|
|
3160
3018
|
const checkData = (data) => {
|
|
@@ -3170,15 +3028,15 @@ var PointCloudTiler = class {
|
|
|
3170
3028
|
if (data.dictionary)
|
|
3171
3029
|
for (const dictionaryData of data.dictionary.data) checkData(dictionaryData);
|
|
3172
3030
|
};
|
|
3173
|
-
for (const batch of
|
|
3031
|
+
for (const batch of table.batches) checkData(batch.data);
|
|
3174
3032
|
if (arrowBytes > this.options.maxInputBytes)
|
|
3175
3033
|
throw new Error("PointCloudTiler: input byte budget exceeded");
|
|
3176
|
-
for (const column of
|
|
3177
|
-
if (
|
|
3034
|
+
for (const column of table.schema.fields) {
|
|
3035
|
+
if (table.getChild(column.name)?.nullCount)
|
|
3178
3036
|
throw new Error("PointCloudTiler: null point attributes require an explicit mapping");
|
|
3179
3037
|
}
|
|
3180
3038
|
}
|
|
3181
|
-
const mesh = "
|
|
3039
|
+
const mesh = "attributes" in input ? input : convertTableToMesh(input);
|
|
3182
3040
|
if (mesh.topology !== "point-list" || mesh.indices)
|
|
3183
3041
|
throw new Error("PointCloudTiler: unindexed point-list input required");
|
|
3184
3042
|
const position = mesh.attributes.POSITION;
|
|
@@ -3356,17 +3214,18 @@ function getAttributeStorageKey(attribute) {
|
|
|
3356
3214
|
ArrowLikeTable,
|
|
3357
3215
|
ArrowTableBuilder,
|
|
3358
3216
|
AsyncQueue,
|
|
3359
|
-
ColumnarTableBatchAggregator,
|
|
3360
3217
|
PointCloudTiler,
|
|
3361
|
-
RowTableBatchAggregator,
|
|
3362
3218
|
TABLE_CONVERTERS,
|
|
3363
3219
|
TableBatchBuilder,
|
|
3364
3220
|
TableConverter,
|
|
3365
3221
|
convert,
|
|
3222
|
+
convertArrowTable,
|
|
3223
|
+
convertArrowTableBatch,
|
|
3366
3224
|
convertArrowToSchema,
|
|
3367
3225
|
convertArrowToTable,
|
|
3368
3226
|
convertBatch,
|
|
3369
3227
|
convertBatches,
|
|
3228
|
+
convertMeshToArrowTableWrapper,
|
|
3370
3229
|
convertMeshToTable,
|
|
3371
3230
|
convertSchemaToArrow,
|
|
3372
3231
|
convertTable,
|
|
@@ -3400,11 +3259,14 @@ function getAttributeStorageKey(attribute) {
|
|
|
3400
3259
|
isArrowTable,
|
|
3401
3260
|
isColumnarTable,
|
|
3402
3261
|
isGeoJSONTable,
|
|
3262
|
+
isNativeArrowRecordBatch,
|
|
3263
|
+
isNativeArrowTable,
|
|
3403
3264
|
isObjectRowTable,
|
|
3404
3265
|
isTable,
|
|
3405
3266
|
makeArrayRowIterator,
|
|
3267
|
+
makeArrowMetadataBatch,
|
|
3406
3268
|
makeArrowRecordBatchIterator,
|
|
3407
|
-
|
|
3269
|
+
makeArrowTableFromBatches,
|
|
3408
3270
|
makeBatchFromTable,
|
|
3409
3271
|
makeMeshArrowTable,
|
|
3410
3272
|
makeMeshAttributeMetadata,
|
|
@@ -3413,10 +3275,15 @@ function getAttributeStorageKey(attribute) {
|
|
|
3413
3275
|
makeTableBatchIterator,
|
|
3414
3276
|
makeTableFromBatches,
|
|
3415
3277
|
makeTableFromData,
|
|
3278
|
+
mergeArrowSchemas,
|
|
3416
3279
|
queryArrowTable,
|
|
3280
|
+
refineArrowTableBatches,
|
|
3417
3281
|
selectArrowTableRows,
|
|
3418
3282
|
serializeArrowField,
|
|
3419
3283
|
serializeArrowMetadata,
|
|
3420
3284
|
serializeArrowSchema,
|
|
3421
|
-
serializeArrowType
|
|
3285
|
+
serializeArrowType,
|
|
3286
|
+
snapshotArrowSchema,
|
|
3287
|
+
updateArrowTableMetadata,
|
|
3288
|
+
updateArrowTableSchema
|
|
3422
3289
|
});
|