@loaders.gl/schema 3.1.0-beta.1 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +211 -15081
- package/dist/category/common.d.ts +2 -1
- package/dist/category/common.d.ts.map +1 -1
- package/dist/category/mesh/convert-mesh.js +5 -6
- package/dist/category/mesh/mesh-to-arrow-table.d.ts +0 -10
- package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -1
- package/dist/category/mesh/mesh-to-arrow-table.js +36 -26
- package/dist/category/table/table-types.d.ts +3 -1
- package/dist/category/table/table-types.d.ts.map +1 -1
- package/dist/es5/category/mesh/convert-mesh.js +0 -8
- package/dist/es5/category/mesh/convert-mesh.js.map +1 -1
- package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -39
- package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +1 -1
- package/dist/es5/lib/arrow/arrow-type-utils.js +0 -70
- package/dist/es5/lib/arrow/arrow-type-utils.js.map +1 -1
- package/dist/esm/category/mesh/convert-mesh.js +0 -7
- package/dist/esm/category/mesh/convert-mesh.js.map +1 -1
- package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -29
- package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +1 -1
- package/dist/esm/lib/arrow/arrow-type-utils.js +0 -60
- package/dist/esm/lib/arrow/arrow-type-utils.js.map +1 -1
- package/dist/lib/arrow/arrow-type-utils.d.ts +0 -5
- package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -1
- package/dist/lib/arrow/arrow-type-utils.js +67 -47
- package/package.json +3 -4
- package/src/category/common.ts +2 -1
- package/src/category/mesh/convert-mesh.ts +6 -6
- package/src/category/mesh/mesh-to-arrow-table.ts +4 -2
- package/src/category/table/table-types.ts +4 -1
- package/src/lib/arrow/arrow-type-utils.ts +2 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare type RecordBatch = any;
|
|
2
2
|
export declare type Field = any;
|
|
3
3
|
export declare type Schema = {
|
|
4
4
|
[key: string]: Field;
|
|
@@ -16,4 +16,5 @@ export declare type Batch = {
|
|
|
16
16
|
cursor?: number;
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
};
|
|
19
|
+
export {};
|
|
19
20
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/category/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/category/common.ts"],"names":[],"mappings":"AACA,aAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,oBAAY,KAAK,GAAG,GAAG,CAAC;AAExB,oBAAY,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;CACtB,CAAC;AAEF,oBAAY,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertMeshToColumnarTable = exports.convertMesh = void 0;
|
|
4
|
-
const mesh_to_arrow_table_1 = require("./mesh-to-arrow-table");
|
|
5
4
|
/**
|
|
6
5
|
* Convert a mesh to a specific shape
|
|
7
6
|
*/
|
|
@@ -11,11 +10,11 @@ function convertMesh(mesh, shape, options) {
|
|
|
11
10
|
return mesh;
|
|
12
11
|
case 'columnar-table':
|
|
13
12
|
return convertMeshToColumnarTable(mesh);
|
|
14
|
-
case 'arrow-table':
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// case 'arrow-table':
|
|
14
|
+
// return {
|
|
15
|
+
// shape: 'arrow-table',
|
|
16
|
+
// data: convertMeshToArrowTable(mesh)
|
|
17
|
+
// };
|
|
19
18
|
default:
|
|
20
19
|
throw new Error(`Unsupported shape ${options?.shape}`);
|
|
21
20
|
}
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import { Table } from 'apache-arrow/Arrow.dom';
|
|
2
|
-
import type { Mesh } from './mesh-types';
|
|
3
|
-
/**
|
|
4
|
-
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
5
|
-
* @param mesh
|
|
6
|
-
* @param metadata
|
|
7
|
-
* @param batchSize
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table;
|
|
11
1
|
//# sourceMappingURL=mesh-to-arrow-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-to-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mesh-to-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":[],"mappings":""}
|
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/*
|
|
3
|
+
import {
|
|
4
|
+
Table,
|
|
5
|
+
Schema,
|
|
6
|
+
RecordBatch,
|
|
7
|
+
FixedSizeList,
|
|
8
|
+
Field,
|
|
9
|
+
Data,
|
|
10
|
+
FixedSizeListVector
|
|
11
|
+
} from 'apache-arrow';
|
|
12
|
+
import {AbstractVector} from 'apache-arrow/vector';
|
|
13
|
+
import {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils.js';
|
|
14
|
+
import type {Mesh} from './mesh-types.js';
|
|
15
|
+
import {makeMeshAttributeMetadata} from './deduce-mesh-schema.js';
|
|
16
|
+
|
|
7
17
|
/**
|
|
8
18
|
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
9
19
|
* @param mesh
|
|
10
20
|
* @param metadata
|
|
11
21
|
* @param batchSize
|
|
12
22
|
* @returns
|
|
13
|
-
|
|
14
|
-
function convertMeshToArrowTable(mesh, batchSize) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
*
|
|
24
|
+
export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
|
|
25
|
+
const vectors: AbstractVector[] = [];
|
|
26
|
+
const fields: Field[] = [];
|
|
27
|
+
for (const attributeKey in mesh.attributes) {
|
|
28
|
+
const attribute = mesh.attributes[attributeKey];
|
|
29
|
+
const {value, size = 1} = attribute;
|
|
30
|
+
const type = getArrowType(value);
|
|
31
|
+
const vector = getArrowVector(value);
|
|
32
|
+
const listType = new FixedSizeList(size, new Field('value', type));
|
|
33
|
+
const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));
|
|
34
|
+
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
35
|
+
const listVector = new FixedSizeListVector(data);
|
|
36
|
+
vectors.push(listVector);
|
|
37
|
+
fields.push(field);
|
|
38
|
+
}
|
|
39
|
+
const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());
|
|
40
|
+
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
41
|
+
const table = new Table(schema, recordBatch);
|
|
42
|
+
return table;
|
|
33
43
|
}
|
|
34
|
-
|
|
44
|
+
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Schema } from '../../lib/schema/schema';
|
|
2
|
-
import type { Table as ApacheArrowTable, RecordBatch } from 'apache-arrow/Arrow.dom';
|
|
3
2
|
import type { AnyArray } from '../../types';
|
|
4
3
|
import type { Batch } from '../common';
|
|
4
|
+
declare type ApacheArrowTable = any;
|
|
5
|
+
declare type RecordBatch = any;
|
|
5
6
|
/** A general table */
|
|
6
7
|
export interface Table {
|
|
7
8
|
shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';
|
|
@@ -73,4 +74,5 @@ export declare type ArrowTableBatch = TableBatch & {
|
|
|
73
74
|
shape: 'arrow-table';
|
|
74
75
|
data: RecordBatch;
|
|
75
76
|
};
|
|
77
|
+
export {};
|
|
76
78
|
//# sourceMappingURL=table-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-types.d.ts","sourceRoot":"","sources":["../../../src/category/table/table-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"table-types.d.ts","sourceRoot":"","sources":["../../../src/category/table/table-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,WAAW,CAAC;AAGrC,aAAK,gBAAgB,GAAG,GAAG,CAAC;AAC5B,aAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,sBAAsB;AACtB,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAC/F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC;AAED,4CAA4C;AAC5C,MAAM,WAAW,QAAS,SAAQ,KAAK;IACrC,KAAK,EAAE,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;IAC5D,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,KAAK,EAAE,iBAAiB,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;CACf;AAED,6FAA6F;AAC7F,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,CAAC;CACrC;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAc,SAAQ,KAAK;IAC1C,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAC,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAID,gCAAgC;AAChC,oBAAY,UAAU,GAAG,KAAK,GAAG;IAC/B,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,sDAAsD;AACtD,oBAAY,aAAa,GAAG,UAAU,GAAG;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;CACb,CAAC;AAEF,sFAAsF;AACtF,oBAAY,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,EAAE,iBAAiB,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;CACf,CAAC;AAEF,uGAAuG;AACvG,oBAAY,mBAAmB,GAAG,aAAa,GAAG;IAChD,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,CAAC;CACrC,CAAC;AAEF,wFAAwF;AACxF,oBAAY,kBAAkB,GAAG,UAAU,GAAG;IAC5C,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAC,CAAC;CACxC,CAAC;AAEF,2DAA2D;AAC3D,oBAAY,eAAe,GAAG,UAAU,GAAG;IACzC,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.convertMesh = convertMesh;
|
|
7
7
|
exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
|
|
8
8
|
|
|
9
|
-
var _meshToArrowTable = require("./mesh-to-arrow-table");
|
|
10
|
-
|
|
11
9
|
function convertMesh(mesh, shape, options) {
|
|
12
10
|
switch (shape || 'mesh') {
|
|
13
11
|
case 'mesh':
|
|
@@ -16,12 +14,6 @@ function convertMesh(mesh, shape, options) {
|
|
|
16
14
|
case 'columnar-table':
|
|
17
15
|
return convertMeshToColumnarTable(mesh);
|
|
18
16
|
|
|
19
|
-
case 'arrow-table':
|
|
20
|
-
return {
|
|
21
|
-
shape: 'arrow-table',
|
|
22
|
-
data: (0, _meshToArrowTable.convertMeshToArrowTable)(mesh)
|
|
23
|
-
};
|
|
24
|
-
|
|
25
17
|
default:
|
|
26
18
|
throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));
|
|
27
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","
|
|
1
|
+
{"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","columnName","attribute","Object","entries","attributes","value","schema","data"],"mappings":";;;;;;;;AASO,SAASA,WAAT,CACLC,IADK,EAELC,KAFK,EAGLC,OAHK,EAI8B;AACnC,UAAQD,KAAK,IAAI,MAAjB;AACE,SAAK,MAAL;AACE,aAAOD,IAAP;;AACF,SAAK,gBAAL;AACE,aAAOG,0BAA0B,CAACH,IAAD,CAAjC;;AAMF;AACE,YAAM,IAAII,KAAJ,6BAA+BF,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;;AAOM,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMK,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeT,IAAI,CAACU,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLV,IAAAA,KAAK,EAAE,gBADF;AAELW,IAAAA,MAAM,EAAEZ,IAAI,CAACY,MAFR;AAGLC,IAAAA,IAAI,EAAER;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n// import {convertMeshToArrowTable} from './mesh-to-arrow-table';\n\ntype TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';\n\n/**\n * Convert a mesh to a specific shape\n */\nexport function convertMesh(\n mesh: Mesh,\n shape: TargetShape,\n options?: any\n): Mesh | ColumnarTable | ArrowTable {\n switch (shape || 'mesh') {\n case 'mesh':\n return mesh;\n case 'columnar-table':\n return convertMeshToColumnarTable(mesh);\n // case 'arrow-table':\n // return {\n // shape: 'arrow-table',\n // data: convertMeshToArrowTable(mesh)\n // };\n default:\n throw new Error(`Unsupported shape ${options?.shape}`);\n }\n}\n\n/**\n * Convert a loaders.gl Mesh to a Columnar Table\n * @param mesh\n * @returns\n */\nexport function convertMeshToColumnarTable(mesh: Mesh): ColumnarTable {\n const columns = {};\n\n for (const [columnName, attribute] of Object.entries(mesh.attributes)) {\n columns[columnName] = attribute.value;\n }\n\n return {\n shape: 'columnar-table',\n schema: mesh.schema,\n data: columns\n };\n}\n"],"file":"convert-mesh.js"}
|
|
@@ -1,41 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.convertMeshToArrowTable = convertMeshToArrowTable;
|
|
7
|
-
|
|
8
|
-
var _Arrow = require("apache-arrow/Arrow.dom");
|
|
9
|
-
|
|
10
|
-
var _arrowTypeUtils = require("../../lib/arrow/arrow-type-utils");
|
|
11
|
-
|
|
12
|
-
var _deduceMeshSchema = require("./deduce-mesh-schema");
|
|
13
|
-
|
|
14
|
-
function convertMeshToArrowTable(mesh, batchSize) {
|
|
15
|
-
var _mesh$schema;
|
|
16
|
-
|
|
17
|
-
const vectors = [];
|
|
18
|
-
const fields = [];
|
|
19
|
-
|
|
20
|
-
for (const attributeKey in mesh.attributes) {
|
|
21
|
-
const attribute = mesh.attributes[attributeKey];
|
|
22
|
-
const {
|
|
23
|
-
value,
|
|
24
|
-
size = 1
|
|
25
|
-
} = attribute;
|
|
26
|
-
const type = (0, _arrowTypeUtils.getArrowType)(value);
|
|
27
|
-
const vector = (0, _arrowTypeUtils.getArrowVector)(value);
|
|
28
|
-
const listType = new _Arrow.FixedSizeList(size, new _Arrow.Field('value', type));
|
|
29
|
-
const field = new _Arrow.Field(attributeKey, listType, false, (0, _deduceMeshSchema.makeMeshAttributeMetadata)(attribute));
|
|
30
|
-
const data = new _Arrow.Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
31
|
-
const listVector = new _Arrow.FixedSizeListVector(data);
|
|
32
|
-
vectors.push(listVector);
|
|
33
|
-
fields.push(field);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const schema = new _Arrow.Schema(fields, (mesh === null || mesh === void 0 ? void 0 : (_mesh$schema = mesh.schema) === null || _mesh$schema === void 0 ? void 0 : _mesh$schema.metadata) || new Map());
|
|
37
|
-
const recordBatch = new _Arrow.RecordBatch(schema, vectors[0].length, vectors);
|
|
38
|
-
const table = new _Arrow.Table(schema, recordBatch);
|
|
39
|
-
return table;
|
|
40
|
-
}
|
|
41
2
|
//# sourceMappingURL=mesh-to-arrow-table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"mesh-to-arrow-table.js"}
|
|
@@ -1,72 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getArrowType = getArrowType;
|
|
7
|
-
exports.getArrowVector = getArrowVector;
|
|
8
|
-
|
|
9
|
-
var _Arrow = require("apache-arrow/Arrow.dom");
|
|
10
|
-
|
|
11
|
-
function getArrowType(array) {
|
|
12
|
-
switch (array.constructor) {
|
|
13
|
-
case Int8Array:
|
|
14
|
-
return new _Arrow.Int8();
|
|
15
|
-
|
|
16
|
-
case Uint8Array:
|
|
17
|
-
return new _Arrow.Uint8();
|
|
18
|
-
|
|
19
|
-
case Int16Array:
|
|
20
|
-
return new _Arrow.Int16();
|
|
21
|
-
|
|
22
|
-
case Uint16Array:
|
|
23
|
-
return new _Arrow.Uint16();
|
|
24
|
-
|
|
25
|
-
case Int32Array:
|
|
26
|
-
return new _Arrow.Int32();
|
|
27
|
-
|
|
28
|
-
case Uint32Array:
|
|
29
|
-
return new _Arrow.Uint32();
|
|
30
|
-
|
|
31
|
-
case Float32Array:
|
|
32
|
-
return new _Arrow.Float32();
|
|
33
|
-
|
|
34
|
-
case Float64Array:
|
|
35
|
-
return new _Arrow.Float64();
|
|
36
|
-
|
|
37
|
-
default:
|
|
38
|
-
throw new Error('array type not supported');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getArrowVector(array) {
|
|
43
|
-
switch (array.constructor) {
|
|
44
|
-
case Int8Array:
|
|
45
|
-
return _Arrow.Int8Vector.from(array);
|
|
46
|
-
|
|
47
|
-
case Uint8Array:
|
|
48
|
-
return _Arrow.Uint8Vector.from(array);
|
|
49
|
-
|
|
50
|
-
case Int16Array:
|
|
51
|
-
return _Arrow.Int16Vector.from(array);
|
|
52
|
-
|
|
53
|
-
case Uint16Array:
|
|
54
|
-
return _Arrow.Uint16Vector.from(array);
|
|
55
|
-
|
|
56
|
-
case Int32Array:
|
|
57
|
-
return _Arrow.Int32Vector.from(array);
|
|
58
|
-
|
|
59
|
-
case Uint32Array:
|
|
60
|
-
return _Arrow.Uint32Vector.from(array);
|
|
61
|
-
|
|
62
|
-
case Float32Array:
|
|
63
|
-
return _Arrow.Float32Vector.from(array);
|
|
64
|
-
|
|
65
|
-
case Float64Array:
|
|
66
|
-
return _Arrow.Float64Vector.from(array);
|
|
67
|
-
|
|
68
|
-
default:
|
|
69
|
-
throw new Error('array type not supported');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
2
|
//# sourceMappingURL=arrow-type-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"arrow-type-utils.js"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { convertMeshToArrowTable } from './mesh-to-arrow-table';
|
|
2
1
|
export function convertMesh(mesh, shape, options) {
|
|
3
2
|
switch (shape || 'mesh') {
|
|
4
3
|
case 'mesh':
|
|
@@ -7,12 +6,6 @@ export function convertMesh(mesh, shape, options) {
|
|
|
7
6
|
case 'columnar-table':
|
|
8
7
|
return convertMeshToColumnarTable(mesh);
|
|
9
8
|
|
|
10
|
-
case 'arrow-table':
|
|
11
|
-
return {
|
|
12
|
-
shape: 'arrow-table',
|
|
13
|
-
data: convertMeshToArrowTable(mesh)
|
|
14
|
-
};
|
|
15
|
-
|
|
16
9
|
default:
|
|
17
10
|
throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));
|
|
18
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","columnName","attribute","Object","entries","attributes","value","schema","data"],"mappings":"AASA,OAAO,SAASA,WAAT,CACLC,IADK,EAELC,KAFK,EAGLC,OAHK,EAI8B;AACnC,UAAQD,KAAK,IAAI,MAAjB;AACE,SAAK,MAAL;AACE,aAAOD,IAAP;;AACF,SAAK,gBAAL;AACE,aAAOG,0BAA0B,CAACH,IAAD,CAAjC;;AAMF;AACE,YAAM,IAAII,KAAJ,6BAA+BF,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;AAOD,OAAO,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMK,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeT,IAAI,CAACU,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLV,IAAAA,KAAK,EAAE,gBADF;AAELW,IAAAA,MAAM,EAAEZ,IAAI,CAACY,MAFR;AAGLC,IAAAA,IAAI,EAAER;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n// import {convertMeshToArrowTable} from './mesh-to-arrow-table';\n\ntype TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';\n\n/**\n * Convert a mesh to a specific shape\n */\nexport function convertMesh(\n mesh: Mesh,\n shape: TargetShape,\n options?: any\n): Mesh | ColumnarTable | ArrowTable {\n switch (shape || 'mesh') {\n case 'mesh':\n return mesh;\n case 'columnar-table':\n return convertMeshToColumnarTable(mesh);\n // case 'arrow-table':\n // return {\n // shape: 'arrow-table',\n // data: convertMeshToArrowTable(mesh)\n // };\n default:\n throw new Error(`Unsupported shape ${options?.shape}`);\n }\n}\n\n/**\n * Convert a loaders.gl Mesh to a Columnar Table\n * @param mesh\n * @returns\n */\nexport function convertMeshToColumnarTable(mesh: Mesh): ColumnarTable {\n const columns = {};\n\n for (const [columnName, attribute] of Object.entries(mesh.attributes)) {\n columns[columnName] = attribute.value;\n }\n\n return {\n shape: 'columnar-table',\n schema: mesh.schema,\n data: columns\n };\n}\n"],"file":"convert-mesh.js"}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import { Table, Schema, RecordBatch, FixedSizeList, Field, Data, FixedSizeListVector } from 'apache-arrow/Arrow.dom';
|
|
2
|
-
import { getArrowType, getArrowVector } from '../../lib/arrow/arrow-type-utils';
|
|
3
|
-
import { makeMeshAttributeMetadata } from './deduce-mesh-schema';
|
|
4
|
-
export function convertMeshToArrowTable(mesh, batchSize) {
|
|
5
|
-
var _mesh$schema;
|
|
6
1
|
|
|
7
|
-
const vectors = [];
|
|
8
|
-
const fields = [];
|
|
9
|
-
|
|
10
|
-
for (const attributeKey in mesh.attributes) {
|
|
11
|
-
const attribute = mesh.attributes[attributeKey];
|
|
12
|
-
const {
|
|
13
|
-
value,
|
|
14
|
-
size = 1
|
|
15
|
-
} = attribute;
|
|
16
|
-
const type = getArrowType(value);
|
|
17
|
-
const vector = getArrowVector(value);
|
|
18
|
-
const listType = new FixedSizeList(size, new Field('value', type));
|
|
19
|
-
const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));
|
|
20
|
-
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
21
|
-
const listVector = new FixedSizeListVector(data);
|
|
22
|
-
vectors.push(listVector);
|
|
23
|
-
fields.push(field);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const schema = new Schema(fields, (mesh === null || mesh === void 0 ? void 0 : (_mesh$schema = mesh.schema) === null || _mesh$schema === void 0 ? void 0 : _mesh$schema.metadata) || new Map());
|
|
27
|
-
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
28
|
-
const table = new Table(schema, recordBatch);
|
|
29
|
-
return table;
|
|
30
|
-
}
|
|
31
2
|
//# sourceMappingURL=mesh-to-arrow-table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"mesh-to-arrow-table.js"}
|
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
import { Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8, Int8Vector, Uint8Vector, Int16Vector, Uint16Vector, Int32Vector, Uint32Vector, Float32Vector, Float64Vector } from 'apache-arrow/Arrow.dom';
|
|
2
|
-
export function getArrowType(array) {
|
|
3
|
-
switch (array.constructor) {
|
|
4
|
-
case Int8Array:
|
|
5
|
-
return new Int8();
|
|
6
1
|
|
|
7
|
-
case Uint8Array:
|
|
8
|
-
return new Uint8();
|
|
9
|
-
|
|
10
|
-
case Int16Array:
|
|
11
|
-
return new Int16();
|
|
12
|
-
|
|
13
|
-
case Uint16Array:
|
|
14
|
-
return new Uint16();
|
|
15
|
-
|
|
16
|
-
case Int32Array:
|
|
17
|
-
return new Int32();
|
|
18
|
-
|
|
19
|
-
case Uint32Array:
|
|
20
|
-
return new Uint32();
|
|
21
|
-
|
|
22
|
-
case Float32Array:
|
|
23
|
-
return new Float32();
|
|
24
|
-
|
|
25
|
-
case Float64Array:
|
|
26
|
-
return new Float64();
|
|
27
|
-
|
|
28
|
-
default:
|
|
29
|
-
throw new Error('array type not supported');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export function getArrowVector(array) {
|
|
33
|
-
switch (array.constructor) {
|
|
34
|
-
case Int8Array:
|
|
35
|
-
return Int8Vector.from(array);
|
|
36
|
-
|
|
37
|
-
case Uint8Array:
|
|
38
|
-
return Uint8Vector.from(array);
|
|
39
|
-
|
|
40
|
-
case Int16Array:
|
|
41
|
-
return Int16Vector.from(array);
|
|
42
|
-
|
|
43
|
-
case Uint16Array:
|
|
44
|
-
return Uint16Vector.from(array);
|
|
45
|
-
|
|
46
|
-
case Int32Array:
|
|
47
|
-
return Int32Vector.from(array);
|
|
48
|
-
|
|
49
|
-
case Uint32Array:
|
|
50
|
-
return Uint32Vector.from(array);
|
|
51
|
-
|
|
52
|
-
case Float32Array:
|
|
53
|
-
return Float32Vector.from(array);
|
|
54
|
-
|
|
55
|
-
case Float64Array:
|
|
56
|
-
return Float64Vector.from(array);
|
|
57
|
-
|
|
58
|
-
default:
|
|
59
|
-
throw new Error('array type not supported');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
2
|
//# sourceMappingURL=arrow-type-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"arrow-type-utils.js"}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import type { TypedArray } from '../../types';
|
|
2
|
-
import { DataType } from 'apache-arrow/Arrow.dom';
|
|
3
|
-
import { AbstractVector } from 'apache-arrow/vector';
|
|
4
|
-
export declare function getArrowType(array: TypedArray): DataType;
|
|
5
|
-
export declare function getArrowVector(array: TypedArray): AbstractVector;
|
|
6
1
|
//# sourceMappingURL=arrow-type-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-type-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/arrow/arrow-type-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"arrow-type-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/arrow/arrow-type-utils.ts"],"names":[],"mappings":""}
|
|
@@ -1,50 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
/*
|
|
3
|
+
import type {TypedArray} from '../../types.js';
|
|
4
|
+
import {
|
|
5
|
+
DataType,
|
|
6
|
+
Float32,
|
|
7
|
+
Float64,
|
|
8
|
+
Int16,
|
|
9
|
+
Int32,
|
|
10
|
+
Int8,
|
|
11
|
+
Uint16,
|
|
12
|
+
Uint32,
|
|
13
|
+
Uint8,
|
|
14
|
+
Int8Vector,
|
|
15
|
+
Uint8Vector,
|
|
16
|
+
Int16Vector,
|
|
17
|
+
Uint16Vector,
|
|
18
|
+
Int32Vector,
|
|
19
|
+
Uint32Vector,
|
|
20
|
+
Float32Vector,
|
|
21
|
+
Float64Vector
|
|
22
|
+
} from 'apache-arrow/Arrow.dom';
|
|
23
|
+
import {AbstractVector} from 'apache-arrow/vector';
|
|
24
|
+
|
|
25
|
+
export function getArrowType(array: TypedArray): DataType {
|
|
26
|
+
switch (array.constructor) {
|
|
27
|
+
case Int8Array:
|
|
28
|
+
return new Int8();
|
|
29
|
+
case Uint8Array:
|
|
30
|
+
return new Uint8();
|
|
31
|
+
case Int16Array:
|
|
32
|
+
return new Int16();
|
|
33
|
+
case Uint16Array:
|
|
34
|
+
return new Uint16();
|
|
35
|
+
case Int32Array:
|
|
36
|
+
return new Int32();
|
|
37
|
+
case Uint32Array:
|
|
38
|
+
return new Uint32();
|
|
39
|
+
case Float32Array:
|
|
40
|
+
return new Float32();
|
|
41
|
+
case Float64Array:
|
|
42
|
+
return new Float64();
|
|
43
|
+
default:
|
|
44
|
+
throw new Error('array type not supported');
|
|
45
|
+
}
|
|
26
46
|
}
|
|
27
|
-
|
|
28
|
-
function getArrowVector(array) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
export function getArrowVector(array: TypedArray): AbstractVector {
|
|
49
|
+
switch (array.constructor) {
|
|
50
|
+
case Int8Array:
|
|
51
|
+
return Int8Vector.from(array);
|
|
52
|
+
case Uint8Array:
|
|
53
|
+
return Uint8Vector.from(array);
|
|
54
|
+
case Int16Array:
|
|
55
|
+
return Int16Vector.from(array);
|
|
56
|
+
case Uint16Array:
|
|
57
|
+
return Uint16Vector.from(array);
|
|
58
|
+
case Int32Array:
|
|
59
|
+
return Int32Vector.from(array);
|
|
60
|
+
case Uint32Array:
|
|
61
|
+
return Uint32Vector.from(array);
|
|
62
|
+
case Float32Array:
|
|
63
|
+
return Float32Vector.from(array);
|
|
64
|
+
case Float64Array:
|
|
65
|
+
return Float64Vector.from(array);
|
|
66
|
+
default:
|
|
67
|
+
throw new Error('array type not supported');
|
|
68
|
+
}
|
|
49
69
|
}
|
|
50
|
-
|
|
70
|
+
*/
|