@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,53 @@
|
|
|
1
|
+
import type { Schema } from '../../../types/schema';
|
|
2
|
+
import type { TableBatch } from '../../../types/category-table';
|
|
3
|
+
import type { TableBatchConstructor } from './table-batch-aggregator';
|
|
4
|
+
type TableBatchBuilderOptions = {
|
|
5
|
+
shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';
|
|
6
|
+
batchSize?: number | 'auto';
|
|
7
|
+
batchDebounceMs?: number;
|
|
8
|
+
limit: number;
|
|
9
|
+
_limitMB: number;
|
|
10
|
+
};
|
|
11
|
+
type GetBatchOptions = {
|
|
12
|
+
bytesUsed?: number;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
/** Incrementally builds batches from a stream of rows */
|
|
16
|
+
export declare class TableBatchBuilder {
|
|
17
|
+
schema: Schema;
|
|
18
|
+
options: Required<TableBatchBuilderOptions>;
|
|
19
|
+
private aggregator;
|
|
20
|
+
private batchCount;
|
|
21
|
+
private bytesUsed;
|
|
22
|
+
private isChunkComplete;
|
|
23
|
+
private lastBatchEmittedMs;
|
|
24
|
+
private totalLength;
|
|
25
|
+
private totalBytes;
|
|
26
|
+
private rowBytes;
|
|
27
|
+
static ArrowBatch?: TableBatchConstructor;
|
|
28
|
+
constructor(schema: Schema, options?: TableBatchBuilderOptions);
|
|
29
|
+
limitReached(): boolean;
|
|
30
|
+
/** @deprecated Use addArrayRow or addObjectRow */
|
|
31
|
+
addRow(row: any[] | {
|
|
32
|
+
[columnName: string]: any;
|
|
33
|
+
}): void;
|
|
34
|
+
/** Add one row to the batch */
|
|
35
|
+
protected addArrayRow(row: any[]): void;
|
|
36
|
+
/** Add one row to the batch */
|
|
37
|
+
protected addObjectRow(row: {
|
|
38
|
+
[columnName: string]: any;
|
|
39
|
+
}): void;
|
|
40
|
+
/** Mark an incoming raw memory chunk has completed */
|
|
41
|
+
chunkComplete(chunk: ArrayBuffer | string): void;
|
|
42
|
+
getFullBatch(options?: GetBatchOptions): TableBatch | null;
|
|
43
|
+
getFinalBatch(options?: GetBatchOptions): TableBatch | null;
|
|
44
|
+
_estimateRowMB(row: any[] | object): number;
|
|
45
|
+
private _isFull;
|
|
46
|
+
/**
|
|
47
|
+
* bytesUsed can be set via chunkComplete or via getBatch*
|
|
48
|
+
*/
|
|
49
|
+
private _getBatch;
|
|
50
|
+
private _getTableBatchType;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=table-batch-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-batch-builder.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/batches/table-batch-builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAuB,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AAM1F,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAC/F,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAYF,yDAAyD;AACzD,qBAAa,iBAAiB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,wBAAwB,CAAC,CAAC;IAE5C,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAa;IAE7B,MAAM,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAC;gBAE9B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAK9D,YAAY,IAAI,OAAO;IAUvB,kDAAkD;IAClD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,IAAI;IActD,+BAA+B;IAC/B,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;IAQhC,+BAA+B;IAC/B,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,IAAI;IAQ9D,sDAAsD;IACtD,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;IAUhD,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,IAAI;IAI1D,aAAa,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,IAAI;IAM3D,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,MAAM;IAI3C,OAAO,CAAC,OAAO;IA2Bf;;OAEG;IACH,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,kBAAkB;CAkB3B"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TableBatchBuilder = void 0;
|
|
5
|
+
const base_table_batch_aggregator_1 = require("./base-table-batch-aggregator");
|
|
6
|
+
const row_table_batch_aggregator_1 = require("./row-table-batch-aggregator");
|
|
7
|
+
const columnar_table_batch_aggregator_1 = require("./columnar-table-batch-aggregator");
|
|
8
|
+
const DEFAULT_OPTIONS = {
|
|
9
|
+
shape: 'array-row-table',
|
|
10
|
+
batchSize: 'auto',
|
|
11
|
+
batchDebounceMs: 0,
|
|
12
|
+
limit: 0,
|
|
13
|
+
_limitMB: 0
|
|
14
|
+
};
|
|
15
|
+
const ERR_MESSAGE = 'TableBatchBuilder';
|
|
16
|
+
/** Incrementally builds batches from a stream of rows */
|
|
17
|
+
class TableBatchBuilder {
|
|
18
|
+
constructor(schema, options) {
|
|
19
|
+
this.aggregator = null;
|
|
20
|
+
this.batchCount = 0;
|
|
21
|
+
this.bytesUsed = 0;
|
|
22
|
+
this.isChunkComplete = false;
|
|
23
|
+
this.lastBatchEmittedMs = Date.now();
|
|
24
|
+
this.totalLength = 0;
|
|
25
|
+
this.totalBytes = 0;
|
|
26
|
+
this.rowBytes = 0;
|
|
27
|
+
this.schema = schema;
|
|
28
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
29
|
+
}
|
|
30
|
+
limitReached() {
|
|
31
|
+
if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
/** @deprecated Use addArrayRow or addObjectRow */
|
|
40
|
+
addRow(row) {
|
|
41
|
+
if (this.limitReached()) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.totalLength++;
|
|
45
|
+
this.rowBytes = this.rowBytes || this._estimateRowMB(row);
|
|
46
|
+
this.totalBytes += this.rowBytes;
|
|
47
|
+
if (Array.isArray(row)) {
|
|
48
|
+
this.addArrayRow(row);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.addObjectRow(row);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Add one row to the batch */
|
|
55
|
+
addArrayRow(row) {
|
|
56
|
+
if (!this.aggregator) {
|
|
57
|
+
const TableBatchType = this._getTableBatchType();
|
|
58
|
+
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
59
|
+
}
|
|
60
|
+
this.aggregator.addArrayRow(row);
|
|
61
|
+
}
|
|
62
|
+
/** Add one row to the batch */
|
|
63
|
+
addObjectRow(row) {
|
|
64
|
+
if (!this.aggregator) {
|
|
65
|
+
const TableBatchType = this._getTableBatchType();
|
|
66
|
+
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
67
|
+
}
|
|
68
|
+
this.aggregator.addObjectRow(row);
|
|
69
|
+
}
|
|
70
|
+
/** Mark an incoming raw memory chunk has completed */
|
|
71
|
+
chunkComplete(chunk) {
|
|
72
|
+
if (chunk instanceof ArrayBuffer) {
|
|
73
|
+
this.bytesUsed += chunk.byteLength;
|
|
74
|
+
}
|
|
75
|
+
if (typeof chunk === 'string') {
|
|
76
|
+
this.bytesUsed += chunk.length;
|
|
77
|
+
}
|
|
78
|
+
this.isChunkComplete = true;
|
|
79
|
+
}
|
|
80
|
+
getFullBatch(options) {
|
|
81
|
+
return this._isFull() ? this._getBatch(options) : null;
|
|
82
|
+
}
|
|
83
|
+
getFinalBatch(options) {
|
|
84
|
+
return this._getBatch(options);
|
|
85
|
+
}
|
|
86
|
+
// INTERNAL
|
|
87
|
+
_estimateRowMB(row) {
|
|
88
|
+
return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
|
|
89
|
+
}
|
|
90
|
+
_isFull() {
|
|
91
|
+
// No batch, not ready
|
|
92
|
+
if (!this.aggregator || this.aggregator.rowCount() === 0) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
// if batchSize === 'auto' we wait for chunk to complete
|
|
96
|
+
// if batchSize === number, ensure we have enough rows
|
|
97
|
+
if (this.options.batchSize === 'auto') {
|
|
98
|
+
if (!this.isChunkComplete) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (this.options.batchSize > this.aggregator.rowCount()) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
// Debounce batches
|
|
106
|
+
if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
// Emit batch
|
|
110
|
+
this.isChunkComplete = false;
|
|
111
|
+
this.lastBatchEmittedMs = Date.now();
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* bytesUsed can be set via chunkComplete or via getBatch*
|
|
116
|
+
*/
|
|
117
|
+
_getBatch(options) {
|
|
118
|
+
if (!this.aggregator) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// TODO - this can overly increment bytes used?
|
|
122
|
+
if (options?.bytesUsed) {
|
|
123
|
+
this.bytesUsed = options.bytesUsed;
|
|
124
|
+
}
|
|
125
|
+
const normalizedBatch = this.aggregator.getBatch();
|
|
126
|
+
normalizedBatch.count = this.batchCount;
|
|
127
|
+
normalizedBatch.bytesUsed = this.bytesUsed;
|
|
128
|
+
Object.assign(normalizedBatch, options);
|
|
129
|
+
this.batchCount++;
|
|
130
|
+
this.aggregator = null;
|
|
131
|
+
return normalizedBatch;
|
|
132
|
+
}
|
|
133
|
+
_getTableBatchType() {
|
|
134
|
+
switch (this.options.shape) {
|
|
135
|
+
case 'row-table':
|
|
136
|
+
return base_table_batch_aggregator_1.BaseTableBatchAggregator;
|
|
137
|
+
case 'array-row-table':
|
|
138
|
+
case 'object-row-table':
|
|
139
|
+
return row_table_batch_aggregator_1.RowTableBatchAggregator;
|
|
140
|
+
case 'columnar-table':
|
|
141
|
+
return columnar_table_batch_aggregator_1.ColumnarTableBatchAggregator;
|
|
142
|
+
case 'arrow-table':
|
|
143
|
+
if (!TableBatchBuilder.ArrowBatch) {
|
|
144
|
+
throw new Error(ERR_MESSAGE);
|
|
145
|
+
}
|
|
146
|
+
return TableBatchBuilder.ArrowBatch;
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(ERR_MESSAGE);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.TableBatchBuilder = TableBatchBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Table, ArrayRowTable, ObjectRowTable, ColumnarTable } from '../../../types/category-table';
|
|
2
|
+
/** Convert any simple table into columnar format */
|
|
3
|
+
export declare function makeColumnarTable(table: Table): ColumnarTable;
|
|
4
|
+
/** Convert any table into array row format */
|
|
5
|
+
export declare function makeArrayRowTable(table: Table): ArrayRowTable;
|
|
6
|
+
/** Convert any table into object row format */
|
|
7
|
+
export declare function makeObjectRowTable(table: Table): ObjectRowTable;
|
|
8
|
+
//# sourceMappingURL=convert-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-table.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/simple-table/convert-table.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAIlG,oDAAoD;AACpD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAyB7D;AAED,8CAA8C;AAC9C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAc7D;AAED,+CAA+C;AAC/C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAc/D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeObjectRowTable = exports.makeArrayRowTable = exports.makeColumnarTable = void 0;
|
|
4
|
+
// loaders.gl, MIT license
|
|
5
|
+
const table_accessors_1 = require("./table-accessors");
|
|
6
|
+
const table_schema_1 = require("./table-schema");
|
|
7
|
+
const table_column_1 = require("./table-column");
|
|
8
|
+
/** Convert any simple table into columnar format */
|
|
9
|
+
function makeColumnarTable(table) {
|
|
10
|
+
// TODO - should schema really be optional?
|
|
11
|
+
const schema = table.schema || (0, table_schema_1.deduceTableSchema)(table);
|
|
12
|
+
const fields = table.schema?.fields || [];
|
|
13
|
+
if (table.shape === 'columnar-table') {
|
|
14
|
+
return { ...table, schema };
|
|
15
|
+
}
|
|
16
|
+
const length = (0, table_accessors_1.getTableLength)(table);
|
|
17
|
+
const columns = {};
|
|
18
|
+
for (const field of fields) {
|
|
19
|
+
const column = (0, table_column_1.makeColumnFromField)(field, length);
|
|
20
|
+
columns[field.name] = column;
|
|
21
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
22
|
+
column[rowIndex] = (0, table_accessors_1.getTableCell)(table, rowIndex, field.name);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
shape: 'columnar-table',
|
|
27
|
+
schema,
|
|
28
|
+
data: columns
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.makeColumnarTable = makeColumnarTable;
|
|
32
|
+
/** Convert any table into array row format */
|
|
33
|
+
function makeArrayRowTable(table) {
|
|
34
|
+
if (table.shape === 'array-row-table') {
|
|
35
|
+
return table;
|
|
36
|
+
}
|
|
37
|
+
const length = (0, table_accessors_1.getTableLength)(table);
|
|
38
|
+
const data = new Array(length);
|
|
39
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
40
|
+
data[rowIndex] = (0, table_accessors_1.getTableRowAsArray)(table, rowIndex);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
shape: 'array-row-table',
|
|
44
|
+
schema: table.schema,
|
|
45
|
+
data
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.makeArrayRowTable = makeArrayRowTable;
|
|
49
|
+
/** Convert any table into object row format */
|
|
50
|
+
function makeObjectRowTable(table) {
|
|
51
|
+
if (table.shape === 'object-row-table') {
|
|
52
|
+
return table;
|
|
53
|
+
}
|
|
54
|
+
const length = (0, table_accessors_1.getTableLength)(table);
|
|
55
|
+
const data = new Array(length);
|
|
56
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
57
|
+
data[rowIndex] = (0, table_accessors_1.getTableRowAsObject)(table, rowIndex);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
shape: 'object-row-table',
|
|
61
|
+
schema: table.schema,
|
|
62
|
+
data
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.makeObjectRowTable = makeObjectRowTable;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DataType } from '../../../types/schema';
|
|
2
|
+
import { TypedArray, TypedArrayConstructor, ArrayType } from '../../../types/types';
|
|
3
|
+
/** Deduce column types from values */
|
|
4
|
+
export declare function getDataTypeFromValue(value: unknown, defaultNumberType?: 'float32'): DataType;
|
|
5
|
+
/**
|
|
6
|
+
* Deduces a simple data type "descriptor from a typed array instance
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDataTypeFromArray(array: ArrayType): {
|
|
9
|
+
type: DataType;
|
|
10
|
+
nullable: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Deduces a simple data type "descriptor from a typed array instance
|
|
14
|
+
*/
|
|
15
|
+
export declare function getDataTypeFromTypedArray(array: TypedArray): DataType;
|
|
16
|
+
export declare function getArrayTypeFromDataType(type: DataType, nullable: boolean | undefined): TypedArrayConstructor | ArrayConstructor;
|
|
17
|
+
//# sourceMappingURL=data-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-type.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/simple-table/data-type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAE,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAElF,sCAAsC;AACtC,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,iBAAiB,GAAE,SAAqB,GACvC,QAAQ,CAcV;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAC,CAW1F;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAsBrE;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,OAAO,GAAG,SAAS,GAC5B,qBAAqB,GAAG,gBAAgB,CA8B1C"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getArrayTypeFromDataType = exports.getDataTypeFromTypedArray = exports.getDataTypeFromArray = exports.getDataTypeFromValue = void 0;
|
|
5
|
+
/** Deduce column types from values */
|
|
6
|
+
function getDataTypeFromValue(value, defaultNumberType = 'float32') {
|
|
7
|
+
if (value instanceof Date) {
|
|
8
|
+
return 'date-millisecond';
|
|
9
|
+
}
|
|
10
|
+
if (value instanceof Number) {
|
|
11
|
+
return defaultNumberType;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'string') {
|
|
14
|
+
return 'utf8';
|
|
15
|
+
}
|
|
16
|
+
if (value === null || value === 'undefined') {
|
|
17
|
+
return 'null';
|
|
18
|
+
}
|
|
19
|
+
return 'null';
|
|
20
|
+
}
|
|
21
|
+
exports.getDataTypeFromValue = getDataTypeFromValue;
|
|
22
|
+
/**
|
|
23
|
+
* Deduces a simple data type "descriptor from a typed array instance
|
|
24
|
+
*/
|
|
25
|
+
function getDataTypeFromArray(array) {
|
|
26
|
+
let type = getDataTypeFromTypedArray(array);
|
|
27
|
+
if (type !== 'null') {
|
|
28
|
+
return { type, nullable: false };
|
|
29
|
+
}
|
|
30
|
+
if (array.length > 0) {
|
|
31
|
+
type = getDataTypeFromValue(array[0]);
|
|
32
|
+
return { type, nullable: true };
|
|
33
|
+
}
|
|
34
|
+
return { type: 'null', nullable: true };
|
|
35
|
+
}
|
|
36
|
+
exports.getDataTypeFromArray = getDataTypeFromArray;
|
|
37
|
+
/**
|
|
38
|
+
* Deduces a simple data type "descriptor from a typed array instance
|
|
39
|
+
*/
|
|
40
|
+
function getDataTypeFromTypedArray(array) {
|
|
41
|
+
switch (array.constructor) {
|
|
42
|
+
case Int8Array:
|
|
43
|
+
return 'int8';
|
|
44
|
+
case Uint8Array:
|
|
45
|
+
case Uint8ClampedArray:
|
|
46
|
+
return 'uint8';
|
|
47
|
+
case Int16Array:
|
|
48
|
+
return 'int16';
|
|
49
|
+
case Uint16Array:
|
|
50
|
+
return 'uint16';
|
|
51
|
+
case Int32Array:
|
|
52
|
+
return 'int32';
|
|
53
|
+
case Uint32Array:
|
|
54
|
+
return 'uint32';
|
|
55
|
+
case Float32Array:
|
|
56
|
+
return 'float32';
|
|
57
|
+
case Float64Array:
|
|
58
|
+
return 'float64';
|
|
59
|
+
default:
|
|
60
|
+
return 'null';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.getDataTypeFromTypedArray = getDataTypeFromTypedArray;
|
|
64
|
+
function getArrayTypeFromDataType(type, nullable) {
|
|
65
|
+
if (!nullable) {
|
|
66
|
+
switch (type) {
|
|
67
|
+
case 'int8':
|
|
68
|
+
return Int8Array;
|
|
69
|
+
case 'uint8':
|
|
70
|
+
return Uint8Array;
|
|
71
|
+
case 'int16':
|
|
72
|
+
return Int16Array;
|
|
73
|
+
case 'uint16':
|
|
74
|
+
return Uint16Array;
|
|
75
|
+
case 'int32':
|
|
76
|
+
return Int32Array;
|
|
77
|
+
case 'uint32':
|
|
78
|
+
return Uint32Array;
|
|
79
|
+
case 'float32':
|
|
80
|
+
return Float32Array;
|
|
81
|
+
case 'float64':
|
|
82
|
+
return Float64Array;
|
|
83
|
+
default:
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// if (typeof BigInt64Array !== 'undefined') {
|
|
88
|
+
// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();
|
|
89
|
+
// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
|
|
90
|
+
// }
|
|
91
|
+
return Array;
|
|
92
|
+
}
|
|
93
|
+
exports.getArrayTypeFromDataType = getArrayTypeFromDataType;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ArrayRowTable, ObjectRowTable, ColumnarTable } from '../../../types/category-table';
|
|
2
|
+
/**
|
|
3
|
+
* Makes a typed table from data.
|
|
4
|
+
* @throws Row tables must contain at least one row. Columnar tables must contain empty arrays
|
|
5
|
+
*/
|
|
6
|
+
export declare function makeTableFromData(data: unknown[][]): ArrayRowTable;
|
|
7
|
+
export declare function makeTableFromData(data: {
|
|
8
|
+
[column: string]: unknown;
|
|
9
|
+
}[]): ObjectRowTable;
|
|
10
|
+
export declare function makeTableFromData(data: {
|
|
11
|
+
[column: string]: ArrayLike<unknown>;
|
|
12
|
+
}): ColumnarTable;
|
|
13
|
+
/** Convert any table into object row format *
|
|
14
|
+
export function makeColumnarTable(table: Table): ColumnarTable {
|
|
15
|
+
if (table.shape === 'columnar-table') {
|
|
16
|
+
return table;
|
|
17
|
+
}
|
|
18
|
+
const length = getTableLength(table);
|
|
19
|
+
const data = new Array<{[key: string]: unknown}>(length);
|
|
20
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
21
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
shape: 'columnar-table',
|
|
25
|
+
schema: table.schema,
|
|
26
|
+
data
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/** Convert any table into array row format *
|
|
32
|
+
export function makeArrayRowTable(table: TableLike): ArrayRowTable {
|
|
33
|
+
if (table.shape === 'array-row-table') {
|
|
34
|
+
return table;
|
|
35
|
+
}
|
|
36
|
+
const length = getTableLength(table);
|
|
37
|
+
const data = new Array<unknown[]>(length);
|
|
38
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
39
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
shape: 'array-row-table',
|
|
43
|
+
schema: table.schema,
|
|
44
|
+
data
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Convert any table into object row format *
|
|
49
|
+
export function makeObjectRowTable(table: Table): ObjectRowTable {
|
|
50
|
+
if (table.shape === 'object-row-table') {
|
|
51
|
+
return table;
|
|
52
|
+
}
|
|
53
|
+
const length = getTableLength(table);
|
|
54
|
+
const data = new Array<{[key: string]: unknown}>(length);
|
|
55
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
56
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
shape: 'object-row-table',
|
|
60
|
+
schema: table.schema,
|
|
61
|
+
data
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
*/
|
|
65
|
+
//# sourceMappingURL=make-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-table.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/simple-table/make-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,aAAa,EAAE,cAAc,EAAE,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAGlG;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,GAAG,aAAa,CAAC;AACpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,EAAE,GAAG,cAAc,CAAC;AACvF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAC,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;CAAC,GAAG,aAAa,CAAC;AA8C/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTableFromData = void 0;
|
|
4
|
+
const table_schema_1 = require("./table-schema");
|
|
5
|
+
function makeTableFromData(data) {
|
|
6
|
+
let table;
|
|
7
|
+
switch (getTableShapeFromData(data)) {
|
|
8
|
+
case 'array-row-table':
|
|
9
|
+
table = { shape: 'array-row-table', data: data };
|
|
10
|
+
break;
|
|
11
|
+
case 'object-row-table':
|
|
12
|
+
table = { shape: 'object-row-table', data: data };
|
|
13
|
+
break;
|
|
14
|
+
case 'columnar-table':
|
|
15
|
+
table = { shape: 'columnar-table', data: data };
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
throw new Error('table');
|
|
19
|
+
}
|
|
20
|
+
const schema = (0, table_schema_1.deduceTableSchema)(table);
|
|
21
|
+
return { ...table, schema };
|
|
22
|
+
}
|
|
23
|
+
exports.makeTableFromData = makeTableFromData;
|
|
24
|
+
/** Helper function to get shape of data */
|
|
25
|
+
function getTableShapeFromData(data) {
|
|
26
|
+
if (Array.isArray(data)) {
|
|
27
|
+
if (data.length === 0) {
|
|
28
|
+
throw new Error('cannot deduce type of empty table');
|
|
29
|
+
}
|
|
30
|
+
// Deduce the table shape from the first row
|
|
31
|
+
const firstRow = data[0];
|
|
32
|
+
if (Array.isArray(firstRow)) {
|
|
33
|
+
return 'array-row-table';
|
|
34
|
+
}
|
|
35
|
+
if (firstRow && typeof firstRow === 'object') {
|
|
36
|
+
return 'object-row-table';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (data && typeof data === 'object') {
|
|
40
|
+
return 'columnar-table';
|
|
41
|
+
}
|
|
42
|
+
throw new Error('invalid table');
|
|
43
|
+
}
|
|
44
|
+
/** Convert any table into object row format *
|
|
45
|
+
export function makeColumnarTable(table: Table): ColumnarTable {
|
|
46
|
+
if (table.shape === 'columnar-table') {
|
|
47
|
+
return table;
|
|
48
|
+
}
|
|
49
|
+
const length = getTableLength(table);
|
|
50
|
+
const data = new Array<{[key: string]: unknown}>(length);
|
|
51
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
52
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
shape: 'columnar-table',
|
|
56
|
+
schema: table.schema,
|
|
57
|
+
data
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/** Convert any table into array row format *
|
|
63
|
+
export function makeArrayRowTable(table: TableLike): ArrayRowTable {
|
|
64
|
+
if (table.shape === 'array-row-table') {
|
|
65
|
+
return table;
|
|
66
|
+
}
|
|
67
|
+
const length = getTableLength(table);
|
|
68
|
+
const data = new Array<unknown[]>(length);
|
|
69
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
70
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
shape: 'array-row-table',
|
|
74
|
+
schema: table.schema,
|
|
75
|
+
data
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Convert any table into object row format *
|
|
80
|
+
export function makeObjectRowTable(table: Table): ObjectRowTable {
|
|
81
|
+
if (table.shape === 'object-row-table') {
|
|
82
|
+
return table;
|
|
83
|
+
}
|
|
84
|
+
const length = getTableLength(table);
|
|
85
|
+
const data = new Array<{[key: string]: unknown}>(length);
|
|
86
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
87
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
shape: 'object-row-table',
|
|
91
|
+
schema: table.schema,
|
|
92
|
+
data
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Convert an object row to an array row */
|
|
2
|
+
export declare function convertToObjectRow(arrayRow: any[], headers: string[]): {
|
|
3
|
+
[columnName: string]: any;
|
|
4
|
+
};
|
|
5
|
+
/** Convert an object row to an array row */
|
|
6
|
+
export declare function convertToArrayRow(objectRow: {
|
|
7
|
+
[columnName: string]: any;
|
|
8
|
+
}, headers: string[]): any[];
|
|
9
|
+
//# sourceMappingURL=row-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/simple-table/row-utils.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,GAAG,EAAE,EACf,OAAO,EAAE,MAAM,EAAE,GAChB;IAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAY7B;AAED,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE;IAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,EACtC,OAAO,EAAE,MAAM,EAAE,GAChB,GAAG,EAAE,CAYP"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToArrayRow = exports.convertToObjectRow = void 0;
|
|
4
|
+
/** Convert an object row to an array row */
|
|
5
|
+
function convertToObjectRow(arrayRow, headers) {
|
|
6
|
+
if (!arrayRow) {
|
|
7
|
+
throw new Error('null row');
|
|
8
|
+
}
|
|
9
|
+
if (!headers) {
|
|
10
|
+
throw new Error('no headers');
|
|
11
|
+
}
|
|
12
|
+
const objectRow = {};
|
|
13
|
+
for (let i = 0; i < headers.length; i++) {
|
|
14
|
+
objectRow[headers[i]] = arrayRow[i];
|
|
15
|
+
}
|
|
16
|
+
return objectRow;
|
|
17
|
+
}
|
|
18
|
+
exports.convertToObjectRow = convertToObjectRow;
|
|
19
|
+
/** Convert an object row to an array row */
|
|
20
|
+
function convertToArrayRow(objectRow, headers) {
|
|
21
|
+
if (!objectRow) {
|
|
22
|
+
throw new Error('null row');
|
|
23
|
+
}
|
|
24
|
+
if (!headers) {
|
|
25
|
+
throw new Error('no headers');
|
|
26
|
+
}
|
|
27
|
+
const arrayRow = new Array(headers.length);
|
|
28
|
+
for (let i = 0; i < headers.length; i++) {
|
|
29
|
+
arrayRow[i] = objectRow[headers[i]];
|
|
30
|
+
}
|
|
31
|
+
return arrayRow;
|
|
32
|
+
}
|
|
33
|
+
exports.convertToArrayRow = convertToArrayRow;
|