@loaders.gl/schema 4.0.0-beta.2 → 4.0.0-beta.3
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/dist.dev.js +1745 -0
- package/dist/index.cjs +1692 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/lib → lib}/mesh/convert-mesh.js +1 -1
- package/dist/lib/mesh/convert-mesh.js.map +1 -0
- package/dist/{esm/lib → lib}/mesh/deduce-mesh-schema.js +1 -1
- package/dist/lib/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/lib/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/lib/mesh/mesh-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-field.js +5 -6
- package/dist/lib/table/arrow-api/arrow-like-field.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-schema.js +3 -4
- package/dist/lib/table/arrow-api/arrow-like-schema.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-table.js +7 -8
- package/dist/lib/table/arrow-api/arrow-like-table.js.map +1 -0
- package/dist/lib/table/arrow-api/arrow-like-type.d.ts +1 -1
- package/dist/lib/table/arrow-api/arrow-like-type.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-type.js +22 -23
- package/dist/lib/table/arrow-api/arrow-like-type.js.map +1 -0
- package/dist/lib/table/arrow-api/enum.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/get-type-info.js +1 -1
- package/dist/lib/table/arrow-api/get-type-info.js.map +1 -0
- package/dist/lib/table/arrow-api/index.js +5 -0
- package/dist/lib/table/arrow-api/index.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/base-table-batch-aggregator.js +6 -7
- package/dist/lib/table/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/columnar-table-batch-aggregator.js +4 -5
- package/dist/lib/table/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/row-table-batch-aggregator.js +8 -9
- package/dist/lib/table/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/lib/table/batches/table-batch-aggregator.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/table-batch-builder.js +14 -15
- package/dist/lib/table/batches/table-batch-builder.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/convert-table.js +3 -3
- package/dist/lib/table/simple-table/convert-table.js.map +1 -0
- package/dist/lib/table/simple-table/data-type.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/make-table.js +1 -1
- package/dist/lib/table/simple-table/make-table.js.map +1 -0
- package/dist/lib/table/simple-table/row-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/table-accessors.js +2 -2
- package/dist/lib/table/simple-table/table-accessors.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/table-column.js +1 -1
- package/dist/lib/table/simple-table/table-column.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/table-schema.js +1 -1
- package/dist/lib/table/simple-table/table-schema.js.map +1 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/{esm/lib → lib}/utils/async-queue.js +3 -4
- package/dist/lib/utils/async-queue.js.map +1 -0
- package/dist/types/batch.d.ts +3 -2
- package/dist/types/batch.d.ts.map +1 -1
- package/dist/types/batch.js.map +1 -0
- package/dist/types/binary-geometries.js.map +1 -0
- package/dist/types/category-gis.js.map +1 -0
- package/dist/types/category-image.js.map +1 -0
- package/dist/types/category-mesh.js.map +1 -0
- package/dist/types/category-table.js.map +1 -0
- package/dist/types/category-texture.js.map +1 -0
- package/dist/types/flat-geometries.js.map +1 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js.map +1 -0
- package/package.json +14 -6
- package/src/index.ts +0 -1
- package/src/lib/table/arrow-api/arrow-like-type.ts +0 -2
- package/src/types/batch.ts +4 -2
- package/src/types/types.ts +0 -2
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/dist.min.js +0 -13204
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -413
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/mesh/convert-mesh.js +0 -34
- package/dist/es5/lib/mesh/convert-mesh.js.map +0 -1
- package/dist/es5/lib/mesh/deduce-mesh-schema.js +0 -56
- package/dist/es5/lib/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/es5/lib/mesh/mesh-to-arrow-table.js +0 -2
- package/dist/es5/lib/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/es5/lib/mesh/mesh-utils.js +0 -40
- package/dist/es5/lib/mesh/mesh-utils.js.map +0 -1
- package/dist/es5/lib/table/arrow/arrow-type-utils.js +0 -30
- package/dist/es5/lib/table/arrow/arrow-type-utils.js.map +0 -1
- package/dist/es5/lib/table/arrow/convert-schema-arrow.js +0 -179
- package/dist/es5/lib/table/arrow/convert-schema-arrow.js.map +0 -1
- package/dist/es5/lib/table/arrow/convert-table-to-arrow.js +0 -2
- package/dist/es5/lib/table/arrow/convert-table-to-arrow.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-field.js +0 -49
- package/dist/es5/lib/table/arrow-api/arrow-like-field.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-schema.js +0 -118
- package/dist/es5/lib/table/arrow-api/arrow-like-schema.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js +0 -81
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-type.js +0 -740
- package/dist/es5/lib/table/arrow-api/arrow-like-type.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/enum.js +0 -55
- package/dist/es5/lib/table/arrow-api/enum.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/get-type-info.js +0 -27
- package/dist/es5/lib/table/arrow-api/get-type-info.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/index.js +0 -44
- package/dist/es5/lib/table/arrow-api/index.js.map +0 -1
- package/dist/es5/lib/table/batches/base-table-batch-aggregator.js +0 -78
- package/dist/es5/lib/table/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/columnar-table-batch-aggregator.js +0 -106
- package/dist/es5/lib/table/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js +0 -96
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/table-batch-aggregator.js +0 -2
- package/dist/es5/lib/table/batches/table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/table-batch-builder.js +0 -173
- package/dist/es5/lib/table/batches/table-batch-builder.js.map +0 -1
- package/dist/es5/lib/table/simple-table/convert-table.js +0 -106
- package/dist/es5/lib/table/simple-table/convert-table.js.map +0 -1
- package/dist/es5/lib/table/simple-table/data-type.js +0 -94
- package/dist/es5/lib/table/simple-table/data-type.js.map +0 -1
- package/dist/es5/lib/table/simple-table/make-table.js +0 -60
- package/dist/es5/lib/table/simple-table/make-table.js.map +0 -1
- package/dist/es5/lib/table/simple-table/row-utils.js +0 -34
- package/dist/es5/lib/table/simple-table/row-utils.js.map +0 -1
- package/dist/es5/lib/table/simple-table/table-accessors.js +0 -370
- package/dist/es5/lib/table/simple-table/table-accessors.js.map +0 -1
- package/dist/es5/lib/table/simple-table/table-column.js +0 -12
- package/dist/es5/lib/table/simple-table/table-column.js.map +0 -1
- package/dist/es5/lib/table/simple-table/table-schema.js +0 -85
- package/dist/es5/lib/table/simple-table/table-schema.js.map +0 -1
- package/dist/es5/lib/utils/assert.js +0 -12
- package/dist/es5/lib/utils/assert.js.map +0 -1
- package/dist/es5/lib/utils/async-queue.js +0 -169
- package/dist/es5/lib/utils/async-queue.js.map +0 -1
- package/dist/es5/types/batch.js +0 -2
- package/dist/es5/types/batch.js.map +0 -1
- package/dist/es5/types/binary-geometries.js +0 -2
- package/dist/es5/types/binary-geometries.js.map +0 -1
- package/dist/es5/types/category-gis.js +0 -2
- package/dist/es5/types/category-gis.js.map +0 -1
- package/dist/es5/types/category-image.js +0 -2
- package/dist/es5/types/category-image.js.map +0 -1
- package/dist/es5/types/category-mesh.js +0 -2
- package/dist/es5/types/category-mesh.js.map +0 -1
- package/dist/es5/types/category-table.js +0 -2
- package/dist/es5/types/category-table.js.map +0 -1
- package/dist/es5/types/category-texture.js +0 -2
- package/dist/es5/types/category-texture.js.map +0 -1
- package/dist/es5/types/flat-geometries.js +0 -2
- package/dist/es5/types/flat-geometries.js.map +0 -1
- package/dist/es5/types/schema.js +0 -2
- package/dist/es5/types/schema.js.map +0 -1
- package/dist/es5/types/types.js +0 -2
- package/dist/es5/types/types.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -17
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/mesh/convert-mesh.js.map +0 -1
- package/dist/esm/lib/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/esm/lib/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/esm/lib/mesh/mesh-utils.js.map +0 -1
- package/dist/esm/lib/table/arrow/arrow-type-utils.js +0 -24
- package/dist/esm/lib/table/arrow/arrow-type-utils.js.map +0 -1
- package/dist/esm/lib/table/arrow/convert-schema-arrow.js +0 -158
- package/dist/esm/lib/table/arrow/convert-schema-arrow.js.map +0 -1
- package/dist/esm/lib/table/arrow/convert-table-to-arrow.js +0 -2
- package/dist/esm/lib/table/arrow/convert-table-to-arrow.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-field.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-schema.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-type.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/enum.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/get-type-info.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/index.js +0 -5
- package/dist/esm/lib/table/arrow-api/index.js.map +0 -1
- package/dist/esm/lib/table/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/table-batch-builder.js.map +0 -1
- package/dist/esm/lib/table/simple-table/convert-table.js.map +0 -1
- package/dist/esm/lib/table/simple-table/data-type.js.map +0 -1
- package/dist/esm/lib/table/simple-table/make-table.js.map +0 -1
- package/dist/esm/lib/table/simple-table/row-utils.js.map +0 -1
- package/dist/esm/lib/table/simple-table/table-accessors.js.map +0 -1
- package/dist/esm/lib/table/simple-table/table-column.js.map +0 -1
- package/dist/esm/lib/table/simple-table/table-schema.js.map +0 -1
- package/dist/esm/lib/utils/assert.js.map +0 -1
- package/dist/esm/lib/utils/async-queue.js.map +0 -1
- package/dist/esm/types/batch.js.map +0 -1
- package/dist/esm/types/binary-geometries.js.map +0 -1
- package/dist/esm/types/category-gis.js.map +0 -1
- package/dist/esm/types/category-image.js.map +0 -1
- package/dist/esm/types/category-mesh.js.map +0 -1
- package/dist/esm/types/category-table.js.map +0 -1
- package/dist/esm/types/category-texture.js.map +0 -1
- package/dist/esm/types/flat-geometries.js.map +0 -1
- package/dist/esm/types/schema.js.map +0 -1
- package/dist/esm/types/types.js.map +0 -1
- package/dist/lib/table/arrow/arrow-type-utils.d.ts +0 -4
- package/dist/lib/table/arrow/arrow-type-utils.d.ts.map +0 -1
- package/dist/lib/table/arrow/convert-schema-arrow.d.ts +0 -13
- package/dist/lib/table/arrow/convert-schema-arrow.d.ts.map +0 -1
- package/dist/lib/table/arrow/convert-table-to-arrow.d.ts +0 -42
- package/dist/lib/table/arrow/convert-table-to-arrow.d.ts.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/lib/table/arrow/arrow-type-utils.ts +0 -71
- package/src/lib/table/arrow/convert-schema-arrow.ts +0 -232
- package/src/lib/table/arrow/convert-table-to-arrow.ts +0 -59
- /package/dist/{esm/lib → lib}/mesh/mesh-to-arrow-table.js +0 -0
- /package/dist/{esm/lib → lib}/mesh/mesh-utils.js +0 -0
- /package/dist/{esm/lib → lib}/table/arrow-api/enum.js +0 -0
- /package/dist/{esm/lib → lib}/table/batches/table-batch-aggregator.js +0 -0
- /package/dist/{esm/lib → lib}/table/simple-table/data-type.js +0 -0
- /package/dist/{esm/lib → lib}/table/simple-table/row-utils.js +0 -0
- /package/dist/{esm/lib → lib}/utils/assert.js +0 -0
- /package/dist/{esm/types → types}/batch.js +0 -0
- /package/dist/{esm/types → types}/binary-geometries.js +0 -0
- /package/dist/{esm/types → types}/category-gis.js +0 -0
- /package/dist/{esm/types → types}/category-image.js +0 -0
- /package/dist/{esm/types → types}/category-mesh.js +0 -0
- /package/dist/{esm/types → types}/category-table.js +0 -0
- /package/dist/{esm/types → types}/category-texture.js +0 -0
- /package/dist/{esm/types → types}/flat-geometries.js +0 -0
- /package/dist/{esm/types → types}/schema.js +0 -0
- /package/dist/{esm/types → types}/types.js +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { convertToArrayRow, convertToObjectRow } from '../simple-table/row-utils';
|
|
1
|
+
import { convertToArrayRow, convertToObjectRow } from "../simple-table/row-utils.js";
|
|
3
2
|
const DEFAULT_ROW_COUNT = 100;
|
|
4
3
|
export class RowTableBatchAggregator {
|
|
5
4
|
constructor(schema, options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
this.schema = void 0;
|
|
6
|
+
this.options = void 0;
|
|
7
|
+
this.length = 0;
|
|
8
|
+
this.objectRows = null;
|
|
9
|
+
this.arrayRows = null;
|
|
10
|
+
this.cursor = 0;
|
|
11
|
+
this._headers = [];
|
|
13
12
|
this.options = options;
|
|
14
13
|
this.schema = schema;
|
|
15
14
|
if (!Array.isArray(schema)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-table-batch-aggregator.js","names":["convertToArrayRow","convertToObjectRow","DEFAULT_ROW_COUNT","RowTableBatchAggregator","constructor","schema","options","length","objectRows","arrayRows","cursor","_headers","Array","isArray","key","index","name","rowCount","addArrayRow","row","Number","isFinite","shape","rowObject","addObjectRow","rowArray","getBatch","rows","slice","batchType","data"],"sources":["../../../../src/lib/table/batches/row-table-batch-aggregator.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from '../../../types/schema';\nimport type {TableBatch} from '../../../types/category-table';\n// import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';\nimport {convertToArrayRow, convertToObjectRow} from '../simple-table/row-utils';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n objectRows: {[columnName: string]: unknown}[] | null = null;\n arrayRows: unknown[][] | null = null;\n cursor: number = 0;\n private _headers: string[] = [];\n\n constructor(schema: Schema, options: TableBatchOptions) {\n this.options = options;\n this.schema = schema;\n\n // schema is an array if there're no headers\n // object if there are headers\n if (!Array.isArray(schema)) {\n this._headers = [];\n for (const key in schema) {\n this._headers[schema[key].index] = schema[key].name;\n }\n }\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[], cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'object-row-table':\n const rowObject = convertToObjectRow(row, this._headers);\n this.addObjectRow(rowObject, cursor);\n break;\n case 'array-row-table':\n this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT);\n this.arrayRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n addObjectRow(row: {[columnName: string]: any}, cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'array-row-table':\n const rowArray = convertToArrayRow(row, this._headers);\n this.addArrayRow(rowArray, cursor);\n break;\n case 'object-row-table':\n this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT);\n this.objectRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n getBatch(): TableBatch | null {\n let rows = this.arrayRows || this.objectRows;\n if (!rows) {\n return null;\n }\n\n rows = rows.slice(0, this.length);\n this.arrayRows = null;\n this.objectRows = null;\n\n return {\n shape: this.options.shape,\n batchType: 'data',\n data: rows,\n length: this.length,\n schema: this.schema,\n cursor: this.cursor\n };\n }\n}\n"],"mappings":"SAKQA,iBAAiB,EAAEC,kBAAkB;AAG7C,MAAMC,iBAAiB,GAAG,GAAG;AAE7B,OAAO,MAAMC,uBAAuB,CAAiC;EAUnEC,WAAWA,CAACC,MAAc,EAAEC,OAA0B,EAAE;IAAA,KATxDD,MAAM;IAAA,KACNC,OAAO;IAAA,KAEPC,MAAM,GAAW,CAAC;IAAA,KAClBC,UAAU,GAA6C,IAAI;IAAA,KAC3DC,SAAS,GAAuB,IAAI;IAAA,KACpCC,MAAM,GAAW,CAAC;IAAA,KACVC,QAAQ,GAAa,EAAE;IAG7B,IAAI,CAACL,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACD,MAAM,GAAGA,MAAM;IAIpB,IAAI,CAACO,KAAK,CAACC,OAAO,CAACR,MAAM,CAAC,EAAE;MAC1B,IAAI,CAACM,QAAQ,GAAG,EAAE;MAClB,KAAK,MAAMG,G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,IAAII,KAAK,CAACV,iBAAiB,CAAC;QACjE,IAAI,CAACM,UAAU,CAAC,IAAI,CAACD,MAAM,CAAC,GAAGY,GAAG;QAClC,IAAI,CAACZ,MAAM,EAAE;QACb;IACJ;EACF;EAEAmB,QAAQA,CAAA,EAAsB;IAC5B,IAAIC,IAAI,GAAG,IAAI,CAAClB,SAAS,IAAI,IAAI,CAACD,UAAU;IAC5C,IAAI,CAACmB,IAAI,EAAE;MACT,OAAO,IAAI;IACb;IAEAA,IAAI,GAAGA,IAAI,CAACC,KAAK,CAAC,CAAC,EAAE,IAAI,CAACrB,MAAM,CAAC;IACjC,IAAI,CAACE,SAAS,GAAG,IAAI;IACrB,IAAI,CAACD,UAAU,GAAG,IAAI;IAEtB,OAAO;MACLc,KAAK,EAAE,IAAI,CAAChB,OAAO,CAACgB,KAAK;MACzBO,SAAS,EAAE,MAAM;MACjBC,IAAI,EAAEH,IAAI;MACVpB,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBF,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBK,MAAM,EAAE,IAAI,CAACA;IACf,CAAC;EACH;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-batch-aggregator.js","names":[],"sources":["../../../../src/lib/table/batches/table-batch-aggregator.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from '../../../types/schema';\nimport type {TableBatch} from '../../../types/category-table';\n\nexport interface TableBatchOptions {\n batchSize: number | string;\n [key: string]: any;\n}\n\nexport interface TableBatchConstructor {\n new (schema: Schema, options: TableBatchOptions): TableBatchAggregator;\n}\n\n/**\n * TableBatchBuilder delegates batch building to this interface\n */\nexport interface TableBatchAggregator {\n /** Number of rows */\n rowCount(): number;\n /** Add one row */\n addArrayRow(row: any[]): void;\n /** Add one row */\n addObjectRow(row: {[columnName: string]: any}): void;\n /** return a batch object */\n getBatch(): TableBatch | null;\n}\n"],"mappings":""}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ColumnarTableBatchAggregator } from './columnar-table-batch-aggregator';
|
|
1
|
+
import { BaseTableBatchAggregator } from "./base-table-batch-aggregator.js";
|
|
2
|
+
import { RowTableBatchAggregator } from "./row-table-batch-aggregator.js";
|
|
3
|
+
import { ColumnarTableBatchAggregator } from "./columnar-table-batch-aggregator.js";
|
|
5
4
|
const DEFAULT_OPTIONS = {
|
|
6
5
|
shape: 'array-row-table',
|
|
7
6
|
batchSize: 'auto',
|
|
@@ -12,16 +11,16 @@ const DEFAULT_OPTIONS = {
|
|
|
12
11
|
const ERR_MESSAGE = 'TableBatchBuilder';
|
|
13
12
|
export class TableBatchBuilder {
|
|
14
13
|
constructor(schema, options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
this.schema = void 0;
|
|
15
|
+
this.options = void 0;
|
|
16
|
+
this.aggregator = null;
|
|
17
|
+
this.batchCount = 0;
|
|
18
|
+
this.bytesUsed = 0;
|
|
19
|
+
this.isChunkComplete = false;
|
|
20
|
+
this.lastBatchEmittedMs = Date.now();
|
|
21
|
+
this.totalLength = 0;
|
|
22
|
+
this.totalBytes = 0;
|
|
23
|
+
this.rowBytes = 0;
|
|
25
24
|
this.schema = schema;
|
|
26
25
|
this.options = {
|
|
27
26
|
...DEFAULT_OPTIONS,
|
|
@@ -135,5 +134,5 @@ export class TableBatchBuilder {
|
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
|
|
137
|
+
TableBatchBuilder.ArrowBatch = void 0;
|
|
139
138
|
//# sourceMappingURL=table-batch-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-batch-builder.js","names":["BaseTableBatchAggregator","RowTableBatchAggregator","ColumnarTableBatchAggregator","DEFAULT_OPTIONS","shape","batchSize","batchDebounceMs","limit","_limitMB","ERR_MESSAGE","TableBatchBuilder","constructor","schema","options","aggregator","batchCount","bytesUsed","isChunkComplete","lastBatchEmittedMs","Date","now","totalLength","totalBytes","rowBytes","limitReached","_this$options","_this$options2","Boolean","addRow","row","_estimateRowMB","Array","isArray","addArrayRow","addObjectRow","TableBatchType","_getTableBatchType","chunkComplete","chunk","ArrayBuffer","byteLength","length","getFullBatch","_isFull","_getBatch","getFinalBatch","Object","keys","rowCount","normalizedBatch","getBatch","count","assign","ArrowBatch","Error"],"sources":["../../../../src/lib/table/batches/table-batch-builder.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from '../../../types/schema';\nimport type {TableBatch} from '../../../types/category-table';\nimport type {TableBatchAggregator, TableBatchConstructor} from './table-batch-aggregator';\nimport {BaseTableBatchAggregator} from './base-table-batch-aggregator';\nimport {RowTableBatchAggregator} from './row-table-batch-aggregator';\nimport {ColumnarTableBatchAggregator} from './columnar-table-batch-aggregator';\n\n// TODO define interface instead\ntype TableBatchBuilderOptions = {\n shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';\n batchSize?: number | 'auto';\n batchDebounceMs?: number;\n limit: number;\n _limitMB: number;\n};\n\ntype GetBatchOptions = {\n bytesUsed?: number;\n [key: string]: any;\n};\n\nconst DEFAULT_OPTIONS: Required<TableBatchBuilderOptions> = {\n shape: 'array-row-table',\n batchSize: 'auto',\n batchDebounceMs: 0,\n limit: 0,\n _limitMB: 0\n};\n\nconst ERR_MESSAGE = 'TableBatchBuilder';\n\n/** Incrementally builds batches from a stream of rows */\nexport class TableBatchBuilder {\n schema: Schema;\n options: Required<TableBatchBuilderOptions>;\n\n private aggregator: TableBatchAggregator | null = null;\n private batchCount: number = 0;\n private bytesUsed: number = 0;\n private isChunkComplete: boolean = false;\n private lastBatchEmittedMs: number = Date.now();\n private totalLength: number = 0;\n private totalBytes: number = 0;\n private rowBytes: number = 0;\n\n static ArrowBatch?: TableBatchConstructor;\n\n constructor(schema: Schema, options?: TableBatchBuilderOptions) {\n this.schema = schema;\n this.options = {...DEFAULT_OPTIONS, ...options};\n }\n\n limitReached(): boolean {\n if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {\n return true;\n }\n if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {\n return true;\n }\n return false;\n }\n\n /** @deprecated Use addArrayRow or addObjectRow */\n addRow(row: any[] | {[columnName: string]: any}): void {\n if (this.limitReached()) {\n return;\n }\n this.totalLength++;\n this.rowBytes = this.rowBytes || this._estimateRowMB(row);\n this.totalBytes += this.rowBytes;\n if (Array.isArray(row)) {\n this.addArrayRow(row);\n } else {\n this.addObjectRow(row);\n }\n }\n\n /** Add one row to the batch */\n protected addArrayRow(row: any[]) {\n if (!this.aggregator) {\n const TableBatchType = this._getTableBatchType();\n this.aggregator = new TableBatchType(this.schema, this.options);\n }\n this.aggregator.addArrayRow(row);\n }\n\n /** Add one row to the batch */\n protected addObjectRow(row: {[columnName: string]: any}): void {\n if (!this.aggregator) {\n const TableBatchType = this._getTableBatchType();\n this.aggregator = new TableBatchType(this.schema, this.options);\n }\n this.aggregator.addObjectRow(row);\n }\n\n /** Mark an incoming raw memory chunk has completed */\n chunkComplete(chunk: ArrayBuffer | string): void {\n if (chunk instanceof ArrayBuffer) {\n this.bytesUsed += chunk.byteLength;\n }\n if (typeof chunk === 'string') {\n this.bytesUsed += chunk.length;\n }\n this.isChunkComplete = true;\n }\n\n getFullBatch(options?: GetBatchOptions): TableBatch | null {\n return this._isFull() ? this._getBatch(options) : null;\n }\n\n getFinalBatch(options?: GetBatchOptions): TableBatch | null {\n return this._getBatch(options);\n }\n\n // INTERNAL\n\n _estimateRowMB(row: any[] | object): number {\n return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;\n }\n\n private _isFull(): boolean {\n // No batch, not ready\n if (!this.aggregator || this.aggregator.rowCount() === 0) {\n return false;\n }\n\n // if batchSize === 'auto' we wait for chunk to complete\n // if batchSize === number, ensure we have enough rows\n if (this.options.batchSize === 'auto') {\n if (!this.isChunkComplete) {\n return false;\n }\n } else if (this.options.batchSize > this.aggregator.rowCount()) {\n return false;\n }\n\n // Debounce batches\n if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {\n return false;\n }\n\n // Emit batch\n this.isChunkComplete = false;\n this.lastBatchEmittedMs = Date.now();\n return true;\n }\n\n /**\n * bytesUsed can be set via chunkComplete or via getBatch*\n */\n private _getBatch(options?: GetBatchOptions): TableBatch | null {\n if (!this.aggregator) {\n return null;\n }\n\n // TODO - this can overly increment bytes used?\n if (options?.bytesUsed) {\n this.bytesUsed = options.bytesUsed;\n }\n const normalizedBatch = this.aggregator.getBatch() as TableBatch;\n normalizedBatch.count = this.batchCount;\n normalizedBatch.bytesUsed = this.bytesUsed;\n Object.assign(normalizedBatch, options);\n\n this.batchCount++;\n this.aggregator = null;\n return normalizedBatch;\n }\n\n private _getTableBatchType(): TableBatchConstructor {\n switch (this.options.shape) {\n case 'row-table':\n return BaseTableBatchAggregator;\n case 'array-row-table':\n case 'object-row-table':\n return RowTableBatchAggregator;\n case 'columnar-table':\n return ColumnarTableBatchAggregator;\n case 'arrow-table':\n if (!TableBatchBuilder.ArrowBatch) {\n throw new Error(ERR_MESSAGE);\n }\n return TableBatchBuilder.ArrowBatch;\n default:\n throw new Error(ERR_MESSAGE);\n }\n }\n}\n"],"mappings":"SAKQA,wBAAwB;AAAA,SACxBC,uBAAuB;AAAA,SACvBC,4BAA4B;AAgBpC,MAAMC,eAAmD,GAAG;EAC1DC,KAAK,EAAE,iBAAiB;EACxBC,SAAS,EAAE,MAAM;EACjBC,eAAe,EAAE,CAAC;EAClBC,KAAK,EAAE,CAAC;EACRC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,WAAW,GAAG,mBAAmB;AAGvC,OAAO,MAAMC,iBAAiB,CAAC;EAe7BC,WAAWA,CAACC,MAAc,EAAEC,O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,IAAI,CAACpC,UAAU;IACvCkC,eAAe,CAACjC,SAAS,GAAG,IAAI,CAACA,SAAS;IAC1C8B,MAAM,CAACM,MAAM,CAACH,eAAe,EAAEpC,OAAO,CAAC;IAEvC,IAAI,CAACE,UAAU,EAAE;IACjB,IAAI,CAACD,UAAU,GAAG,IAAI;IACtB,OAAOmC,eAAe;EACxB;EAEQb,kBAAkBA,CAAA,EAA0B;IAClD,QAAQ,IAAI,CAACvB,OAAO,CAACT,KAAK;MACxB,KAAK,WAAW;QACd,OAAOJ,wBAAwB;MACjC,KAAK,iBAAiB;MACtB,KAAK,kBAAkB;QACrB,OAAOC,uBAAuB;MAChC,KAAK,gBAAgB;QACnB,OAAOC,4BAA4B;MACrC,KAAK,aAAa;QAChB,IAAI,CAACQ,iBAAiB,CAAC2C,UAAU,EAAE;UACjC,MAAM,IAAIC,KAAK,CAAC7C,WAAW,CAAC;QAC9B;QACA,OAAOC,iBAAiB,CAAC2C,UAAU;MACrC;QACE,MAAM,IAAIC,KAAK,CAAC7C,WAAW,CAAC;IAChC;EACF;AACF;AA3JaC,iBAAiB,CAarB2C,UAAU"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getTableCell, getTableLength, getTableRowAsArray, getTableRowAsObject } from
|
|
2
|
-
import { deduceTableSchema } from
|
|
3
|
-
import { makeColumnFromField } from
|
|
1
|
+
import { getTableCell, getTableLength, getTableRowAsArray, getTableRowAsObject } from "./table-accessors.js";
|
|
2
|
+
import { deduceTableSchema } from "./table-schema.js";
|
|
3
|
+
import { makeColumnFromField } from "./table-column.js";
|
|
4
4
|
export function convertTable(table, shape) {
|
|
5
5
|
switch (shape) {
|
|
6
6
|
case 'object-row-table':
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-table.js","names":["getTableCell","getTableLength","getTableRowAsArray","getTableRowAsObject","deduceTableSchema","makeColumnFromField","convertTable","table","shape","makeObjectRowTable","makeArrayRowTable","makeColumnarTable","makeArrowTable","Error","_globalThis$__luma","_makeArrowTable","globalThis","__luma","_table$schema","schema","fields","length","columns","field","column","name","rowIndex","data","Array"],"sources":["../../../../src/lib/table/simple-table/convert-table.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport {\n getTableCell,\n getTableLength,\n getTableRowAsArray,\n getTableRowAsObject\n} from './table-accessors';\nimport {\n Table,\n ArrayRowTable,\n ObjectRowTable,\n ColumnarTable,\n ArrowTable\n} from '../../../types/category-table';\nimport {deduceTableSchema} from './table-schema';\nimport {makeColumnFromField} from './table-column';\n\nexport function convertTable(table: Table, shape: 'object-row-table'): ObjectRowTable;\nexport function convertTable(table: Table, shape: 'array-row-table'): ArrayRowTable;\nexport function convertTable(table: Table, shape: 'columnar-table'): ColumnarTable;\nexport function convertTable(table: Table, shape: 'arrow-table'): ArrowTable;\n\n/**\n * Convert a table to a different shape\n * @param table\n * @param shape\n * @returns\n */\nexport function convertTable(\n table: Table,\n shape: 'object-row-table' | 'array-row-table' | 'columnar-table' | 'arrow-table'\n) {\n switch (shape) {\n case 'object-row-table':\n return makeObjectRowTable(table);\n case 'array-row-table':\n return makeArrayRowTable(table);\n case 'columnar-table':\n return makeColumnarTable(table);\n case 'arrow-table':\n return makeArrowTable(table);\n default:\n throw new Error(shape);\n }\n}\n\n/**\n * Convert a table to apache arrow format\n * @note this depends on the `@loaders.gl/arrow module being imported\n */\nexport function makeArrowTable(table: Table): Table {\n const _makeArrowTable = globalThis.__luma?._makeArrowTable;\n if (!_makeArrowTable) {\n throw new Error('');\n }\n return _makeArrowTable(table);\n}\n\n/** Convert any simple table into columnar format */\nexport function makeColumnarTable(table: Table): ColumnarTable {\n // TODO - should schema really be optional?\n const schema = table.schema || deduceTableSchema(table);\n const fields = table.schema?.fields || [];\n\n if (table.shape === 'columnar-table') {\n return {...table, schema};\n }\n\n const length = getTableLength(table);\n\n const columns: {[column: string]: ArrayLike<unknown>} = {};\n for (const field of fields) {\n const column = makeColumnFromField(field, length);\n columns[field.name] = column;\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n column[rowIndex] = getTableCell(table, rowIndex, field.name);\n }\n }\n\n return {\n shape: 'columnar-table',\n schema,\n data: columns\n };\n}\n\n/** Convert any table into array row format */\nexport function makeArrayRowTable(table: Table): ArrayRowTable {\n if (table.shape === 'array-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<unknown[]>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsArray(table, rowIndex);\n }\n return {\n shape: 'array-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeObjectRowTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n/**\n/**\n *\n * @note - should be part of schema module\nexport function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable {\n const tableKeys = ;\n const tableRowsCount = columnarTable[tableKeys[0]].length;\n\n const objectRows: ObjectRowTable['data'] = [];\n\n for (let index = 0; index < tableRowsCount; index++) {\n const objectRow = {};\n for (const fieldName of Object.keys(columnarTable.data)) {\n objectRow[fieldName] = columnarTable[fieldName][index];\n }\n objectRows.push(objectRow);\n }\n\n return {\n shape: 'object-row-table',\n data: objectRows\n };\n}\n */\n"],"mappings":"SAEEA,YAAY,EACZC,cAAc,EACdC,kBAAkB,EAClBC,mBAAmB;AAAA,SASbC,iBAAiB;AAAA,SACjBC,mBAAmB;AAa3B,OAAO,SAASC,YAAYA,CAC1BC,KAAY,EACZC,KAAgF,EAChF;EACA,QAAQA,KAAK;IACX,KAAK,kBAAkB;MACrB,OAAOC,kBAAkB,CAACF,KAAK,CAAC;IAClC,KAAK,iBAAiB;MACpB,OAAOG,iBAAiB,CAACH,KAA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@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-type.js","names":["getDataTypeFromValue","value","defaultNumberType","arguments","length","undefined","Date","Number","getDataTypeFromArray","array","type","getDataTypeFromTypedArray","nullable","constructor","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","getArrayTypeFromDataType","Array"],"sources":["../../../../src/lib/table/simple-table/data-type.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {DataType} from '../../../types/schema';\nimport {TypedArray, TypedArrayConstructor, ArrayType} from '../../../types/types';\n\n/** Deduce column types from values */\nexport function getDataTypeFromValue(\n value: unknown,\n defaultNumberType: 'float32' = 'float32'\n): DataType {\n if (value instanceof Date) {\n return 'date-millisecond';\n }\n if (value instanceof Number) {\n return defaultNumberType;\n }\n if (typeof value === 'string') {\n return 'utf8';\n }\n if (value === null || value === 'undefined') {\n return 'null';\n }\n return 'null';\n}\n\n/**\n * Deduces a simple data type \"descriptor from a typed array instance\n */\nexport function getDataTypeFromArray(array: ArrayType): {type: DataType; nullable: boolean} {\n let type = getDataTypeFromTypedArray(array as TypedArray);\n if (type !== 'null') {\n return {type, nullable: false};\n }\n if (array.length > 0) {\n type = getDataTypeFromValue(array[0]);\n return {type, nullable: true};\n }\n\n return {type: 'null', nullable: true};\n}\n\n/**\n * Deduces a simple data type \"descriptor from a typed array instance\n */\nexport function getDataTypeFromTypedArray(array: TypedArray): DataType {\n switch (array.constructor) {\n case Int8Array:\n return 'int8';\n case Uint8Array:\n case Uint8ClampedArray:\n return 'uint8';\n case Int16Array:\n return 'int16';\n case Uint16Array:\n return 'uint16';\n case Int32Array:\n return 'int32';\n case Uint32Array:\n return 'uint32';\n case Float32Array:\n return 'float32';\n case Float64Array:\n return 'float64';\n default:\n return 'null';\n }\n}\n\nexport function getArrayTypeFromDataType(\n type: DataType,\n nullable: boolean | undefined\n): TypedArrayConstructor | ArrayConstructor {\n if (!nullable) {\n switch (type) {\n case 'int8':\n return Int8Array;\n case 'uint8':\n return Uint8Array;\n case 'int16':\n return Int16Array;\n case 'uint16':\n return Uint16Array;\n case 'int32':\n return Int32Array;\n case 'uint32':\n return Uint32Array;\n case 'float32':\n return Float32Array;\n case 'float64':\n return Float64Array;\n default:\n break;\n }\n }\n\n // if (typeof BigInt64Array !== 'undefined') {\n // TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();\n // TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();\n // }\n\n return Array;\n}\n"],"mappings":"AAMA,OAAO,SAASA,oBAAoBA,CAClCC,KAAc,EAEJ;EAAA,IADVC,iBAA4B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;EAExC,IAAIF,KAAK,YAAYK,IAAI,EAAE;IACzB,OAAO,kBAAkB;EAC3B;EACA,IAAIL,KAAK,YAAYM,MAAM,EAAE;IAC3B,OAAOL,iBAAiB;EAC1B;EACA,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO,MAAM;EACf;EACA,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,WAAW,EAAE;IAC3C,OAAO,MAAM;EACf;EACA,OAAO,MAAM;AACf;AAKA,OAAO,SAASO,oBAAoBA,CAACC,KAAgB,EAAuC;EAC1F,IAAIC,IAAI,GAAGC,yBAAyB,CAACF,KAAmB,CAAC;EACzD,IAAIC,IAAI,KAAK,MAAM,EAAE;IACnB,OAAO;MAACA,IAAI;MAAEE,QAAQ,EAAE;IAAK,CAAC;EAChC;EACA,IAAIH,KAAK,CAACL,MAAM,GAAG,CAAC,EAAE;IACpBM,IAAI,GAAGV,oBAAoB,CAACS,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,OAAO;MAACC,IAAI;MAAEE,QAAQ,EAAE;IAAI,CAAC;EAC/B;EAEA,OAAO;IAACF,IAAI,EAAE,MAAM;IAAEE,QAAQ,EAAE;EAAI,CAAC;AACvC;AAKA,OAAO,SAASD,yBAAyBA,CAACF,KAAiB,EAAY;EACrE,QAAQA,KAAK,CAACI,WAAW;IACvB,KAAKC,SAAS;MACZ,OAAO,MAAM;IACf,KAAKC,UAAU;IACf,KAAKC,iBAAiB;MACpB,OAAO,OAAO;IAChB,KAAKC,UAAU;MACb,OAAO,OAAO;IAChB,KAAKC,WAAW;MACd,OAAO,QAAQ;IACjB,KAAKC,UAAU;MACb,OAAO,OAAO;IAChB,KAAKC,WAAW;MACd,OAAO,QAAQ;IACjB,KAAKC,YAAY;MACf,OAAO,SAAS;IAClB,KAAKC,YAAY;MACf,OAAO,SAAS;IAClB;MACE,OAAO,MAAM;EACjB;AACF;AAEA,OAAO,SAASC,wBAAwBA,CACtCb,IAAc,EACdE,QAA6B,EACa;EAC1C,IAAI,CAACA,QAAQ,EAAE;IACb,QAAQF,IAAI;MACV,KAAK,MAAM;QACT,OAAOI,SAAS;MAClB,KAAK,OAAO;QACV,OAAOC,UAAU;MACnB,KAAK,OAAO;QACV,OAAOE,UAAU;MACnB,KAAK,QAAQ;QACX,OAAOC,WAAW;MACpB,KAAK,OAAO;QACV,OAAOC,UAAU;MACnB,KAAK,QAAQ;QACX,OAAOC,WAAW;MACpB,KAAK,SAAS;QACZ,OAAOC,YAAY;MACrB,KAAK,SAAS;QACZ,OAAOC,YAAY;MACrB;QACE;IACJ;EACF;EAOA,OAAOE,KAAK;AACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-table.js","names":["deduceTableSchema","makeTableFromData","data","table","getTableShapeFromData","shape","Error","schema","Array","isArray","length","firstRow"],"sources":["../../../../src/lib/table/simple-table/make-table.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport {Table, ArrayRowTable, ObjectRowTable, ColumnarTable} from '../../../types/category-table';\nimport {deduceTableSchema} from './table-schema';\n\n/**\n * Makes a typed table from data.\n * @throws Row tables must contain at least one row. Columnar tables must contain empty arrays\n */\nexport function makeTableFromData(data: unknown[][]): ArrayRowTable;\nexport function makeTableFromData(data: {[column: string]: unknown}[]): ObjectRowTable;\nexport function makeTableFromData(data: {[column: string]: ArrayLike<unknown>}): ColumnarTable;\nexport function makeTableFromData(data: unknown): Table {\n let table: Table;\n switch (getTableShapeFromData(data)) {\n case 'array-row-table':\n table = {shape: 'array-row-table', data: data as unknown[][]};\n break;\n case 'object-row-table':\n table = {shape: 'object-row-table', data: data as {[key: string]: unknown}[]};\n break;\n case 'columnar-table':\n table = {shape: 'columnar-table', data: data as {[column: string]: ArrayLike<unknown>}};\n break;\n default:\n throw new Error('table');\n }\n const schema = deduceTableSchema(table);\n return {...table, schema};\n}\n\n/** Helper function to get shape of data */\nfunction getTableShapeFromData(data) {\n if (Array.isArray(data)) {\n if (data.length === 0) {\n throw new Error('cannot deduce type of empty table');\n }\n\n // Deduce the table shape from the first row\n const firstRow = data[0];\n\n if (Array.isArray(firstRow)) {\n return 'array-row-table';\n }\n\n if (firstRow && typeof firstRow === 'object') {\n return 'object-row-table';\n }\n }\n\n if (data && typeof data === 'object') {\n return 'columnar-table';\n }\n\n throw new Error('invalid table');\n}\n\n/** Convert any table into object row format *\nexport function makeColumnarTable(table: Table): ColumnarTable {\n if (table.shape === 'columnar-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'columnar-table',\n schema: table.schema,\n data\n };\n}\n\n\n/** Convert any table into array row format *\nexport function makeArrayRowTable(table: TableLike): ArrayRowTable {\n if (table.shape === 'array-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<unknown[]>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsArray(table, rowIndex);\n }\n return {\n shape: 'array-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format *\nexport function makeObjectRowTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n*/\n"],"mappings":"SAEQA,iBAAiB;AASzB,OAAO,SAASC,iBAAiBA,CAACC,IAAa,EAAS;EACtD,IAAIC,KAAY;EAChB,QAAQC,qBAAqB,CAACF,IAAI,CAAC;IACjC,KAAK,iBAAiB;MACpBC,KAAK,GAAG;QAACE,KAAK,EAAE,iBAAiB;QAAEH,IAAI,EAAEA;MAAmB,CAAC;MAC7D;IACF,KAAK,kBAAkB;MACrBC,KAAK,GAAG;QAACE,KAAK,EAAE,kBAAkB;QAAEH,IAAI,EAAEA;MAAkC,CAAC;MAC7E;IACF,KAAK,gBAAgB;MACnBC,KAAK,GAAG;QAACE,KAAK,EAAE,gBAAgB;QAAEH,IAAI,EAAEA;MAA8C,CAAC;MACvF;IACF;MACE,MAAM,IAAII,KAAK,CAAC,OAAO,CAAC;EAC5B;EACA,MAAMC,MAAM,GAAGP,iBAAiB,CAACG,KAAK,CAAC;EACvC,OAAO;IAAC,GAAGA,KAAK;IAAEI;EAAM,CAAC;AAC3B;AAGA,SAASH,qBAAqBA,CAACF,IAAI,EAAE;EACnC,IAAIM,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAE;IACvB,IAAIA,IAAI,CAACQ,MAAM,KAAK,CAAC,EAAE;MACrB,MAAM,IAAIJ,KAAK,CAAC,mCAAmC,CAAC;IACtD;IAGA,MAAMK,QAAQ,GAAGT,IAAI,CAAC,CAAC,CAAC;IAExB,IAAIM,KAAK,CAACC,OAAO,CAACE,QAAQ,CAAC,EAAE;MAC3B,OAAO,iBAAiB;IAC1B;IAEA,IAAIA,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MAC5C,OAAO,kBAAkB;IAC3B;EACF;EAEA,IAAIT,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACpC,OAAO,gBAAgB;EACzB;EAEA,MAAM,IAAII,KAAK,CAAC,eAAe,CAAC;AAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-utils.js","names":["convertToObjectRow","arrayRow","headers","Error","objectRow","i","length","convertToArrayRow","Array"],"sources":["../../../../src/lib/table/simple-table/row-utils.ts"],"sourcesContent":["/** Convert an object row to an array row */\nexport function convertToObjectRow(\n arrayRow: any[],\n headers: string[]\n): {[columnName: string]: any} {\n if (!arrayRow) {\n throw new Error('null row');\n }\n if (!headers) {\n throw new Error('no headers');\n }\n const objectRow = {};\n for (let i = 0; i < headers.length; i++) {\n objectRow[headers[i]] = arrayRow[i];\n }\n return objectRow;\n}\n\n/** Convert an object row to an array row */\nexport function convertToArrayRow(\n objectRow: {[columnName: string]: any},\n headers: string[]\n): any[] {\n if (!objectRow) {\n throw new Error('null row');\n }\n if (!headers) {\n throw new Error('no headers');\n }\n const arrayRow = new Array(headers.length);\n for (let i = 0; i < headers.length; i++) {\n arrayRow[i] = objectRow[headers[i]];\n }\n return arrayRow;\n}\n"],"mappings":"AACA,OAAO,SAASA,kBAAkBA,CAChCC,QAAe,EACfC,OAAiB,EACY;EAC7B,IAAI,CAACD,QAAQ,EAAE;IACb,MAAM,IAAIE,KAAK,CAAC,UAAU,CAAC;EAC7B;EACA,IAAI,CAACD,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,YAAY,CAAC;EAC/B;EACA,MAAMC,SAAS,GAAG,CAAC,CAAC;EACpB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACvCD,SAAS,CAACF,OAAO,CAACG,CAAC,CAAC,CAAC,GAAGJ,QAAQ,CAACI,CAAC,CAAC;EACrC;EACA,OAAOD,SAAS;AAClB;AAGA,OAAO,SAASG,iBAAiBA,CAC/BH,SAAsC,EACtCF,OAAiB,EACV;EACP,IAAI,CAACE,SAAS,EAAE;IACd,MAAM,IAAID,KAAK,CAAC,UAAU,CAAC;EAC7B;EACA,IAAI,CAACD,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,YAAY,CAAC;EAC/B;EACA,MAAMF,QAAQ,GAAG,IAAIO,KAAK,CAACN,OAAO,CAACI,MAAM,CAAC;EAC1C,KAAK,IAAID,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACvCJ,QAAQ,CAACI,CAAC,CAAC,GAAGD,SAAS,CAACF,OAAO,CAACG,CAAC,CAAC,CAAC;EACrC;EACA,OAAOJ,QAAQ;AACjB"}
|
|
@@ -107,7 +107,7 @@ export function getTableColumnName(table, columnIndex) {
|
|
|
107
107
|
var _table$schema2, _table$schema2$fields;
|
|
108
108
|
const columnName = (_table$schema2 = table.schema) === null || _table$schema2 === void 0 ? void 0 : (_table$schema2$fields = _table$schema2.fields[columnIndex]) === null || _table$schema2$fields === void 0 ? void 0 : _table$schema2$fields.name;
|
|
109
109
|
if (!columnName) {
|
|
110
|
-
throw new Error(
|
|
110
|
+
throw new Error(`${columnIndex}`);
|
|
111
111
|
}
|
|
112
112
|
return columnName;
|
|
113
113
|
}
|
|
@@ -265,7 +265,7 @@ export function* makeRowIterator(table, shape) {
|
|
|
265
265
|
yield* makeObjectRowIterator(table);
|
|
266
266
|
break;
|
|
267
267
|
default:
|
|
268
|
-
throw new Error(
|
|
268
|
+
throw new Error(`Unknown row type ${shape}`);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
export function makeArrayRowIterator(table) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-accessors.js","names":["getTableLength","table","shape","data","length","features","arrowTable","numRows","column","Object","values","Error","getTableNumCols","schema","fields","keys","numCols","getTableCell","rowIndex","columnName","_arrowTable$getChildA","columnIndex","getTableColumnIndex","arrowColumnIndex","findIndex","field","name","getChildAt","get","getTableCellAt","_arrowTable$getChildA2","columnName1","getTableColumnName","columnName2","columnName3","getTableRowShape","_table$schema","undefined","_table$schema2","_table$schema2$fields","getTableRowAsObject","target","copy","fromEntries","entries","objectRow","i","row","getTableRowAsArray","Array","from","arrayRow","makeArrayRowTable","makeObjectRowTable","makeColumnarTable","makeRowIterator","makeArrayRowIterator","makeObjectRowIterator","arguments"],"sources":["../../../../src/lib/table/simple-table/table-accessors.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/* eslint-disable no-else-return */\n\nimport {Table, ArrayRowTable, ObjectRowTable} from '../../../types/category-table';\n\n/**\n * Returns the length of the table (i.e. the number of rows)\n */\nexport function getTableLength(table: Table): number {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n return table.data.length;\n\n case 'geojson-table':\n return table.features.length;\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n return arrowTable.numRows;\n\n case 'columnar-table':\n for (const column of Object.values(table.data)) {\n return column.length || 0;\n }\n return 0;\n default:\n throw new Error('table');\n }\n}\n\n/**\n * Returns the number of columns in the table\n * @throws Fails to deduce number of columns if the table has no schema and is empty\n */\nexport function getTableNumCols(table: Table): number {\n if (table.schema) {\n return table.schema.fields.length;\n }\n if (getTableLength(table) === 0) {\n throw new Error('empty table');\n }\n switch (table.shape) {\n case 'array-row-table':\n return table.data[0].length;\n case 'object-row-table':\n return Object.keys(table.data[0]).length;\n case 'geojson-table':\n return Object.keys(table.features[0]).length;\n case 'columnar-table':\n return Object.keys(table.data).length;\n case 'arrow-table':\n const arrowTable = table.data as any;\n return arrowTable.numCols;\n default:\n throw new Error('table');\n }\n}\n\n/** Get a table cell value at row index and column name */\nexport function getTableCell(table: Table, rowIndex: number, columnName: string): unknown {\n switch (table.shape) {\n case 'array-row-table':\n const columnIndex = getTableColumnIndex(table, columnName);\n return table.data[rowIndex][columnIndex];\n\n case 'object-row-table':\n return table.data[rowIndex][columnName];\n\n case 'geojson-table':\n return table.features[rowIndex][columnName];\n\n case 'columnar-table':\n const column = table.data[columnName];\n return column[rowIndex];\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n const arrowColumnIndex = arrowTable.schema.fields.findIndex(\n (field) => field.name === columnName\n );\n return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);\n\n default:\n throw new Error('todo');\n }\n}\n\n/** Get a table cell value at row index and column name */\nexport function getTableCellAt(table: Table, rowIndex: number, columnIndex: number): unknown {\n switch (table.shape) {\n case 'array-row-table':\n return table.data[rowIndex][columnIndex];\n\n case 'object-row-table':\n const columnName1 = getTableColumnName(table, columnIndex);\n return table.data[rowIndex][columnName1];\n\n case 'geojson-table':\n const columnName2 = getTableColumnName(table, columnIndex);\n return table.features[rowIndex][columnName2];\n\n case 'columnar-table':\n const columnName3 = getTableColumnName(table, columnIndex);\n const column = table.data[columnName3];\n return column[rowIndex];\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n return arrowTable.getChildAt(columnIndex)?.get(rowIndex);\n\n default:\n throw new Error('todo');\n }\n}\n\n/** Deduce the table row shape */\nexport function getTableRowShape(table: Table): 'array-row-table' | 'object-row-table' {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n return table.shape;\n\n case 'geojson-table':\n // TODO - this is not correct, geojson-table is not a row table\n return 'object-row-table';\n\n case 'columnar-table':\n default:\n throw new Error('Not a row table');\n }\n}\n\n/** Get the index of a named table column. Requires the table to have a schema */\nexport function getTableColumnIndex(table: Table, columnName: string): number {\n const columnIndex = table.schema?.fields.findIndex((field) => field.name === columnName);\n if (columnIndex === undefined) {\n throw new Error(columnName);\n }\n return columnIndex;\n}\n\n/** Get the name of a table column by index. Requires the table to have a schema */\nexport function getTableColumnName(table: Table, columnIndex: number): string {\n const columnName = table.schema?.fields[columnIndex]?.name;\n if (!columnName) {\n throw new Error(`${columnIndex}`);\n }\n return columnName;\n}\n\n/**\n * Returns one row of the table in object format.\n * @param target Optional parameter will be used if needed to store the row. Can be reused between calls to improve performance\n * @returns an array representing the row. May be the original array in the row, a new object, or the target parameter\n */\n// eslint-disable-next-line complexity\nexport function getTableRowAsObject(\n table: Table,\n rowIndex: number,\n target?: {[columnName: string]: unknown},\n copy?: 'copy'\n): {[columnName: string]: unknown} {\n switch (table.shape) {\n case 'object-row-table':\n return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];\n\n case 'array-row-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] = table.data[rowIndex][i];\n }\n return objectRow;\n }\n throw new Error('no schema');\n\n case 'geojson-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n // TODO - should lift properties to top level\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] = table.features[rowIndex][i];\n }\n return objectRow;\n }\n throw new Error('no schema');\n\n case 'columnar-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] =\n table.data[table.schema.fields[i].name][rowIndex];\n }\n return objectRow;\n } else {\n // eslint-disable-line no-else-return\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (const [name, column] of Object.entries(table.data)) {\n objectRow[name] = column[rowIndex];\n }\n return objectRow;\n }\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n const objectRow: {[columnName: string]: unknown} = target || {};\n const row = arrowTable.get(rowIndex);\n const schema = arrowTable.schema;\n for (let i = 0; i < schema.fields.length; i++) {\n objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];\n }\n return objectRow;\n\n default:\n throw new Error('shape');\n }\n}\n\n/**\n * Returns one row of the table in array format.\n * @param target Optional parameter will be used if needed to store the row. Can be reused between calls to improve performance.\n * @returns an array representing the row. May be the original array in the row, a new object, or the target parameter\n */\n// eslint-disable-next-line complexity\nexport function getTableRowAsArray(\n table: Table,\n rowIndex: number,\n target?: unknown[],\n copy?: 'copy'\n): unknown[] {\n switch (table.shape) {\n case 'array-row-table':\n return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];\n\n case 'object-row-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.data[rowIndex][table.schema.fields[i].name];\n }\n return arrayRow;\n }\n // Warning: just slap on the values, this risks mismatches between rows\n return Object.values(table.data[rowIndex]);\n\n case 'geojson-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n // TODO - should lift properties to top level\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.features[rowIndex][table.schema.fields[i].name];\n }\n return arrayRow;\n }\n // Warning: just slap on the values, this risks mismatches between rows\n return Object.values(table.features[rowIndex]);\n\n case 'columnar-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.data[table.schema.fields[i].name][rowIndex];\n }\n return arrayRow;\n } else {\n // eslint-disable-line no-else-return\n const arrayRow: unknown[] = target || [];\n let i = 0;\n for (const column of Object.values(table.data)) {\n arrayRow[i] = column[rowIndex];\n i++;\n }\n return arrayRow;\n }\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n const arrayRow: unknown[] = target || [];\n const row = arrowTable.get(rowIndex);\n const schema = arrowTable.schema;\n for (let i = 0; i < schema.fields.length; i++) {\n arrayRow[i] = row?.[schema.fields[i].name];\n }\n return arrayRow;\n\n default:\n throw new Error('shape');\n }\n}\n\n/** Convert any table into array row format */\nexport function makeArrayRowTable(table: Table): ArrayRowTable {\n if (table.shape === 'array-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<unknown[]>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsArray(table, rowIndex);\n }\n return {\n shape: 'array-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeObjectRowTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeColumnarTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n// Row Iterators\n\n/**\n * Iterate over table rows\n * @param table\n * @param shape\n */\nexport function* makeRowIterator(\n table: Table,\n shape: 'object-row-table' | 'array-row-table'\n): Iterable<unknown[] | {[key: string]: unknown}> {\n switch (shape) {\n case 'array-row-table':\n yield* makeArrayRowIterator(table);\n break;\n case 'object-row-table':\n yield* makeObjectRowIterator(table);\n break;\n\n default:\n throw new Error(`Unknown row type ${shape}`);\n }\n}\n\n/**\n * Streaming processing: Iterate over table, yielding array rows\n * @param table\n * @param shape\n */\nexport function* makeArrayRowIterator(table: Table, target: unknown[] = []): Iterable<unknown[]> {\n const length = getTableLength(table);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n yield getTableRowAsArray(table, rowIndex, target);\n }\n}\n\n/**\n * Streaming processing: Iterate over table, yielding object rows\n * @param table\n * @param shape\n */\nexport function* makeObjectRowIterator(\n table: Table,\n target: {[key: string]: unknown} = {}\n): Iterable<{[key: string]: unknown}> {\n const length = getTableLength(table);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n yield getTableRowAsObject(table, rowIndex, target);\n }\n}\n"],"mappings":"AASA,OAAO,SAASA,cAAcA,CA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-
import { getArrayTypeFromDataType } from
|
|
1
|
+
import { getArrayTypeFromDataType } from "./data-type.js";
|
|
2
2
|
export function makeColumnFromField(field, length) {
|
|
3
3
|
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
4
4
|
return new ArrayType(length);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-column.js","names":["getArrayTypeFromDataType","makeColumnFromField","field","length","ArrayType","type","nullable"],"sources":["../../../../src/lib/table/simple-table/table-column.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// import type {TypedArray,} from '../../../types/types';\nimport {Field} from '../../../types/schema';\nimport {getArrayTypeFromDataType} from './data-type';\n\nexport interface ArrayType<T = unknown> {\n readonly length: number;\n [n: number]: T;\n}\n\nexport function makeColumnFromField(field: Field, length: number): ArrayType {\n const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);\n return new ArrayType(length);\n}\n\n/*\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction deduceSchema(rows) {\n const row = rows[0];\n\n const schema = {};\n let i = 0;\n for (const columnName in row) {\n const value = row[columnName];\n switch (typeof value) {\n case 'number':\n case 'boolean':\n // TODO - booleans could be handled differently...\n schema[columnName] = {name: String(columnName), index: i, type: Float32Array};\n break;\n\n case 'object':\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n break;\n\n case 'string':\n default:\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n // We currently only handle numeric rows\n // TODO we could offer a function to map strings to numbers?\n }\n i++;\n }\n return schema;\n}\n*/\n"],"mappings":"SAIQA,wBAAwB;AAOhC,OAAO,SAASC,mBAAmBA,CAACC,KAAY,EAAEC,MAAc,EAAa;EAC3E,MAAMC,SAAS,GAAGJ,wBAAwB,CAACE,KAAK,CAACG,IAAI,EAAEH,KAAK,CAACI,QAAQ,CAAC;EACtE,OAAO,IAAIF,SAAS,CAACD,MAAM,CAAC;AAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-schema.js","names":["getDataTypeFromArray","getDataTypeFromValue","deduceTableSchema","table","shape","deduceSchemaFromRows","data","deduceSchemaFromColumns","Error","deduceSchema","Array","isArray","columnarTable","fields","columnName","column","Object","entries","field","deduceFieldFromColumn","push","metadata","rowTable","length","row0","value","deduceFieldFromValue","name","ArrayBuffer","isView","type","nullable"],"sources":["../../../../src/lib/table/simple-table/table-schema.ts"],"sourcesContent":["// Type deduction\nimport {Schema, Field} from '../../../types/schema';\nimport {ArrayType} from '../../../types/types';\nimport {Table} from '../../../types/category-table';\nimport {getDataTypeFromArray, getDataTypeFromValue} from './data-type';\n\n/**\n * SCHEMA SUPPORT - AUTODEDUCTION\n * @param {*} table\n * @param {*} schema\n * @returns\n */\nexport function deduceTableSchema(table: Table): Schema {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n return deduceSchemaFromRows(table.data);\n\n case 'columnar-table':\n return deduceSchemaFromColumns(table.data);\n\n case 'arrow-table':\n default:\n throw new Error('Deduce schema');\n }\n}\n\nexport function deduceSchema(\n data: unknown[][] | {[key: string]: unknown}[] | {[key: string]: unknown[]}\n): Schema {\n return Array.isArray(data) ? deduceSchemaFromRows(data) : deduceSchemaFromColumns(data);\n}\n\n/** Given an object with columnar arrays, try to deduce a schema */\nfunction deduceSchemaFromColumns(columnarTable: {[key: string]: ArrayType}): Schema {\n const fields: Field[] = [];\n for (const [columnName, column] of Object.entries(columnarTable)) {\n const field = deduceFieldFromColumn(column, columnName);\n fields.push(field);\n }\n return {fields, metadata: {}};\n}\n\n/** Given an array of rows, try to deduce a schema */\nfunction deduceSchemaFromRows(rowTable: unknown[][] | {[key: string]: unknown}[]): Schema {\n if (!rowTable.length) {\n throw new Error('deduce from empty table');\n }\n const fields: Field[] = [];\n const row0 = rowTable[0];\n // TODO - fields can be nullable, false detection...\n // Could look at additional rows if nulls in first row\n // TODO - if array, column names will be numbers\n for (const [columnName, value] of Object.entries(row0)) {\n fields.push(deduceFieldFromValue(value, columnName));\n }\n\n return {fields, metadata: {}};\n}\n\n/** Given a column (i.e. array), attempt to deduce an appropriate `Field` */\nfunction deduceFieldFromColumn(column: ArrayType, name: string): Field {\n if (ArrayBuffer.isView(column)) {\n const type = getDataTypeFromArray(column);\n return {\n name,\n type: type.type || 'null',\n nullable: type.nullable\n // metadata: {}\n };\n }\n\n if (Array.isArray(column) && column.length > 0) {\n const value = column[0];\n const type = getDataTypeFromValue(value);\n // TODO - support nested schemas?\n return {\n name,\n type,\n nullable: true\n // metadata: {},\n };\n }\n\n throw new Error('empty table');\n}\n\n/** Given a value, attempt to deduce an appropriate `Field` */\nfunction deduceFieldFromValue(value: unknown, name: string): Field {\n const type = getDataTypeFromValue(value);\n return {\n name,\n type,\n nullable: true\n // metadata: {}\n };\n}\n"],"mappings":"SAIQA,oBAAoB,EAAEC,oBAAoB;AAQlD,OAAO,SAASC,iBAAiBA,CAACC,KAAY,EAAU;EACtD,QAAQA,KAAK,CAACC,KAAK;IACjB,KAAK,iBAAiB;IACtB,KAAK,kBAAkB;MACrB,OAAOC,oBAAoB,CAACF,KAAK,CAACG,IAAI,CAAC;IAEzC,KAAK,gBAAgB;MACnB,OAAOC,uBAAuB,CAACJ,KAAK,CAACG,IAAI,CAAC;IAE5C,KAAK,aAAa;IAClB;MACE,MAAM,IAAIE,KAAK,CAAC,eAAe,CAAC;EACpC;AACF;AAEA,OAAO,SAASC,YAAYA,CAC1BH,IAA2E,EACnE;EACR,OAAOI,KAAK,CAACC,OAAO,CAACL,IAAI,CAAC,GAAGD,oBAAoB,CAACC,IAAI,CAAC,GAAGC,uBAAuB,CAACD,IAAI,CAAC;AACzF;AAGA,SAASC,uBAAuBA,CAACK,aAAyC,EAAU;EAClF,MAAMC,MAAe,GAAG,EAAE;EAC1B,KAAK,MAAM,CAACC,UAAU,EAAEC,MAAM,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,aAAa,CAAC,EAAE;IAChE,MAAMM,KAAK,GAAGC,qBAAqB,CAACJ,MAAM,EAAED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ASkB,oBAAoBA,CAACD,KAAc,EAAEE,IAAY,EAAS;EACjE,MAAMG,IAAI,GAAG7B,oBAAoB,CAACwB,KAAK,CAAC;EACxC,OAAO;IACLE,IAAI;IACJG,IAAI;IACJC,QAAQ,EAAE;EAEZ,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","names":["assert","condition","message","Error"],"sources":["../../../src/lib/utils/assert.ts"],"sourcesContent":["// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\nexport function assert(condition: boolean, message?: string) {\n if (!condition) {\n throw new Error(message || 'loader assertion failed.');\n }\n}\n"],"mappings":"AAGA,OAAO,SAASA,MAAMA,CAACC,SAAkB,EAAEC,OAAgB,EAAE;EAC3D,IAAI,CAACD,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAACD,OAAO,IAAI,0BAA0B,CAAC;EACxD;AACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
let _Symbol$asyncIterator;
|
|
3
2
|
class ArrayQueue extends Array {
|
|
4
3
|
enqueue(value) {
|
|
@@ -11,9 +10,9 @@ class ArrayQueue extends Array {
|
|
|
11
10
|
_Symbol$asyncIterator = Symbol.asyncIterator;
|
|
12
11
|
export default class AsyncQueue {
|
|
13
12
|
constructor() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
this._values = void 0;
|
|
14
|
+
this._settlers = void 0;
|
|
15
|
+
this._closed = void 0;
|
|
17
16
|
this._values = new ArrayQueue();
|
|
18
17
|
this._settlers = new ArrayQueue();
|
|
19
18
|
this._closed = false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-queue.js","names":["ArrayQueue","Array","enqueue","value","push","dequeue","shift","_Symbol$asyncIterator","Symbol","asyncIterator","AsyncQueue","constructor","_values","_settlers","_closed","close","length","resolve","done","Error","settler","reject","next","Promise","takeAsync","asyncIterable","count","arguments","undefined","Infinity","result","iterator"],"sources":["../../../src/lib/utils/async-queue.ts"],"sourcesContent":["// From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license\n// http://2ality.com/2016/10/asynchronous-iteration.html\n\nclass ArrayQueue<T> extends Array<T> {\n enqueue(value: T) {\n // Add at the end\n return this.push(value);\n }\n dequeue(): T {\n // Remove first element\n return this.shift() as T;\n }\n}\n\nexport default class AsyncQueue<T> {\n private _values: ArrayQueue<T | Error>;\n private _settlers: ArrayQueue<{resolve: (value: any) => void; reject: (reason?: any) => void}>;\n private _closed: boolean;\n\n constructor() {\n // enqueues > dequeues\n this._values = new ArrayQueue<T>();\n // dequeues > enqueues\n this._settlers = new ArrayQueue<{\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }>();\n this._closed = false;\n }\n\n close(): void {\n while (this._settlers.length > 0) {\n this._settlers.dequeue().resolve({done: true});\n }\n this._closed = true;\n }\n\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return this;\n }\n\n enqueue(value: T | Error): void {\n if (this._closed) {\n throw new Error('Closed');\n }\n\n if (this._settlers.length > 0) {\n if (this._values.length > 0) {\n throw new Error('Illegal internal state');\n }\n const settler = this._settlers.dequeue();\n if (value instanceof Error) {\n settler.reject(value);\n } else {\n settler.resolve({value});\n }\n } else {\n this._values.enqueue(value);\n }\n }\n\n /**\n * @returns a Promise for an IteratorResult\n */\n next(): Promise<any> {\n if (this._values.length > 0) {\n const value = this._values.dequeue();\n if (value instanceof Error) {\n return Promise.reject(value);\n }\n return Promise.resolve({value});\n }\n\n if (this._closed) {\n if (this._settlers.length > 0) {\n throw new Error('Illegal internal state');\n }\n return Promise.resolve({done: true});\n }\n // Wait for new values to be enqueued\n return new Promise((resolve, reject) => {\n this._settlers.enqueue({resolve, reject});\n });\n }\n}\n\n/**\n * @returns a Promise for an Array with the elements in `asyncIterable`\n */\nexport async function takeAsync(\n asyncIterable: AsyncIterable<any>,\n count = Infinity\n): Promise<any[]> {\n const result: Array<any> = [];\n const iterator = asyncIterable[Symbol.asyncIterator]();\n while (result.length < count) {\n const {value, done} = await iterator.next();\n if (done) {\n break;\n }\n result.push(value);\n }\n return result;\n}\n"],"mappings":";AAGA,MAAMA,UAAU,SAAYC,KAAK,CAAI;EACnCC,OAAOA,CAACC,KAAQ,EAAE;IAEhB,OAAO,IAAI,CAACC,IAAI,CAACD,KAAK,CAAC;EACzB;EACAE,OAAOA,CAAA,EAAM;IAEX,OAAO,IAAI,CAACC,KAAK,CAAC,CAAC;EACrB;AACF;AAACC,qBAAA,GAyBEC,MAAM,CAACC,aAAa;AAvBvB,eAAe,MAAMC,UAAU,CAAI;EAKjCC,WAAWA,CAAA,EAAG;IAAA,KAJNC,OAAO;IAAA,KACPC,SAAS;IAAA,KACTC,OAAO;IAIb,IAAI,CAACF,OAAO,GAAG,IAAIZ,UAAU,CAAI,CAAC;IAElC,IAAI,CAACa,SAAS,GAAG,IAAIb,UAAU,CAG5B,CAAC;IACJ,IAAI,CAACc,OAAO,GAAG,KAAK;EACtB;EAEAC,KAAKA,CAAA,EAAS;IACZ,OAAO,IAAI,CAACF,SAAS,CAACG,MAAM,GAAG,CAAC,EAAE;MAChC,IAAI,CAACH,SAAS,CAACR,OAAO,CAAC,CAAC,CAACY,OAAO,CAAC;QAACC,IAAI,EAAE;MAAI,CAAC,CAAC;IAChD;IACA,IAAI,CAACJ,OAAO,GAAG,IAAI;EACrB;EAEA,CAAAP,qBAAA,IAA2C;IACzC,OAAO,IAAI;EACb;EAEAL,OAAOA,CAACC,KAAgB,EAAQ;IAC9B,IAAI,IAAI,CAACW,OAAO,EAAE;MAChB,MAAM,IAAIK,KAAK,CAAC,QAAQ,CAAC;IAC3B;IAEA,IAAI,IAAI,CAACN,SAAS,CAACG,MAAM,GAAG,CAAC,EAAE;MAC7B,IAAI,IAAI,CAACJ,OAAO,CAACI,MAAM,GAAG,CAAC,EAAE;QAC3B,MAAM,IAAIG,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C,MAAkB,GAAG,EAAE;EAC7B,MAAMC,QAAQ,GAAGN,aAAa,CAACjB,MAAM,CAACC,aAAa,CAAC,CAAC,CAAC;EACtD,OAAOqB,MAAM,CAACd,MAAM,GAAGU,KAAK,EAAE;IAC5B,MAAM;MAACvB,KAAK;MAAEe;IAAI,CAAC,GAAG,MAAMa,QAAQ,CAACT,IAAI,CAAC,CAAC;IAC3C,IAAIJ,IAAI,EAAE;MACR;IACF;IACAY,MAAM,CAAC1B,IAAI,CAACD,KAAK,CAAC;EACpB;EACA,OAAO2B,MAAM;AACf"}
|
package/dist/types/batch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from './schema';
|
|
2
|
-
|
|
2
|
+
type ApacheRecordBatch = unknown;
|
|
3
3
|
/**
|
|
4
4
|
* A batch of data (or metadata/schema), from a streaming loader
|
|
5
5
|
* @see parseInBatches()
|
|
@@ -15,7 +15,7 @@ export type Batch = {
|
|
|
15
15
|
/** Data in this batch */
|
|
16
16
|
data: unknown;
|
|
17
17
|
/** If this is an arrow table. @deprecated Use `data` */
|
|
18
|
-
recordBatch?:
|
|
18
|
+
recordBatch?: ApacheRecordBatch;
|
|
19
19
|
/** Length of data in this batch */
|
|
20
20
|
length: number;
|
|
21
21
|
/** A count of batches received */
|
|
@@ -31,4 +31,5 @@ export type Batch = {
|
|
|
31
31
|
/** Any other data */
|
|
32
32
|
[key: string]: unknown;
|
|
33
33
|
};
|
|
34
|
+
export {};
|
|
34
35
|
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/types/batch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/types/batch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,KAAK,iBAAiB,GAAG,OAAO,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,iFAAiF;IACjF,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACnE,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,yDAAyD;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IAEf,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qBAAqB;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","names":[],"sources":["../../src/types/batch.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Schema} from './schema';\n// import type {RecordBatch} from 'apache-arrow';\n\ntype ApacheRecordBatch = unknown;\n\n/**\n * A batch of data (or metadata/schema), from a streaming loader\n * @see parseInBatches()\n * @see loadInBatches()\n */\nexport type Batch = {\n /** A batch can contain metadata, data, or in case of unstructured data (JSON) */\n batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';\n /** A string identifying the shape of data in this batch (table, etc) */\n shape: string;\n /** Schema of the data in this batch */\n schema?: Schema;\n /** Data in this batch */\n data: unknown;\n /** If this is an arrow table. @deprecated Use `data` */\n recordBatch?: ApacheRecordBatch;\n /** Length of data in this batch */\n length: number;\n\n /** A count of batches received */\n batch?: number;\n\n /** A count of batches received */\n count?: number;\n\n /** Bytes used so far */\n bytesUsed?: number;\n /** cursor is the */\n cursor?: number;\n\n /** MIME type of the data generating this batch */\n mimeType?: string;\n\n /** Any other data */\n [key: string]: unknown;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-geometries.js","names":[],"sources":["../../src/types/binary-geometries.ts"],"sourcesContent":["// GIS\nimport type {TypedArray} from './types';\n\n// BINARY FORMAT GEOMETRY\n\nexport type BinaryAttribute = {value: TypedArray; size: number};\nexport type BinaryGeometryType = 'Point' | 'LineString' | 'Polygon';\n\ntype NumericProps = {[key: string]: BinaryAttribute};\ntype Properties = object[];\n\n/**\n * Represent a single Geometry, similar to a GeoJSON Geometry\n */\nexport type BinaryGeometry = BinaryPointGeometry | BinaryLineGeometry | BinaryPolygonGeometry;\n\n/** Binary point geometry: an array of positions */\nexport type BinaryPointGeometry = {\n type: 'Point';\n positions: BinaryAttribute;\n};\n\n/** Binary line geometry, array of positions and indices to the start of each line */\nexport type BinaryLineGeometry = {\n type: 'LineString';\n positions: BinaryAttribute;\n pathIndices: BinaryAttribute;\n};\n\n/** Binary polygon geometry, an array of positions to each primitite polygon and polygon */\nexport type BinaryPolygonGeometry = {\n type: 'Polygon';\n positions: BinaryAttribute;\n polygonIndices: BinaryAttribute;\n primitivePolygonIndices: BinaryAttribute;\n triangles?: BinaryAttribute;\n};\n\n/** Common properties for binary geometries */\nexport type BinaryProperties = {\n featureIds: BinaryAttribute;\n globalFeatureIds: BinaryAttribute;\n numericProps: NumericProps;\n properties: Properties;\n fields?: Properties;\n};\n\n/** Binary feature + binary attributes */\nexport type BinaryFeature = BinaryPointFeature | BinaryLineFeature | BinaryPolygonFeature;\n\nexport type BinaryPointFeature = BinaryPointGeometry & BinaryProperties;\nexport type BinaryLineFeature = BinaryLineGeometry & BinaryProperties;\nexport type BinaryPolygonFeature = BinaryPolygonGeometry & BinaryProperties;\n\n/**\n * Represent a collection of Features, similar to a GeoJSON FeatureCollection\n */\nexport type BinaryFeatureCollection = {\n points?: BinaryPointFeature;\n lines?: BinaryLineFeature;\n polygons?: BinaryPolygonFeature;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-gis.js","names":[],"sources":["../../src/types/category-gis.ts"],"sourcesContent":["// GIS\n\n// NORMAL GEOJSON FORMAT GEOMETRY\nexport type {\n GeoJSON,\n Feature,\n FeatureCollection,\n Geometry,\n Position,\n GeoJsonProperties\n} from 'geojson';\n\nexport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon,\n GeometryCollection\n} from 'geojson';\n\n// FLAT GEOJSON FORMAT GEOMETRY\nexport type {\n FlatGeometryType,\n FlatIndexedGeometry,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n FlatGeometry,\n FlatFeature\n} from './flat-geometries';\n\n// BINARY FORMAT GEOMETRY\nexport type {\n BinaryAttribute,\n BinaryGeometryType,\n BinaryGeometry,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryProperties,\n BinaryFeatureCollection,\n BinaryFeature,\n BinaryPointFeature,\n BinaryLineFeature,\n BinaryPolygonFeature\n} from './binary-geometries';\n\n/** Aggregate information for converting GeoJSON into other formats */\nexport type GeojsonGeometryInfo = {\n coordLength: number;\n pointPositionsCount: number;\n pointFeaturesCount: number;\n linePositionsCount: number;\n linePathsCount: number;\n lineFeaturesCount: number;\n polygonPositionsCount: number;\n polygonObjectsCount: number;\n polygonRingsCount: number;\n polygonFeaturesCount: number;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-image.js","names":[],"sources":["../../src/types/category-image.ts"],"sourcesContent":["/**\n * data images\n */\nexport type ImageDataType = {\n data: Uint8Array;\n width: number;\n height: number;\n compressed?: boolean;\n};\n\n/**\n * Supported Image Types\n */\nexport type ImageType = ImageBitmap | ImageDataType | HTMLImageElement;\n\n/**\n * Image type string used to control or determine the type of images returned from ImageLoader\n */\nexport type ImageTypeEnum = 'imagebitmap' | 'image' | 'data';\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-mesh.js","names":[],"sources":["../../src/types/category-mesh.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from './schema';\nimport type {TypedArray} from './types';\nimport type {ColumnarTable, ArrowTable} from './category-table';\n\n/** Mesh as columnar table */\nexport interface MeshTable extends ColumnarTable {\n // shape: 'mesh-table';\n topology: 'point-list' | 'triangle-list' | 'triangle-strip';\n indices?: MeshAttribute;\n}\n\n/** Mesh as arrow table */\nexport interface MeshArrowTable extends ArrowTable {\n // shape: 'mesh-arrow-table';\n topology: 'point-list' | 'triangle-list' | 'triangle-strip';\n indices?: MeshAttribute;\n}\n\n/** Geometry part of a Mesh (compatible with a standard luma.gl \"mesh\") */\nexport type MeshGeometry = {\n attributes: {[attributeName: string]: MeshAttribute};\n indices?: MeshAttribute;\n topology: 'point-list' | 'triangle-list' | 'triangle-strip';\n mode: number;\n};\n\n/** Geometry and metadata for a Mesh (compatible with a standard luma.gl \"mesh\") */\nexport type Mesh = MeshGeometry & {\n loader?: string;\n loaderData?: {[key: string]: any};\n header?: {\n vertexCount: number;\n boundingBox?: [number[], number[]];\n };\n schema: Schema;\n};\n\n/**\n * luma.gl compatible attribute descriptors\n * Can be mapped to any WebGL framework\n */\nexport type MeshAttribute = {\n value: TypedArray;\n size: number;\n byteOffset?: number;\n byteStride?: number;\n normalized?: boolean;\n};\n\n/** A map of mesh attributes keyed by attribute names */\nexport type MeshAttributes = Record<string, MeshAttribute>;\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-table.js","names":[],"sources":["../../src/types/category-table.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from './schema';\nimport type {Batch} from './batch';\nimport type {Feature} from './category-gis';\n\n// Avoid a big dependency, apparently even a type import can pull in a lot of code\n// import type {Table as ApacheArrowTable} from 'apache-arrow';\n\ntype ApacheArrowTable = unknown;\ntype ApacheRecordBatch = unknown;\n\n/** A general table */\nexport type Table =\n | RowTable\n | ArrayRowTable\n | ObjectRowTable\n | GeoJSONTable\n | ColumnarTable\n | ArrowTable;\n\n/** A table organized as an array of rows */\nexport type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;\n\n/** A table organized as an array of rows, each row is an array of values */\nexport type ArrayRowTable = {\n shape: 'array-row-table';\n schema?: Schema;\n data: any[][];\n};\n\n/** A table organized as an array of rows, each row is an object mapping columns to values */\nexport type ObjectRowTable = {\n shape: 'object-row-table';\n schema?: Schema;\n data: {[columnName: string]: any}[];\n};\n\n/**\n * A table organized as an array of rows, each row is a GeoJSON Feature\n * @note For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data`\n */\nexport type GeoJSONTable = {\n shape: 'geojson-table';\n schema?: Schema;\n /** For compatibility with GeoJSON, the type field must always be set to `FeatureCollection` */\n type: 'FeatureCollection';\n /** For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data` */\n features: Feature[];\n};\n\n/** A table organized as a map of columns, each column is an array of value */\nexport type ColumnarTable = {\n shape: 'columnar-table';\n schema?: Schema;\n data: {[columnName: string]: ArrayLike<unknown>};\n};\n\n/** A table organized as an Apache Arrow table */\nexport type ArrowTable = {\n shape: 'arrow-table';\n schema?: Schema;\n data: ApacheArrowTable;\n};\n\n/** A collection of tables */\nexport type Tables<TableType = Table> = {\n shape: 'tables';\n tables: {name: string; table: TableType}[];\n};\n\n// Batches\n\n/** Batch for a general table */\nexport type TableBatch =\n | ArrayRowTableBatch\n | ObjectRowTableBatch\n | GeoJSONTableBatch\n | ColumnarTableBatch\n | ArrowTableBatch;\n\n/** Batch for a table organized as an array of rows, each row is an array of values */\nexport type ArrayRowTableBatch = Batch & {\n shape: 'array-row-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n data: any[][];\n length: number;\n};\n\n/** Batch for a table organized as an array of rows, each row is an object mapping columns to values */\nexport type ObjectRowTableBatch = Batch & {\n shape: 'object-row-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n data: {[columnName: string]: any}[];\n length: number;\n};\n\n/** Batch for a table organized as an array of rows, each row is an array of values */\nexport type GeoJSONTableBatch = Batch & {\n shape: 'geojson-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n type: 'FeatureCollection';\n features: Feature[];\n length: number;\n};\n\n/** Batch for a table organized as a map of columns, each column is an array of value */\nexport type ColumnarTableBatch = Batch & {\n shape: 'columnar-table';\n schemaType?: 'explicit' | 'deduced';\n schema?: Schema;\n data: {[columnName: string]: ArrayLike<unknown>};\n length: number;\n};\n\n/** Batch for a table organized as an Apache Arrow table */\nexport type ArrowTableBatch = Batch & {\n shape: 'arrow-table';\n schemaType?: 'explicit' | 'deduced';\n schema?: Schema;\n data: ApacheRecordBatch;\n length: number;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-texture.js","names":[],"sources":["../../src/types/category-texture.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {ImageType} from './category-image';\n\n/**\n * These represent the main compressed texture formats\n * Each format typically has a number of more specific subformats\n */\nexport type GPUTextureFormat =\n | 'dxt'\n | 'dxt-srgb'\n | 'etc1'\n | 'etc2'\n | 'pvrtc'\n | 'atc'\n | 'astc'\n | 'rgtc';\n\n/** One mip level */\nexport type TextureLevel = {\n compressed: boolean;\n format?: number;\n data: Uint8Array;\n width: number;\n height: number;\n levelSize?: number;\n hasAlpha?: boolean;\n};\n\nexport type TextureOrImage = ImageType | (TextureLevel | ImageType);\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-geometries.js","names":[],"sources":["../../src/types/flat-geometries.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// FLAT GEOJSON FORMAT GEOMETRY\nimport type {Feature, Geometry, Point, LineString, Polygon} from 'geojson';\n\n/** Flat geometry type */\nexport type FlatGeometryType = 'Point' | 'LineString' | 'Polygon';\n\ntype RemoveCoordinatesField<Type> = {\n [Property in keyof Type as Exclude<Property, 'coordinates'>]: Type[Property];\n};\n\n/** Generic flat geometry data storage type */\nexport type FlatIndexedGeometry = {\n data: number[];\n indices: number[];\n};\n\n/** GeoJSON (Multi)Point geometry with coordinate data flattened into `data` array and indexed by `indices` */\nexport type FlatPoint = RemoveCoordinatesField<Point> & FlatIndexedGeometry;\n\n/** GeoJSON (Multi)LineString geometry with coordinate data flattened into `data` array and indexed by `indices` */\nexport type FlatLineString = RemoveCoordinatesField<LineString> & FlatIndexedGeometry;\n\n/** GeoJSON (Multi)Polygon geometry with coordinate data flattened into `data` array and indexed by 2D `indices` */\nexport type FlatPolygon = RemoveCoordinatesField<Polygon> & {\n data: number[];\n indices: number[][];\n areas: number[][];\n};\n\n/** GeoJSON geometry with coordinate data flattened into `data` array and indexed by 2D `indices` */\nexport type FlatGeometry = FlatPoint | FlatLineString | FlatPolygon;\n\ntype FlattenGeometry<Type> = {\n [Property in keyof Type]: Type[Property] extends Geometry ? FlatGeometry : Type[Property];\n};\n\n/** GeoJSON Feature with Geometry replaced by FlatGeometry */\nexport type FlatFeature = FlattenGeometry<Feature>;\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/types/schema.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/** For dictionary type */\nexport type KeyType = 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32';\n\n/** ArrowLike DataType class */\nexport type DataType =\n | 'null'\n // Primitive types\n | 'bool'\n | 'int'\n | 'int8'\n | 'int16'\n | 'int32'\n | 'int64'\n | 'uint8'\n | 'uint16'\n | 'uint32'\n | 'uint64'\n | 'float'\n | 'float16'\n | 'float32'\n | 'float64'\n | 'binary'\n | 'utf8'\n | 'date-day'\n | 'date-millisecond'\n | 'time-second'\n | 'time-millisecond'\n | 'time-microsecond'\n | 'time-nanosecond'\n | 'timestamp-second'\n | 'timestamp-millisecond'\n | 'timestamp-microsecond'\n | 'timestamp-nanosecond'\n | 'interval-daytime'\n | 'interval-yearmonth'\n // Composite types\n | {type: 'list'; children: Field[]} // one child only\n | {type: 'struct'; children: Field[]}\n | {\n type: 'sparse-union';\n typeIds: Int32Array;\n children: Field[];\n typeIdToChildIndex: {[key: number]: number};\n }\n | {\n type: 'dense-union';\n typeIds: Int32Array;\n children: Field[];\n typeIdToChildIndex: {[key: number]: number};\n }\n | {type: 'fixed-size-binary'; byteWidth: number}\n | {type: 'fixed-size-list'; listSize: number; children: Field[]}\n | {type: 'map'; keysSorted: boolean; children: Field[]} // Field is \"struct\"\n | {type: 'dictionary'; id: number; indices: KeyType; dictionary: DataType; isOrdered: boolean};\n// TODO - unions etc\n\n/**\n * SchemaMetadata\n */\nexport type SchemaMetadata = Record<string, string>;\nexport type FieldMetadata = Record<string, string>;\n\nexport type Field = {\n name: string;\n type: DataType;\n nullable?: boolean;\n metadata?: FieldMetadata;\n};\n\n/**\n * `Schema` type that that can hold all data required by an Arrow Schema\n * but is fully serializable. Helper functions make it easy to convert to and from arrow schemas\n * https://loaders.gl/arrowjs/docs/api-reference/schema\n */\nexport type Schema = {\n fields: Field[];\n metadata: SchemaMetadata;\n};\n"],"mappings":""}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Any typed array */
|
|
2
2
|
export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
3
3
|
export type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;
|
|
4
|
-
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor |
|
|
4
|
+
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
|
5
5
|
export type BigTypedArrayConstructor = TypedArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor;
|
|
6
6
|
/** Any numeric array: typed array or `number[]` */
|
|
7
7
|
export type NumberArray = number[] | TypedArray;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,YAAY,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,YAAY,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,wBAAwB,GAChC,qBAAqB,GACrB,wBAAwB,GACxB,yBAAyB,CAAC;AAE9B,mDAAmD;AACnD,MAAM,MAAM,WAAW,GAAG,MAAM,EAAE,GAAG,UAAU,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,MAAM,EAAE,GAAG,UAAU,CAAC;AAEjD,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;CAChB;AAED,mDAAmD;AACnD,MAAM,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types/types.ts"],"sourcesContent":["/** Any typed array */\nexport type TypedArray =\n | Int8Array\n | Uint8Array\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Uint8ClampedArray\n | Float32Array\n | Float64Array;\n\nexport type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;\n\nexport type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport type BigTypedArrayConstructor =\n | TypedArrayConstructor\n | BigInt64ArrayConstructor\n | BigUint64ArrayConstructor;\n\n/** Any numeric array: typed array or `number[]` */\nexport type NumberArray = number[] | TypedArray;\n\nexport type NumericArray = number[] | TypedArray;\n\nexport interface ArrayType<T = unknown> {\n readonly length: number;\n [n: number]: T;\n}\n\n/** Any array: typed array or js array (`any[]`) */\nexport type AnyArray = any[] | TypedArray;\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/schema",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "Table format APIs for JSON, CSV, etc...",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"publishConfig": {
|
|
7
8
|
"access": "public"
|
|
8
9
|
},
|
|
@@ -19,8 +20,15 @@
|
|
|
19
20
|
"PLY"
|
|
20
21
|
],
|
|
21
22
|
"types": "dist/index.d.ts",
|
|
22
|
-
"main": "dist/
|
|
23
|
-
"module": "dist/
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs",
|
|
29
|
+
"types": "./dist/index.d.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
24
32
|
"sideEffects": false,
|
|
25
33
|
"files": [
|
|
26
34
|
"src",
|
|
@@ -28,11 +36,11 @@
|
|
|
28
36
|
"README.md"
|
|
29
37
|
],
|
|
30
38
|
"scripts": {
|
|
31
|
-
"pre-build": "npm run build-bundle",
|
|
32
|
-
"build-bundle": "
|
|
39
|
+
"pre-build": "npm run build-bundle && npm run build-bundle -- --env=dev",
|
|
40
|
+
"build-bundle": "ocular-bundle ./src/index.ts"
|
|
33
41
|
},
|
|
34
42
|
"dependencies": {
|
|
35
43
|
"@types/geojson": "^7946.0.7"
|
|
36
44
|
},
|
|
37
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
|
|
38
46
|
}
|
package/src/index.ts
CHANGED
package/src/types/batch.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
3
|
import {Schema} from './schema';
|
|
4
|
-
import type {RecordBatch} from 'apache-arrow';
|
|
4
|
+
// import type {RecordBatch} from 'apache-arrow';
|
|
5
|
+
|
|
6
|
+
type ApacheRecordBatch = unknown;
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* A batch of data (or metadata/schema), from a streaming loader
|
|
@@ -18,7 +20,7 @@ export type Batch = {
|
|
|
18
20
|
/** Data in this batch */
|
|
19
21
|
data: unknown;
|
|
20
22
|
/** If this is an arrow table. @deprecated Use `data` */
|
|
21
|
-
recordBatch?:
|
|
23
|
+
recordBatch?: ApacheRecordBatch;
|
|
22
24
|
/** Length of data in this batch */
|
|
23
25
|
length: number;
|
|
24
26
|
|
package/src/types/types.ts
CHANGED
package/dist/bundle.d.ts
DELETED
package/dist/bundle.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,KAAqB,CAAC"}
|