@loaders.gl/schema 4.3.2 → 4.4.0-alpha.1

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.
Files changed (163) hide show
  1. package/dist/categories/category-gis.d.ts +6 -0
  2. package/dist/categories/category-gis.d.ts.map +1 -0
  3. package/dist/categories/category-image.d.ts.map +1 -0
  4. package/dist/{types → categories}/category-mesh.d.ts +2 -2
  5. package/dist/categories/category-mesh.d.ts.map +1 -0
  6. package/dist/{types → categories}/category-table.d.ts +14 -14
  7. package/dist/categories/category-table.d.ts.map +1 -0
  8. package/dist/categories/category-texture.d.ts.map +1 -0
  9. package/dist/{lib/mesh → deprecated}/mesh-utils.d.ts +4 -2
  10. package/dist/deprecated/mesh-utils.d.ts.map +1 -0
  11. package/dist/{lib/mesh → deprecated}/mesh-utils.js +2 -0
  12. package/dist/dist.dev.js +0 -1836
  13. package/dist/dist.min.js +1 -1
  14. package/dist/geometry/binary-features.d.ts +30 -0
  15. package/dist/geometry/binary-features.d.ts.map +1 -0
  16. package/dist/geometry/binary-geometries.d.ts +33 -0
  17. package/dist/geometry/binary-geometries.d.ts.map +1 -0
  18. package/dist/geometry/flat-geometries.d.ts +61 -0
  19. package/dist/geometry/flat-geometries.d.ts.map +1 -0
  20. package/dist/index.cjs +2 -1792
  21. package/dist/index.cjs.map +4 -4
  22. package/dist/index.d.ts +10 -28
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -23
  25. package/dist/types/batch.d.ts +3 -1
  26. package/dist/types/batch.d.ts.map +1 -1
  27. package/package.json +5 -4
  28. package/src/{types → categories}/category-gis.ts +7 -18
  29. package/src/{types → categories}/category-mesh.ts +2 -2
  30. package/src/{types → categories}/category-table.ts +14 -17
  31. package/src/{lib/mesh → deprecated}/mesh-utils.ts +4 -2
  32. package/src/geometry/binary-features.ts +43 -0
  33. package/src/geometry/binary-geometries.ts +45 -0
  34. package/src/{types → geometry}/flat-geometries.ts +44 -14
  35. package/src/index.ts +15 -101
  36. package/src/types/batch.ts +3 -1
  37. package/dist/lib/mesh/convert-mesh.d.ts +0 -15
  38. package/dist/lib/mesh/convert-mesh.d.ts.map +0 -1
  39. package/dist/lib/mesh/convert-mesh.js +0 -37
  40. package/dist/lib/mesh/deduce-mesh-schema.d.ts +0 -24
  41. package/dist/lib/mesh/deduce-mesh-schema.d.ts.map +0 -1
  42. package/dist/lib/mesh/deduce-mesh-schema.js +0 -62
  43. package/dist/lib/mesh/mesh-to-arrow-table.d.ts +0 -1
  44. package/dist/lib/mesh/mesh-to-arrow-table.d.ts.map +0 -1
  45. package/dist/lib/mesh/mesh-to-arrow-table.js +0 -47
  46. package/dist/lib/mesh/mesh-utils.d.ts.map +0 -1
  47. package/dist/lib/table/arrow-api/arrow-like-field.d.ts +0 -19
  48. package/dist/lib/table/arrow-api/arrow-like-field.d.ts.map +0 -1
  49. package/dist/lib/table/arrow-api/arrow-like-field.js +0 -36
  50. package/dist/lib/table/arrow-api/arrow-like-interface.d.ts +0 -43
  51. package/dist/lib/table/arrow-api/arrow-like-interface.d.ts.map +0 -1
  52. package/dist/lib/table/arrow-api/arrow-like-schema.d.ts +0 -12
  53. package/dist/lib/table/arrow-api/arrow-like-schema.d.ts.map +0 -1
  54. package/dist/lib/table/arrow-api/arrow-like-schema.js +0 -81
  55. package/dist/lib/table/arrow-api/arrow-like-table.d.ts +0 -24
  56. package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +0 -1
  57. package/dist/lib/table/arrow-api/arrow-like-table.js +0 -63
  58. package/dist/lib/table/arrow-api/arrow-like-type.d.ts +0 -177
  59. package/dist/lib/table/arrow-api/arrow-like-type.d.ts.map +0 -1
  60. package/dist/lib/table/arrow-api/arrow-like-type.js +0 -442
  61. package/dist/lib/table/arrow-api/enum.d.ts +0 -92
  62. package/dist/lib/table/arrow-api/enum.d.ts.map +0 -1
  63. package/dist/lib/table/arrow-api/enum.js +0 -97
  64. package/dist/lib/table/arrow-api/get-type-info.d.ts +0 -13
  65. package/dist/lib/table/arrow-api/get-type-info.d.ts.map +0 -1
  66. package/dist/lib/table/arrow-api/get-type-info.js +0 -27
  67. package/dist/lib/table/arrow-api/index.d.ts +0 -5
  68. package/dist/lib/table/arrow-api/index.d.ts.map +0 -1
  69. package/dist/lib/table/arrow-api/index.js +0 -7
  70. package/dist/lib/table/batches/base-table-batch-aggregator.d.ts +0 -20
  71. package/dist/lib/table/batches/base-table-batch-aggregator.d.ts.map +0 -1
  72. package/dist/lib/table/batches/base-table-batch-aggregator.js +0 -63
  73. package/dist/lib/table/batches/columnar-table-batch-aggregator.d.ts +0 -23
  74. package/dist/lib/table/batches/columnar-table-batch-aggregator.d.ts.map +0 -1
  75. package/dist/lib/table/batches/columnar-table-batch-aggregator.js +0 -91
  76. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +0 -22
  77. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +0 -1
  78. package/dist/lib/table/batches/row-table-batch-aggregator.js +0 -85
  79. package/dist/lib/table/batches/table-batch-aggregator.d.ts +0 -25
  80. package/dist/lib/table/batches/table-batch-aggregator.d.ts.map +0 -1
  81. package/dist/lib/table/batches/table-batch-aggregator.js +0 -4
  82. package/dist/lib/table/batches/table-batch-builder.d.ts +0 -53
  83. package/dist/lib/table/batches/table-batch-builder.d.ts.map +0 -1
  84. package/dist/lib/table/batches/table-batch-builder.js +0 -151
  85. package/dist/lib/table/simple-table/convert-table.d.ts +0 -43
  86. package/dist/lib/table/simple-table/convert-table.d.ts.map +0 -1
  87. package/dist/lib/table/simple-table/convert-table.js +0 -118
  88. package/dist/lib/table/simple-table/data-type.d.ts +0 -17
  89. package/dist/lib/table/simple-table/data-type.d.ts.map +0 -1
  90. package/dist/lib/table/simple-table/data-type.js +0 -88
  91. package/dist/lib/table/simple-table/make-table-from-batches.d.ts +0 -22
  92. package/dist/lib/table/simple-table/make-table-from-batches.d.ts.map +0 -1
  93. package/dist/lib/table/simple-table/make-table-from-batches.js +0 -79
  94. package/dist/lib/table/simple-table/make-table.d.ts +0 -65
  95. package/dist/lib/table/simple-table/make-table.d.ts.map +0 -1
  96. package/dist/lib/table/simple-table/make-table.js +0 -94
  97. package/dist/lib/table/simple-table/row-utils.d.ts +0 -15
  98. package/dist/lib/table/simple-table/row-utils.d.ts.map +0 -1
  99. package/dist/lib/table/simple-table/row-utils.js +0 -49
  100. package/dist/lib/table/simple-table/table-accessors.d.ts +0 -68
  101. package/dist/lib/table/simple-table/table-accessors.d.ts.map +0 -1
  102. package/dist/lib/table/simple-table/table-accessors.js +0 -350
  103. package/dist/lib/table/simple-table/table-column.d.ts +0 -7
  104. package/dist/lib/table/simple-table/table-column.d.ts.map +0 -1
  105. package/dist/lib/table/simple-table/table-column.js +0 -39
  106. package/dist/lib/table/simple-table/table-schema.d.ts +0 -15
  107. package/dist/lib/table/simple-table/table-schema.d.ts.map +0 -1
  108. package/dist/lib/table/simple-table/table-schema.js +0 -100
  109. package/dist/lib/utils/assert.d.ts +0 -2
  110. package/dist/lib/utils/assert.d.ts.map +0 -1
  111. package/dist/lib/utils/assert.js +0 -8
  112. package/dist/lib/utils/async-queue.d.ts +0 -18
  113. package/dist/lib/utils/async-queue.d.ts.map +0 -1
  114. package/dist/lib/utils/async-queue.js +0 -90
  115. package/dist/types/binary-geometries.d.ts +0 -57
  116. package/dist/types/binary-geometries.d.ts.map +0 -1
  117. package/dist/types/category-gis.d.ts +0 -18
  118. package/dist/types/category-gis.d.ts.map +0 -1
  119. package/dist/types/category-image.d.ts.map +0 -1
  120. package/dist/types/category-mesh.d.ts.map +0 -1
  121. package/dist/types/category-table.d.ts.map +0 -1
  122. package/dist/types/category-texture.d.ts.map +0 -1
  123. package/dist/types/flat-geometries.d.ts +0 -30
  124. package/dist/types/flat-geometries.d.ts.map +0 -1
  125. package/src/lib/mesh/convert-mesh.ts +0 -51
  126. package/src/lib/mesh/deduce-mesh-schema.ts +0 -76
  127. package/src/lib/mesh/mesh-to-arrow-table.ts +0 -47
  128. package/src/lib/table/arrow-api/arrow-like-field.ts +0 -53
  129. package/src/lib/table/arrow-api/arrow-like-interface.ts +0 -84
  130. package/src/lib/table/arrow-api/arrow-like-schema.ts +0 -101
  131. package/src/lib/table/arrow-api/arrow-like-table.ts +0 -86
  132. package/src/lib/table/arrow-api/arrow-like-type.ts +0 -502
  133. package/src/lib/table/arrow-api/enum.ts +0 -99
  134. package/src/lib/table/arrow-api/get-type-info.ts +0 -38
  135. package/src/lib/table/arrow-api/index.ts +0 -8
  136. package/src/lib/table/batches/base-table-batch-aggregator.ts +0 -83
  137. package/src/lib/table/batches/columnar-table-batch-aggregator.ts +0 -112
  138. package/src/lib/table/batches/row-table-batch-aggregator.ts +0 -109
  139. package/src/lib/table/batches/table-batch-aggregator.ts +0 -29
  140. package/src/lib/table/batches/table-batch-builder.ts +0 -190
  141. package/src/lib/table/simple-table/convert-table.ts +0 -149
  142. package/src/lib/table/simple-table/data-type.ts +0 -104
  143. package/src/lib/table/simple-table/make-table-from-batches.ts +0 -98
  144. package/src/lib/table/simple-table/make-table.ts +0 -111
  145. package/src/lib/table/simple-table/row-utils.ts +0 -59
  146. package/src/lib/table/simple-table/table-accessors.ts +0 -417
  147. package/src/lib/table/simple-table/table-column.ts +0 -49
  148. package/src/lib/table/simple-table/table-schema.ts +0 -121
  149. package/src/lib/utils/assert.ts +0 -8
  150. package/src/lib/utils/async-queue.ts +0 -104
  151. package/src/types/binary-geometries.ts +0 -67
  152. /package/dist/{types → categories}/category-gis.js +0 -0
  153. /package/dist/{types → categories}/category-image.d.ts +0 -0
  154. /package/dist/{types → categories}/category-image.js +0 -0
  155. /package/dist/{types → categories}/category-mesh.js +0 -0
  156. /package/dist/{types → categories}/category-table.js +0 -0
  157. /package/dist/{types → categories}/category-texture.d.ts +0 -0
  158. /package/dist/{types → categories}/category-texture.js +0 -0
  159. /package/dist/{lib/table/arrow-api/arrow-like-interface.js → geometry/binary-features.js} +0 -0
  160. /package/dist/{types → geometry}/binary-geometries.js +0 -0
  161. /package/dist/{types → geometry}/flat-geometries.js +0 -0
  162. /package/src/{types → categories}/category-image.ts +0 -0
  163. /package/src/{types → categories}/category-texture.ts +0 -0
@@ -1,20 +0,0 @@
1
- import type { Schema } from "../../../types/schema.js";
2
- import type { TableBatch } from "../../../types/category-table.js";
3
- import { TableBatchAggregator, TableBatchOptions } from "./table-batch-aggregator.js";
4
- export declare class BaseTableBatchAggregator implements TableBatchAggregator {
5
- schema: Schema;
6
- options: TableBatchOptions;
7
- shape?: 'array-row-table' | 'object-row-table';
8
- length: number;
9
- rows: any[] | null;
10
- cursor: number;
11
- private _headers;
12
- constructor(schema: Schema, options: TableBatchOptions);
13
- rowCount(): number;
14
- addArrayRow(row: any[], cursor?: number): void;
15
- addObjectRow(row: {
16
- [columnName: string]: any;
17
- }, cursor?: number): void;
18
- getBatch(): TableBatch | null;
19
- }
20
- //# sourceMappingURL=base-table-batch-aggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-table-batch-aggregator.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/batches/base-table-batch-aggregator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,iCAA8B;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,yCAAsC;AAC9D,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,oCAAiC;AAIjF,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,iBAAiB,CAAC;IAE3B,KAAK,CAAC,EAAE,iBAAiB,GAAG,kBAAkB,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAK;IACnB,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAQ;IAC1B,MAAM,EAAE,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;IActD,QAAQ,IAAI,MAAM;IAIlB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAY9C,YAAY,CAAC,GAAG,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAYrE,QAAQ,IAAI,UAAU,GAAG,IAAI;CAoB9B"}
@@ -1,63 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- const DEFAULT_ROW_COUNT = 100;
5
- export class BaseTableBatchAggregator {
6
- schema;
7
- options;
8
- shape;
9
- length = 0;
10
- rows = null;
11
- cursor = 0;
12
- _headers = [];
13
- constructor(schema, options) {
14
- this.options = options;
15
- this.schema = schema;
16
- // schema is an array if there're no headers
17
- // object if there are headers
18
- if (!Array.isArray(schema)) {
19
- this._headers = [];
20
- for (const key in schema) {
21
- this._headers[schema[key].index] = schema[key].name;
22
- }
23
- }
24
- }
25
- rowCount() {
26
- return this.length;
27
- }
28
- addArrayRow(row, cursor) {
29
- if (Number.isFinite(cursor)) {
30
- this.cursor = cursor;
31
- }
32
- this.shape = 'array-row-table';
33
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
34
- this.rows[this.length] = row;
35
- this.length++;
36
- }
37
- addObjectRow(row, cursor) {
38
- if (Number.isFinite(cursor)) {
39
- this.cursor = cursor;
40
- }
41
- this.shape = 'object-row-table';
42
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
43
- this.rows[this.length] = row;
44
- this.length++;
45
- }
46
- getBatch() {
47
- let rows = this.rows;
48
- if (!rows) {
49
- return null;
50
- }
51
- rows = rows.slice(0, this.length);
52
- this.rows = null;
53
- const batch = {
54
- shape: this.shape || 'array-row-table',
55
- batchType: 'data',
56
- data: rows,
57
- length: this.length,
58
- schema: this.schema,
59
- cursor: this.cursor
60
- };
61
- return batch;
62
- }
63
- }
@@ -1,23 +0,0 @@
1
- import type { Schema } from "../../../types/schema.js";
2
- import type { ColumnarTableBatch, ArrowTableBatch } from "../../../types/category-table.js";
3
- import { TableBatchAggregator } from "./table-batch-aggregator.js";
4
- type ColumnarTableBatchOptions = {};
5
- export declare class ColumnarTableBatchAggregator implements TableBatchAggregator {
6
- schema: Schema;
7
- length: number;
8
- allocated: number;
9
- columns: {
10
- [columnName: string]: any[];
11
- };
12
- constructor(schema: Schema, options: ColumnarTableBatchOptions);
13
- rowCount(): number;
14
- addArrayRow(row: any[]): void;
15
- addObjectRow(row: {
16
- [columnName: string]: any;
17
- }): void;
18
- getBatch(): ColumnarTableBatch | ArrowTableBatch | null;
19
- _reallocateColumns(): void;
20
- _pruneColumns(): void;
21
- }
22
- export {};
23
- //# sourceMappingURL=columnar-table-batch-aggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"columnar-table-batch-aggregator.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/batches/columnar-table-batch-aggregator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,iCAA8B;AAClD,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,yCAAsC;AACvF,OAAO,EAAC,oBAAoB,EAAC,oCAAiC;AAE9D,KAAK,yBAAyB,GAAG,EAAE,CAAC;AAIpC,qBAAa,4BAA6B,YAAW,oBAAoB;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAK;IACnB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;KAAC,CAAM;gBAEhC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB;IAK9D,QAAQ,IAAI,MAAM;IAIlB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;IAWtB,YAAY,CAAC,GAAG,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,IAAI;IASpD,QAAQ,IAAI,kBAAkB,GAAG,eAAe,GAAG,IAAI;IA6BvD,kBAAkB;IA8BlB,aAAa;CAKd"}
@@ -1,91 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- const DEFAULT_ROW_COUNT = 100;
5
- export class ColumnarTableBatchAggregator {
6
- schema;
7
- length = 0;
8
- allocated = 0;
9
- columns = {};
10
- constructor(schema, options) {
11
- this.schema = schema;
12
- this._reallocateColumns();
13
- }
14
- rowCount() {
15
- return this.length;
16
- }
17
- addArrayRow(row) {
18
- // If user keeps pushing rows beyond batch size, reallocate
19
- this._reallocateColumns();
20
- let i = 0;
21
- // TODO what if no csv header, columns not populated?
22
- for (const fieldName in this.columns) {
23
- this.columns[fieldName][this.length] = row[i++];
24
- }
25
- this.length++;
26
- }
27
- addObjectRow(row) {
28
- // If user keeps pushing rows beyond batch size, reallocate
29
- this._reallocateColumns();
30
- for (const fieldName in row) {
31
- this.columns[fieldName][this.length] = row[fieldName];
32
- }
33
- this.length++;
34
- }
35
- getBatch() {
36
- this._pruneColumns();
37
- const columns = Array.isArray(this.schema) ? this.columns : {};
38
- // schema is an array if there're no headers
39
- // object if there are headers
40
- // columns should match schema format
41
- if (!Array.isArray(this.schema)) {
42
- for (const fieldName in this.schema) {
43
- const field = this.schema[fieldName];
44
- columns[field.name] = this.columns[field.index];
45
- }
46
- }
47
- this.columns = {};
48
- const batch = {
49
- shape: 'columnar-table',
50
- batchType: 'data',
51
- data: columns,
52
- schema: this.schema,
53
- length: this.length
54
- };
55
- return batch;
56
- }
57
- // HELPERS
58
- _reallocateColumns() {
59
- if (this.length < this.allocated) {
60
- return;
61
- }
62
- // @ts-ignore TODO
63
- this.allocated = this.allocated > 0 ? (this.allocated *= 2) : DEFAULT_ROW_COUNT;
64
- this.columns = {};
65
- for (const fieldName in this.schema) {
66
- const field = this.schema[fieldName];
67
- const ArrayType = field.type || Float32Array;
68
- const oldColumn = this.columns[field.index];
69
- if (oldColumn && ArrayBuffer.isView(oldColumn)) {
70
- // Copy the old data to the new array
71
- const typedArray = new ArrayType(this.allocated);
72
- typedArray.set(oldColumn);
73
- this.columns[field.index] = typedArray;
74
- }
75
- else if (oldColumn) {
76
- // Plain array
77
- oldColumn.length = this.allocated;
78
- this.columns[field.index] = oldColumn;
79
- }
80
- else {
81
- // Create new
82
- this.columns[field.index] = new ArrayType(this.allocated);
83
- }
84
- }
85
- }
86
- _pruneColumns() {
87
- for (const [columnName, column] of Object.entries(this.columns)) {
88
- this.columns[columnName] = column.slice(0, this.length);
89
- }
90
- }
91
- }
@@ -1,22 +0,0 @@
1
- import type { Schema } from "../../../types/schema.js";
2
- import type { TableBatch } from "../../../types/category-table.js";
3
- import { TableBatchAggregator, TableBatchOptions } from "./table-batch-aggregator.js";
4
- export declare class RowTableBatchAggregator implements TableBatchAggregator {
5
- schema: Schema | null;
6
- options: TableBatchOptions;
7
- length: number;
8
- objectRows: {
9
- [columnName: string]: unknown;
10
- }[] | null;
11
- arrayRows: unknown[][] | null;
12
- cursor: number;
13
- private _headers;
14
- constructor(schema: Schema | null, options: TableBatchOptions);
15
- rowCount(): number;
16
- addArrayRow(row: any[], cursor?: number): void;
17
- addObjectRow(row: {
18
- [columnName: string]: any;
19
- }, cursor?: number): void;
20
- getBatch(): TableBatch | null;
21
- }
22
- //# sourceMappingURL=row-table-batch-aggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"row-table-batch-aggregator.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/batches/row-table-batch-aggregator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,iCAA8B;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,yCAAsC;AAC9D,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,oCAAiC;AAUjF,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,iBAAiB,CAAC;IAE3B,MAAM,EAAE,MAAM,CAAK;IACnB,UAAU,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,EAAE,GAAG,IAAI,CAAQ;IAC5D,SAAS,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,CAAQ;IACrC,MAAM,EAAE,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAyB;gBAE7B,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,iBAAiB;IAc7D,QAAQ,IAAI,MAAM;IAIlB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAsB9C,YAAY,CAAC,GAAG,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAsBrE,QAAQ,IAAI,UAAU,GAAG,IAAI;CAoB9B"}
@@ -1,85 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { convertToArrayRow, convertToObjectRow, inferHeadersFromArrayRow, inferHeadersFromObjectRow } from "../simple-table/row-utils.js";
5
- const DEFAULT_ROW_COUNT = 100;
6
- export class RowTableBatchAggregator {
7
- schema;
8
- options;
9
- length = 0;
10
- objectRows = null;
11
- arrayRows = null;
12
- cursor = 0;
13
- _headers = null;
14
- constructor(schema, options) {
15
- this.options = options;
16
- this.schema = schema;
17
- // schema is an array if there're no headers
18
- // object if there are headers
19
- if (schema) {
20
- this._headers = [];
21
- for (const key in schema) {
22
- this._headers[schema[key].index] = schema[key].name;
23
- }
24
- }
25
- }
26
- rowCount() {
27
- return this.length;
28
- }
29
- addArrayRow(row, cursor) {
30
- if (Number.isFinite(cursor)) {
31
- this.cursor = cursor;
32
- }
33
- // TODO - infer schema at a higher level, instead of hacking headers here?
34
- this._headers ||= inferHeadersFromArrayRow(row);
35
- // eslint-disable-next-line default-case
36
- switch (this.options.shape) {
37
- case 'object-row-table':
38
- const rowObject = convertToObjectRow(row, this._headers);
39
- this.addObjectRow(rowObject, cursor);
40
- break;
41
- case 'array-row-table':
42
- this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT);
43
- this.arrayRows[this.length] = row;
44
- this.length++;
45
- break;
46
- }
47
- }
48
- addObjectRow(row, cursor) {
49
- if (Number.isFinite(cursor)) {
50
- this.cursor = cursor;
51
- }
52
- // TODO - infer schema at a higher level, instead of hacking headers here?
53
- this._headers ||= inferHeadersFromObjectRow(row);
54
- // eslint-disable-next-line default-case
55
- switch (this.options.shape) {
56
- case 'array-row-table':
57
- const rowArray = convertToArrayRow(row, this._headers);
58
- this.addArrayRow(rowArray, cursor);
59
- break;
60
- case 'object-row-table':
61
- this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT);
62
- this.objectRows[this.length] = row;
63
- this.length++;
64
- break;
65
- }
66
- }
67
- getBatch() {
68
- let rows = this.arrayRows || this.objectRows;
69
- if (!rows) {
70
- return null;
71
- }
72
- rows = rows.slice(0, this.length);
73
- this.arrayRows = null;
74
- this.objectRows = null;
75
- return {
76
- shape: this.options.shape,
77
- batchType: 'data',
78
- data: rows,
79
- length: this.length,
80
- // @ts-expect-error we should infer a schema
81
- schema: this.schema,
82
- cursor: this.cursor
83
- };
84
- }
85
- }
@@ -1,25 +0,0 @@
1
- import type { Schema } from "../../../types/schema.js";
2
- import type { TableBatch } from "../../../types/category-table.js";
3
- export interface TableBatchOptions {
4
- batchSize: number | string;
5
- [key: string]: any;
6
- }
7
- export interface TableBatchConstructor {
8
- new (schema: Schema, options: TableBatchOptions): TableBatchAggregator;
9
- }
10
- /**
11
- * TableBatchBuilder delegates batch building to this interface
12
- */
13
- export interface TableBatchAggregator {
14
- /** Number of rows */
15
- rowCount(): number;
16
- /** Add one row */
17
- addArrayRow(row: any[]): void;
18
- /** Add one row */
19
- addObjectRow(row: {
20
- [columnName: string]: any;
21
- }): void;
22
- /** return a batch object */
23
- getBatch(): TableBatch | null;
24
- }
25
- //# sourceMappingURL=table-batch-aggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-batch-aggregator.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/batches/table-batch-aggregator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,iCAA8B;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,yCAAsC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,oBAAoB,CAAC;CACxE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qBAAqB;IACrB,QAAQ,IAAI,MAAM,CAAC;IACnB,kBAAkB;IAClB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC9B,kBAAkB;IAClB,YAAY,CAAC,GAAG,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,IAAI,CAAC;IACrD,4BAA4B;IAC5B,QAAQ,IAAI,UAAU,GAAG,IAAI,CAAC;CAC/B"}
@@ -1,4 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- export {};
@@ -1,53 +0,0 @@
1
- import type { Schema } from "../../../types/schema.js";
2
- import type { TableBatch } from "../../../types/category-table.js";
3
- import type { TableBatchConstructor } from "./table-batch-aggregator.js";
4
- type TableBatchBuilderOptions = {
5
- shape?: 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';
6
- batchSize?: number | 'auto';
7
- batchDebounceMs?: number;
8
- limit?: number;
9
- _limitMB?: number;
10
- };
11
- type GetBatchOptions = {
12
- bytesUsed?: number;
13
- [key: string]: any;
14
- };
15
- /** Incrementally builds batches from a stream of rows */
16
- export declare class TableBatchBuilder {
17
- schema: Schema;
18
- options: Required<TableBatchBuilderOptions>;
19
- private aggregator;
20
- private batchCount;
21
- private bytesUsed;
22
- private isChunkComplete;
23
- private lastBatchEmittedMs;
24
- private totalLength;
25
- private totalBytes;
26
- private rowBytes;
27
- static ArrowBatch?: TableBatchConstructor;
28
- constructor(schema: Schema, options?: TableBatchBuilderOptions);
29
- limitReached(): boolean;
30
- /** @deprecated Use addArrayRow or addObjectRow */
31
- addRow(row: any[] | {
32
- [columnName: string]: any;
33
- }): void;
34
- /** Add one row to the batch */
35
- protected addArrayRow(row: any[]): void;
36
- /** Add one row to the batch */
37
- protected addObjectRow(row: {
38
- [columnName: string]: any;
39
- }): void;
40
- /** Mark an incoming raw memory chunk has completed */
41
- chunkComplete(chunk: ArrayBuffer | string): void;
42
- getFullBatch(options?: GetBatchOptions): TableBatch | null;
43
- getFinalBatch(options?: GetBatchOptions): TableBatch | null;
44
- _estimateRowMB(row: any[] | object): number;
45
- private _isFull;
46
- /**
47
- * bytesUsed can be set via chunkComplete or via getBatch*
48
- */
49
- private _getBatch;
50
- private _getTableBatchType;
51
- }
52
- export {};
53
- //# sourceMappingURL=table-batch-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-batch-builder.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/batches/table-batch-builder.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,iCAA8B;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,yCAAsC;AAC9D,OAAO,KAAK,EAAuB,qBAAqB,EAAC,oCAAiC;AAM1F,KAAK,wBAAwB,GAAG;IAC9B,KAAK,CAAC,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAClF,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAYF,yDAAyD;AACzD,qBAAa,iBAAiB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,wBAAwB,CAAC,CAAC;IAE5C,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAa;IAE7B,MAAM,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAC;gBAE9B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAK9D,YAAY,IAAI,OAAO;IAUvB,kDAAkD;IAClD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,IAAI;IActD,+BAA+B;IAC/B,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;IAQhC,+BAA+B;IAC/B,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,IAAI;IAQ9D,sDAAsD;IACtD,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;IAUhD,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,IAAI;IAI1D,aAAa,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,IAAI;IAM3D,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,MAAM;IAI3C,OAAO,CAAC,OAAO;IA2Bf;;OAEG;IACH,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,kBAAkB;CAgB3B"}
@@ -1,151 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { BaseTableBatchAggregator } from "./base-table-batch-aggregator.js";
5
- import { RowTableBatchAggregator } from "./row-table-batch-aggregator.js";
6
- import { ColumnarTableBatchAggregator } from "./columnar-table-batch-aggregator.js";
7
- const DEFAULT_OPTIONS = {
8
- shape: undefined,
9
- batchSize: 'auto',
10
- batchDebounceMs: 0,
11
- limit: 0,
12
- _limitMB: 0
13
- };
14
- const ERR_MESSAGE = 'TableBatchBuilder';
15
- /** Incrementally builds batches from a stream of rows */
16
- export class TableBatchBuilder {
17
- schema;
18
- options;
19
- aggregator = null;
20
- batchCount = 0;
21
- bytesUsed = 0;
22
- isChunkComplete = false;
23
- lastBatchEmittedMs = Date.now();
24
- totalLength = 0;
25
- totalBytes = 0;
26
- rowBytes = 0;
27
- static ArrowBatch;
28
- constructor(schema, options) {
29
- this.schema = schema;
30
- this.options = { ...DEFAULT_OPTIONS, ...options };
31
- }
32
- limitReached() {
33
- if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
34
- return true;
35
- }
36
- if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
37
- return true;
38
- }
39
- return false;
40
- }
41
- /** @deprecated Use addArrayRow or addObjectRow */
42
- addRow(row) {
43
- if (this.limitReached()) {
44
- return;
45
- }
46
- this.totalLength++;
47
- this.rowBytes = this.rowBytes || this._estimateRowMB(row);
48
- this.totalBytes += this.rowBytes;
49
- if (Array.isArray(row)) {
50
- this.addArrayRow(row);
51
- }
52
- else {
53
- this.addObjectRow(row);
54
- }
55
- }
56
- /** Add one row to the batch */
57
- addArrayRow(row) {
58
- if (!this.aggregator) {
59
- const TableBatchType = this._getTableBatchType();
60
- this.aggregator = new TableBatchType(this.schema, this.options);
61
- }
62
- this.aggregator.addArrayRow(row);
63
- }
64
- /** Add one row to the batch */
65
- addObjectRow(row) {
66
- if (!this.aggregator) {
67
- const TableBatchType = this._getTableBatchType();
68
- this.aggregator = new TableBatchType(this.schema, this.options);
69
- }
70
- this.aggregator.addObjectRow(row);
71
- }
72
- /** Mark an incoming raw memory chunk has completed */
73
- chunkComplete(chunk) {
74
- if (chunk instanceof ArrayBuffer) {
75
- this.bytesUsed += chunk.byteLength;
76
- }
77
- if (typeof chunk === 'string') {
78
- this.bytesUsed += chunk.length;
79
- }
80
- this.isChunkComplete = true;
81
- }
82
- getFullBatch(options) {
83
- return this._isFull() ? this._getBatch(options) : null;
84
- }
85
- getFinalBatch(options) {
86
- return this._getBatch(options);
87
- }
88
- // INTERNAL
89
- _estimateRowMB(row) {
90
- return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
91
- }
92
- _isFull() {
93
- // No batch, not ready
94
- if (!this.aggregator || this.aggregator.rowCount() === 0) {
95
- return false;
96
- }
97
- // if batchSize === 'auto' we wait for chunk to complete
98
- // if batchSize === number, ensure we have enough rows
99
- if (this.options.batchSize === 'auto') {
100
- if (!this.isChunkComplete) {
101
- return false;
102
- }
103
- }
104
- else if (this.options.batchSize > this.aggregator.rowCount()) {
105
- return false;
106
- }
107
- // Debounce batches
108
- if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
109
- return false;
110
- }
111
- // Emit batch
112
- this.isChunkComplete = false;
113
- this.lastBatchEmittedMs = Date.now();
114
- return true;
115
- }
116
- /**
117
- * bytesUsed can be set via chunkComplete or via getBatch*
118
- */
119
- _getBatch(options) {
120
- if (!this.aggregator) {
121
- return null;
122
- }
123
- // TODO - this can overly increment bytes used?
124
- if (options?.bytesUsed) {
125
- this.bytesUsed = options.bytesUsed;
126
- }
127
- const normalizedBatch = this.aggregator.getBatch();
128
- normalizedBatch.count = this.batchCount;
129
- normalizedBatch.bytesUsed = this.bytesUsed;
130
- Object.assign(normalizedBatch, options);
131
- this.batchCount++;
132
- this.aggregator = null;
133
- return normalizedBatch;
134
- }
135
- _getTableBatchType() {
136
- switch (this.options.shape) {
137
- case 'array-row-table':
138
- case 'object-row-table':
139
- return RowTableBatchAggregator;
140
- case 'columnar-table':
141
- return ColumnarTableBatchAggregator;
142
- case 'arrow-table':
143
- if (!TableBatchBuilder.ArrowBatch) {
144
- throw new Error(ERR_MESSAGE);
145
- }
146
- return TableBatchBuilder.ArrowBatch;
147
- default:
148
- return BaseTableBatchAggregator;
149
- }
150
- }
151
- }
@@ -1,43 +0,0 @@
1
- import { Table, ArrayRowTable, ObjectRowTable, ColumnarTable, ArrowTable } from "../../../types/category-table.js";
2
- export declare function convertTable(table: Table, shape: 'object-row-table'): ObjectRowTable;
3
- export declare function convertTable(table: Table, shape: 'array-row-table'): ArrayRowTable;
4
- export declare function convertTable(table: Table, shape: 'columnar-table'): ColumnarTable;
5
- export declare function convertTable(table: Table, shape: 'arrow-table'): ArrowTable;
6
- /**
7
- * Convert a table to apache arrow format
8
- * @note this depends on the `@loaders.gl/arrow module being imported
9
- */
10
- export declare function makeArrowTable(table: Table): Table;
11
- /** Convert any simple table into columnar format */
12
- export declare function makeColumnarTable(table: Table): ColumnarTable;
13
- /** Convert any table into array row format */
14
- export declare function makeArrayRowTable(table: Table): ArrayRowTable;
15
- /** Convert any table into object row format */
16
- export declare function makeObjectRowTable(table: Table): ObjectRowTable;
17
- /**
18
- *
19
- * @note - should be part of schema module
20
- *
21
- export function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable {
22
- const tableKeys = Object.keys(columnarTable);
23
- const tableRowsCount = columnarTable[tableKeys[0]].length;
24
-
25
- const rowFormatTable: {}[] = [];
26
-
27
- for (let index = 0; index < tableRowsCount; index++) {
28
- const tableItem = {};
29
- for (let keyIndex = 0; keyIndex < tableKeys.length; keyIndex++) {
30
- const fieldName = tableKeys[keyIndex];
31
- tableItem[fieldName] = columnarTable[fieldName][index];
32
- }
33
- rowFormatTable.push(tableItem);
34
- }
35
-
36
- return {
37
- shape: 'object-row-table',
38
- schema: columnarTable.schema,
39
- data: rowFormatTable
40
- };
41
- }
42
- */
43
- //# sourceMappingURL=convert-table.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert-table.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/simple-table/convert-table.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACX,yCAAsC;AAIvC,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,GAAG,cAAc,CAAC;AACtF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAAC;AACpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,GAAG,aAAa,CAAC;AACnF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC;AA0B7E;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAMlD;AAED,oDAAoD;AACpD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAyB7D;AAED,8CAA8C;AAC9C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAc7D;AAED,+CAA+C;AAC/C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAc/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;EAyBE"}