@loaders.gl/schema 4.0.0-alpha.4 → 4.0.0-alpha.6
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/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +13589 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +406 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/mesh/convert-mesh.js +34 -0
- package/dist/es5/lib/mesh/convert-mesh.js.map +1 -0
- package/dist/es5/lib/mesh/deduce-mesh-schema.js +56 -0
- package/dist/es5/lib/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/es5/lib/mesh/mesh-to-arrow-table.js +2 -0
- package/dist/es5/lib/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/es5/lib/mesh/mesh-utils.js +40 -0
- package/dist/es5/lib/mesh/mesh-utils.js.map +1 -0
- package/dist/es5/lib/table/arrow/arrow-type-utils.js +30 -0
- package/dist/es5/lib/table/arrow/arrow-type-utils.js.map +1 -0
- package/dist/es5/lib/table/arrow/convert-schema-arrow.js +179 -0
- package/dist/es5/lib/table/arrow/convert-schema-arrow.js.map +1 -0
- package/dist/es5/lib/table/arrow/convert-table-to-arrow.js +2 -0
- package/dist/es5/lib/table/arrow/convert-table-to-arrow.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-field.js +49 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-field.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-schema.js +118 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-schema.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js +80 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-type.js +740 -0
- package/dist/es5/lib/table/arrow-api/arrow-like-type.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/enum.js +55 -0
- package/dist/es5/lib/table/arrow-api/enum.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/get-type-info.js +27 -0
- package/dist/es5/lib/table/arrow-api/get-type-info.js.map +1 -0
- package/dist/es5/lib/table/arrow-api/index.js +44 -0
- package/dist/es5/lib/table/arrow-api/index.js.map +1 -0
- package/dist/es5/lib/table/batches/base-table-batch-aggregator.js +78 -0
- package/dist/es5/lib/table/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/table/batches/columnar-table-batch-aggregator.js +106 -0
- package/dist/es5/lib/table/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js +96 -0
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/table/batches/table-batch-aggregator.js +2 -0
- package/dist/es5/lib/table/batches/table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/table/batches/table-batch-builder.js +173 -0
- package/dist/es5/lib/table/batches/table-batch-builder.js.map +1 -0
- package/dist/es5/lib/table/simple-table/convert-table.js +82 -0
- package/dist/es5/lib/table/simple-table/convert-table.js.map +1 -0
- package/dist/es5/lib/table/simple-table/data-type.js +94 -0
- package/dist/es5/lib/table/simple-table/data-type.js.map +1 -0
- package/dist/es5/lib/table/simple-table/make-table.js +60 -0
- package/dist/es5/lib/table/simple-table/make-table.js.map +1 -0
- package/dist/es5/lib/table/simple-table/row-utils.js +34 -0
- package/dist/es5/lib/table/simple-table/row-utils.js.map +1 -0
- package/dist/es5/lib/table/simple-table/table-accessors.js +343 -0
- package/dist/es5/lib/table/simple-table/table-accessors.js.map +1 -0
- package/dist/es5/lib/table/simple-table/table-column.js +12 -0
- package/dist/es5/lib/table/simple-table/table-column.js.map +1 -0
- package/dist/es5/lib/table/simple-table/table-schema.js +85 -0
- package/dist/es5/lib/table/simple-table/table-schema.js.map +1 -0
- package/dist/es5/lib/utils/assert.js +12 -0
- package/dist/es5/lib/utils/assert.js.map +1 -0
- package/dist/es5/lib/utils/async-queue.js +169 -0
- package/dist/es5/lib/utils/async-queue.js.map +1 -0
- package/dist/es5/types/category-gis.js +2 -0
- package/dist/es5/types/category-gis.js.map +1 -0
- package/dist/es5/types/category-image.js +2 -0
- package/dist/es5/types/category-image.js.map +1 -0
- package/dist/es5/types/category-mesh.js +2 -0
- package/dist/es5/types/category-mesh.js.map +1 -0
- package/dist/es5/types/category-table.js +2 -0
- package/dist/es5/types/category-table.js.map +1 -0
- package/dist/es5/types/category-texture.js +2 -0
- package/dist/es5/types/category-texture.js.map +1 -0
- package/dist/es5/types/schema.js +2 -0
- package/dist/es5/types/schema.js.map +1 -0
- package/dist/es5/types/types.js +2 -0
- package/dist/es5/types/types.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/{category → esm/lib}/mesh/convert-mesh.js +0 -11
- package/dist/esm/lib/mesh/convert-mesh.js.map +1 -0
- package/dist/esm/lib/mesh/deduce-mesh-schema.js +48 -0
- package/dist/esm/lib/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/esm/lib/mesh/mesh-to-arrow-table.js +2 -0
- package/dist/esm/lib/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/{category → esm/lib}/mesh/mesh-utils.js +0 -5
- package/dist/esm/lib/mesh/mesh-utils.js.map +1 -0
- package/dist/{lib/arrow/arrow-like-type-utils.js → esm/lib/table/arrow/arrow-type-utils.js} +3 -11
- package/dist/esm/lib/table/arrow/arrow-type-utils.js.map +1 -0
- package/dist/esm/lib/table/arrow/convert-schema-arrow.js +158 -0
- package/dist/esm/lib/table/arrow/convert-schema-arrow.js.map +1 -0
- package/dist/esm/lib/table/arrow/convert-table-to-arrow.js +2 -0
- package/dist/esm/lib/table/arrow/convert-table-to-arrow.js.map +1 -0
- package/dist/{lib/schema/impl/field.js → esm/lib/table/arrow-api/arrow-like-field.js} +6 -13
- package/dist/esm/lib/table/arrow-api/arrow-like-field.js.map +1 -0
- package/dist/{lib/schema/impl/schema.js → esm/lib/table/arrow-api/arrow-like-schema.js} +22 -47
- package/dist/esm/lib/table/arrow-api/arrow-like-schema.js.map +1 -0
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js +51 -0
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +1 -0
- package/dist/{lib/schema/impl/type.js → esm/lib/table/arrow-api/arrow-like-type.js} +11 -116
- package/dist/esm/lib/table/arrow-api/arrow-like-type.js.map +1 -0
- package/dist/{lib/schema/impl → esm/lib/table/arrow-api}/enum.js +3 -4
- package/dist/esm/lib/table/arrow-api/enum.js.map +1 -0
- package/dist/{lib/arrow → esm/lib/table/arrow-api}/get-type-info.js +1 -4
- package/dist/esm/lib/table/arrow-api/get-type-info.js.map +1 -0
- package/dist/esm/lib/table/arrow-api/index.js +5 -0
- package/dist/esm/lib/table/arrow-api/index.js.map +1 -0
- package/dist/{lib → esm/lib/table}/batches/base-table-batch-aggregator.js +1 -18
- package/dist/esm/lib/table/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/{lib → esm/lib/table}/batches/columnar-table-batch-aggregator.js +1 -24
- package/dist/esm/lib/table/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/{lib → esm/lib/table}/batches/row-table-batch-aggregator.js +2 -22
- package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/esm/lib/table/batches/table-batch-aggregator.js.map +1 -0
- package/dist/{lib → esm/lib/table}/batches/table-batch-builder.js +6 -49
- package/dist/esm/lib/table/batches/table-batch-builder.js.map +1 -0
- package/dist/esm/lib/table/simple-table/convert-table.js +59 -0
- package/dist/esm/lib/table/simple-table/convert-table.js.map +1 -0
- package/dist/esm/lib/table/simple-table/data-type.js +85 -0
- package/dist/esm/lib/table/simple-table/data-type.js.map +1 -0
- package/dist/esm/lib/table/simple-table/make-table.js +50 -0
- package/dist/esm/lib/table/simple-table/make-table.js.map +1 -0
- package/dist/{lib/utils → esm/lib/table/simple-table}/row-utils.js +0 -8
- package/dist/esm/lib/table/simple-table/row-utils.js.map +1 -0
- package/dist/esm/lib/table/simple-table/table-accessors.js +262 -0
- package/dist/esm/lib/table/simple-table/table-accessors.js.map +1 -0
- package/dist/esm/lib/table/simple-table/table-column.js +6 -0
- package/dist/esm/lib/table/simple-table/table-column.js.map +1 -0
- package/dist/esm/lib/table/simple-table/table-schema.js +70 -0
- package/dist/esm/lib/table/simple-table/table-schema.js.map +1 -0
- package/dist/esm/lib/utils/assert.js +6 -0
- package/dist/esm/lib/utils/assert.js.map +1 -0
- package/dist/esm/lib/utils/async-queue.js +94 -0
- package/dist/esm/lib/utils/async-queue.js.map +1 -0
- package/dist/esm/types/category-gis.js +2 -0
- package/dist/esm/types/category-gis.js.map +1 -0
- package/dist/esm/types/category-image.js +2 -0
- package/dist/esm/types/category-image.js.map +1 -0
- package/dist/esm/types/category-mesh.js +2 -0
- package/dist/esm/types/category-mesh.js.map +1 -0
- package/dist/esm/types/category-table.js +2 -0
- package/dist/esm/types/category-table.js.map +1 -0
- package/dist/esm/types/category-texture.js +2 -0
- package/dist/esm/types/category-texture.js.map +1 -0
- package/dist/esm/types/schema.js +2 -0
- package/dist/esm/types/schema.js.map +1 -0
- package/dist/esm/types/types.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +92 -13
- package/dist/lib/mesh/convert-mesh.d.ts +15 -0
- package/dist/lib/mesh/convert-mesh.d.ts.map +1 -0
- package/dist/lib/mesh/convert-mesh.js +40 -0
- package/dist/lib/mesh/deduce-mesh-schema.d.ts +24 -0
- package/dist/lib/mesh/deduce-mesh-schema.d.ts.map +1 -0
- package/dist/lib/mesh/deduce-mesh-schema.js +66 -0
- package/dist/lib/mesh/mesh-to-arrow-table.d.ts +1 -0
- package/dist/lib/mesh/mesh-to-arrow-table.d.ts.map +1 -0
- package/dist/lib/mesh/mesh-to-arrow-table.js +44 -0
- package/dist/lib/mesh/mesh-utils.d.ts +23 -0
- package/dist/lib/mesh/mesh-utils.d.ts.map +1 -0
- package/dist/lib/mesh/mesh-utils.js +51 -0
- package/dist/lib/table/arrow/arrow-type-utils.d.ts +4 -0
- package/dist/lib/table/arrow/arrow-type-utils.d.ts.map +1 -0
- package/dist/lib/table/arrow/arrow-type-utils.js +53 -0
- package/dist/lib/table/arrow/convert-schema-arrow.d.ts +13 -0
- package/dist/lib/table/arrow/convert-schema-arrow.d.ts.map +1 -0
- package/dist/lib/table/arrow/convert-schema-arrow.js +187 -0
- package/dist/lib/table/arrow/convert-table-to-arrow.d.ts +42 -0
- package/dist/lib/table/arrow/convert-table-to-arrow.d.ts.map +1 -0
- package/dist/lib/table/arrow/convert-table-to-arrow.js +57 -0
- package/dist/lib/table/arrow-api/arrow-like-field.d.ts +19 -0
- package/dist/lib/table/arrow-api/arrow-like-field.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/arrow-like-field.js +34 -0
- package/dist/lib/table/arrow-api/arrow-like-schema.d.ts +12 -0
- package/dist/lib/table/arrow-api/arrow-like-schema.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/arrow-like-schema.js +81 -0
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts +28 -0
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/arrow-like-table.js +53 -0
- package/dist/lib/table/arrow-api/arrow-like-type.d.ts +177 -0
- package/dist/lib/table/arrow-api/arrow-like-type.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/arrow-like-type.js +463 -0
- package/dist/lib/table/arrow-api/enum.d.ts +92 -0
- package/dist/lib/table/arrow-api/enum.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/enum.js +97 -0
- package/dist/lib/table/arrow-api/get-type-info.d.ts +13 -0
- package/dist/lib/table/arrow-api/get-type-info.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/get-type-info.js +29 -0
- package/dist/lib/table/arrow-api/index.d.ts +5 -0
- package/dist/lib/table/arrow-api/index.d.ts.map +1 -0
- package/dist/lib/table/arrow-api/index.js +25 -0
- package/dist/lib/table/batches/base-table-batch-aggregator.d.ts +19 -0
- package/dist/lib/table/batches/base-table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/table/batches/base-table-batch-aggregator.js +60 -0
- package/dist/lib/table/batches/columnar-table-batch-aggregator.d.ts +23 -0
- package/dist/lib/table/batches/columnar-table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/table/batches/columnar-table-batch-aggregator.js +92 -0
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +22 -0
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/table/batches/row-table-batch-aggregator.js +81 -0
- package/dist/lib/table/batches/table-batch-aggregator.d.ts +25 -0
- package/dist/lib/table/batches/table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/table/batches/table-batch-aggregator.js +3 -0
- package/dist/lib/table/batches/table-batch-builder.d.ts +53 -0
- package/dist/lib/table/batches/table-batch-builder.d.ts.map +1 -0
- package/dist/lib/table/batches/table-batch-builder.js +152 -0
- package/dist/lib/table/simple-table/convert-table.d.ts +8 -0
- package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -0
- package/dist/lib/table/simple-table/convert-table.js +65 -0
- package/dist/lib/table/simple-table/data-type.d.ts +17 -0
- package/dist/lib/table/simple-table/data-type.d.ts.map +1 -0
- package/dist/lib/table/simple-table/data-type.js +93 -0
- package/dist/lib/table/simple-table/make-table.d.ts +65 -0
- package/dist/lib/table/simple-table/make-table.d.ts.map +1 -0
- package/dist/lib/table/simple-table/make-table.js +95 -0
- package/dist/lib/table/simple-table/row-utils.d.ts +9 -0
- package/dist/lib/table/simple-table/row-utils.d.ts.map +1 -0
- package/dist/lib/table/simple-table/row-utils.js +33 -0
- package/dist/lib/table/simple-table/table-accessors.d.ts +67 -0
- package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -0
- package/dist/lib/table/simple-table/table-accessors.js +319 -0
- package/dist/lib/table/simple-table/table-column.d.ts +7 -0
- package/dist/lib/table/simple-table/table-column.d.ts.map +1 -0
- package/dist/lib/table/simple-table/table-column.js +41 -0
- package/dist/lib/table/simple-table/table-schema.d.ts +15 -0
- package/dist/lib/table/simple-table/table-schema.d.ts.map +1 -0
- package/dist/lib/table/simple-table/table-schema.js +85 -0
- package/dist/lib/utils/assert.d.ts +2 -0
- package/dist/lib/utils/assert.d.ts.map +1 -0
- package/dist/lib/utils/assert.js +11 -5
- package/dist/lib/utils/async-queue.d.ts +18 -0
- package/dist/lib/utils/async-queue.d.ts.map +1 -0
- package/dist/lib/utils/async-queue.js +82 -109
- package/dist/types/category-gis.d.ts +99 -0
- package/dist/types/category-gis.d.ts.map +1 -0
- package/dist/types/category-gis.js +2 -0
- package/dist/types/category-image.d.ts +18 -0
- package/dist/types/category-image.d.ts.map +1 -0
- package/dist/types/category-image.js +2 -0
- package/dist/types/category-mesh.d.ts +48 -0
- package/dist/types/category-mesh.d.ts.map +1 -0
- package/dist/types/category-mesh.js +3 -0
- package/dist/types/category-table.d.ts +86 -0
- package/dist/types/category-table.d.ts.map +1 -0
- package/dist/types/category-table.js +3 -0
- package/dist/types/category-texture.d.ts +18 -0
- package/dist/types/category-texture.d.ts.map +1 -0
- package/dist/types/category-texture.js +3 -0
- package/dist/types/schema.d.ts +77 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +3 -0
- package/dist/types/types.d.ts +15 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/package.json +7 -8
- package/src/index.ts +82 -29
- package/src/{category → lib}/mesh/convert-mesh.ts +10 -8
- package/src/{category → lib}/mesh/deduce-mesh-schema.ts +20 -19
- package/src/{category → lib}/mesh/mesh-to-arrow-table.ts +5 -3
- package/src/{category → lib}/mesh/mesh-utils.ts +2 -2
- package/src/lib/{arrow → table/arrow}/arrow-type-utils.ts +16 -12
- package/src/lib/table/arrow/convert-schema-arrow.ts +232 -0
- package/src/lib/table/arrow/convert-table-to-arrow.ts +59 -0
- package/src/lib/{schema/impl/field.ts → table/arrow-api/arrow-like-field.ts} +6 -4
- package/src/lib/table/arrow-api/arrow-like-schema.ts +99 -0
- package/src/lib/table/arrow-api/arrow-like-table.ts +83 -0
- package/src/lib/{schema/impl/type.ts → table/arrow-api/arrow-like-type.ts} +2 -1
- package/src/lib/{arrow → table/arrow-api}/get-type-info.ts +4 -3
- package/src/lib/table/arrow-api/index.ts +6 -0
- package/src/lib/{batches → table/batches}/base-table-batch-aggregator.ts +5 -3
- package/src/lib/{batches → table/batches}/columnar-table-batch-aggregator.ts +5 -3
- package/src/lib/{batches → table/batches}/row-table-batch-aggregator.ts +6 -4
- package/src/lib/{batches → table/batches}/table-batch-aggregator.ts +4 -2
- package/src/lib/{batches → table/batches}/table-batch-builder.ts +8 -6
- package/src/lib/table/simple-table/convert-table.ts +72 -0
- package/src/lib/table/simple-table/data-type.ts +102 -0
- package/src/lib/table/simple-table/make-table.ts +108 -0
- package/src/lib/table/simple-table/table-accessors.ts +360 -0
- package/src/lib/table/simple-table/table-column.ts +47 -0
- package/src/lib/table/simple-table/table-schema.ts +97 -0
- package/src/types/category-gis.ts +136 -0
- package/src/types/category-image.ts +19 -0
- package/src/{category/mesh/mesh-types.ts → types/category-mesh.ts} +6 -4
- package/src/types/category-table.ts +104 -0
- package/src/types/category-texture.ts +30 -0
- package/src/types/schema.ts +97 -0
- package/src/types/types.ts +43 -0
- package/dist/bundle.js.map +0 -1
- package/dist/category/common.js +0 -2
- package/dist/category/common.js.map +0 -1
- package/dist/category/gis.js +0 -2
- package/dist/category/gis.js.map +0 -1
- package/dist/category/mesh/convert-mesh.js.map +0 -1
- package/dist/category/mesh/deduce-mesh-schema.js +0 -42
- package/dist/category/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/category/mesh/mesh-to-arrow-table.js +0 -31
- package/dist/category/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/category/mesh/mesh-types.js +0 -2
- package/dist/category/mesh/mesh-types.js.map +0 -1
- package/dist/category/mesh/mesh-utils.js.map +0 -1
- package/dist/category/table/deduce-table-schema.js +0 -51
- package/dist/category/table/deduce-table-schema.js.map +0 -1
- package/dist/category/table/table-types.js +0 -2
- package/dist/category/table/table-types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/arrow/arrow-like-type-utils.js.map +0 -1
- package/dist/lib/arrow/arrow-type-utils.js +0 -62
- package/dist/lib/arrow/arrow-type-utils.js.map +0 -1
- package/dist/lib/arrow/get-type-info.js.map +0 -1
- package/dist/lib/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/table-batch-builder.js.map +0 -1
- package/dist/lib/schema/impl/enum.js.map +0 -1
- package/dist/lib/schema/impl/field.js.map +0 -1
- package/dist/lib/schema/impl/schema.js.map +0 -1
- package/dist/lib/schema/impl/type.js.map +0 -1
- package/dist/lib/schema/index.js +0 -5
- package/dist/lib/schema/index.js.map +0 -1
- package/dist/lib/schema-utils/deduce-column-type.js +0 -23
- package/dist/lib/schema-utils/deduce-column-type.js.map +0 -1
- package/dist/lib/utils/assert.js.map +0 -1
- package/dist/lib/utils/async-queue.js.map +0 -1
- package/dist/lib/utils/row-utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/category/common.ts +0 -30
- package/src/category/gis.ts +0 -61
- package/src/category/table/deduce-table-schema.ts +0 -123
- package/src/category/table/table-types.ts +0 -81
- package/src/lib/arrow/arrow-like-type-utils.ts +0 -25
- package/src/lib/schema/impl/schema.ts +0 -99
- package/src/lib/schema/index.ts +0 -82
- package/src/lib/schema-utils/deduce-column-type.ts +0 -92
- package/src/types.ts +0 -19
- /package/dist/{lib → esm/lib/table}/batches/table-batch-aggregator.js +0 -0
- /package/dist/{types.js → esm/types/types.js} +0 -0
- /package/src/lib/{schema/impl → table/arrow-api}/enum.ts +0 -0
- /package/src/lib/{utils → table/simple-table}/row-utils.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
// import {
|
|
4
|
+
// Table as ApacheArrowTable,
|
|
5
|
+
// Schema as ApacheArrowSchema,
|
|
6
|
+
// RecordBatch,
|
|
7
|
+
// FixedSizeList,
|
|
8
|
+
// Field,
|
|
9
|
+
// Data,
|
|
10
|
+
// FixedSizeListVector
|
|
11
|
+
// } from 'apache-arrow/Arrow.dom';
|
|
12
|
+
// import {AbstractVector} from 'apache-arrow/vector';
|
|
13
|
+
|
|
14
|
+
// import {Table} from '../../types/category-table';
|
|
15
|
+
// import {getArrowType, getArrowVector} from './arrow-type-utils';
|
|
16
|
+
// import {makeMeshAttributeMetadata} from './deduce-mesh-schema';
|
|
17
|
+
// import {getTableLength, getTableNumCols} from './table-accessors';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
21
|
+
* @param mesh
|
|
22
|
+
* @param metadata
|
|
23
|
+
* @param batchSize
|
|
24
|
+
* @returns
|
|
25
|
+
*
|
|
26
|
+
export function convertTableToArrow(table: Table, options?: {batchSize?: number}): ArrowTable {
|
|
27
|
+
const vectors: AbstractVector[] = [];
|
|
28
|
+
const fields: Field[] = [];
|
|
29
|
+
|
|
30
|
+
const length = getTableLength(table);
|
|
31
|
+
const batchSize = options?.batchSize || length;
|
|
32
|
+
|
|
33
|
+
const recordBatches: RecordBatch[] = [];
|
|
34
|
+
for (let i = 0; i < length; i += batchSize) {
|
|
35
|
+
for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {
|
|
36
|
+
const field_ = table.schema.fields[columnIndex];
|
|
37
|
+
const column = getTableColumnAt(table, columnIndex, i, batchSize);
|
|
38
|
+
const type = getArrowType(column);
|
|
39
|
+
const vector = getArrowVector(column);
|
|
40
|
+
const listType = new FixedSizeList(size, new Field('value', type));
|
|
41
|
+
const field = new Field(field_.name, listType, false, makeMeshAttributeMetadata(attribute));
|
|
42
|
+
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
43
|
+
const listVector = new FixedSizeListVector(data);
|
|
44
|
+
vectors.push(listVector);
|
|
45
|
+
fields.push(field);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (const attributeKey in table.columns) {
|
|
49
|
+
const attribute = mesh.attributes[attributeKey];
|
|
50
|
+
const {value, size = 1} = attribute;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const schema = new ApacheArrowSchema(fields, table?.schema?.metadata || new Map<string, string>());
|
|
54
|
+
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
55
|
+
const apacheArrowTable = new ApacheArrowTable(schema, recordBatch);
|
|
56
|
+
|
|
57
|
+
return apacheArrowTable;
|
|
58
|
+
}
|
|
59
|
+
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {DataType} from './arrow-like-type';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* ArrowJS `Field` API-compatible class for row-based tables
|
|
@@ -6,7 +8,7 @@ import {DataType} from './type';
|
|
|
6
8
|
* A field holds name, nullable, and metadata information about a table "column"
|
|
7
9
|
* A Schema is essentially a list of fields
|
|
8
10
|
*/
|
|
9
|
-
export
|
|
11
|
+
export class ArrowLikeField {
|
|
10
12
|
name: string;
|
|
11
13
|
type: DataType;
|
|
12
14
|
nullable: boolean;
|
|
@@ -28,8 +30,8 @@ export default class Field {
|
|
|
28
30
|
return this.type && this.type.typeId;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
clone():
|
|
32
|
-
return new
|
|
33
|
+
clone(): ArrowLikeField {
|
|
34
|
+
return new ArrowLikeField(this.name, this.type, this.nullable, this.metadata);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
compareTo(other: this): boolean {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {SchemaMetadata, Field} from '../../../types/schema';
|
|
4
|
+
import {ArrowLikeField} from './arrow-like-field';
|
|
5
|
+
|
|
6
|
+
export class ArrowLikeSchema {
|
|
7
|
+
fields: ArrowLikeField[];
|
|
8
|
+
metadata: Map<string, string>;
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
fields: ArrowLikeField[] | Field[],
|
|
12
|
+
metadata: SchemaMetadata | Map<string, string> = new Map<string, string>()
|
|
13
|
+
) {
|
|
14
|
+
// checkNames(fields);
|
|
15
|
+
// For kepler fields, create arrow compatible `Fields` that have kepler fields as `metadata`
|
|
16
|
+
this.fields = fields.map(
|
|
17
|
+
(field) => new ArrowLikeField(field.name, field.type, field.nullable, field.metadata)
|
|
18
|
+
);
|
|
19
|
+
this.metadata =
|
|
20
|
+
metadata instanceof Map ? metadata : new Map<string, string>(Object.entries(metadata));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// TODO - arrow only seems to compare fields, not metadata
|
|
24
|
+
compareTo(other: ArrowLikeSchema): boolean {
|
|
25
|
+
if (this.metadata !== other.metadata) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (this.fields.length !== other.fields.length) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i < this.fields.length; ++i) {
|
|
32
|
+
if (!this.fields[i].compareTo(other.fields[i])) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
select(...columnNames: string[]): ArrowLikeSchema {
|
|
40
|
+
// Ensure column names reference valid fields
|
|
41
|
+
const nameMap = Object.create(null);
|
|
42
|
+
for (const name of columnNames) {
|
|
43
|
+
nameMap[name] = true;
|
|
44
|
+
}
|
|
45
|
+
const selectedFields = this.fields.filter((field) => nameMap[field.name]);
|
|
46
|
+
return new ArrowLikeSchema(selectedFields, this.metadata);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
selectAt(...columnIndices: number[]): ArrowLikeSchema {
|
|
50
|
+
// Ensure column indices reference valid fields
|
|
51
|
+
const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
|
|
52
|
+
return new ArrowLikeSchema(selectedFields, this.metadata);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
assign(schemaOrFields: ArrowLikeSchema | ArrowLikeField[]): ArrowLikeSchema {
|
|
56
|
+
let fields: ArrowLikeField[];
|
|
57
|
+
let metadata = this.metadata;
|
|
58
|
+
|
|
59
|
+
if (schemaOrFields instanceof ArrowLikeSchema) {
|
|
60
|
+
const otherArrowLikeSchema = schemaOrFields;
|
|
61
|
+
fields = otherArrowLikeSchema.fields;
|
|
62
|
+
metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherArrowLikeSchema.metadata);
|
|
63
|
+
} else {
|
|
64
|
+
fields = schemaOrFields;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Create a merged list of fields, overwrite fields in place, new fields at end
|
|
68
|
+
const fieldMap: {[key: string]: ArrowLikeField} = Object.create(null);
|
|
69
|
+
|
|
70
|
+
for (const field of this.fields) {
|
|
71
|
+
fieldMap[field.name] = field;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const field of fields) {
|
|
75
|
+
fieldMap[field.name] = field;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const mergedFields = Object.values(fieldMap);
|
|
79
|
+
|
|
80
|
+
return new ArrowLikeSchema(mergedFields, metadata);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Warn if any duplicated field names
|
|
85
|
+
// function checkNames(fields: Field[]): void {
|
|
86
|
+
// const usedNames: Record<string, boolean> = {};
|
|
87
|
+
// for (const field of fields) {
|
|
88
|
+
// if (usedNames[field.name]) {
|
|
89
|
+
// // eslint-disable-next-line
|
|
90
|
+
// console.warn('ArrowLikeSchema: duplicated field name', field.name, field);
|
|
91
|
+
// }
|
|
92
|
+
// usedNames[field.name] = true;
|
|
93
|
+
// }
|
|
94
|
+
// }
|
|
95
|
+
|
|
96
|
+
function mergeMaps<T>(m1: T, m2: T): T {
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
return new Map([...(m1 || new Map()), ...(m2 || new Map())]);
|
|
99
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {Table} from '../../../types/category-table';
|
|
4
|
+
|
|
5
|
+
import {ArrowLikeSchema} from './arrow-like-schema';
|
|
6
|
+
|
|
7
|
+
import {deduceTableSchema} from '../simple-table/table-schema';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
getTableCell,
|
|
11
|
+
getTableLength,
|
|
12
|
+
getTableNumCols
|
|
13
|
+
// getTableCell,
|
|
14
|
+
// getTableRowShape,
|
|
15
|
+
// getTableColumnIndex,
|
|
16
|
+
// getTableColumnName,
|
|
17
|
+
// getTableRowAsObject,
|
|
18
|
+
// getTableRowAsArray
|
|
19
|
+
} from '../simple-table/table-accessors';
|
|
20
|
+
|
|
21
|
+
class ArrowLikeVector {
|
|
22
|
+
table: Table;
|
|
23
|
+
columnName: string;
|
|
24
|
+
|
|
25
|
+
constructor(table: Table, columnName: string) {
|
|
26
|
+
this.table = table;
|
|
27
|
+
this.columnName = columnName;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get(rowIndex: number): unknown {
|
|
31
|
+
return getTableCell(this.table, rowIndex, this.columnName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
toArray(): ArrayLike<unknown> {
|
|
35
|
+
switch (this.table.shape) {
|
|
36
|
+
case 'arrow-table':
|
|
37
|
+
return this.table.data.getChild(this.columnName)?.toArray();
|
|
38
|
+
case 'columnar-table':
|
|
39
|
+
return this.table.data[this.columnName];
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(this.table.shape);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Class that provides an API similar to Apache Arrow Table class
|
|
48
|
+
* Forwards methods directly if the underlying table is Arrow, otherwise calls accessor functions
|
|
49
|
+
*/
|
|
50
|
+
export class ArrowLikeTable {
|
|
51
|
+
schema: ArrowLikeSchema;
|
|
52
|
+
table: Table;
|
|
53
|
+
|
|
54
|
+
constructor(table: Table) {
|
|
55
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
56
|
+
this.schema = new ArrowLikeSchema(schema.fields, schema.metadata);
|
|
57
|
+
this.table = {...table, schema};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// get schema() {
|
|
61
|
+
// return this.table.schema;
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
get data() {
|
|
65
|
+
return this.table.data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get numCols(): number {
|
|
69
|
+
return getTableNumCols(this.table);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get length(): number {
|
|
73
|
+
return getTableLength(this.table);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getChild(columnName: string): ArrowLikeVector {
|
|
77
|
+
return new ArrowLikeVector(this.table, columnName);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// getChildAt(columnIndex: number): ArrowLikeVector {
|
|
81
|
+
// return
|
|
82
|
+
// }
|
|
83
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import {Type} from './enum';
|
|
5
5
|
|
|
6
|
-
import Field from './field';
|
|
6
|
+
import {ArrowLikeField as Field} from './arrow-like-field';
|
|
7
7
|
|
|
8
8
|
export {Type} from './enum';
|
|
9
9
|
|
|
@@ -24,6 +24,7 @@ export type TypedArray = TypedIntArray | TypedFloatArray;
|
|
|
24
24
|
|
|
25
25
|
export type AnyArrayType = Array<any> | TypedIntArray | TypedFloatArray;
|
|
26
26
|
|
|
27
|
+
/** ArrowLike DataType class */
|
|
27
28
|
export class DataType {
|
|
28
29
|
static isNull(x: any): boolean {
|
|
29
30
|
return x && x.typeId === Type.Null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {Type} from './arrow-like-type';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Gets type information from an Arrow type object or "mock" Arrow type object
|
|
@@ -7,7 +8,7 @@ import {AnyArray} from '../../types';
|
|
|
7
8
|
*/
|
|
8
9
|
export function getTypeInfo(arrowTypeLike: any): {
|
|
9
10
|
typeId: Type;
|
|
10
|
-
ArrayType:
|
|
11
|
+
ArrayType: ArrayLike<unknown>;
|
|
11
12
|
typeName: string;
|
|
12
13
|
typeEnumName?: string;
|
|
13
14
|
precision?: number;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {Schema} from '../../../types/schema';
|
|
4
|
+
import type {TableBatch} from '../../../types/category-table';
|
|
3
5
|
import {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';
|
|
4
6
|
|
|
5
7
|
const DEFAULT_ROW_COUNT = 100;
|
|
6
8
|
|
|
7
|
-
export
|
|
9
|
+
export class BaseTableBatchAggregator implements TableBatchAggregator {
|
|
8
10
|
schema: Schema;
|
|
9
11
|
options: TableBatchOptions;
|
|
10
12
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {Schema} from '../../../types/schema';
|
|
4
|
+
import type {ColumnarTableBatch, ArrowTableBatch} from '../../../types/category-table';
|
|
3
5
|
import {TableBatchAggregator} from './table-batch-aggregator';
|
|
4
6
|
|
|
5
7
|
type ColumnarTableBatchOptions = {};
|
|
6
8
|
|
|
7
9
|
const DEFAULT_ROW_COUNT = 100;
|
|
8
10
|
|
|
9
|
-
export
|
|
11
|
+
export class ColumnarTableBatchAggregator implements TableBatchAggregator {
|
|
10
12
|
schema: Schema;
|
|
11
13
|
length: number = 0;
|
|
12
14
|
allocated: number = 0;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {Schema} from '../../../types/schema';
|
|
4
|
+
import type {TableBatch} from '../../../types/category-table';
|
|
3
5
|
// import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';
|
|
4
|
-
import {convertToArrayRow, convertToObjectRow} from '../
|
|
6
|
+
import {convertToArrayRow, convertToObjectRow} from '../simple-table/row-utils';
|
|
5
7
|
import {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';
|
|
6
8
|
|
|
7
9
|
const DEFAULT_ROW_COUNT = 100;
|
|
8
10
|
|
|
9
|
-
export
|
|
11
|
+
export class RowTableBatchAggregator implements TableBatchAggregator {
|
|
10
12
|
schema: Schema;
|
|
11
13
|
options: TableBatchOptions;
|
|
12
14
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {Schema} from '../../../types/schema';
|
|
4
|
+
import type {TableBatch} from '../../../types/category-table';
|
|
3
5
|
|
|
4
6
|
export interface TableBatchOptions {
|
|
5
7
|
batchSize: number | string;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {Schema} from '../../../types/schema';
|
|
4
|
+
import type {TableBatch} from '../../../types/category-table';
|
|
3
5
|
import type {TableBatchAggregator, TableBatchConstructor} from './table-batch-aggregator';
|
|
4
|
-
import BaseTableBatchAggregator from './base-table-batch-aggregator';
|
|
5
|
-
import RowTableBatchAggregator from './row-table-batch-aggregator';
|
|
6
|
-
import ColumnarTableBatchAggregator from './columnar-table-batch-aggregator';
|
|
6
|
+
import {BaseTableBatchAggregator} from './base-table-batch-aggregator';
|
|
7
|
+
import {RowTableBatchAggregator} from './row-table-batch-aggregator';
|
|
8
|
+
import {ColumnarTableBatchAggregator} from './columnar-table-batch-aggregator';
|
|
7
9
|
|
|
8
10
|
// TODO define interface instead
|
|
9
11
|
type TableBatchBuilderOptions = {
|
|
@@ -30,7 +32,7 @@ const DEFAULT_OPTIONS: Required<TableBatchBuilderOptions> = {
|
|
|
30
32
|
const ERR_MESSAGE = 'TableBatchBuilder';
|
|
31
33
|
|
|
32
34
|
/** Incrementally builds batches from a stream of rows */
|
|
33
|
-
export
|
|
35
|
+
export class TableBatchBuilder {
|
|
34
36
|
schema: Schema;
|
|
35
37
|
options: Required<TableBatchBuilderOptions>;
|
|
36
38
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
import {
|
|
3
|
+
getTableCell,
|
|
4
|
+
getTableLength,
|
|
5
|
+
getTableRowAsArray,
|
|
6
|
+
getTableRowAsObject
|
|
7
|
+
} from './table-accessors';
|
|
8
|
+
import {Table, ArrayRowTable, ObjectRowTable, ColumnarTable} from '../../../types/category-table';
|
|
9
|
+
import {deduceTableSchema} from './table-schema';
|
|
10
|
+
import {makeColumnFromField} from './table-column';
|
|
11
|
+
|
|
12
|
+
/** Convert any simple table into columnar format */
|
|
13
|
+
export function makeColumnarTable(table: Table): ColumnarTable {
|
|
14
|
+
// TODO - should schema really be optional?
|
|
15
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
16
|
+
const fields = table.schema?.fields || [];
|
|
17
|
+
|
|
18
|
+
if (table.shape === 'columnar-table') {
|
|
19
|
+
return {...table, schema};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const length = getTableLength(table);
|
|
23
|
+
|
|
24
|
+
const columns: {[column: string]: ArrayLike<unknown>} = {};
|
|
25
|
+
for (const field of fields) {
|
|
26
|
+
const column = makeColumnFromField(field, length);
|
|
27
|
+
columns[field.name] = column;
|
|
28
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
29
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
shape: 'columnar-table',
|
|
35
|
+
schema,
|
|
36
|
+
data: columns
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Convert any table into array row format */
|
|
41
|
+
export function makeArrayRowTable(table: Table): ArrayRowTable {
|
|
42
|
+
if (table.shape === 'array-row-table') {
|
|
43
|
+
return table;
|
|
44
|
+
}
|
|
45
|
+
const length = getTableLength(table);
|
|
46
|
+
const data = new Array<unknown[]>(length);
|
|
47
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
48
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
shape: 'array-row-table',
|
|
52
|
+
schema: table.schema,
|
|
53
|
+
data
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Convert any table into object row format */
|
|
58
|
+
export function makeObjectRowTable(table: Table): ObjectRowTable {
|
|
59
|
+
if (table.shape === 'object-row-table') {
|
|
60
|
+
return table;
|
|
61
|
+
}
|
|
62
|
+
const length = getTableLength(table);
|
|
63
|
+
const data = new Array<{[key: string]: unknown}>(length);
|
|
64
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
65
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
shape: 'object-row-table',
|
|
69
|
+
schema: table.schema,
|
|
70
|
+
data
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {DataType} from '../../../types/schema';
|
|
4
|
+
import {TypedArray, TypedArrayConstructor, ArrayType} from '../../../types/types';
|
|
5
|
+
|
|
6
|
+
/** Deduce column types from values */
|
|
7
|
+
export function getDataTypeFromValue(
|
|
8
|
+
value: unknown,
|
|
9
|
+
defaultNumberType: 'float32' = 'float32'
|
|
10
|
+
): DataType {
|
|
11
|
+
if (value instanceof Date) {
|
|
12
|
+
return 'date-millisecond';
|
|
13
|
+
}
|
|
14
|
+
if (value instanceof Number) {
|
|
15
|
+
return defaultNumberType;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'string') {
|
|
18
|
+
return 'utf8';
|
|
19
|
+
}
|
|
20
|
+
if (value === null || value === 'undefined') {
|
|
21
|
+
return 'null';
|
|
22
|
+
}
|
|
23
|
+
return 'null';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Deduces a simple data type "descriptor from a typed array instance
|
|
28
|
+
*/
|
|
29
|
+
export function getDataTypeFromArray(array: ArrayType): {type: DataType; nullable: boolean} {
|
|
30
|
+
let type = getDataTypeFromTypedArray(array as TypedArray);
|
|
31
|
+
if (type !== 'null') {
|
|
32
|
+
return {type, nullable: false};
|
|
33
|
+
}
|
|
34
|
+
if (array.length > 0) {
|
|
35
|
+
type = getDataTypeFromValue(array[0]);
|
|
36
|
+
return {type, nullable: true};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {type: 'null', nullable: true};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Deduces a simple data type "descriptor from a typed array instance
|
|
44
|
+
*/
|
|
45
|
+
export function getDataTypeFromTypedArray(array: TypedArray): DataType {
|
|
46
|
+
switch (array.constructor) {
|
|
47
|
+
case Int8Array:
|
|
48
|
+
return 'int8';
|
|
49
|
+
case Uint8Array:
|
|
50
|
+
case Uint8ClampedArray:
|
|
51
|
+
return 'uint8';
|
|
52
|
+
case Int16Array:
|
|
53
|
+
return 'int16';
|
|
54
|
+
case Uint16Array:
|
|
55
|
+
return 'uint16';
|
|
56
|
+
case Int32Array:
|
|
57
|
+
return 'int32';
|
|
58
|
+
case Uint32Array:
|
|
59
|
+
return 'uint32';
|
|
60
|
+
case Float32Array:
|
|
61
|
+
return 'float32';
|
|
62
|
+
case Float64Array:
|
|
63
|
+
return 'float64';
|
|
64
|
+
default:
|
|
65
|
+
return 'null';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getArrayTypeFromDataType(
|
|
70
|
+
type: DataType,
|
|
71
|
+
nullable: boolean | undefined
|
|
72
|
+
): TypedArrayConstructor | ArrayConstructor {
|
|
73
|
+
if (!nullable) {
|
|
74
|
+
switch (type) {
|
|
75
|
+
case 'int8':
|
|
76
|
+
return Int8Array;
|
|
77
|
+
case 'uint8':
|
|
78
|
+
return Uint8Array;
|
|
79
|
+
case 'int16':
|
|
80
|
+
return Int16Array;
|
|
81
|
+
case 'uint16':
|
|
82
|
+
return Uint16Array;
|
|
83
|
+
case 'int32':
|
|
84
|
+
return Int32Array;
|
|
85
|
+
case 'uint32':
|
|
86
|
+
return Uint32Array;
|
|
87
|
+
case 'float32':
|
|
88
|
+
return Float32Array;
|
|
89
|
+
case 'float64':
|
|
90
|
+
return Float64Array;
|
|
91
|
+
default:
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// if (typeof BigInt64Array !== 'undefined') {
|
|
97
|
+
// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();
|
|
98
|
+
// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
|
|
99
|
+
// }
|
|
100
|
+
|
|
101
|
+
return Array;
|
|
102
|
+
}
|