@loaders.gl/core 5.0.0-beta.10 → 5.0.0-beta.12
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/SCAN-README.md +2 -2
- package/SCHEMA-UTILS-README.md +1 -1
- package/dist/arrow-geometry/binary-features.cjs +4 -1
- package/dist/arrow-geometry/binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/binary-features.d.ts.map +1 -1
- package/dist/arrow-geometry/binary-features.js +1 -1
- package/dist/arrow-geometry/binary-features.js.map +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 +1 -5
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +2 -10
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts +6 -5
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +5 -13
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +3 -3
- package/dist/arrow-geometry/geojson-table.cjs.map +3 -3
- package/dist/arrow-geometry/geojson-table.d.ts +1 -1
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +2 -2
- 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/legacy-binary/convert-flat-geojson-to-binary-features.cjs +3 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js +3 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
- package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
- package/dist/arrow-geometry/wkb-arrow-utils.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 +8 -76
- package/dist/arrow-worker-transport.cjs.map +1 -1
- package/dist/arrow-worker-transport.d.ts +4 -8
- package/dist/arrow-worker-transport.d.ts.map +1 -1
- package/dist/arrow-worker-transport.js +15 -89
- package/dist/arrow-worker-transport.js.map +1 -1
- package/dist/cluster-source.cjs +47 -45
- package/dist/cluster-source.cjs.map +2 -2
- package/dist/dist.dev.js +71 -60
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +88 -126
- package/dist/federated-table-scan-source.cjs.map +2 -2
- 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 +12 -12
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +12 -14
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
- 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 +3 -3
- 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 +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.d.ts.map +1 -1
- 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 +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
- 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 +2 -3
- 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 +10 -11
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-stream.js +9 -12
- 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-arrow-binary-feature-collection.cjs.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +5 -2
- 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.js +2 -2
- 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.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/index.cjs +69 -54
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +2 -4
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/loader-options.d.ts +6 -0
- package/dist/lib/api/loader-options.d.ts.map +1 -1
- package/dist/lib/api/loader-options.js +48 -0
- package/dist/lib/api/loader-options.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +2 -5
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -10
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +2 -5
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +2 -5
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
- package/dist/lib/loader-utils/native-arrow.js +13 -31
- package/dist/lib/loader-utils/native-arrow.js.map +1 -1
- package/dist/loader-utils/index.cjs +48 -31
- package/dist/loader-utils/index.cjs.map +1 -1
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
- 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 +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
- 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 +36 -22
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts +6 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.js +32 -14
- package/dist/loader-utils/lib/sources/tile-grid.js.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +3 -5
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/tile-grid.cjs +21 -9
- package/dist/loader-utils/tile-grid.cjs.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +4 -4
- package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
- package/dist/scan/arrow-execution/expressions.d.ts +4 -4
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +4 -4
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/arrow-query-worker-entry.cjs +121 -0
- package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
- package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
- package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker-entry.js +7 -0
- package/dist/scan/arrow-query-worker-entry.js.map +1 -0
- package/dist/scan/arrow-query-worker.cjs +197 -0
- package/dist/scan/arrow-query-worker.cjs.map +7 -0
- package/dist/scan/arrow-query-worker.d.ts +47 -0
- package/dist/scan/arrow-query-worker.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker.js +101 -0
- package/dist/scan/arrow-query-worker.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +12 -13
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +14 -15
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +5 -2
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +2 -2
- package/dist/scan/parse-sql-predicate.cjs.map +2 -2
- package/dist/scan/parse-sql-predicate.js +1 -1
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +6 -6
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.d.ts +1 -1
- package/dist/scan/query-pushdown.d.ts.map +1 -1
- package/dist/scan/query-pushdown.js +3 -6
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query-scales.cjs +195 -0
- package/dist/scan/query-scales.cjs.map +7 -0
- package/dist/scan/query-scales.d.ts +47 -0
- package/dist/scan/query-scales.d.ts.map +1 -0
- package/dist/scan/query-scales.js +201 -0
- package/dist/scan/query-scales.js.map +1 -0
- package/dist/scan/query.cjs +49 -45
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts +7 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +35 -52
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +19 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +3 -4
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +11 -12
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/categories/category-mesh.d.ts +3 -10
- package/dist/schema/categories/category-mesh.d.ts.map +1 -1
- package/dist/schema/categories/category-mesh.js.map +1 -1
- package/dist/schema/categories/category-table.d.ts +2 -19
- package/dist/schema/categories/category-table.d.ts.map +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
- package/dist/schema/geometry/geoarrow.d.ts +2 -2
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/types/batch.d.ts +0 -4
- package/dist/schema/types/batch.d.ts.map +1 -1
- package/dist/schema-utils/index.cjs +420 -503
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +4 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +4 -5
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
- 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 +8 -21
- 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 -4
- 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 +13 -15
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.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 +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
- 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 +1 -1
- 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 +2 -6
- 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 +1 -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 +4 -24
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
- 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 +8 -58
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
- 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 +4 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
- package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
- package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +17 -11
- package/dist/vector-table-scan-source.cjs.map +2 -2
- package/dist/wkt/index.cjs.map +1 -1
- package/dist/wkt/index.d.ts.map +1 -1
- package/dist/wkt/index.js.map +1 -1
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/npm-tag.d.ts.map +1 -1
- package/dist/worker-utils/lib/npm-tag.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js.map +1 -1
- package/dist/worker-utils/null-worker.js.map +1 -1
- package/package.json +22 -8
- package/src/arrow-geometry/binary-features.ts +4 -1
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
- package/src/arrow-geometry/feature-table.ts +8 -21
- package/src/arrow-geometry/geojson-table.ts +2 -2
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.ts +3 -1
- package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +22 -121
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/clustering/cluster-source.ts +16 -23
- package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
- 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 -7
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +15 -15
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +5 -2
- 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 +7 -5
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +1 -1
- package/src/index.ts +1 -1
- package/src/lib/api/load.ts +2 -12
- package/src/lib/api/loader-options.ts +69 -0
- package/src/lib/api/parse-file.ts +2 -11
- package/src/lib/api/parse-in-batches.ts +8 -12
- package/src/lib/api/parse-sync.ts +3 -7
- package/src/lib/api/parse.ts +2 -6
- package/src/lib/loader-utils/native-arrow.ts +12 -38
- package/src/loader-utils/index.ts +0 -1
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
- package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
- package/src/loader-utils/lib/sources/tile-grid.ts +34 -18
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
- package/src/loader-utils/loader-types.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +7 -7
- package/src/scan/arrow-execution/filter-arrow-table.ts +1 -1
- package/src/scan/arrow-query-worker-entry.ts +8 -0
- package/src/scan/arrow-query-worker.ts +158 -0
- package/src/scan/federated-table-scan-source.ts +15 -18
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +1 -1
- package/src/scan/query-pushdown.ts +7 -7
- package/src/scan/query-scales.ts +299 -0
- package/src/scan/query.ts +68 -71
- package/src/scan/vector-table-scan-source.ts +16 -21
- package/src/schema/categories/category-mesh.ts +3 -11
- package/src/schema/categories/category-table.ts +2 -28
- package/src/schema/geometry/arrow-binary-features.ts +1 -1
- package/src/schema/geometry/geoarrow.ts +2 -2
- package/src/schema/index.ts +1 -3
- package/src/schema/types/batch.ts +0 -5
- package/src/schema-utils/index.ts +5 -11
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
- package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +11 -73
- package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
- package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
- package/src/wkt/index.ts +1 -1
- package/src/worker-utils/lib/npm-tag.ts +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
|
@@ -41,13 +41,11 @@ __export(index_exports, {
|
|
|
41
41
|
TableBatchBuilder: () => TableBatchBuilder,
|
|
42
42
|
TableConverter: () => TableConverter,
|
|
43
43
|
convert: () => convert,
|
|
44
|
-
convertArrowTable: () => convertArrowTable,
|
|
45
|
-
convertArrowTableBatch: () => convertArrowTableBatch,
|
|
46
44
|
convertArrowToSchema: () => convertArrowToSchema,
|
|
47
45
|
convertArrowToTable: () => convertArrowToTable2,
|
|
48
46
|
convertBatch: () => convertBatch,
|
|
49
47
|
convertBatches: () => convertBatches,
|
|
50
|
-
|
|
48
|
+
convertMeshToArrowTable: () => convertMeshToArrowTable,
|
|
51
49
|
convertMeshToTable: () => convertMeshToTable,
|
|
52
50
|
convertSchemaToArrow: () => convertSchemaToArrow,
|
|
53
51
|
convertTable: () => convertTable2,
|
|
@@ -78,11 +76,10 @@ __export(index_exports, {
|
|
|
78
76
|
getTableRowShape: () => getTableRowShape,
|
|
79
77
|
getTypeInfo: () => getTypeInfo,
|
|
80
78
|
isArrayRowTable: () => isArrayRowTable,
|
|
79
|
+
isArrowRecordBatch: () => isArrowRecordBatch,
|
|
81
80
|
isArrowTable: () => isArrowTable,
|
|
82
81
|
isColumnarTable: () => isColumnarTable,
|
|
83
82
|
isGeoJSONTable: () => isGeoJSONTable,
|
|
84
|
-
isNativeArrowRecordBatch: () => isNativeArrowRecordBatch,
|
|
85
|
-
isNativeArrowTable: () => isNativeArrowTable,
|
|
86
83
|
isObjectRowTable: () => isObjectRowTable,
|
|
87
84
|
isTable: () => isTable,
|
|
88
85
|
makeArrayRowIterator: () => makeArrayRowIterator,
|
|
@@ -106,8 +103,8 @@ __export(index_exports, {
|
|
|
106
103
|
serializeArrowSchema: () => serializeArrowSchema,
|
|
107
104
|
serializeArrowType: () => serializeArrowType,
|
|
108
105
|
snapshotArrowSchema: () => snapshotArrowSchema,
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
updateArrowTableSchema: () => updateArrowTableSchema,
|
|
107
|
+
updateNativeArrowTableMetadata: () => updateNativeArrowTableMetadata
|
|
111
108
|
});
|
|
112
109
|
module.exports = __toCommonJS(index_exports);
|
|
113
110
|
|
|
@@ -732,24 +729,238 @@ function deserializeArrowDictionaryKeyType(keyType) {
|
|
|
732
729
|
}
|
|
733
730
|
}
|
|
734
731
|
|
|
735
|
-
// src/schema-utils/lib/
|
|
736
|
-
|
|
732
|
+
// src/schema-utils/lib/schema/deduce-table-schema.ts
|
|
733
|
+
function deduceTableSchema(table) {
|
|
734
|
+
if (!("shape" in table)) return convertArrowToSchema(table.schema);
|
|
735
|
+
switch (table.shape) {
|
|
736
|
+
case "array-row-table":
|
|
737
|
+
case "object-row-table":
|
|
738
|
+
return deduceSchemaFromRows(table.data);
|
|
739
|
+
case "geojson-table":
|
|
740
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
741
|
+
case "columnar-table":
|
|
742
|
+
return deduceSchemaFromColumns(table.data);
|
|
743
|
+
default:
|
|
744
|
+
throw new Error("Deduce schema");
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
748
|
+
const fields = [];
|
|
749
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
750
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
751
|
+
fields.push(field);
|
|
752
|
+
}
|
|
753
|
+
return { fields, metadata: {} };
|
|
754
|
+
}
|
|
755
|
+
function deduceSchemaFromRows(rowTable) {
|
|
756
|
+
if (!rowTable.length) {
|
|
757
|
+
throw new Error("deduce from empty table");
|
|
758
|
+
}
|
|
759
|
+
const fields = [];
|
|
760
|
+
const row0 = rowTable[0];
|
|
761
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
762
|
+
const name = Array.isArray(row0) ? `column${Number(columnName) + 1}` : columnName;
|
|
763
|
+
fields.push(deduceFieldFromValue(value, name));
|
|
764
|
+
}
|
|
765
|
+
return { fields, metadata: {} };
|
|
766
|
+
}
|
|
767
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
768
|
+
if (!features.length) {
|
|
769
|
+
throw new Error("deduce from empty table");
|
|
770
|
+
}
|
|
771
|
+
const fields = [];
|
|
772
|
+
const row0 = features[0].properties || {};
|
|
773
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
774
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
775
|
+
}
|
|
776
|
+
return { fields, metadata: {} };
|
|
777
|
+
}
|
|
778
|
+
function deduceFieldFromColumn(column, name) {
|
|
779
|
+
if (ArrayBuffer.isView(column)) {
|
|
780
|
+
const type = getDataTypeFromArray(column);
|
|
781
|
+
return {
|
|
782
|
+
name,
|
|
783
|
+
type: type.type || "null",
|
|
784
|
+
nullable: type.nullable
|
|
785
|
+
// metadata: {}
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
789
|
+
const value = column[0];
|
|
790
|
+
const type = getDataTypeFromValue(value);
|
|
791
|
+
return {
|
|
792
|
+
name,
|
|
793
|
+
type,
|
|
794
|
+
nullable: true
|
|
795
|
+
// metadata: {},
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
throw new Error("empty table");
|
|
799
|
+
}
|
|
800
|
+
function deduceFieldFromValue(value, name) {
|
|
801
|
+
const type = getDataTypeFromValue(value);
|
|
802
|
+
return {
|
|
803
|
+
name,
|
|
804
|
+
type,
|
|
805
|
+
nullable: true
|
|
806
|
+
// metadata: {}
|
|
807
|
+
};
|
|
808
|
+
}
|
|
737
809
|
|
|
738
810
|
// src/lib/loader-utils/native-arrow.ts
|
|
739
|
-
function
|
|
811
|
+
function isArrowTable(value) {
|
|
740
812
|
return Boolean(
|
|
741
813
|
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
814
|
);
|
|
743
815
|
}
|
|
744
|
-
function
|
|
816
|
+
function isArrowRecordBatch(value) {
|
|
745
817
|
return Boolean(
|
|
746
818
|
value && typeof value === "object" && value[/* @__PURE__ */ Symbol.for("apache-arrow/RecordBatch")] === true
|
|
747
819
|
);
|
|
748
820
|
}
|
|
749
821
|
|
|
822
|
+
// src/schema-utils/lib/table/tables/make-table.ts
|
|
823
|
+
function makeTableFromData(data) {
|
|
824
|
+
if (isArrowTable(data)) return data;
|
|
825
|
+
let table;
|
|
826
|
+
switch (getTableShapeFromData(data)) {
|
|
827
|
+
case "array-row-table":
|
|
828
|
+
table = { shape: "array-row-table", data };
|
|
829
|
+
break;
|
|
830
|
+
case "object-row-table":
|
|
831
|
+
table = { shape: "object-row-table", data };
|
|
832
|
+
break;
|
|
833
|
+
case "columnar-table":
|
|
834
|
+
table = { shape: "columnar-table", data };
|
|
835
|
+
break;
|
|
836
|
+
default:
|
|
837
|
+
throw new Error("table");
|
|
838
|
+
}
|
|
839
|
+
const schema = deduceTableSchema(table);
|
|
840
|
+
return { ...table, schema };
|
|
841
|
+
}
|
|
842
|
+
function getTableShapeFromData(data) {
|
|
843
|
+
if (Array.isArray(data)) {
|
|
844
|
+
if (data.length === 0) {
|
|
845
|
+
throw new Error("cannot deduce type of empty table");
|
|
846
|
+
}
|
|
847
|
+
const firstRow = data[0];
|
|
848
|
+
if (Array.isArray(firstRow)) {
|
|
849
|
+
return "array-row-table";
|
|
850
|
+
}
|
|
851
|
+
if (firstRow && typeof firstRow === "object") {
|
|
852
|
+
return "object-row-table";
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
if (data && typeof data === "object") {
|
|
856
|
+
return "columnar-table";
|
|
857
|
+
}
|
|
858
|
+
throw new Error("invalid table");
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/schema-utils/lib/arrow/arrow-metadata.ts
|
|
862
|
+
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
863
|
+
function snapshotArrowSchema(schema) {
|
|
864
|
+
return deserializeArrowSchema(serializeArrowSchema(schema));
|
|
865
|
+
}
|
|
866
|
+
function mergeArrowSchemas(previous, next) {
|
|
867
|
+
if (!previous) return snapshotArrowSchema(next);
|
|
868
|
+
new arrow2.Table(previous, [new arrow2.RecordBatch(next, void 0)]);
|
|
869
|
+
const earlier = serializeArrowSchema(previous);
|
|
870
|
+
const later = serializeArrowSchema(next);
|
|
871
|
+
return deserializeArrowSchema({
|
|
872
|
+
...later,
|
|
873
|
+
fields: later.fields.map((field, index) => mergeFieldMetadata(earlier.fields[index], field)),
|
|
874
|
+
metadata: { ...earlier.metadata, ...later.metadata }
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function mergeFieldMetadata(previous, next) {
|
|
878
|
+
return {
|
|
879
|
+
...next,
|
|
880
|
+
type: mergeTypeMetadata(previous.type, next.type),
|
|
881
|
+
metadata: { ...previous.metadata, ...next.metadata }
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function mergeTypeMetadata(previous, next) {
|
|
885
|
+
if (typeof previous !== "object" || typeof next !== "object") return next;
|
|
886
|
+
if ("children" in previous && "children" in next) {
|
|
887
|
+
const previousChildren = previous.children;
|
|
888
|
+
return {
|
|
889
|
+
...next,
|
|
890
|
+
children: next.children.map(
|
|
891
|
+
(field, index) => mergeFieldMetadata(previousChildren[index], field)
|
|
892
|
+
)
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
if (previous.type === "dictionary" && next.type === "dictionary") {
|
|
896
|
+
return { ...next, dictionary: mergeTypeMetadata(previous.dictionary, next.dictionary) };
|
|
897
|
+
}
|
|
898
|
+
return next;
|
|
899
|
+
}
|
|
900
|
+
function snapshotArrowBatch(batch, schema) {
|
|
901
|
+
const snapshot = new arrow2.RecordBatch(
|
|
902
|
+
snapshotArrowSchema(schema),
|
|
903
|
+
batch.data,
|
|
904
|
+
new Map(batch.metadata)
|
|
905
|
+
);
|
|
906
|
+
if (snapshot.numRows !== batch.numRows) {
|
|
907
|
+
Object.defineProperty(snapshot, "data", { value: batch.data });
|
|
908
|
+
}
|
|
909
|
+
return snapshot;
|
|
910
|
+
}
|
|
911
|
+
function updateArrowTableSchema(table, schema) {
|
|
912
|
+
const snapshot = snapshotArrowSchema(schema);
|
|
913
|
+
const batches = table.batches.map((batch) => snapshotArrowBatch(batch, snapshot));
|
|
914
|
+
return new arrow2.Table(
|
|
915
|
+
snapshot,
|
|
916
|
+
batches.length ? batches : [new arrow2.RecordBatch(snapshotArrowSchema(snapshot), void 0)]
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
function updateNativeArrowTableMetadata(table, metadata) {
|
|
920
|
+
const schema = new arrow2.Schema(
|
|
921
|
+
table.schema.fields,
|
|
922
|
+
new Map([...table.schema.metadata, ...Object.entries(metadata)])
|
|
923
|
+
);
|
|
924
|
+
return updateArrowTableSchema(table, schema);
|
|
925
|
+
}
|
|
926
|
+
function makeArrowMetadataBatch(schema) {
|
|
927
|
+
return new arrow2.RecordBatch(snapshotArrowSchema(schema), void 0);
|
|
928
|
+
}
|
|
929
|
+
async function makeArrowTableFromBatches(batches) {
|
|
930
|
+
let schema;
|
|
931
|
+
const collected = [];
|
|
932
|
+
for await (const batch of batches) {
|
|
933
|
+
schema = mergeArrowSchemas(schema, batch.schema);
|
|
934
|
+
collected.push(snapshotArrowBatch(batch, batch.schema));
|
|
935
|
+
}
|
|
936
|
+
return schema ? new arrow2.Table(schema, collected) : null;
|
|
937
|
+
}
|
|
938
|
+
async function* refineArrowTableBatches(batches) {
|
|
939
|
+
let schema;
|
|
940
|
+
let bounds;
|
|
941
|
+
for await (const table of batches) {
|
|
942
|
+
const localBounds = table.schema.metadata.get("boundingBox");
|
|
943
|
+
const nextSchema = snapshotArrowSchema(table.schema);
|
|
944
|
+
if (localBounds) {
|
|
945
|
+
const nextBounds = JSON.parse(localBounds);
|
|
946
|
+
bounds = bounds ? [
|
|
947
|
+
nextBounds[0].map((value, index) => Math.min(bounds[0][index], value)),
|
|
948
|
+
nextBounds[1].map((value, index) => Math.max(bounds[1][index], value))
|
|
949
|
+
] : nextBounds;
|
|
950
|
+
nextSchema.metadata.set("boundingBox", JSON.stringify(bounds));
|
|
951
|
+
}
|
|
952
|
+
schema = mergeArrowSchemas(schema, nextSchema);
|
|
953
|
+
const data = updateArrowTableSchema(table, schema);
|
|
954
|
+
if (localBounds) {
|
|
955
|
+
for (const recordBatch of data.batches) recordBatch.metadata.set("boundingBox", localBounds);
|
|
956
|
+
}
|
|
957
|
+
yield data;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
750
961
|
// src/schema-utils/lib/table/tables/table-accessors.ts
|
|
751
962
|
function isTable(table) {
|
|
752
|
-
if (
|
|
963
|
+
if (isArrowTable(table)) return true;
|
|
753
964
|
const shape = typeof table === "object" && table?.shape;
|
|
754
965
|
switch (shape) {
|
|
755
966
|
case "array-row-table":
|
|
@@ -759,8 +970,6 @@ function isTable(table) {
|
|
|
759
970
|
return Array.isArray(table.features);
|
|
760
971
|
case "columnar-table":
|
|
761
972
|
return Boolean(table.data && typeof table.data === "object");
|
|
762
|
-
case "arrow-table":
|
|
763
|
-
return Boolean(table?.data?.numRows !== void 0);
|
|
764
973
|
default:
|
|
765
974
|
return false;
|
|
766
975
|
}
|
|
@@ -773,8 +982,6 @@ function getTableLength(table) {
|
|
|
773
982
|
return table.data.length;
|
|
774
983
|
case "geojson-table":
|
|
775
984
|
return table.features.length;
|
|
776
|
-
case "arrow-table":
|
|
777
|
-
return getTableLength(table.data);
|
|
778
985
|
case "columnar-table":
|
|
779
986
|
for (const column of Object.values(table.data)) {
|
|
780
987
|
return column.length || 0;
|
|
@@ -801,8 +1008,6 @@ function getTableNumCols(table) {
|
|
|
801
1008
|
return Object.keys(table.features[0]).length;
|
|
802
1009
|
case "columnar-table":
|
|
803
1010
|
return Object.keys(table.data).length;
|
|
804
|
-
case "arrow-table":
|
|
805
|
-
return getTableNumCols(table.data);
|
|
806
1011
|
default:
|
|
807
1012
|
throw new Error("table");
|
|
808
1013
|
}
|
|
@@ -820,8 +1025,6 @@ function getTableCell(table, rowIndex, columnName) {
|
|
|
820
1025
|
case "columnar-table":
|
|
821
1026
|
const column = table.data[columnName];
|
|
822
1027
|
return column[rowIndex];
|
|
823
|
-
case "arrow-table":
|
|
824
|
-
return getTableCell(table.data, rowIndex, columnName);
|
|
825
1028
|
default:
|
|
826
1029
|
throw new Error("todo");
|
|
827
1030
|
}
|
|
@@ -841,8 +1044,6 @@ function getTableCellAt(table, rowIndex, columnIndex) {
|
|
|
841
1044
|
const columnName3 = getTableColumnName(table, columnIndex);
|
|
842
1045
|
const column = table.data[columnName3];
|
|
843
1046
|
return column[rowIndex];
|
|
844
|
-
case "arrow-table":
|
|
845
|
-
return getTableCellAt(table.data, rowIndex, columnIndex);
|
|
846
1047
|
default:
|
|
847
1048
|
throw new Error("todo");
|
|
848
1049
|
}
|
|
@@ -916,8 +1117,6 @@ function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
|
916
1117
|
}
|
|
917
1118
|
return objectRow;
|
|
918
1119
|
}
|
|
919
|
-
case "arrow-table":
|
|
920
|
-
return getTableRowAsObject(table.data, rowIndex, target, copy);
|
|
921
1120
|
default:
|
|
922
1121
|
throw new Error("shape");
|
|
923
1122
|
}
|
|
@@ -968,8 +1167,6 @@ function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
|
968
1167
|
}
|
|
969
1168
|
return arrayRow;
|
|
970
1169
|
}
|
|
971
|
-
case "arrow-table":
|
|
972
|
-
return getTableRowAsArray(table.data, rowIndex, target, copy);
|
|
973
1170
|
default:
|
|
974
1171
|
throw new Error("shape");
|
|
975
1172
|
}
|
|
@@ -999,159 +1196,78 @@ function* makeObjectRowIterator(table, target = {}) {
|
|
|
999
1196
|
}
|
|
1000
1197
|
}
|
|
1001
1198
|
|
|
1002
|
-
// src/schema-utils/lib/
|
|
1003
|
-
function
|
|
1004
|
-
|
|
1199
|
+
// src/schema-utils/lib/table/batches/make-table-from-batches.ts
|
|
1200
|
+
async function makeTableFromBatches(batchIterator) {
|
|
1201
|
+
let arrayRows;
|
|
1202
|
+
let objectRows;
|
|
1203
|
+
let features;
|
|
1204
|
+
let shape = null;
|
|
1205
|
+
let schema;
|
|
1206
|
+
const arrowBatches = [];
|
|
1207
|
+
for await (const batch of batchIterator) {
|
|
1208
|
+
const batchShape = isArrowRecordBatch(batch) ? "arrow" : batch.shape;
|
|
1209
|
+
shape ??= batchShape;
|
|
1210
|
+
if (shape !== batchShape) throw new Error("Batches must have the same shape");
|
|
1211
|
+
if (isArrowRecordBatch(batch)) {
|
|
1212
|
+
arrowBatches.push(batch);
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
schema = schema || batch.schema;
|
|
1216
|
+
switch (batch.shape) {
|
|
1217
|
+
case "array-row-table":
|
|
1218
|
+
arrayRows = arrayRows || [];
|
|
1219
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1220
|
+
const row = batch.data[rowIndex];
|
|
1221
|
+
arrayRows.push(row);
|
|
1222
|
+
}
|
|
1223
|
+
break;
|
|
1224
|
+
case "object-row-table":
|
|
1225
|
+
objectRows = objectRows || [];
|
|
1226
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1227
|
+
const row = batch.data[rowIndex];
|
|
1228
|
+
objectRows.push(row);
|
|
1229
|
+
}
|
|
1230
|
+
break;
|
|
1231
|
+
case "geojson-table":
|
|
1232
|
+
features = features || [];
|
|
1233
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1234
|
+
const row = batch.features[rowIndex];
|
|
1235
|
+
features.push(row);
|
|
1236
|
+
}
|
|
1237
|
+
break;
|
|
1238
|
+
case "columnar-table":
|
|
1239
|
+
default:
|
|
1240
|
+
throw new Error("shape");
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (!shape) {
|
|
1244
|
+
return null;
|
|
1245
|
+
}
|
|
1246
|
+
switch (shape) {
|
|
1247
|
+
case "arrow":
|
|
1248
|
+
return makeArrowTableFromBatches(arrowBatches);
|
|
1005
1249
|
case "array-row-table":
|
|
1250
|
+
return { shape: "array-row-table", data: arrayRows, schema };
|
|
1006
1251
|
case "object-row-table":
|
|
1007
|
-
return
|
|
1252
|
+
return { shape: "object-row-table", data: objectRows, schema };
|
|
1008
1253
|
case "geojson-table":
|
|
1009
|
-
return
|
|
1010
|
-
case "columnar-table":
|
|
1011
|
-
return deduceSchemaFromColumns(table.data);
|
|
1012
|
-
case "arrow-table":
|
|
1254
|
+
return { shape: "geojson-table", type: "FeatureCollection", features, schema };
|
|
1013
1255
|
default:
|
|
1014
|
-
|
|
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));
|
|
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
|
-
};
|
|
1256
|
+
return null;
|
|
1067
1257
|
}
|
|
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
|
-
};
|
|
1078
1258
|
}
|
|
1079
1259
|
|
|
1080
1260
|
// src/schema-utils/lib/table/tables/table-column.ts
|
|
1081
|
-
function makeColumnFromField(field, length) {
|
|
1082
|
-
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
1083
|
-
return new ArrayType(length);
|
|
1084
|
-
}
|
|
1085
|
-
|
|
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
|
-
};
|
|
1261
|
+
function makeColumnFromField(field, length) {
|
|
1262
|
+
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
1263
|
+
return new ArrayType(length);
|
|
1151
1264
|
}
|
|
1152
1265
|
|
|
1266
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
1267
|
+
var arrow4 = __toESM(require("apache-arrow"), 1);
|
|
1268
|
+
|
|
1153
1269
|
// src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts
|
|
1154
|
-
var
|
|
1270
|
+
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
1155
1271
|
function* sliceNativeArrowBatches(table, batchSize) {
|
|
1156
1272
|
if (batchSize !== void 0 && (!Number.isSafeInteger(batchSize) || batchSize < 1)) {
|
|
1157
1273
|
throw new RangeError("batchSize must be a positive integer");
|
|
@@ -1171,24 +1287,20 @@ function* makeArrowRecordBatchIterator(table, options) {
|
|
|
1171
1287
|
yield* sliceNativeArrowBatches(table, options?.batchSize);
|
|
1172
1288
|
return;
|
|
1173
1289
|
}
|
|
1174
|
-
yield*
|
|
1290
|
+
yield* makePortableTableRecordBatchIterator(table, options);
|
|
1175
1291
|
}
|
|
1176
|
-
function*
|
|
1177
|
-
if (table.shape === "arrow-table") {
|
|
1178
|
-
yield* sliceNativeArrowBatches(table.data, options?.batchSize);
|
|
1179
|
-
return;
|
|
1180
|
-
}
|
|
1292
|
+
function* makePortableTableRecordBatchIterator(table, options) {
|
|
1181
1293
|
const arrowSchema = convertSchemaToArrow(table.schema);
|
|
1182
1294
|
const length = getTableLength(table);
|
|
1183
1295
|
const numColumns = getTableNumCols(table);
|
|
1184
1296
|
const batchSize = options?.batchSize || length;
|
|
1185
1297
|
const builders = arrowSchema?.fields.map(
|
|
1186
|
-
(arrowField) =>
|
|
1298
|
+
(arrowField) => arrow3.makeBuilder({
|
|
1187
1299
|
type: arrowField.type,
|
|
1188
1300
|
nullValues: [null, void 0]
|
|
1189
1301
|
})
|
|
1190
1302
|
);
|
|
1191
|
-
const structField = new
|
|
1303
|
+
const structField = new arrow3.Struct(arrowSchema.fields);
|
|
1192
1304
|
let batchLength = 0;
|
|
1193
1305
|
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1194
1306
|
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
@@ -1199,15 +1311,15 @@ function* makeWrappedTableRecordBatchIterator(table, options) {
|
|
|
1199
1311
|
batchLength++;
|
|
1200
1312
|
if (batchLength >= batchSize) {
|
|
1201
1313
|
const datas = builders.map((builder) => builder.flush());
|
|
1202
|
-
const structData = new
|
|
1203
|
-
yield new
|
|
1314
|
+
const structData = new arrow3.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1315
|
+
yield new arrow3.RecordBatch(arrowSchema, structData);
|
|
1204
1316
|
batchLength = 0;
|
|
1205
1317
|
}
|
|
1206
1318
|
}
|
|
1207
1319
|
if (batchLength > 0) {
|
|
1208
1320
|
const datas = builders.map((builder) => builder.flush());
|
|
1209
|
-
const structData = new
|
|
1210
|
-
yield new
|
|
1321
|
+
const structData = new arrow3.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1322
|
+
yield new arrow3.RecordBatch(arrowSchema, structData);
|
|
1211
1323
|
batchLength = 0;
|
|
1212
1324
|
}
|
|
1213
1325
|
builders.map((builder) => builder.finish());
|
|
@@ -1216,19 +1328,10 @@ function* makeWrappedTableRecordBatchIterator(table, options) {
|
|
|
1216
1328
|
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
1217
1329
|
function convertTableToArrow(table, options) {
|
|
1218
1330
|
if (!("shape" in table)) return table;
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
// TODO - optimized implementation is possible
|
|
1224
|
-
// return convertColumnarTableToArrow(table, options);
|
|
1225
|
-
// fall through
|
|
1226
|
-
default:
|
|
1227
|
-
const schema = table.schema ?? deduceTableSchema(table);
|
|
1228
|
-
return new arrow3.Table(convertSchemaToArrow(schema), [
|
|
1229
|
-
...makeWrappedTableRecordBatchIterator({ ...table, schema }, options)
|
|
1230
|
-
]);
|
|
1231
|
-
}
|
|
1331
|
+
const schema = table.schema ?? deduceTableSchema(table);
|
|
1332
|
+
return new arrow4.Table(convertSchemaToArrow(schema), [
|
|
1333
|
+
...makePortableTableRecordBatchIterator({ ...table, schema }, options)
|
|
1334
|
+
]);
|
|
1232
1335
|
}
|
|
1233
1336
|
function convertArrowToTable(arrowTable, shape) {
|
|
1234
1337
|
switch (shape) {
|
|
@@ -1258,7 +1361,7 @@ function convertArrowToColumnarTable(arrowTable) {
|
|
|
1258
1361
|
const columns = {};
|
|
1259
1362
|
for (const field of arrowTable.schema.fields) {
|
|
1260
1363
|
const arrowColumn = arrowTable.getChild(field.name);
|
|
1261
|
-
const values = arrowColumn?.toArray();
|
|
1364
|
+
const values = arrowColumn?.nullCount ? Array.from(arrowColumn) : arrowColumn?.toArray();
|
|
1262
1365
|
columns[field.name] = values;
|
|
1263
1366
|
}
|
|
1264
1367
|
const schema = convertArrowToSchema(arrowTable.schema);
|
|
@@ -1283,236 +1386,71 @@ function convertArrowToGeoJSONTable(arrowTable) {
|
|
|
1283
1386
|
};
|
|
1284
1387
|
}
|
|
1285
1388
|
|
|
1286
|
-
// src/schema-utils/lib/table/tables/convert-
|
|
1287
|
-
function
|
|
1288
|
-
|
|
1289
|
-
return
|
|
1290
|
-
|
|
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)) {
|
|
1304
|
-
case "array-row-table":
|
|
1305
|
-
table = { shape: "array-row-table", data };
|
|
1306
|
-
break;
|
|
1389
|
+
// src/schema-utils/lib/table/tables/convert-table.ts
|
|
1390
|
+
function convertTable(table, shape) {
|
|
1391
|
+
if (shape === "arrow") return convertTableToArrow(table);
|
|
1392
|
+
if (!("shape" in table)) return convertArrowToTable(table, shape);
|
|
1393
|
+
switch (shape) {
|
|
1307
1394
|
case "object-row-table":
|
|
1308
|
-
|
|
1309
|
-
|
|
1395
|
+
return convertToObjectRowTable(table);
|
|
1396
|
+
case "array-row-table":
|
|
1397
|
+
return convertToArrayRowTable(table);
|
|
1310
1398
|
case "columnar-table":
|
|
1311
|
-
|
|
1312
|
-
break;
|
|
1399
|
+
return convertToColumnarTable(table);
|
|
1313
1400
|
default:
|
|
1314
|
-
throw new Error(
|
|
1401
|
+
throw new Error(shape);
|
|
1315
1402
|
}
|
|
1316
|
-
const schema = deduceTableSchema(table);
|
|
1317
|
-
return { ...table, schema };
|
|
1318
1403
|
}
|
|
1319
|
-
function
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
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";
|
|
1330
|
-
}
|
|
1404
|
+
function convertToColumnarTable(table) {
|
|
1405
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
1406
|
+
const fields = schema.fields;
|
|
1407
|
+
if (table.shape === "columnar-table") {
|
|
1408
|
+
return { ...table, schema };
|
|
1331
1409
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1410
|
+
const length = getTableLength(table);
|
|
1411
|
+
const columns = {};
|
|
1412
|
+
for (const field of fields) {
|
|
1413
|
+
const column = makeColumnFromField(field, length);
|
|
1414
|
+
columns[field.name] = column;
|
|
1415
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1416
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
1417
|
+
}
|
|
1334
1418
|
}
|
|
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) {
|
|
1358
1419
|
return {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1420
|
+
shape: "columnar-table",
|
|
1421
|
+
schema,
|
|
1422
|
+
data: columns
|
|
1362
1423
|
};
|
|
1363
1424
|
}
|
|
1364
|
-
function
|
|
1365
|
-
if (
|
|
1366
|
-
|
|
1367
|
-
const previousChildren = previous.children;
|
|
1368
|
-
return {
|
|
1369
|
-
...next,
|
|
1370
|
-
children: next.children.map(
|
|
1371
|
-
(field, index) => mergeFieldMetadata(previousChildren[index], field)
|
|
1372
|
-
)
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1375
|
-
if (previous.type === "dictionary" && next.type === "dictionary") {
|
|
1376
|
-
return { ...next, dictionary: mergeTypeMetadata(previous.dictionary, next.dictionary) };
|
|
1377
|
-
}
|
|
1378
|
-
return next;
|
|
1379
|
-
}
|
|
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
|
-
);
|
|
1425
|
+
function convertToArrayRowTable(table) {
|
|
1426
|
+
if (table.shape === "array-row-table") {
|
|
1427
|
+
return table;
|
|
1409
1428
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
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) };
|
|
1429
|
+
const length = getTableLength(table);
|
|
1430
|
+
const data = new Array(length);
|
|
1431
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1432
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
1437
1433
|
}
|
|
1434
|
+
return {
|
|
1435
|
+
shape: "array-row-table",
|
|
1436
|
+
schema: table.schema,
|
|
1437
|
+
data
|
|
1438
|
+
};
|
|
1438
1439
|
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
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;
|
|
1440
|
+
function convertToObjectRowTable(table) {
|
|
1441
|
+
if (table.shape === "object-row-table") {
|
|
1442
|
+
return table;
|
|
1498
1443
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
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;
|
|
1444
|
+
const length = getTableLength(table);
|
|
1445
|
+
const data = new Array(length);
|
|
1446
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1447
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
1515
1448
|
}
|
|
1449
|
+
return {
|
|
1450
|
+
shape: "object-row-table",
|
|
1451
|
+
schema: table.schema,
|
|
1452
|
+
data
|
|
1453
|
+
};
|
|
1516
1454
|
}
|
|
1517
1455
|
|
|
1518
1456
|
// src/schema-utils/lib/table/tables/table-converter/convert-tables.ts
|
|
@@ -1534,14 +1472,14 @@ function convertTables(table, shape) {
|
|
|
1534
1472
|
// src/schema-utils/lib/table/tables/table-converter/table-converter.ts
|
|
1535
1473
|
var TableConverter = {
|
|
1536
1474
|
id: "table",
|
|
1537
|
-
from: ["object-row-table", "array-row-table", "columnar-table", "arrow
|
|
1475
|
+
from: ["object-row-table", "array-row-table", "columnar-table", "arrow"],
|
|
1538
1476
|
to: ["object-row-table", "array-row-table", "columnar-table", "arrow"],
|
|
1539
1477
|
canConvert(sourceShape, targetShape) {
|
|
1540
1478
|
return sourceShape !== targetShape;
|
|
1541
1479
|
},
|
|
1542
1480
|
detectInputShape(input) {
|
|
1543
|
-
if (
|
|
1544
|
-
if (typeof input === "object" && input !== null && "shape" in input && typeof input.shape === "string" && ["object-row-table", "array-row-table", "columnar-table"
|
|
1481
|
+
if (isArrowTable(input)) return "arrow";
|
|
1482
|
+
if (typeof input === "object" && input !== null && "shape" in input && typeof input.shape === "string" && ["object-row-table", "array-row-table", "columnar-table"].includes(input.shape)) {
|
|
1545
1483
|
return input.shape;
|
|
1546
1484
|
}
|
|
1547
1485
|
return null;
|
|
@@ -1632,7 +1570,7 @@ function makeBatchFromTable(table) {
|
|
|
1632
1570
|
}
|
|
1633
1571
|
|
|
1634
1572
|
// src/schema-utils/lib/table/query-arrow-table.ts
|
|
1635
|
-
var
|
|
1573
|
+
var arrow5 = __toESM(require("apache-arrow"), 1);
|
|
1636
1574
|
function queryArrowTable(table, options = {}, filterRows) {
|
|
1637
1575
|
const availableColumns = table.schema.fields.map((field) => field.name);
|
|
1638
1576
|
const selectedColumns = options.columns ? [...options.columns] : availableColumns;
|
|
@@ -1664,7 +1602,7 @@ function selectArrowTableRows(table, rowIndices, columns, limit) {
|
|
|
1664
1602
|
return createArrowTableFromRowIndices(table, selectedColumns, limitedRowIndices);
|
|
1665
1603
|
}
|
|
1666
1604
|
function createArrowTableFromRowIndices(sourceData, selectedColumns, rowIndices) {
|
|
1667
|
-
const schema = new
|
|
1605
|
+
const schema = new arrow5.Schema(
|
|
1668
1606
|
selectedColumns.map(
|
|
1669
1607
|
(columnName) => sourceData.schema.fields.find((field) => field.name === columnName)
|
|
1670
1608
|
),
|
|
@@ -1675,7 +1613,7 @@ function createArrowTableFromRowIndices(sourceData, selectedColumns, rowIndices)
|
|
|
1675
1613
|
const sourceVector = sourceData.getChild(columnName);
|
|
1676
1614
|
return [
|
|
1677
1615
|
columnName,
|
|
1678
|
-
|
|
1616
|
+
arrow5.vectorFromArray(
|
|
1679
1617
|
rowIndices.map((rowIndex) => sourceVector?.get(rowIndex)),
|
|
1680
1618
|
sourceVector?.type
|
|
1681
1619
|
)
|
|
@@ -1683,20 +1621,20 @@ function createArrowTableFromRowIndices(sourceData, selectedColumns, rowIndices)
|
|
|
1683
1621
|
})
|
|
1684
1622
|
);
|
|
1685
1623
|
const children = selectedColumns.map((columnName) => vectors[columnName].data[0]);
|
|
1686
|
-
const data = new
|
|
1687
|
-
new
|
|
1624
|
+
const data = new arrow5.Data(
|
|
1625
|
+
new arrow5.Struct(schema.fields),
|
|
1688
1626
|
0,
|
|
1689
1627
|
rowIndices.length,
|
|
1690
1628
|
0,
|
|
1691
1629
|
void 0,
|
|
1692
1630
|
children
|
|
1693
1631
|
);
|
|
1694
|
-
return new
|
|
1632
|
+
return new arrow5.Table(schema, new arrow5.RecordBatch(schema, data));
|
|
1695
1633
|
}
|
|
1696
1634
|
|
|
1697
1635
|
// src/schema-utils/lib/table/batches/convert-batches.ts
|
|
1698
1636
|
function convertBatch(batch, shape) {
|
|
1699
|
-
if (
|
|
1637
|
+
if (isArrowRecordBatch(batch)) {
|
|
1700
1638
|
if (shape === "arrow") return batch;
|
|
1701
1639
|
throw new Error("Convert a native RecordBatch as a table to select a row or column layout");
|
|
1702
1640
|
}
|
|
@@ -1709,9 +1647,6 @@ function convertBatch(batch, shape) {
|
|
|
1709
1647
|
return { ...batch, ...convertTable(batch, "columnar-table") };
|
|
1710
1648
|
case "arrow": {
|
|
1711
1649
|
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
1650
|
return table.batches[0] ?? makeArrowMetadataBatch(table.schema);
|
|
1716
1651
|
}
|
|
1717
1652
|
default:
|
|
@@ -1720,7 +1655,7 @@ function convertBatch(batch, shape) {
|
|
|
1720
1655
|
}
|
|
1721
1656
|
async function* convertBatches(batches, shape) {
|
|
1722
1657
|
for await (const batch of batches) {
|
|
1723
|
-
if (
|
|
1658
|
+
if (isArrowRecordBatch(batch)) {
|
|
1724
1659
|
if (shape !== "arrow") throw new Error("Expected a loaders.gl table batch");
|
|
1725
1660
|
yield batch;
|
|
1726
1661
|
continue;
|
|
@@ -1760,15 +1695,12 @@ function isColumnarTable(table) {
|
|
|
1760
1695
|
function isGeoJSONTable(table) {
|
|
1761
1696
|
return table.shape === "geojson-table";
|
|
1762
1697
|
}
|
|
1763
|
-
function isArrowTable(table) {
|
|
1764
|
-
return table.shape === "arrow-table";
|
|
1765
|
-
}
|
|
1766
1698
|
|
|
1767
1699
|
// src/schema-utils/lib/table/batch-builder/table-batch-builder.ts
|
|
1768
1700
|
var import_apache_arrow = require("apache-arrow");
|
|
1769
1701
|
|
|
1770
1702
|
// src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts
|
|
1771
|
-
var
|
|
1703
|
+
var arrow6 = __toESM(require("apache-arrow"), 1);
|
|
1772
1704
|
var ArrowTableBuilder = class {
|
|
1773
1705
|
schema;
|
|
1774
1706
|
arrowSchema;
|
|
@@ -1778,7 +1710,7 @@ var ArrowTableBuilder = class {
|
|
|
1778
1710
|
this.arrowSchema = convertSchemaToArrow(schema, options);
|
|
1779
1711
|
this.schema = options?.viewTypes && options.viewTypes !== "never" ? convertArrowToSchema(this.arrowSchema) : schema;
|
|
1780
1712
|
this.arrowBuilders = this.arrowSchema.fields.map(
|
|
1781
|
-
(field) =>
|
|
1713
|
+
(field) => arrow6.makeBuilder({ type: field.type, nullValues: [null, void 0] })
|
|
1782
1714
|
);
|
|
1783
1715
|
this.length = 0;
|
|
1784
1716
|
}
|
|
@@ -1814,7 +1746,7 @@ var ArrowTableBuilder = class {
|
|
|
1814
1746
|
finishTable() {
|
|
1815
1747
|
const batch = this._getArrowRecordBatch();
|
|
1816
1748
|
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
1817
|
-
return new
|
|
1749
|
+
return new arrow6.Table(batch);
|
|
1818
1750
|
}
|
|
1819
1751
|
/** Extract a record batch flushing the currently accumulated data in the builders */
|
|
1820
1752
|
_getArrowRecordBatch() {
|
|
@@ -1822,9 +1754,9 @@ var ArrowTableBuilder = class {
|
|
|
1822
1754
|
const arrowDatas = arrowBuilders.map((builder) => builder.flush());
|
|
1823
1755
|
const length = arrowDatas[0]?.length || this.length;
|
|
1824
1756
|
this.length = 0;
|
|
1825
|
-
const structField = new
|
|
1826
|
-
const arrowStructData = new
|
|
1827
|
-
const arrowRecordBatch = new
|
|
1757
|
+
const structField = new arrow6.Struct(arrowSchema.fields);
|
|
1758
|
+
const arrowStructData = new arrow6.Data(structField, 0, length, 0, void 0, arrowDatas);
|
|
1759
|
+
const arrowRecordBatch = new arrow6.RecordBatch(
|
|
1828
1760
|
snapshotArrowSchema(arrowSchema),
|
|
1829
1761
|
arrowStructData
|
|
1830
1762
|
);
|
|
@@ -2051,10 +1983,8 @@ var ArrowLikeVector = class {
|
|
|
2051
1983
|
return getTableCell(this.table, rowIndex, this.columnName);
|
|
2052
1984
|
}
|
|
2053
1985
|
toArray() {
|
|
1986
|
+
if (!("shape" in this.table)) return this.table.getChild(this.columnName)?.toArray();
|
|
2054
1987
|
switch (this.table.shape) {
|
|
2055
|
-
case "arrow-table":
|
|
2056
|
-
const arrowTable = this.table.data;
|
|
2057
|
-
return arrowTable.getChild(this.columnName)?.toArray();
|
|
2058
1988
|
case "columnar-table":
|
|
2059
1989
|
return this.table.data[this.columnName];
|
|
2060
1990
|
default:
|
|
@@ -2066,14 +1996,15 @@ var ArrowLikeTable = class {
|
|
|
2066
1996
|
schema;
|
|
2067
1997
|
table;
|
|
2068
1998
|
constructor(table) {
|
|
2069
|
-
const schema = table.schema || deduceTableSchema(table);
|
|
1999
|
+
const schema = "shape" in table ? table.schema || deduceTableSchema(table) : deduceTableSchema(table);
|
|
2070
2000
|
this.schema = new ArrowLikeSchema(schema.fields, schema.metadata);
|
|
2071
|
-
this.table = { ...table, schema };
|
|
2001
|
+
this.table = "shape" in table ? { ...table, schema } : table;
|
|
2072
2002
|
}
|
|
2073
2003
|
// get schema() {
|
|
2074
2004
|
// return this.table.schema;
|
|
2075
2005
|
// }
|
|
2076
2006
|
get data() {
|
|
2007
|
+
if (!("shape" in this.table)) return this.table;
|
|
2077
2008
|
return this.table.shape === "geojson-table" ? this.table.features : this.table.data;
|
|
2078
2009
|
}
|
|
2079
2010
|
get numCols() {
|
|
@@ -2198,34 +2129,34 @@ function decodeFloat16(value) {
|
|
|
2198
2129
|
}
|
|
2199
2130
|
|
|
2200
2131
|
// src/schema/categories/category-mesh.ts
|
|
2201
|
-
var
|
|
2202
|
-
var meshArrowSchema = new
|
|
2203
|
-
new
|
|
2132
|
+
var arrow7 = __toESM(require("apache-arrow"), 1);
|
|
2133
|
+
var meshArrowSchema = new arrow7.Schema([
|
|
2134
|
+
new arrow7.Field(
|
|
2204
2135
|
"POSITION",
|
|
2205
|
-
new
|
|
2136
|
+
new arrow7.FixedSizeList(3, new arrow7.Field("value", new arrow7.Float32(), false)),
|
|
2206
2137
|
false
|
|
2207
2138
|
)
|
|
2208
2139
|
]);
|
|
2209
|
-
var indexedMeshArrowSchema = new
|
|
2140
|
+
var indexedMeshArrowSchema = new arrow7.Schema([
|
|
2210
2141
|
...meshArrowSchema.fields,
|
|
2211
|
-
new
|
|
2142
|
+
new arrow7.Field(
|
|
2212
2143
|
"indices",
|
|
2213
|
-
new
|
|
2144
|
+
new arrow7.List(new arrow7.Field("item", new arrow7.Uint32(), false)),
|
|
2214
2145
|
true
|
|
2215
2146
|
)
|
|
2216
2147
|
]);
|
|
2217
2148
|
|
|
2218
2149
|
// src/schema-utils/lib/mesh/convert-mesh-to-table.ts
|
|
2219
|
-
var
|
|
2150
|
+
var arrow9 = __toESM(require("apache-arrow"), 1);
|
|
2220
2151
|
|
|
2221
2152
|
// src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts
|
|
2222
|
-
var
|
|
2153
|
+
var arrow8 = __toESM(require("apache-arrow"), 1);
|
|
2223
2154
|
function getFixedSizeListSize(vector) {
|
|
2224
|
-
return vector.type instanceof
|
|
2155
|
+
return vector.type instanceof arrow8.FixedSizeList ? vector.type.listSize : 1;
|
|
2225
2156
|
}
|
|
2226
2157
|
function getFixedSizeListVector(typedArray, stride, logicalType) {
|
|
2227
2158
|
const data = getFixedSizeListData(typedArray, stride, logicalType);
|
|
2228
|
-
return new
|
|
2159
|
+
return new arrow8.Vector([data]);
|
|
2229
2160
|
}
|
|
2230
2161
|
function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
2231
2162
|
const listType = getFixedSizeListType(typedArray, stride, logicalType);
|
|
@@ -2233,13 +2164,13 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
2233
2164
|
const storage = logicalType === "float16" && isNativeFloat16Array(typedArray) ? getFloat16Storage(typedArray) : typedArray;
|
|
2234
2165
|
const buffers = {
|
|
2235
2166
|
// valueOffsets: undefined,
|
|
2236
|
-
[
|
|
2167
|
+
[arrow8.BufferType.DATA]: storage
|
|
2237
2168
|
// values
|
|
2238
2169
|
// nullBitmap: undefined,
|
|
2239
2170
|
// typeIds: undefined
|
|
2240
2171
|
};
|
|
2241
|
-
const nestedData = new
|
|
2242
|
-
const data = new
|
|
2172
|
+
const nestedData = new arrow8.Data(nestedType, 0, storage.length, 0, buffers);
|
|
2173
|
+
const data = new arrow8.Data(
|
|
2243
2174
|
listType,
|
|
2244
2175
|
0,
|
|
2245
2176
|
storage.length / stride,
|
|
@@ -2252,7 +2183,7 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
2252
2183
|
function getFixedSizeListType(typedArray, stride, logicalType) {
|
|
2253
2184
|
const type = logicalType || getDataTypeFromArray(typedArray).type;
|
|
2254
2185
|
const arrowType = deserializeArrowType(type);
|
|
2255
|
-
const listType = new
|
|
2186
|
+
const listType = new arrow8.FixedSizeList(stride, new arrow8.Field("value", arrowType, false));
|
|
2256
2187
|
return listType;
|
|
2257
2188
|
}
|
|
2258
2189
|
|
|
@@ -2263,7 +2194,7 @@ function convertMeshToTable(mesh, shape) {
|
|
|
2263
2194
|
case "columnar-table":
|
|
2264
2195
|
return convertMeshToColumnarTable(mesh);
|
|
2265
2196
|
case "arrow":
|
|
2266
|
-
return
|
|
2197
|
+
return convertMeshToArrowTable(mesh);
|
|
2267
2198
|
default:
|
|
2268
2199
|
throw new Error(shape);
|
|
2269
2200
|
}
|
|
@@ -2282,7 +2213,7 @@ function convertMeshToColumnarTable(mesh) {
|
|
|
2282
2213
|
indices: hasIndices ? mesh.indices : void 0
|
|
2283
2214
|
};
|
|
2284
2215
|
}
|
|
2285
|
-
function
|
|
2216
|
+
function convertMeshToArrowTable(mesh) {
|
|
2286
2217
|
return makeMeshArrowTable(mesh.attributes, {
|
|
2287
2218
|
schema: mesh.schema,
|
|
2288
2219
|
topology: mesh.topology,
|
|
@@ -2303,35 +2234,27 @@ function makeMeshArrowTable(attributes, options = {}) {
|
|
|
2303
2234
|
fields.push(
|
|
2304
2235
|
getAttributeArrowField(options.schema, attributeName, column, attribute.componentType)
|
|
2305
2236
|
);
|
|
2306
|
-
if (attributeName ===
|
|
2237
|
+
if (attributeName === attributeNames[0] && options.indices?.value?.length) {
|
|
2307
2238
|
const indicesField = indexedMeshArrowSchema.fields.find((field) => field.name === "indices");
|
|
2308
2239
|
columns.indices = getIndicesVector(options.indices.value, column.length, indicesField.type);
|
|
2309
2240
|
fields.push(indicesField);
|
|
2310
2241
|
}
|
|
2311
2242
|
}
|
|
2312
|
-
const arrowSchema = new
|
|
2313
|
-
|
|
2314
|
-
const schema = serializeArrowSchema(table.schema);
|
|
2315
|
-
return {
|
|
2316
|
-
shape: "arrow-table",
|
|
2317
|
-
schema,
|
|
2318
|
-
data: table,
|
|
2319
|
-
topology: options.topology || "point-list",
|
|
2320
|
-
indices: options.indices
|
|
2321
|
-
};
|
|
2243
|
+
const arrowSchema = new arrow9.Schema(fields, getMeshArrowMetadata(options));
|
|
2244
|
+
return columns[attributeNames[0]]?.length === 0 ? new arrow9.Table(arrowSchema) : new arrow9.Table(arrowSchema, columns);
|
|
2322
2245
|
}
|
|
2323
2246
|
function getAttributeArrowVector(value, size, componentType) {
|
|
2324
2247
|
if (componentType === "float16") {
|
|
2325
2248
|
const storage = isNativeFloat16Array(value) ? getFloat16Storage(value) : value;
|
|
2326
2249
|
if (size === 1) {
|
|
2327
|
-
const data = new
|
|
2328
|
-
[
|
|
2250
|
+
const data = new arrow9.Data(new arrow9.Float16(), 0, storage.length, 0, {
|
|
2251
|
+
[arrow9.BufferType.DATA]: storage
|
|
2329
2252
|
});
|
|
2330
|
-
return new
|
|
2253
|
+
return new arrow9.Vector([data]);
|
|
2331
2254
|
}
|
|
2332
2255
|
return getFixedSizeListVector(value, size, componentType);
|
|
2333
2256
|
}
|
|
2334
|
-
return size === 1 ?
|
|
2257
|
+
return size === 1 ? arrow9.makeVector(value) : getFixedSizeListVector(value, size);
|
|
2335
2258
|
}
|
|
2336
2259
|
function getOrderedAttributeNames(attributes) {
|
|
2337
2260
|
const attributeNames = Object.keys(attributes);
|
|
@@ -2357,7 +2280,7 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
|
|
|
2357
2280
|
for (const [key, value] of Object.entries(suppliedField.metadata)) {
|
|
2358
2281
|
metadata.set(key, value);
|
|
2359
2282
|
}
|
|
2360
|
-
return new
|
|
2283
|
+
return new arrow9.Field(
|
|
2361
2284
|
canonicalField.name,
|
|
2362
2285
|
canonicalField.type,
|
|
2363
2286
|
canonicalField.nullable,
|
|
@@ -2368,21 +2291,21 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
|
|
|
2368
2291
|
if (componentType === "float16") {
|
|
2369
2292
|
const metadata = new Map(Object.entries(field?.metadata || {}));
|
|
2370
2293
|
metadata.set("componentType", "float16");
|
|
2371
|
-
return new
|
|
2294
|
+
return new arrow9.Field(attributeName, column.type, false, metadata);
|
|
2372
2295
|
}
|
|
2373
2296
|
if (field && field.type.toString() !== column.type.toString()) {
|
|
2374
2297
|
const deserializedField = deserializeArrowField(field);
|
|
2375
|
-
return new
|
|
2298
|
+
return new arrow9.Field(
|
|
2376
2299
|
attributeName,
|
|
2377
2300
|
column.type,
|
|
2378
2301
|
deserializedField.nullable,
|
|
2379
2302
|
deserializedField.metadata
|
|
2380
2303
|
);
|
|
2381
2304
|
}
|
|
2382
|
-
return field ? deserializeArrowField(field) : new
|
|
2305
|
+
return field ? deserializeArrowField(field) : new arrow9.Field(attributeName, column.type, false);
|
|
2383
2306
|
}
|
|
2384
2307
|
function isMeshPositionColumn(column) {
|
|
2385
|
-
return column.type instanceof
|
|
2308
|
+
return column.type instanceof arrow9.FixedSizeList && column.type.listSize === 3 && column.type.children[0].type instanceof arrow9.Float32;
|
|
2386
2309
|
}
|
|
2387
2310
|
function getIndicesVector(indices, vertexCount, type) {
|
|
2388
2311
|
const indicesType = type;
|
|
@@ -2395,25 +2318,25 @@ function getIndicesVector(indices, vertexCount, type) {
|
|
|
2395
2318
|
if (vertexCount > 0) {
|
|
2396
2319
|
nullBitmap[0] = 1;
|
|
2397
2320
|
}
|
|
2398
|
-
const valuesData = new
|
|
2321
|
+
const valuesData = new arrow9.Data(
|
|
2399
2322
|
indicesType.children[0].type,
|
|
2400
2323
|
0,
|
|
2401
2324
|
values.length,
|
|
2402
2325
|
0,
|
|
2403
|
-
{ [
|
|
2326
|
+
{ [arrow9.BufferType.DATA]: values }
|
|
2404
2327
|
);
|
|
2405
|
-
const indicesData = new
|
|
2328
|
+
const indicesData = new arrow9.Data(
|
|
2406
2329
|
indicesType,
|
|
2407
2330
|
0,
|
|
2408
2331
|
vertexCount,
|
|
2409
2332
|
Math.max(0, vertexCount - 1),
|
|
2410
2333
|
{
|
|
2411
|
-
[
|
|
2412
|
-
[
|
|
2334
|
+
[arrow9.BufferType.OFFSET]: valueOffsets,
|
|
2335
|
+
[arrow9.BufferType.VALIDITY]: nullBitmap
|
|
2413
2336
|
},
|
|
2414
2337
|
[valuesData]
|
|
2415
2338
|
);
|
|
2416
|
-
return new
|
|
2339
|
+
return new arrow9.Vector([indicesData]);
|
|
2417
2340
|
}
|
|
2418
2341
|
function getMeshArrowMetadata(options) {
|
|
2419
2342
|
const metadata = { ...options.schema?.metadata };
|
|
@@ -2430,20 +2353,12 @@ function getMeshArrowMetadata(options) {
|
|
|
2430
2353
|
}
|
|
2431
2354
|
|
|
2432
2355
|
// src/schema-utils/lib/mesh/convert-table-to-mesh.ts
|
|
2433
|
-
var
|
|
2356
|
+
var arrow10 = __toESM(require("apache-arrow"), 1);
|
|
2434
2357
|
function convertTableToMesh(table) {
|
|
2435
|
-
if (
|
|
2436
|
-
|
|
2437
|
-
// case 'columnar-table':
|
|
2438
|
-
// return convertColumnarTableToMesh(table);
|
|
2439
|
-
case "arrow-table":
|
|
2440
|
-
return convertArrowTableToMesh(table);
|
|
2441
|
-
default:
|
|
2442
|
-
throw new Error(table.shape);
|
|
2443
|
-
}
|
|
2358
|
+
if (isArrowTable(table)) return convertArrowTableToMesh(table);
|
|
2359
|
+
throw new Error(table.shape);
|
|
2444
2360
|
}
|
|
2445
|
-
function convertArrowTableToMesh(
|
|
2446
|
-
const arrowTable = isNativeArrowTable(table) ? table : table.data;
|
|
2361
|
+
function convertArrowTableToMesh(arrowTable) {
|
|
2447
2362
|
const schema = serializeArrowSchema(arrowTable.schema);
|
|
2448
2363
|
const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
|
|
2449
2364
|
if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
|
|
@@ -2544,16 +2459,21 @@ function fixMetadata(schema) {
|
|
|
2544
2459
|
schema.metadata.mode ||= "0";
|
|
2545
2460
|
}
|
|
2546
2461
|
function getAttributeTypedArray(attributeData, size) {
|
|
2547
|
-
if (!(attributeData.type instanceof
|
|
2462
|
+
if (!(attributeData.type instanceof arrow10.FixedSizeList)) {
|
|
2548
2463
|
return attributeData.toArray();
|
|
2549
2464
|
}
|
|
2550
|
-
|
|
2465
|
+
if (attributeData.length === 0) {
|
|
2466
|
+
const EmptyStorage = attributeData.type.valueType.ArrayType;
|
|
2467
|
+
return new EmptyStorage(0);
|
|
2468
|
+
}
|
|
2469
|
+
const values = attributeData.data.find((chunk) => chunk.length > 0).children[0].values;
|
|
2551
2470
|
const TypedArrayConstructor = values.constructor;
|
|
2552
2471
|
const typedArray = new TypedArrayConstructor(attributeData.length * size);
|
|
2553
2472
|
let targetOffset = 0;
|
|
2554
2473
|
for (const data of attributeData.data) {
|
|
2555
|
-
const child = data.children[0];
|
|
2556
2474
|
const sourceLength = data.length * size;
|
|
2475
|
+
if (sourceLength === 0) continue;
|
|
2476
|
+
const child = data.children[0];
|
|
2557
2477
|
const sourceOffset = child.offset || data.offset * size;
|
|
2558
2478
|
const sourceStart = sourceOffset + sourceLength <= child.values.length ? sourceOffset : 0;
|
|
2559
2479
|
const source = child.values.subarray(sourceStart, sourceStart + sourceLength);
|
|
@@ -3012,7 +2932,7 @@ var PointCloudTiler = class {
|
|
|
3012
2932
|
async initialize(input) {
|
|
3013
2933
|
this.signal.throwIfAborted();
|
|
3014
2934
|
if (!("attributes" in input)) {
|
|
3015
|
-
const table =
|
|
2935
|
+
const table = input;
|
|
3016
2936
|
const buffers2 = /* @__PURE__ */ new Set();
|
|
3017
2937
|
let arrowBytes = 0;
|
|
3018
2938
|
const checkData = (data) => {
|
|
@@ -3219,13 +3139,11 @@ function getAttributeStorageKey(attribute) {
|
|
|
3219
3139
|
TableBatchBuilder,
|
|
3220
3140
|
TableConverter,
|
|
3221
3141
|
convert,
|
|
3222
|
-
convertArrowTable,
|
|
3223
|
-
convertArrowTableBatch,
|
|
3224
3142
|
convertArrowToSchema,
|
|
3225
3143
|
convertArrowToTable,
|
|
3226
3144
|
convertBatch,
|
|
3227
3145
|
convertBatches,
|
|
3228
|
-
|
|
3146
|
+
convertMeshToArrowTable,
|
|
3229
3147
|
convertMeshToTable,
|
|
3230
3148
|
convertSchemaToArrow,
|
|
3231
3149
|
convertTable,
|
|
@@ -3256,11 +3174,10 @@ function getAttributeStorageKey(attribute) {
|
|
|
3256
3174
|
getTableRowShape,
|
|
3257
3175
|
getTypeInfo,
|
|
3258
3176
|
isArrayRowTable,
|
|
3177
|
+
isArrowRecordBatch,
|
|
3259
3178
|
isArrowTable,
|
|
3260
3179
|
isColumnarTable,
|
|
3261
3180
|
isGeoJSONTable,
|
|
3262
|
-
isNativeArrowRecordBatch,
|
|
3263
|
-
isNativeArrowTable,
|
|
3264
3181
|
isObjectRowTable,
|
|
3265
3182
|
isTable,
|
|
3266
3183
|
makeArrayRowIterator,
|
|
@@ -3284,6 +3201,6 @@ function getAttributeStorageKey(attribute) {
|
|
|
3284
3201
|
serializeArrowSchema,
|
|
3285
3202
|
serializeArrowType,
|
|
3286
3203
|
snapshotArrowSchema,
|
|
3287
|
-
|
|
3288
|
-
|
|
3204
|
+
updateArrowTableSchema,
|
|
3205
|
+
updateNativeArrowTableMetadata
|
|
3289
3206
|
});
|