@loaders.gl/schema 4.0.0-alpha.24 → 4.0.0-alpha.26
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.min.js +41 -16
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js +4 -3
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/table/simple-table/table-accessors.js +69 -42
- package/dist/es5/lib/table/simple-table/table-accessors.js.map +1 -1
- package/dist/es5/types/batch.js +2 -0
- package/dist/es5/types/batch.js.map +1 -0
- package/dist/es5/types/category-table.js.map +1 -1
- package/dist/es5/types/schema.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js +4 -3
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/table/simple-table/table-accessors.js +49 -22
- package/dist/esm/lib/table/simple-table/table-accessors.js.map +1 -1
- package/dist/esm/types/batch.js +2 -0
- package/dist/esm/types/batch.js.map +1 -0
- package/dist/esm/types/category-table.js.map +1 -1
- package/dist/esm/types/schema.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts +1 -5
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +3 -3
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -1
- package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -1
- package/dist/types/batch.d.ts +34 -0
- package/dist/types/batch.d.ts.map +1 -0
- package/dist/types/category-table.d.ts +23 -13
- package/dist/types/category-table.d.ts.map +1 -1
- package/dist/types/schema.d.ts +0 -15
- package/dist/types/schema.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +5 -3
- package/src/lib/table/arrow-api/arrow-like-table.ts +3 -2
- package/src/lib/table/batches/row-table-batch-aggregator.ts +2 -2
- package/src/lib/table/simple-table/table-accessors.ts +56 -22
- package/src/types/batch.ts +41 -0
- package/src/types/category-table.ts +25 -18
- package/src/types/schema.ts +0 -17
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Schema } from './schema';
|
|
2
|
+
import type { RecordBatch } from 'apache-arrow';
|
|
3
|
+
/**
|
|
4
|
+
* A batch of data (or metadata/schema), from a streaming loader
|
|
5
|
+
* @see parseInBatches()
|
|
6
|
+
* @see loadInBatches()
|
|
7
|
+
*/
|
|
8
|
+
export type Batch = {
|
|
9
|
+
/** A batch can contain metadata, data, or in case of unstructured data (JSON) */
|
|
10
|
+
batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
|
|
11
|
+
/** A string identifying the shape of data in this batch (table, etc) */
|
|
12
|
+
shape: string;
|
|
13
|
+
/** Schema of the data in this batch */
|
|
14
|
+
schema?: Schema;
|
|
15
|
+
/** Data in this batch */
|
|
16
|
+
data: unknown;
|
|
17
|
+
/** If this is an arrow table. @deprecated Use `data` */
|
|
18
|
+
recordBatch?: RecordBatch;
|
|
19
|
+
/** Length of data in this batch */
|
|
20
|
+
length: number;
|
|
21
|
+
/** A count of batches received */
|
|
22
|
+
batch?: number;
|
|
23
|
+
/** A count of batches received */
|
|
24
|
+
count?: number;
|
|
25
|
+
/** Bytes used so far */
|
|
26
|
+
bytesUsed?: number;
|
|
27
|
+
/** cursor is the */
|
|
28
|
+
cursor?: number;
|
|
29
|
+
/** MIME type of the data generating this batch */
|
|
30
|
+
mimeType?: string;
|
|
31
|
+
/** Any other data */
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/types/batch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C;;;;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,WAAW,CAAC;IAC1B,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"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Batch
|
|
1
|
+
import type { Schema } from './schema';
|
|
2
|
+
import type { Batch } from './batch';
|
|
3
3
|
import type { Feature } from './category-gis';
|
|
4
|
+
type ApacheArrowTable = unknown;
|
|
5
|
+
type ApacheRecordBatch = unknown;
|
|
4
6
|
/** A general table */
|
|
5
|
-
export type Table = RowTable | ArrayRowTable | ObjectRowTable |
|
|
7
|
+
export type Table = RowTable | ArrayRowTable | ObjectRowTable | GeoJSONTable | ColumnarTable | ArrowTable;
|
|
6
8
|
/** A table organized as an array of rows */
|
|
7
|
-
export type RowTable = ArrayRowTable | ObjectRowTable |
|
|
9
|
+
export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;
|
|
8
10
|
/** A table organized as an array of rows, each row is an array of values */
|
|
9
11
|
export type ArrayRowTable = {
|
|
10
12
|
shape: 'array-row-table';
|
|
@@ -19,11 +21,17 @@ export type ObjectRowTable = {
|
|
|
19
21
|
[columnName: string]: any;
|
|
20
22
|
}[];
|
|
21
23
|
};
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A table organized as an array of rows, each row is a GeoJSON Feature
|
|
26
|
+
* @note For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data`
|
|
27
|
+
*/
|
|
28
|
+
export type GeoJSONTable = {
|
|
29
|
+
shape: 'geojson-table';
|
|
25
30
|
schema?: Schema;
|
|
26
|
-
|
|
31
|
+
/** For compatibility with GeoJSON, the type field must always be set to `FeatureCollection` */
|
|
32
|
+
type: 'FeatureCollection';
|
|
33
|
+
/** For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data` */
|
|
34
|
+
features: Feature[];
|
|
27
35
|
};
|
|
28
36
|
/** A table organized as a map of columns, each column is an array of value */
|
|
29
37
|
export type ColumnarTable = {
|
|
@@ -48,7 +56,7 @@ export type Tables<TableType = Table> = {
|
|
|
48
56
|
}[];
|
|
49
57
|
};
|
|
50
58
|
/** Batch for a general table */
|
|
51
|
-
export type TableBatch = ArrayRowTableBatch | ObjectRowTableBatch |
|
|
59
|
+
export type TableBatch = ArrayRowTableBatch | ObjectRowTableBatch | GeoJSONTableBatch | ColumnarTableBatch | ArrowTableBatch;
|
|
52
60
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
53
61
|
export type ArrayRowTableBatch = Batch & {
|
|
54
62
|
shape: 'array-row-table';
|
|
@@ -68,11 +76,12 @@ export type ObjectRowTableBatch = Batch & {
|
|
|
68
76
|
length: number;
|
|
69
77
|
};
|
|
70
78
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
71
|
-
export type
|
|
72
|
-
shape: 'geojson-
|
|
79
|
+
export type GeoJSONTableBatch = Batch & {
|
|
80
|
+
shape: 'geojson-table';
|
|
73
81
|
schema?: Schema;
|
|
74
82
|
schemaType?: 'explicit' | 'deduced';
|
|
75
|
-
|
|
83
|
+
type: 'FeatureCollection';
|
|
84
|
+
features: Feature[];
|
|
76
85
|
length: number;
|
|
77
86
|
};
|
|
78
87
|
/** Batch for a table organized as a map of columns, each column is an array of value */
|
|
@@ -90,7 +99,8 @@ export type ArrowTableBatch = Batch & {
|
|
|
90
99
|
shape: 'arrow-table';
|
|
91
100
|
schemaType?: 'explicit' | 'deduced';
|
|
92
101
|
schema?: Schema;
|
|
93
|
-
data:
|
|
102
|
+
data: ApacheRecordBatch;
|
|
94
103
|
length: number;
|
|
95
104
|
};
|
|
105
|
+
export {};
|
|
96
106
|
//# sourceMappingURL=category-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-table.d.ts","sourceRoot":"","sources":["../../src/types/category-table.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"category-table.d.ts","sourceRoot":"","sources":["../../src/types/category-table.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAK5C,KAAK,gBAAgB,GAAG,OAAO,CAAC;AAChC,KAAK,iBAAiB,GAAG,OAAO,CAAC;AAEjC,sBAAsB;AACtB,MAAM,MAAM,KAAK,GACb,QAAQ,GACR,aAAa,GACb,cAAc,GACd,YAAY,GACZ,aAAa,GACb,UAAU,CAAC;AAEf,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,cAAc,GAAG,YAAY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C;CAChB,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG;IACpC,KAAK,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/dist/types/schema.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RecordBatch } from 'apache-arrow';
|
|
2
1
|
/** For dictionary type */
|
|
3
2
|
export type KeyType = 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32';
|
|
4
3
|
/** ArrowLike DataType class */
|
|
@@ -60,18 +59,4 @@ export type Schema = {
|
|
|
60
59
|
fields: Field[];
|
|
61
60
|
metadata: SchemaMetadata;
|
|
62
61
|
};
|
|
63
|
-
export type Batch = {
|
|
64
|
-
batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
|
|
65
|
-
batch?: number;
|
|
66
|
-
mimeType?: string;
|
|
67
|
-
shape: string;
|
|
68
|
-
data: any;
|
|
69
|
-
recordBatch?: RecordBatch;
|
|
70
|
-
length: number;
|
|
71
|
-
schema?: Schema;
|
|
72
|
-
bytesUsed?: number;
|
|
73
|
-
count?: number;
|
|
74
|
-
cursor?: number;
|
|
75
|
-
[key: string]: any;
|
|
76
|
-
};
|
|
77
62
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAEA,0BAA0B;AAC1B,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QA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AE,CAAA;CAAC,GACrD;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAC,CAAC;AAGjG;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/schema",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.26",
|
|
4
4
|
"description": "Table format APIs for JSON, CSV, etc...",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@types/geojson": "^7946.0.7"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "91adce71f74dacc7c8bfc379f0d122f2beae70d9"
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,9 @@ export type {
|
|
|
9
9
|
AnyArray
|
|
10
10
|
} from './types/types';
|
|
11
11
|
|
|
12
|
-
export type {Schema, Field, DataType,
|
|
12
|
+
export type {Schema, Field, DataType, SchemaMetadata, FieldMetadata} from './types/schema';
|
|
13
|
+
|
|
14
|
+
export type {Batch} from './types/batch';
|
|
13
15
|
|
|
14
16
|
// TABLE CATEGORY TYPES
|
|
15
17
|
export type {
|
|
@@ -17,7 +19,7 @@ export type {
|
|
|
17
19
|
RowTable,
|
|
18
20
|
ArrayRowTable,
|
|
19
21
|
ObjectRowTable,
|
|
20
|
-
|
|
22
|
+
GeoJSONTable,
|
|
21
23
|
ColumnarTable,
|
|
22
24
|
ArrowTable,
|
|
23
25
|
Tables
|
|
@@ -26,7 +28,7 @@ export type {
|
|
|
26
28
|
TableBatch,
|
|
27
29
|
ArrayRowTableBatch,
|
|
28
30
|
ObjectRowTableBatch,
|
|
29
|
-
|
|
31
|
+
GeoJSONTableBatch,
|
|
30
32
|
ColumnarTableBatch,
|
|
31
33
|
ArrowTableBatch
|
|
32
34
|
} from './types/category-table';
|
|
@@ -34,7 +34,8 @@ class ArrowLikeVector {
|
|
|
34
34
|
toArray(): ArrayLike<unknown> {
|
|
35
35
|
switch (this.table.shape) {
|
|
36
36
|
case 'arrow-table':
|
|
37
|
-
|
|
37
|
+
const arrowTable = this.table.data as any;
|
|
38
|
+
return arrowTable.getChild(this.columnName)?.toArray();
|
|
38
39
|
case 'columnar-table':
|
|
39
40
|
return this.table.data[this.columnName];
|
|
40
41
|
default:
|
|
@@ -62,7 +63,7 @@ export class ArrowLikeTable {
|
|
|
62
63
|
// }
|
|
63
64
|
|
|
64
65
|
get data() {
|
|
65
|
-
return this.table.data;
|
|
66
|
+
return this.table.shape === 'geojson-table' ? this.table.features : this.table.data;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
get numCols(): number {
|
|
@@ -13,8 +13,8 @@ export class RowTableBatchAggregator implements TableBatchAggregator {
|
|
|
13
13
|
options: TableBatchOptions;
|
|
14
14
|
|
|
15
15
|
length: number = 0;
|
|
16
|
-
objectRows: {[columnName: string]:
|
|
17
|
-
arrayRows:
|
|
16
|
+
objectRows: {[columnName: string]: unknown}[] | null = null;
|
|
17
|
+
arrayRows: unknown[][] | null = null;
|
|
18
18
|
cursor: number = 0;
|
|
19
19
|
private _headers: string[] = [];
|
|
20
20
|
|
|
@@ -11,11 +11,14 @@ export function getTableLength(table: Table): number {
|
|
|
11
11
|
switch (table.shape) {
|
|
12
12
|
case 'array-row-table':
|
|
13
13
|
case 'object-row-table':
|
|
14
|
-
case 'geojson-row-table':
|
|
15
14
|
return table.data.length;
|
|
16
15
|
|
|
16
|
+
case 'geojson-table':
|
|
17
|
+
return table.features.length;
|
|
18
|
+
|
|
17
19
|
case 'arrow-table':
|
|
18
|
-
|
|
20
|
+
const arrowTable = table.data as any;
|
|
21
|
+
return arrowTable.numRows;
|
|
19
22
|
|
|
20
23
|
case 'columnar-table':
|
|
21
24
|
for (const column of Object.values(table.data)) {
|
|
@@ -42,14 +45,14 @@ export function getTableNumCols(table: Table): number {
|
|
|
42
45
|
case 'array-row-table':
|
|
43
46
|
return table.data[0].length;
|
|
44
47
|
case 'object-row-table':
|
|
45
|
-
case 'geojson-row-table':
|
|
46
48
|
return Object.keys(table.data[0]).length;
|
|
47
|
-
|
|
49
|
+
case 'geojson-table':
|
|
50
|
+
return Object.keys(table.features[0]).length;
|
|
48
51
|
case 'columnar-table':
|
|
49
52
|
return Object.keys(table.data).length;
|
|
50
|
-
|
|
51
53
|
case 'arrow-table':
|
|
52
|
-
|
|
54
|
+
const arrowTable = table.data as any;
|
|
55
|
+
return arrowTable.numCols;
|
|
53
56
|
default:
|
|
54
57
|
throw new Error('table');
|
|
55
58
|
}
|
|
@@ -63,18 +66,21 @@ export function getTableCell(table: Table, rowIndex: number, columnName: string)
|
|
|
63
66
|
return table.data[rowIndex][columnIndex];
|
|
64
67
|
|
|
65
68
|
case 'object-row-table':
|
|
66
|
-
case 'geojson-row-table':
|
|
67
69
|
return table.data[rowIndex][columnName];
|
|
68
70
|
|
|
71
|
+
case 'geojson-table':
|
|
72
|
+
return table.features[rowIndex][columnName];
|
|
73
|
+
|
|
69
74
|
case 'columnar-table':
|
|
70
75
|
const column = table.data[columnName];
|
|
71
76
|
return column[rowIndex];
|
|
72
77
|
|
|
73
78
|
case 'arrow-table':
|
|
74
|
-
const
|
|
79
|
+
const arrowTable = table.data as any;
|
|
80
|
+
const arrowColumnIndex = arrowTable.schema.fields.findIndex(
|
|
75
81
|
(field) => field.name === columnName
|
|
76
82
|
);
|
|
77
|
-
return
|
|
83
|
+
return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);
|
|
78
84
|
|
|
79
85
|
default:
|
|
80
86
|
throw new Error('todo');
|
|
@@ -88,17 +94,21 @@ export function getTableCellAt(table: Table, rowIndex: number, columnIndex: numb
|
|
|
88
94
|
return table.data[rowIndex][columnIndex];
|
|
89
95
|
|
|
90
96
|
case 'object-row-table':
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
const columnName1 = getTableColumnName(table, columnIndex);
|
|
98
|
+
return table.data[rowIndex][columnName1];
|
|
99
|
+
|
|
100
|
+
case 'geojson-table':
|
|
101
|
+
const columnName2 = getTableColumnName(table, columnIndex);
|
|
102
|
+
return table.features[rowIndex][columnName2];
|
|
94
103
|
|
|
95
104
|
case 'columnar-table':
|
|
96
|
-
|
|
97
|
-
const column = table.data[
|
|
105
|
+
const columnName3 = getTableColumnName(table, columnIndex);
|
|
106
|
+
const column = table.data[columnName3];
|
|
98
107
|
return column[rowIndex];
|
|
99
108
|
|
|
100
109
|
case 'arrow-table':
|
|
101
|
-
|
|
110
|
+
const arrowTable = table.data as any;
|
|
111
|
+
return arrowTable.getChildAt(columnIndex)?.get(rowIndex);
|
|
102
112
|
|
|
103
113
|
default:
|
|
104
114
|
throw new Error('todo');
|
|
@@ -112,7 +122,8 @@ export function getTableRowShape(table: Table): 'array-row-table' | 'object-row-
|
|
|
112
122
|
case 'object-row-table':
|
|
113
123
|
return table.shape;
|
|
114
124
|
|
|
115
|
-
case 'geojson-
|
|
125
|
+
case 'geojson-table':
|
|
126
|
+
// TODO - this is not correct, geojson-table is not a row table
|
|
116
127
|
return 'object-row-table';
|
|
117
128
|
|
|
118
129
|
case 'columnar-table':
|
|
@@ -156,7 +167,6 @@ export function getTableRowAsObject(
|
|
|
156
167
|
return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];
|
|
157
168
|
|
|
158
169
|
case 'array-row-table':
|
|
159
|
-
case 'geojson-row-table':
|
|
160
170
|
if (table.schema) {
|
|
161
171
|
const objectRow: {[columnName: string]: unknown} = target || {};
|
|
162
172
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
@@ -166,6 +176,17 @@ export function getTableRowAsObject(
|
|
|
166
176
|
}
|
|
167
177
|
throw new Error('no schema');
|
|
168
178
|
|
|
179
|
+
case 'geojson-table':
|
|
180
|
+
if (table.schema) {
|
|
181
|
+
const objectRow: {[columnName: string]: unknown} = target || {};
|
|
182
|
+
// TODO - should lift properties to top level
|
|
183
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
184
|
+
objectRow[table.schema.fields[i].name] = table.features[rowIndex][i];
|
|
185
|
+
}
|
|
186
|
+
return objectRow;
|
|
187
|
+
}
|
|
188
|
+
throw new Error('no schema');
|
|
189
|
+
|
|
169
190
|
case 'columnar-table':
|
|
170
191
|
if (table.schema) {
|
|
171
192
|
const objectRow: {[columnName: string]: unknown} = target || {};
|
|
@@ -184,9 +205,10 @@ export function getTableRowAsObject(
|
|
|
184
205
|
}
|
|
185
206
|
|
|
186
207
|
case 'arrow-table':
|
|
208
|
+
const arrowTable = table.data as any;
|
|
187
209
|
const objectRow: {[columnName: string]: unknown} = target || {};
|
|
188
|
-
const row =
|
|
189
|
-
const schema =
|
|
210
|
+
const row = arrowTable.get(rowIndex);
|
|
211
|
+
const schema = arrowTable.schema;
|
|
190
212
|
for (let i = 0; i < schema.fields.length; i++) {
|
|
191
213
|
objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];
|
|
192
214
|
}
|
|
@@ -214,7 +236,6 @@ export function getTableRowAsArray(
|
|
|
214
236
|
return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];
|
|
215
237
|
|
|
216
238
|
case 'object-row-table':
|
|
217
|
-
case 'geojson-row-table':
|
|
218
239
|
if (table.schema) {
|
|
219
240
|
const arrayRow: unknown[] = target || [];
|
|
220
241
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
@@ -225,6 +246,18 @@ export function getTableRowAsArray(
|
|
|
225
246
|
// Warning: just slap on the values, this risks mismatches between rows
|
|
226
247
|
return Object.values(table.data[rowIndex]);
|
|
227
248
|
|
|
249
|
+
case 'geojson-table':
|
|
250
|
+
if (table.schema) {
|
|
251
|
+
const arrayRow: unknown[] = target || [];
|
|
252
|
+
// TODO - should lift properties to top level
|
|
253
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
254
|
+
arrayRow[i] = table.features[rowIndex][table.schema.fields[i].name];
|
|
255
|
+
}
|
|
256
|
+
return arrayRow;
|
|
257
|
+
}
|
|
258
|
+
// Warning: just slap on the values, this risks mismatches between rows
|
|
259
|
+
return Object.values(table.features[rowIndex]);
|
|
260
|
+
|
|
228
261
|
case 'columnar-table':
|
|
229
262
|
if (table.schema) {
|
|
230
263
|
const arrayRow: unknown[] = target || [];
|
|
@@ -244,9 +277,10 @@ export function getTableRowAsArray(
|
|
|
244
277
|
}
|
|
245
278
|
|
|
246
279
|
case 'arrow-table':
|
|
280
|
+
const arrowTable = table.data as any;
|
|
247
281
|
const arrayRow: unknown[] = target || [];
|
|
248
|
-
const row =
|
|
249
|
-
const schema =
|
|
282
|
+
const row = arrowTable.get(rowIndex);
|
|
283
|
+
const schema = arrowTable.schema;
|
|
250
284
|
for (let i = 0; i < schema.fields.length; i++) {
|
|
251
285
|
arrayRow[i] = row?.[schema.fields[i].name];
|
|
252
286
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {Schema} from './schema';
|
|
4
|
+
import type {RecordBatch} from 'apache-arrow';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A batch of data (or metadata/schema), from a streaming loader
|
|
8
|
+
* @see parseInBatches()
|
|
9
|
+
* @see loadInBatches()
|
|
10
|
+
*/
|
|
11
|
+
export type Batch = {
|
|
12
|
+
/** A batch can contain metadata, data, or in case of unstructured data (JSON) */
|
|
13
|
+
batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
|
|
14
|
+
/** A string identifying the shape of data in this batch (table, etc) */
|
|
15
|
+
shape: string;
|
|
16
|
+
/** Schema of the data in this batch */
|
|
17
|
+
schema?: Schema;
|
|
18
|
+
/** Data in this batch */
|
|
19
|
+
data: unknown;
|
|
20
|
+
/** If this is an arrow table. @deprecated Use `data` */
|
|
21
|
+
recordBatch?: RecordBatch;
|
|
22
|
+
/** Length of data in this batch */
|
|
23
|
+
length: number;
|
|
24
|
+
|
|
25
|
+
/** A count of batches received */
|
|
26
|
+
batch?: number;
|
|
27
|
+
|
|
28
|
+
/** A count of batches received */
|
|
29
|
+
count?: number;
|
|
30
|
+
|
|
31
|
+
/** Bytes used so far */
|
|
32
|
+
bytesUsed?: number;
|
|
33
|
+
/** cursor is the */
|
|
34
|
+
cursor?: number;
|
|
35
|
+
|
|
36
|
+
/** MIME type of the data generating this batch */
|
|
37
|
+
mimeType?: string;
|
|
38
|
+
|
|
39
|
+
/** Any other data */
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {Batch
|
|
3
|
+
import type {Schema} from './schema';
|
|
4
|
+
import type {Batch} from './batch';
|
|
5
5
|
import type {Feature} from './category-gis';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
// Avoid a big dependency, apparently even a type import can pull in a lot of code
|
|
8
|
+
// import type {Table as ApacheArrowTable} from 'apache-arrow';
|
|
9
|
+
|
|
10
|
+
type ApacheArrowTable = unknown;
|
|
11
|
+
type ApacheRecordBatch = unknown;
|
|
12
12
|
|
|
13
13
|
/** A general table */
|
|
14
14
|
export type Table =
|
|
15
15
|
| RowTable
|
|
16
16
|
| ArrayRowTable
|
|
17
17
|
| ObjectRowTable
|
|
18
|
-
|
|
|
18
|
+
| GeoJSONTable
|
|
19
19
|
| ColumnarTable
|
|
20
20
|
| ArrowTable;
|
|
21
21
|
|
|
22
22
|
/** A table organized as an array of rows */
|
|
23
|
-
export type RowTable = ArrayRowTable | ObjectRowTable |
|
|
23
|
+
export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;
|
|
24
24
|
|
|
25
25
|
/** A table organized as an array of rows, each row is an array of values */
|
|
26
26
|
export type ArrayRowTable = {
|
|
@@ -36,11 +36,17 @@ export type ObjectRowTable = {
|
|
|
36
36
|
data: {[columnName: string]: any}[];
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/**
|
|
40
|
+
* A table organized as an array of rows, each row is a GeoJSON Feature
|
|
41
|
+
* @note For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data`
|
|
42
|
+
*/
|
|
43
|
+
export type GeoJSONTable = {
|
|
44
|
+
shape: 'geojson-table';
|
|
42
45
|
schema?: Schema;
|
|
43
|
-
|
|
46
|
+
/** For compatibility with GeoJSON, the type field must always be set to `FeatureCollection` */
|
|
47
|
+
type: 'FeatureCollection';
|
|
48
|
+
/** For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data` */
|
|
49
|
+
features: Feature[];
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
/** A table organized as a map of columns, each column is an array of value */
|
|
@@ -69,7 +75,7 @@ export type Tables<TableType = Table> = {
|
|
|
69
75
|
export type TableBatch =
|
|
70
76
|
| ArrayRowTableBatch
|
|
71
77
|
| ObjectRowTableBatch
|
|
72
|
-
|
|
|
78
|
+
| GeoJSONTableBatch
|
|
73
79
|
| ColumnarTableBatch
|
|
74
80
|
| ArrowTableBatch;
|
|
75
81
|
|
|
@@ -92,11 +98,12 @@ export type ObjectRowTableBatch = Batch & {
|
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
95
|
-
export type
|
|
96
|
-
shape: 'geojson-
|
|
101
|
+
export type GeoJSONTableBatch = Batch & {
|
|
102
|
+
shape: 'geojson-table';
|
|
97
103
|
schema?: Schema;
|
|
98
104
|
schemaType?: 'explicit' | 'deduced';
|
|
99
|
-
|
|
105
|
+
type: 'FeatureCollection';
|
|
106
|
+
features: Feature[];
|
|
100
107
|
length: number;
|
|
101
108
|
};
|
|
102
109
|
|
|
@@ -114,6 +121,6 @@ export type ArrowTableBatch = Batch & {
|
|
|
114
121
|
shape: 'arrow-table';
|
|
115
122
|
schemaType?: 'explicit' | 'deduced';
|
|
116
123
|
schema?: Schema;
|
|
117
|
-
data:
|
|
124
|
+
data: ApacheRecordBatch;
|
|
118
125
|
length: number;
|
|
119
126
|
};
|
package/src/types/schema.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
|
-
import type {RecordBatch} from 'apache-arrow';
|
|
4
|
-
|
|
5
3
|
/** For dictionary type */
|
|
6
4
|
export type KeyType = 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32';
|
|
7
5
|
|
|
@@ -80,18 +78,3 @@ export type Schema = {
|
|
|
80
78
|
fields: Field[];
|
|
81
79
|
metadata: SchemaMetadata;
|
|
82
80
|
};
|
|
83
|
-
|
|
84
|
-
export type Batch = {
|
|
85
|
-
batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
|
|
86
|
-
batch?: number;
|
|
87
|
-
mimeType?: string;
|
|
88
|
-
shape: string;
|
|
89
|
-
data: any;
|
|
90
|
-
recordBatch?: RecordBatch;
|
|
91
|
-
length: number;
|
|
92
|
-
schema?: Schema;
|
|
93
|
-
bytesUsed?: number;
|
|
94
|
-
count?: number;
|
|
95
|
-
cursor?: number;
|
|
96
|
-
[key: string]: any;
|
|
97
|
-
};
|