@loaders.gl/schema 3.1.0-alpha.4 → 3.1.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.
Files changed (183) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +1289 -0
  4. package/dist/category/common.d.ts +20 -0
  5. package/dist/category/common.d.ts.map +1 -0
  6. package/dist/category/common.js +10 -0
  7. package/dist/category/gis.d.ts +50 -0
  8. package/dist/category/gis.d.ts.map +1 -0
  9. package/dist/category/gis.js +2 -0
  10. package/dist/category/mesh/convert-mesh.d.ts +15 -0
  11. package/dist/category/mesh/convert-mesh.d.ts.map +1 -0
  12. package/dist/category/mesh/convert-mesh.js +39 -0
  13. package/dist/category/mesh/deduce-mesh-schema.d.ts +24 -0
  14. package/dist/category/mesh/deduce-mesh-schema.d.ts.map +1 -0
  15. package/dist/category/mesh/deduce-mesh-schema.js +62 -0
  16. package/dist/category/mesh/mesh-to-arrow-table.d.ts +1 -0
  17. package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -0
  18. package/dist/category/mesh/mesh-to-arrow-table.js +44 -0
  19. package/dist/category/mesh/mesh-types.d.ts +50 -0
  20. package/dist/category/mesh/mesh-types.d.ts.map +1 -0
  21. package/dist/category/mesh/mesh-types.js +2 -0
  22. package/dist/category/mesh/mesh-utils.d.ts +23 -0
  23. package/dist/category/mesh/mesh-utils.d.ts.map +1 -0
  24. package/dist/category/mesh/mesh-utils.js +51 -0
  25. package/dist/category/table/deduce-table-schema.d.ts +9 -0
  26. package/dist/category/table/deduce-table-schema.d.ts.map +1 -0
  27. package/dist/category/table/deduce-table-schema.js +106 -0
  28. package/dist/category/table/table-types.d.ts +78 -0
  29. package/dist/category/table/table-types.d.ts.map +1 -0
  30. package/dist/category/table/table-types.js +2 -0
  31. package/dist/es5/bundle.js +1 -1
  32. package/dist/es5/bundle.js.map +1 -1
  33. package/dist/es5/category/mesh/convert-mesh.js +2 -18
  34. package/dist/es5/category/mesh/convert-mesh.js.map +1 -1
  35. package/dist/es5/category/mesh/deduce-mesh-schema.js +9 -9
  36. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +1 -1
  37. package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -38
  38. package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +1 -1
  39. package/dist/es5/category/mesh/mesh-utils.js +16 -16
  40. package/dist/es5/category/mesh/mesh-utils.js.map +1 -1
  41. package/dist/es5/category/table/deduce-table-schema.js +9 -9
  42. package/dist/es5/category/table/deduce-table-schema.js.map +1 -1
  43. package/dist/es5/index.js +53 -53
  44. package/dist/es5/index.js.map +1 -1
  45. package/dist/es5/lib/arrow/arrow-like-type-utils.js +1 -1
  46. package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +1 -1
  47. package/dist/es5/lib/arrow/arrow-type-utils.js +0 -70
  48. package/dist/es5/lib/arrow/arrow-type-utils.js.map +1 -1
  49. package/dist/es5/lib/arrow/get-type-info.js +4 -4
  50. package/dist/es5/lib/arrow/get-type-info.js.map +1 -1
  51. package/dist/es5/lib/batches/base-table-batch-aggregator.js +42 -53
  52. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +1 -1
  53. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +71 -90
  54. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
  55. package/dist/es5/lib/batches/row-table-batch-aggregator.js +59 -70
  56. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +1 -1
  57. package/dist/es5/lib/batches/table-batch-builder.js +113 -133
  58. package/dist/es5/lib/batches/table-batch-builder.js.map +1 -1
  59. package/dist/es5/lib/schema/impl/enum.js +1 -1
  60. package/dist/es5/lib/schema/impl/field.js +19 -32
  61. package/dist/es5/lib/schema/impl/field.js.map +1 -1
  62. package/dist/es5/lib/schema/impl/schema.js +54 -119
  63. package/dist/es5/lib/schema/impl/schema.js.map +1 -1
  64. package/dist/es5/lib/schema/impl/type.js +395 -728
  65. package/dist/es5/lib/schema/impl/type.js.map +1 -1
  66. package/dist/es5/lib/schema/{index.js → schema.js} +38 -38
  67. package/dist/es5/lib/schema/schema.js.map +1 -0
  68. package/dist/es5/lib/schema-utils/deduce-column-type.js.map +1 -1
  69. package/dist/es5/lib/utils/async-queue.js +81 -164
  70. package/dist/es5/lib/utils/async-queue.js.map +1 -1
  71. package/dist/es5/lib/utils/row-utils.js +4 -4
  72. package/dist/es5/lib/utils/row-utils.js.map +1 -1
  73. package/dist/esm/category/mesh/convert-mesh.js +1 -8
  74. package/dist/esm/category/mesh/convert-mesh.js.map +1 -1
  75. package/dist/esm/category/mesh/deduce-mesh-schema.js +1 -1
  76. package/dist/esm/category/mesh/deduce-mesh-schema.js.map +1 -1
  77. package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -29
  78. package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +1 -1
  79. package/dist/esm/category/table/deduce-table-schema.js.map +1 -1
  80. package/dist/esm/index.js +1 -1
  81. package/dist/esm/index.js.map +1 -1
  82. package/dist/esm/lib/arrow/arrow-like-type-utils.js +1 -1
  83. package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +1 -1
  84. package/dist/esm/lib/arrow/arrow-type-utils.js +0 -60
  85. package/dist/esm/lib/arrow/arrow-type-utils.js.map +1 -1
  86. package/dist/esm/lib/arrow/get-type-info.js +1 -1
  87. package/dist/esm/lib/arrow/get-type-info.js.map +1 -1
  88. package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +1 -1
  89. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
  90. package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +1 -1
  91. package/dist/esm/lib/batches/table-batch-builder.js.map +1 -1
  92. package/dist/esm/lib/schema/impl/field.js +1 -1
  93. package/dist/esm/lib/schema/impl/field.js.map +1 -1
  94. package/dist/esm/lib/schema/impl/schema.js.map +1 -1
  95. package/dist/esm/lib/schema/impl/type.js +8 -8
  96. package/dist/esm/lib/schema/impl/type.js.map +1 -1
  97. package/dist/esm/lib/schema/{index.js → schema.js} +1 -1
  98. package/dist/esm/lib/schema/schema.js.map +1 -0
  99. package/dist/esm/lib/schema-utils/deduce-column-type.js.map +1 -1
  100. package/dist/esm/lib/utils/async-queue.js.map +1 -1
  101. package/dist/index.d.ts +23 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +75 -0
  104. package/dist/lib/arrow/arrow-like-type-utils.d.ts +4 -0
  105. package/dist/lib/arrow/arrow-like-type-utils.d.ts.map +1 -0
  106. package/dist/lib/arrow/arrow-like-type-utils.js +27 -0
  107. package/dist/lib/arrow/arrow-type-utils.d.ts +1 -0
  108. package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -0
  109. package/dist/lib/arrow/arrow-type-utils.js +70 -0
  110. package/dist/lib/arrow/get-type-info.d.ts +14 -0
  111. package/dist/lib/arrow/get-type-info.d.ts.map +1 -0
  112. package/dist/lib/arrow/get-type-info.js +28 -0
  113. package/dist/lib/batches/base-table-batch-aggregator.d.ts +19 -0
  114. package/dist/lib/batches/base-table-batch-aggregator.d.ts.map +1 -0
  115. package/dist/lib/batches/base-table-batch-aggregator.js +58 -0
  116. package/dist/lib/batches/columnar-table-batch-aggregator.d.ts +23 -0
  117. package/dist/lib/batches/columnar-table-batch-aggregator.d.ts.map +1 -0
  118. package/dist/lib/batches/columnar-table-batch-aggregator.js +90 -0
  119. package/dist/lib/batches/row-table-batch-aggregator.d.ts +22 -0
  120. package/dist/lib/batches/row-table-batch-aggregator.d.ts.map +1 -0
  121. package/dist/lib/batches/row-table-batch-aggregator.js +79 -0
  122. package/dist/lib/batches/table-batch-aggregator.d.ts +25 -0
  123. package/dist/lib/batches/table-batch-aggregator.d.ts.map +1 -0
  124. package/dist/lib/batches/table-batch-aggregator.js +2 -0
  125. package/dist/lib/batches/table-batch-builder.d.ts +53 -0
  126. package/dist/lib/batches/table-batch-builder.d.ts.map +1 -0
  127. package/dist/lib/batches/table-batch-builder.js +153 -0
  128. package/dist/lib/schema/impl/enum.d.ts +92 -0
  129. package/dist/lib/schema/impl/enum.d.ts.map +1 -0
  130. package/dist/lib/schema/impl/enum.js +97 -0
  131. package/dist/lib/schema/impl/field.d.ts +19 -0
  132. package/dist/lib/schema/impl/field.d.ts.map +1 -0
  133. package/dist/lib/schema/impl/field.js +32 -0
  134. package/dist/lib/schema/impl/schema.d.ts +16 -0
  135. package/dist/lib/schema/impl/schema.d.ts.map +1 -0
  136. package/dist/lib/schema/impl/schema.js +83 -0
  137. package/dist/lib/schema/impl/type.d.ts +176 -0
  138. package/dist/lib/schema/impl/type.d.ts.map +1 -0
  139. package/dist/lib/schema/impl/type.js +462 -0
  140. package/dist/lib/schema/schema.d.ts +5 -0
  141. package/dist/lib/schema/schema.d.ts.map +1 -0
  142. package/dist/lib/schema/schema.js +90 -0
  143. package/dist/lib/schema-utils/deduce-column-type.d.ts +3 -0
  144. package/dist/lib/schema-utils/deduce-column-type.d.ts.map +1 -0
  145. package/dist/lib/schema-utils/deduce-column-type.js +92 -0
  146. package/dist/lib/utils/assert.d.ts +2 -0
  147. package/dist/lib/utils/assert.d.ts.map +1 -0
  148. package/dist/lib/utils/assert.js +12 -0
  149. package/dist/lib/utils/async-queue.d.ts +18 -0
  150. package/dist/lib/utils/async-queue.d.ts.map +1 -0
  151. package/dist/lib/utils/async-queue.js +92 -0
  152. package/dist/lib/utils/row-utils.d.ts +9 -0
  153. package/dist/lib/utils/row-utils.d.ts.map +1 -0
  154. package/dist/lib/utils/row-utils.js +33 -0
  155. package/dist/types.d.ts +8 -0
  156. package/dist/types.d.ts.map +1 -0
  157. package/dist/types.js +2 -0
  158. package/package.json +5 -7
  159. package/src/category/common.ts +2 -1
  160. package/src/category/mesh/convert-mesh.ts +6 -6
  161. package/src/category/mesh/deduce-mesh-schema.ts +1 -1
  162. package/src/category/mesh/mesh-to-arrow-table.ts +4 -2
  163. package/src/category/mesh/mesh-types.ts +1 -1
  164. package/src/category/table/deduce-table-schema.ts +1 -1
  165. package/src/category/table/table-types.ts +5 -2
  166. package/src/index.ts +1 -1
  167. package/src/lib/arrow/arrow-like-type-utils.ts +11 -1
  168. package/src/lib/arrow/arrow-type-utils.ts +2 -0
  169. package/src/lib/arrow/get-type-info.ts +1 -1
  170. package/src/lib/batches/base-table-batch-aggregator.ts +1 -1
  171. package/src/lib/batches/columnar-table-batch-aggregator.ts +1 -1
  172. package/src/lib/batches/row-table-batch-aggregator.ts +1 -1
  173. package/src/lib/batches/table-batch-aggregator.ts +1 -1
  174. package/src/lib/batches/table-batch-builder.ts +2 -2
  175. package/src/lib/schema/impl/schema.ts +2 -2
  176. package/src/lib/schema/impl/type.ts +2 -2
  177. package/src/lib/schema/{index.ts → schema.ts} +0 -0
  178. package/src/lib/schema-utils/deduce-column-type.ts +6 -2
  179. package/src/lib/utils/async-queue.ts +7 -4
  180. package/dist/dist.min.js +0 -2
  181. package/dist/dist.min.js.map +0 -1
  182. package/dist/es5/lib/schema/index.js.map +0 -1
  183. package/dist/esm/lib/schema/index.js.map +0 -1
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const base_table_batch_aggregator_1 = __importDefault(require("./base-table-batch-aggregator"));
7
+ const row_table_batch_aggregator_1 = __importDefault(require("./row-table-batch-aggregator"));
8
+ const columnar_table_batch_aggregator_1 = __importDefault(require("./columnar-table-batch-aggregator"));
9
+ const DEFAULT_OPTIONS = {
10
+ shape: 'array-row-table',
11
+ batchSize: 'auto',
12
+ batchDebounceMs: 0,
13
+ limit: 0,
14
+ _limitMB: 0
15
+ };
16
+ const ERR_MESSAGE = 'TableBatchBuilder';
17
+ /** Incrementally builds batches from a stream of rows */
18
+ class TableBatchBuilder {
19
+ constructor(schema, options) {
20
+ this.aggregator = null;
21
+ this.batchCount = 0;
22
+ this.bytesUsed = 0;
23
+ this.isChunkComplete = false;
24
+ this.lastBatchEmittedMs = Date.now();
25
+ this.totalLength = 0;
26
+ this.totalBytes = 0;
27
+ this.rowBytes = 0;
28
+ this.schema = schema;
29
+ this.options = { ...DEFAULT_OPTIONS, ...options };
30
+ }
31
+ limitReached() {
32
+ if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
33
+ return true;
34
+ }
35
+ if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ /** @deprecated Use addArrayRow or addObjectRow */
41
+ addRow(row) {
42
+ if (this.limitReached()) {
43
+ return;
44
+ }
45
+ this.totalLength++;
46
+ this.rowBytes = this.rowBytes || this._estimateRowMB(row);
47
+ this.totalBytes += this.rowBytes;
48
+ if (Array.isArray(row)) {
49
+ this.addArrayRow(row);
50
+ }
51
+ else {
52
+ this.addObjectRow(row);
53
+ }
54
+ }
55
+ /** Add one row to the batch */
56
+ addArrayRow(row) {
57
+ if (!this.aggregator) {
58
+ const TableBatchType = this._getTableBatchType();
59
+ this.aggregator = new TableBatchType(this.schema, this.options);
60
+ }
61
+ this.aggregator.addArrayRow(row);
62
+ }
63
+ /** Add one row to the batch */
64
+ addObjectRow(row) {
65
+ if (!this.aggregator) {
66
+ const TableBatchType = this._getTableBatchType();
67
+ this.aggregator = new TableBatchType(this.schema, this.options);
68
+ }
69
+ this.aggregator.addObjectRow(row);
70
+ }
71
+ /** Mark an incoming raw memory chunk has completed */
72
+ chunkComplete(chunk) {
73
+ if (chunk instanceof ArrayBuffer) {
74
+ this.bytesUsed += chunk.byteLength;
75
+ }
76
+ if (typeof chunk === 'string') {
77
+ this.bytesUsed += chunk.length;
78
+ }
79
+ this.isChunkComplete = true;
80
+ }
81
+ getFullBatch(options) {
82
+ return this._isFull() ? this._getBatch(options) : null;
83
+ }
84
+ getFinalBatch(options) {
85
+ return this._getBatch(options);
86
+ }
87
+ // INTERNAL
88
+ _estimateRowMB(row) {
89
+ return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
90
+ }
91
+ _isFull() {
92
+ // No batch, not ready
93
+ if (!this.aggregator || this.aggregator.rowCount() === 0) {
94
+ return false;
95
+ }
96
+ // if batchSize === 'auto' we wait for chunk to complete
97
+ // if batchSize === number, ensure we have enough rows
98
+ if (this.options.batchSize === 'auto') {
99
+ if (!this.isChunkComplete) {
100
+ return false;
101
+ }
102
+ }
103
+ else if (this.options.batchSize > this.aggregator.rowCount()) {
104
+ return false;
105
+ }
106
+ // Debounce batches
107
+ if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
108
+ return false;
109
+ }
110
+ // Emit batch
111
+ this.isChunkComplete = false;
112
+ this.lastBatchEmittedMs = Date.now();
113
+ return true;
114
+ }
115
+ /**
116
+ * bytesUsed can be set via chunkComplete or via getBatch*
117
+ */
118
+ _getBatch(options) {
119
+ if (!this.aggregator) {
120
+ return null;
121
+ }
122
+ // TODO - this can overly increment bytes used?
123
+ if (options?.bytesUsed) {
124
+ this.bytesUsed = options.bytesUsed;
125
+ }
126
+ const normalizedBatch = this.aggregator.getBatch();
127
+ normalizedBatch.count = this.batchCount;
128
+ normalizedBatch.bytesUsed = this.bytesUsed;
129
+ Object.assign(normalizedBatch, options);
130
+ this.batchCount++;
131
+ this.aggregator = null;
132
+ return normalizedBatch;
133
+ }
134
+ _getTableBatchType() {
135
+ switch (this.options.shape) {
136
+ case 'row-table':
137
+ return base_table_batch_aggregator_1.default;
138
+ case 'array-row-table':
139
+ case 'object-row-table':
140
+ return row_table_batch_aggregator_1.default;
141
+ case 'columnar-table':
142
+ return columnar_table_batch_aggregator_1.default;
143
+ case 'arrow-table':
144
+ if (!TableBatchBuilder.ArrowBatch) {
145
+ throw new Error(ERR_MESSAGE);
146
+ }
147
+ return TableBatchBuilder.ArrowBatch;
148
+ default:
149
+ throw new Error(ERR_MESSAGE);
150
+ }
151
+ }
152
+ }
153
+ exports.default = TableBatchBuilder;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Main data type enumeration.
3
+ *
4
+ * Data types in this library are all *logical*. They can be expressed as
5
+ * either a primitive physical type (bytes or bits of some fixed size), a
6
+ * nested type consisting of other data types, or another data type (e.g. a
7
+ * timestamp encoded as an int64).
8
+ *
9
+ * **Note**: Only enum values 0-17 (NONE through Map) are written to an Arrow
10
+ * IPC payload.
11
+ *
12
+ * The rest of the values are specified here so TypeScript can narrow the type
13
+ * signatures further beyond the base Arrow Types. The Arrow DataTypes include
14
+ * metadata like `bitWidth` that impact the type signatures of the values we
15
+ * accept and return.
16
+ *
17
+ * For example, the `Int8Vector` reads 1-byte numbers from an `Int8Array`, an
18
+ * `Int32Vector` reads a 4-byte number from an `Int32Array`, and an `Int64Vector`
19
+ * reads a pair of 4-byte lo, hi 32-bit integers as a zero-copy slice from the
20
+ * underlying `Int32Array`.
21
+ *
22
+ * Library consumers benefit by knowing the narrowest type, since we can ensure
23
+ * the types across all public methods are propagated, and never bail to `any`.
24
+ * These values are _never_ used at runtime, and they will _never_ be written
25
+ * to the flatbuffers metadata of serialized Arrow IPC payloads.
26
+ */
27
+ export declare enum Type {
28
+ /** The default placeholder type */
29
+ NONE = 0,
30
+ /** A NULL type having no physical storage */
31
+ Null = 1,
32
+ /** Signed or unsigned 8, 16, 32, or 64-bit little-endian integer */
33
+ Int = 2,
34
+ /** 2, 4, or 8-byte floating point value */
35
+ Float = 3,
36
+ /** Variable-length bytes (no guarantee of UTF8-ness) */
37
+ Binary = 4,
38
+ /** UTF8 variable-length string as List<Char> */
39
+ Utf8 = 5,
40
+ /** Boolean as 1 bit, LSB bit-packed ordering */
41
+ Bool = 6,
42
+ /** Precision-and-scale-based decimal type. Storage type depends on the parameters. */
43
+ Decimal = 7,
44
+ /** int32_t days or int64_t milliseconds since the UNIX epoch */
45
+ Date = 8,
46
+ /** Time as signed 32 or 64-bit integer, representing either seconds, milliseconds, microseconds, or nanoseconds since midnight since midnight */
47
+ Time = 9,
48
+ /** Exact timestamp encoded with int64 since UNIX epoch (Default unit millisecond) */
49
+ Timestamp = 10,
50
+ /** YEAR_MONTH or DAY_TIME interval in SQL style */
51
+ Interval = 11,
52
+ /** A list of some logical data type */
53
+ List = 12,
54
+ /** Struct of logical types */
55
+ Struct = 13,
56
+ /** Union of logical types */
57
+ Union = 14,
58
+ /** Fixed-size binary. Each value occupies the same number of bytes */
59
+ FixedSizeBinary = 15,
60
+ /** Fixed-size list. Each value occupies the same number of bytes */
61
+ FixedSizeList = 16,
62
+ /** Map of named logical types */
63
+ Map = 17,
64
+ /** Dictionary aka Category type */
65
+ Dictionary = -1,
66
+ Int8 = -2,
67
+ Int16 = -3,
68
+ Int32 = -4,
69
+ Int64 = -5,
70
+ Uint8 = -6,
71
+ Uint16 = -7,
72
+ Uint32 = -8,
73
+ Uint64 = -9,
74
+ Float16 = -10,
75
+ Float32 = -11,
76
+ Float64 = -12,
77
+ DateDay = -13,
78
+ DateMillisecond = -14,
79
+ TimestampSecond = -15,
80
+ TimestampMillisecond = -16,
81
+ TimestampMicrosecond = -17,
82
+ TimestampNanosecond = -18,
83
+ TimeSecond = -19,
84
+ TimeMillisecond = -20,
85
+ TimeMicrosecond = -21,
86
+ TimeNanosecond = -22,
87
+ DenseUnion = -23,
88
+ SparseUnion = -24,
89
+ IntervalDayTime = -25,
90
+ IntervalYearMonth = -26
91
+ }
92
+ //# sourceMappingURL=enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../../src/lib/schema/impl/enum.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,oBAAY,IAAI;IACd,mCAAmC;IACnC,IAAI,IAAI;IACR,6CAA6C;IAC7C,IAAI,IAAI;IACR,oEAAoE;IACpE,GAAG,IAAI;IACP,2CAA2C;IAC3C,KAAK,IAAI;IACT,wDAAwD;IACxD,MAAM,IAAI;IACV,gDAAgD;IAChD,IAAI,IAAI;IACR,gDAAgD;IAChD,IAAI,IAAI;IACR,sFAAsF;IACtF,OAAO,IAAI;IACX,gEAAgE;IAChE,IAAI,IAAI;IACR,iJAAiJ;IACjJ,IAAI,IAAI;IACR,qFAAqF;IACrF,SAAS,KAAK;IACd,mDAAmD;IACnD,QAAQ,KAAK;IACb,uCAAuC;IACvC,IAAI,KAAK;IACT,8BAA8B;IAC9B,MAAM,KAAK;IACX,6BAA6B;IAC7B,KAAK,KAAK;IACV,sEAAsE;IACtE,eAAe,KAAK;IACpB,oEAAoE;IACpE,aAAa,KAAK;IAClB,iCAAiC;IACjC,GAAG,KAAK;IAER,mCAAmC;IACnC,UAAU,KAAK;IACf,IAAI,KAAK;IACT,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,MAAM,KAAK;IACX,MAAM,KAAK;IACX,MAAM,KAAK;IACX,OAAO,MAAM;IACb,OAAO,MAAM;IACb,OAAO,MAAM;IACb,OAAO,MAAM;IACb,eAAe,MAAM;IACrB,eAAe,MAAM;IACrB,oBAAoB,MAAM;IAC1B,oBAAoB,MAAM;IAC1B,mBAAmB,MAAM;IACzB,UAAU,MAAM;IAChB,eAAe,MAAM;IACrB,eAAe,MAAM;IACrB,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,WAAW,MAAM;IACjB,eAAe,MAAM;IACrB,iBAAiB,MAAM;CACxB"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ // This code is adapted from ArrowJS https://github.com/apache/arrow
3
+ // under Apache license http://www.apache.org/licenses/LICENSE-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.Type = void 0;
6
+ /**
7
+ * Main data type enumeration.
8
+ *
9
+ * Data types in this library are all *logical*. They can be expressed as
10
+ * either a primitive physical type (bytes or bits of some fixed size), a
11
+ * nested type consisting of other data types, or another data type (e.g. a
12
+ * timestamp encoded as an int64).
13
+ *
14
+ * **Note**: Only enum values 0-17 (NONE through Map) are written to an Arrow
15
+ * IPC payload.
16
+ *
17
+ * The rest of the values are specified here so TypeScript can narrow the type
18
+ * signatures further beyond the base Arrow Types. The Arrow DataTypes include
19
+ * metadata like `bitWidth` that impact the type signatures of the values we
20
+ * accept and return.
21
+ *
22
+ * For example, the `Int8Vector` reads 1-byte numbers from an `Int8Array`, an
23
+ * `Int32Vector` reads a 4-byte number from an `Int32Array`, and an `Int64Vector`
24
+ * reads a pair of 4-byte lo, hi 32-bit integers as a zero-copy slice from the
25
+ * underlying `Int32Array`.
26
+ *
27
+ * Library consumers benefit by knowing the narrowest type, since we can ensure
28
+ * the types across all public methods are propagated, and never bail to `any`.
29
+ * These values are _never_ used at runtime, and they will _never_ be written
30
+ * to the flatbuffers metadata of serialized Arrow IPC payloads.
31
+ */
32
+ var Type;
33
+ (function (Type) {
34
+ /** The default placeholder type */
35
+ Type[Type["NONE"] = 0] = "NONE";
36
+ /** A NULL type having no physical storage */
37
+ Type[Type["Null"] = 1] = "Null";
38
+ /** Signed or unsigned 8, 16, 32, or 64-bit little-endian integer */
39
+ Type[Type["Int"] = 2] = "Int";
40
+ /** 2, 4, or 8-byte floating point value */
41
+ Type[Type["Float"] = 3] = "Float";
42
+ /** Variable-length bytes (no guarantee of UTF8-ness) */
43
+ Type[Type["Binary"] = 4] = "Binary";
44
+ /** UTF8 variable-length string as List<Char> */
45
+ Type[Type["Utf8"] = 5] = "Utf8";
46
+ /** Boolean as 1 bit, LSB bit-packed ordering */
47
+ Type[Type["Bool"] = 6] = "Bool";
48
+ /** Precision-and-scale-based decimal type. Storage type depends on the parameters. */
49
+ Type[Type["Decimal"] = 7] = "Decimal";
50
+ /** int32_t days or int64_t milliseconds since the UNIX epoch */
51
+ Type[Type["Date"] = 8] = "Date";
52
+ /** Time as signed 32 or 64-bit integer, representing either seconds, milliseconds, microseconds, or nanoseconds since midnight since midnight */
53
+ Type[Type["Time"] = 9] = "Time";
54
+ /** Exact timestamp encoded with int64 since UNIX epoch (Default unit millisecond) */
55
+ Type[Type["Timestamp"] = 10] = "Timestamp";
56
+ /** YEAR_MONTH or DAY_TIME interval in SQL style */
57
+ Type[Type["Interval"] = 11] = "Interval";
58
+ /** A list of some logical data type */
59
+ Type[Type["List"] = 12] = "List";
60
+ /** Struct of logical types */
61
+ Type[Type["Struct"] = 13] = "Struct";
62
+ /** Union of logical types */
63
+ Type[Type["Union"] = 14] = "Union";
64
+ /** Fixed-size binary. Each value occupies the same number of bytes */
65
+ Type[Type["FixedSizeBinary"] = 15] = "FixedSizeBinary";
66
+ /** Fixed-size list. Each value occupies the same number of bytes */
67
+ Type[Type["FixedSizeList"] = 16] = "FixedSizeList";
68
+ /** Map of named logical types */
69
+ Type[Type["Map"] = 17] = "Map";
70
+ /** Dictionary aka Category type */
71
+ Type[Type["Dictionary"] = -1] = "Dictionary";
72
+ Type[Type["Int8"] = -2] = "Int8";
73
+ Type[Type["Int16"] = -3] = "Int16";
74
+ Type[Type["Int32"] = -4] = "Int32";
75
+ Type[Type["Int64"] = -5] = "Int64";
76
+ Type[Type["Uint8"] = -6] = "Uint8";
77
+ Type[Type["Uint16"] = -7] = "Uint16";
78
+ Type[Type["Uint32"] = -8] = "Uint32";
79
+ Type[Type["Uint64"] = -9] = "Uint64";
80
+ Type[Type["Float16"] = -10] = "Float16";
81
+ Type[Type["Float32"] = -11] = "Float32";
82
+ Type[Type["Float64"] = -12] = "Float64";
83
+ Type[Type["DateDay"] = -13] = "DateDay";
84
+ Type[Type["DateMillisecond"] = -14] = "DateMillisecond";
85
+ Type[Type["TimestampSecond"] = -15] = "TimestampSecond";
86
+ Type[Type["TimestampMillisecond"] = -16] = "TimestampMillisecond";
87
+ Type[Type["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
88
+ Type[Type["TimestampNanosecond"] = -18] = "TimestampNanosecond";
89
+ Type[Type["TimeSecond"] = -19] = "TimeSecond";
90
+ Type[Type["TimeMillisecond"] = -20] = "TimeMillisecond";
91
+ Type[Type["TimeMicrosecond"] = -21] = "TimeMicrosecond";
92
+ Type[Type["TimeNanosecond"] = -22] = "TimeNanosecond";
93
+ Type[Type["DenseUnion"] = -23] = "DenseUnion";
94
+ Type[Type["SparseUnion"] = -24] = "SparseUnion";
95
+ Type[Type["IntervalDayTime"] = -25] = "IntervalDayTime";
96
+ Type[Type["IntervalYearMonth"] = -26] = "IntervalYearMonth";
97
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,19 @@
1
+ import { DataType } from './type';
2
+ /**
3
+ * ArrowJS `Field` API-compatible class for row-based tables
4
+ * https://loaders.gl/arrowjs/docs/api-reference/field
5
+ * A field holds name, nullable, and metadata information about a table "column"
6
+ * A Schema is essentially a list of fields
7
+ */
8
+ export default class Field {
9
+ name: string;
10
+ type: DataType;
11
+ nullable: boolean;
12
+ metadata: Map<string, string>;
13
+ constructor(name: string, type: DataType, nullable?: boolean, metadata?: Map<string, string>);
14
+ get typeId(): number;
15
+ clone(): Field;
16
+ compareTo(other: this): boolean;
17
+ toString(): string;
18
+ }
19
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/lib/schema/impl/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAG5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EACd,QAAQ,UAAQ,EAChB,QAAQ,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa;IAQ3C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,KAAK,IAAI,KAAK;IAId,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;IAS/B,QAAQ,IAAI,MAAM;CAKnB"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * ArrowJS `Field` API-compatible class for row-based tables
5
+ * https://loaders.gl/arrowjs/docs/api-reference/field
6
+ * A field holds name, nullable, and metadata information about a table "column"
7
+ * A Schema is essentially a list of fields
8
+ */
9
+ class Field {
10
+ constructor(name, type, nullable = false, metadata = new Map()) {
11
+ this.name = name;
12
+ this.type = type;
13
+ this.nullable = nullable;
14
+ this.metadata = metadata;
15
+ }
16
+ get typeId() {
17
+ return this.type && this.type.typeId;
18
+ }
19
+ clone() {
20
+ return new Field(this.name, this.type, this.nullable, this.metadata);
21
+ }
22
+ compareTo(other) {
23
+ return (this.name === other.name &&
24
+ this.type === other.type &&
25
+ this.nullable === other.nullable &&
26
+ this.metadata === other.metadata);
27
+ }
28
+ toString() {
29
+ return `${this.type}${this.nullable ? ', nullable' : ''}${this.metadata ? `, metadata: ${this.metadata}` : ''}`;
30
+ }
31
+ }
32
+ exports.default = Field;
@@ -0,0 +1,16 @@
1
+ import Field from './field';
2
+ export declare type SchemaMetadata = Map<string, any>;
3
+ /**
4
+ * ArrowJS `Schema` API-compatible class for row-based tables (returned from `DataTable`)
5
+ * https://loaders.gl/arrowjs/docs/api-reference/schema
6
+ */
7
+ export default class Schema {
8
+ fields: Field[];
9
+ metadata: SchemaMetadata;
10
+ constructor(fields: Field[], metadata?: SchemaMetadata);
11
+ compareTo(other: Schema): boolean;
12
+ select(...columnNames: string[]): Schema;
13
+ selectAt(...columnIndices: number[]): Schema;
14
+ assign(schemaOrFields: Schema | Field[]): Schema;
15
+ }
16
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/lib/schema/impl/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,oBAAY,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,QAAQ,EAAE,cAAc,CAAC;gBAEb,MAAM,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,EAAE,cAAc;IAStD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAejC,MAAM,CAAC,GAAG,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM;IAUxC,QAAQ,CAAC,GAAG,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM;IAM5C,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,MAAM;CA2BjD"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const assert_1 = require("../../utils/assert");
4
+ /**
5
+ * ArrowJS `Schema` API-compatible class for row-based tables (returned from `DataTable`)
6
+ * https://loaders.gl/arrowjs/docs/api-reference/schema
7
+ */
8
+ class Schema {
9
+ constructor(fields, metadata) {
10
+ (0, assert_1.assert)(Array.isArray(fields));
11
+ checkNames(fields);
12
+ // For kepler fields, create arrow compatible `Fields` that have kepler fields as `metadata`
13
+ this.fields = fields;
14
+ this.metadata = metadata || new Map();
15
+ }
16
+ // TODO - arrow only seems to compare fields, not metadata
17
+ compareTo(other) {
18
+ if (this.metadata !== other.metadata) {
19
+ return false;
20
+ }
21
+ if (this.fields.length !== other.fields.length) {
22
+ return false;
23
+ }
24
+ for (let i = 0; i < this.fields.length; ++i) {
25
+ if (!this.fields[i].compareTo(other.fields[i])) {
26
+ return false;
27
+ }
28
+ }
29
+ return true;
30
+ }
31
+ select(...columnNames) {
32
+ // Ensure column names reference valid fields
33
+ const nameMap = Object.create(null);
34
+ for (const name of columnNames) {
35
+ nameMap[name] = true;
36
+ }
37
+ const selectedFields = this.fields.filter((field) => nameMap[field.name]);
38
+ return new Schema(selectedFields, this.metadata);
39
+ }
40
+ selectAt(...columnIndices) {
41
+ // Ensure column indices reference valid fields
42
+ const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
43
+ return new Schema(selectedFields, this.metadata);
44
+ }
45
+ assign(schemaOrFields) {
46
+ let fields;
47
+ let metadata = this.metadata;
48
+ if (schemaOrFields instanceof Schema) {
49
+ const otherSchema = schemaOrFields;
50
+ fields = otherSchema.fields;
51
+ metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
52
+ }
53
+ else {
54
+ fields = schemaOrFields;
55
+ }
56
+ // Create a merged list of fields, overwrite fields in place, new fields at end
57
+ const fieldMap = Object.create(null);
58
+ for (const field of this.fields) {
59
+ fieldMap[field.name] = field;
60
+ }
61
+ for (const field of fields) {
62
+ fieldMap[field.name] = field;
63
+ }
64
+ const mergedFields = Object.values(fieldMap);
65
+ return new Schema(mergedFields, metadata);
66
+ }
67
+ }
68
+ exports.default = Schema;
69
+ // Warn if any duplicated field names
70
+ function checkNames(fields) {
71
+ const usedNames = {};
72
+ for (const field of fields) {
73
+ if (usedNames[field.name]) {
74
+ // eslint-disable-next-line
75
+ console.warn('Schema: duplicated field name', field.name, field);
76
+ }
77
+ usedNames[field.name] = true;
78
+ }
79
+ }
80
+ function mergeMaps(m1, m2) {
81
+ // @ts-ignore
82
+ return new Map([...(m1 || new Map()), ...(m2 || new Map())]);
83
+ }
@@ -0,0 +1,176 @@
1
+ import { Type } from './enum';
2
+ import Field from './field';
3
+ export { Type } from './enum';
4
+ export declare type TypedIntArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Int32Array | Uint32Array | Uint8ClampedArray;
5
+ export declare type TypedFloatArray = Float32Array | Float64Array;
6
+ export declare type TypedArray = TypedIntArray | TypedFloatArray;
7
+ export declare type AnyArrayType = Array<any> | TypedIntArray | TypedFloatArray;
8
+ export declare class DataType {
9
+ static isNull(x: any): boolean;
10
+ static isInt(x: any): boolean;
11
+ static isFloat(x: any): boolean;
12
+ static isBinary(x: any): boolean;
13
+ static isUtf8(x: any): boolean;
14
+ static isBool(x: any): boolean;
15
+ static isDecimal(x: any): boolean;
16
+ static isDate(x: any): boolean;
17
+ static isTime(x: any): boolean;
18
+ static isTimestamp(x: any): boolean;
19
+ static isInterval(x: any): boolean;
20
+ static isList(x: any): boolean;
21
+ static isStruct(x: any): boolean;
22
+ static isUnion(x: any): boolean;
23
+ static isFixedSizeBinary(x: any): boolean;
24
+ static isFixedSizeList(x: any): boolean;
25
+ static isMap(x: any): boolean;
26
+ static isDictionary(x: any): boolean;
27
+ get typeId(): Type;
28
+ compareTo(other: DataType): boolean;
29
+ }
30
+ export declare class Null extends DataType {
31
+ get typeId(): Type;
32
+ get [Symbol.toStringTag](): string;
33
+ toString(): string;
34
+ }
35
+ export declare class Bool extends DataType {
36
+ get typeId(): Type;
37
+ get [Symbol.toStringTag](): string;
38
+ toString(): string;
39
+ }
40
+ export declare class Int extends DataType {
41
+ readonly isSigned: boolean;
42
+ readonly bitWidth: number;
43
+ constructor(isSigned: any, bitWidth: any);
44
+ get typeId(): Type;
45
+ get [Symbol.toStringTag](): string;
46
+ toString(): string;
47
+ }
48
+ export declare class Int8 extends Int {
49
+ constructor();
50
+ }
51
+ export declare class Int16 extends Int {
52
+ constructor();
53
+ }
54
+ export declare class Int32 extends Int {
55
+ constructor();
56
+ }
57
+ export declare class Int64 extends Int {
58
+ constructor();
59
+ }
60
+ export declare class Uint8 extends Int {
61
+ constructor();
62
+ }
63
+ export declare class Uint16 extends Int {
64
+ constructor();
65
+ }
66
+ export declare class Uint32 extends Int {
67
+ constructor();
68
+ }
69
+ export declare class Uint64 extends Int {
70
+ constructor();
71
+ }
72
+ export declare class Float extends DataType {
73
+ readonly precision: number;
74
+ constructor(precision: any);
75
+ get typeId(): Type;
76
+ get [Symbol.toStringTag](): string;
77
+ toString(): string;
78
+ }
79
+ export declare class Float16 extends Float {
80
+ constructor();
81
+ }
82
+ export declare class Float32 extends Float {
83
+ constructor();
84
+ }
85
+ export declare class Float64 extends Float {
86
+ constructor();
87
+ }
88
+ export declare class Binary extends DataType {
89
+ constructor();
90
+ get typeId(): Type;
91
+ toString(): string;
92
+ get [Symbol.toStringTag](): string;
93
+ }
94
+ export declare class Utf8 extends DataType {
95
+ get typeId(): Type;
96
+ get [Symbol.toStringTag](): string;
97
+ toString(): string;
98
+ }
99
+ export declare class Date extends DataType {
100
+ readonly unit: number;
101
+ constructor(unit: any);
102
+ get typeId(): Type;
103
+ get [Symbol.toStringTag](): string;
104
+ toString(): string;
105
+ }
106
+ export declare class DateDay extends Date {
107
+ constructor();
108
+ }
109
+ export declare class DateMillisecond extends Date {
110
+ constructor();
111
+ }
112
+ export declare class Time extends DataType {
113
+ readonly unit: any;
114
+ readonly bitWidth: number;
115
+ constructor(unit: any, bitWidth: number);
116
+ get typeId(): Type;
117
+ toString(): string;
118
+ get [Symbol.toStringTag](): string;
119
+ }
120
+ export declare class TimeSecond extends Time {
121
+ constructor();
122
+ }
123
+ export declare class TimeMillisecond extends Time {
124
+ constructor();
125
+ }
126
+ export declare class Timestamp extends DataType {
127
+ readonly unit: any;
128
+ readonly timezone: any;
129
+ constructor(unit: any, timezone?: null);
130
+ get typeId(): Type;
131
+ get [Symbol.toStringTag](): string;
132
+ toString(): string;
133
+ }
134
+ export declare class TimestampSecond extends Timestamp {
135
+ constructor(timezone?: null);
136
+ }
137
+ export declare class TimestampMillisecond extends Timestamp {
138
+ constructor(timezone?: null);
139
+ }
140
+ export declare class TimestampMicrosecond extends Timestamp {
141
+ constructor(timezone?: null);
142
+ }
143
+ export declare class TimestampNanosecond extends Timestamp {
144
+ constructor(timezone?: null);
145
+ }
146
+ export declare class Interval extends DataType {
147
+ readonly unit: number;
148
+ constructor(unit: number);
149
+ get typeId(): Type;
150
+ get [Symbol.toStringTag](): string;
151
+ toString(): string;
152
+ }
153
+ export declare class IntervalDayTime extends Interval {
154
+ constructor();
155
+ }
156
+ export declare class IntervalYearMonth extends Interval {
157
+ constructor();
158
+ }
159
+ export declare class FixedSizeList extends DataType {
160
+ readonly listSize: number;
161
+ readonly children: Field[];
162
+ constructor(listSize: number, child: Field);
163
+ get typeId(): Type;
164
+ get valueType(): DataType;
165
+ get valueField(): Field;
166
+ get [Symbol.toStringTag](): string;
167
+ toString(): string;
168
+ }
169
+ export declare class Struct extends DataType {
170
+ readonly children: Field[];
171
+ constructor(children: Field[]);
172
+ get typeId(): Type;
173
+ toString(): string;
174
+ get [Symbol.toStringTag](): string;
175
+ }
176
+ //# sourceMappingURL=type.d.ts.map