@loaders.gl/schema 3.1.3 → 4.0.0-alpha.5

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 (194) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/category/common.d.ts +1 -2
  4. package/dist/category/common.d.ts.map +1 -1
  5. package/dist/category/common.js +2 -10
  6. package/dist/{es5/category → category}/common.js.map +0 -0
  7. package/dist/category/gis.js +2 -2
  8. package/dist/{es5/category → category}/gis.js.map +0 -0
  9. package/dist/category/image/image.d.ts +18 -0
  10. package/dist/category/image/image.d.ts.map +1 -0
  11. package/dist/category/image/image.js +2 -0
  12. package/dist/{esm/category/gis.js.map → category/image/image.js.map} +1 -1
  13. package/dist/category/mesh/convert-mesh.js +31 -37
  14. package/dist/category/mesh/convert-mesh.js.map +1 -0
  15. package/dist/category/mesh/deduce-mesh-schema.js +37 -57
  16. package/dist/category/mesh/deduce-mesh-schema.js.map +1 -0
  17. package/dist/category/mesh/mesh-to-arrow-table.d.ts +10 -0
  18. package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -1
  19. package/dist/category/mesh/mesh-to-arrow-table.js +15 -28
  20. package/dist/category/mesh/mesh-to-arrow-table.js.map +1 -0
  21. package/dist/category/mesh/mesh-types.js +2 -2
  22. package/dist/{es5/category → category}/mesh/mesh-types.js.map +0 -0
  23. package/dist/category/mesh/mesh-utils.js +35 -48
  24. package/dist/category/mesh/mesh-utils.js.map +1 -0
  25. package/dist/category/table/deduce-table-schema.js +39 -94
  26. package/dist/category/table/deduce-table-schema.js.map +1 -0
  27. package/dist/category/table/table-types.d.ts +1 -3
  28. package/dist/category/table/table-types.d.ts.map +1 -1
  29. package/dist/category/table/table-types.js +2 -2
  30. package/dist/{es5/category → category}/table/table-types.js.map +0 -0
  31. package/dist/category/texture/texture.d.ts +18 -0
  32. package/dist/category/texture/texture.d.ts.map +1 -0
  33. package/dist/category/texture/texture.js +2 -0
  34. package/dist/{esm/category/common.js.map → category/texture/texture.js.map} +1 -1
  35. package/dist/dist.min.js +15078 -208
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +13 -75
  39. package/dist/index.js.map +1 -0
  40. package/dist/lib/arrow/arrow-like-type-utils.js +31 -26
  41. package/dist/lib/arrow/arrow-like-type-utils.js.map +1 -0
  42. package/dist/lib/arrow/arrow-type-utils.d.ts +5 -0
  43. package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -1
  44. package/dist/lib/arrow/arrow-type-utils.js +20 -28
  45. package/dist/lib/arrow/arrow-type-utils.js.map +1 -0
  46. package/dist/lib/arrow/get-type-info.js +19 -23
  47. package/dist/lib/arrow/get-type-info.js.map +1 -0
  48. package/dist/lib/batches/base-table-batch-aggregator.js +68 -52
  49. package/dist/lib/batches/base-table-batch-aggregator.js.map +1 -0
  50. package/dist/lib/batches/columnar-table-batch-aggregator.js +92 -82
  51. package/dist/lib/batches/columnar-table-batch-aggregator.js.map +1 -0
  52. package/dist/lib/batches/row-table-batch-aggregator.js +88 -72
  53. package/dist/lib/batches/row-table-batch-aggregator.js.map +1 -0
  54. package/dist/lib/batches/table-batch-aggregator.js +2 -2
  55. package/dist/{es5/lib → lib}/batches/table-batch-aggregator.js.map +0 -0
  56. package/dist/lib/batches/table-batch-builder.js +166 -137
  57. package/dist/lib/batches/table-batch-builder.js.map +1 -0
  58. package/dist/lib/schema/impl/enum.js +48 -96
  59. package/dist/lib/schema/impl/enum.js.map +1 -0
  60. package/dist/lib/schema/impl/field.js +34 -31
  61. package/dist/lib/schema/impl/field.js.map +1 -0
  62. package/dist/lib/schema/impl/schema.js +81 -72
  63. package/dist/lib/schema/impl/schema.js.map +1 -0
  64. package/dist/lib/schema/impl/type.js +490 -454
  65. package/dist/lib/schema/impl/type.js.map +1 -0
  66. package/dist/lib/schema/schema.js +5 -90
  67. package/dist/lib/schema/schema.js.map +1 -0
  68. package/dist/lib/schema-utils/deduce-column-type.js +20 -89
  69. package/dist/lib/schema-utils/deduce-column-type.js.map +1 -0
  70. package/dist/lib/utils/assert.js +5 -11
  71. package/dist/lib/utils/assert.js.map +1 -0
  72. package/dist/lib/utils/async-queue.js +109 -82
  73. package/dist/lib/utils/async-queue.js.map +1 -0
  74. package/dist/lib/utils/row-utils.js +33 -31
  75. package/dist/lib/utils/row-utils.js.map +1 -0
  76. package/dist/types.js +2 -2
  77. package/dist/{es5/types.js.map → types.js.map} +0 -0
  78. package/package.json +6 -5
  79. package/src/category/common.ts +1 -2
  80. package/src/category/image/image.ts +19 -0
  81. package/src/category/mesh/convert-mesh.ts +6 -6
  82. package/src/category/mesh/mesh-to-arrow-table.ts +2 -4
  83. package/src/category/table/table-types.ts +1 -4
  84. package/src/category/texture/texture.ts +28 -0
  85. package/src/index.ts +6 -1
  86. package/src/lib/arrow/arrow-type-utils.ts +0 -2
  87. package/dist/es5/bundle.js +0 -7
  88. package/dist/es5/bundle.js.map +0 -1
  89. package/dist/es5/category/common.js +0 -2
  90. package/dist/es5/category/gis.js +0 -2
  91. package/dist/es5/category/mesh/convert-mesh.js +0 -43
  92. package/dist/es5/category/mesh/convert-mesh.js.map +0 -1
  93. package/dist/es5/category/mesh/deduce-mesh-schema.js +0 -54
  94. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +0 -1
  95. package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -2
  96. package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +0 -1
  97. package/dist/es5/category/mesh/mesh-types.js +0 -2
  98. package/dist/es5/category/mesh/mesh-utils.js +0 -47
  99. package/dist/es5/category/mesh/mesh-utils.js.map +0 -1
  100. package/dist/es5/category/table/deduce-table-schema.js +0 -58
  101. package/dist/es5/category/table/deduce-table-schema.js.map +0 -1
  102. package/dist/es5/category/table/table-types.js +0 -2
  103. package/dist/es5/index.js +0 -344
  104. package/dist/es5/index.js.map +0 -1
  105. package/dist/es5/lib/arrow/arrow-like-type-utils.js +0 -40
  106. package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +0 -1
  107. package/dist/es5/lib/arrow/arrow-type-utils.js +0 -2
  108. package/dist/es5/lib/arrow/arrow-type-utils.js.map +0 -1
  109. package/dist/es5/lib/arrow/get-type-info.js +0 -33
  110. package/dist/es5/lib/arrow/get-type-info.js.map +0 -1
  111. package/dist/es5/lib/batches/base-table-batch-aggregator.js +0 -92
  112. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +0 -1
  113. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +0 -128
  114. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
  115. package/dist/es5/lib/batches/row-table-batch-aggregator.js +0 -113
  116. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +0 -1
  117. package/dist/es5/lib/batches/table-batch-aggregator.js +0 -2
  118. package/dist/es5/lib/batches/table-batch-builder.js +0 -207
  119. package/dist/es5/lib/batches/table-batch-builder.js.map +0 -1
  120. package/dist/es5/lib/schema/impl/enum.js +0 -56
  121. package/dist/es5/lib/schema/impl/enum.js.map +0 -1
  122. package/dist/es5/lib/schema/impl/field.js +0 -56
  123. package/dist/es5/lib/schema/impl/field.js.map +0 -1
  124. package/dist/es5/lib/schema/impl/schema.js +0 -168
  125. package/dist/es5/lib/schema/impl/schema.js.map +0 -1
  126. package/dist/es5/lib/schema/impl/type.js +0 -927
  127. package/dist/es5/lib/schema/impl/type.js.map +0 -1
  128. package/dist/es5/lib/schema/schema.js +0 -236
  129. package/dist/es5/lib/schema/schema.js.map +0 -1
  130. package/dist/es5/lib/schema-utils/deduce-column-type.js +0 -32
  131. package/dist/es5/lib/schema-utils/deduce-column-type.js.map +0 -1
  132. package/dist/es5/lib/utils/assert.js +0 -13
  133. package/dist/es5/lib/utils/assert.js.map +0 -1
  134. package/dist/es5/lib/utils/async-queue.js +0 -213
  135. package/dist/es5/lib/utils/async-queue.js.map +0 -1
  136. package/dist/es5/lib/utils/row-utils.js +0 -44
  137. package/dist/es5/lib/utils/row-utils.js.map +0 -1
  138. package/dist/es5/types.js +0 -2
  139. package/dist/esm/bundle.js +0 -5
  140. package/dist/esm/bundle.js.map +0 -1
  141. package/dist/esm/category/common.js +0 -2
  142. package/dist/esm/category/gis.js +0 -2
  143. package/dist/esm/category/mesh/convert-mesh.js +0 -26
  144. package/dist/esm/category/mesh/convert-mesh.js.map +0 -1
  145. package/dist/esm/category/mesh/deduce-mesh-schema.js +0 -42
  146. package/dist/esm/category/mesh/deduce-mesh-schema.js.map +0 -1
  147. package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -2
  148. package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +0 -1
  149. package/dist/esm/category/mesh/mesh-types.js +0 -2
  150. package/dist/esm/category/mesh/mesh-types.js.map +0 -1
  151. package/dist/esm/category/mesh/mesh-utils.js +0 -38
  152. package/dist/esm/category/mesh/mesh-utils.js.map +0 -1
  153. package/dist/esm/category/table/deduce-table-schema.js +0 -51
  154. package/dist/esm/category/table/deduce-table-schema.js.map +0 -1
  155. package/dist/esm/category/table/table-types.js +0 -2
  156. package/dist/esm/category/table/table-types.js.map +0 -1
  157. package/dist/esm/index.js +0 -13
  158. package/dist/esm/index.js.map +0 -1
  159. package/dist/esm/lib/arrow/arrow-like-type-utils.js +0 -32
  160. package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +0 -1
  161. package/dist/esm/lib/arrow/arrow-type-utils.js +0 -2
  162. package/dist/esm/lib/arrow/arrow-type-utils.js.map +0 -1
  163. package/dist/esm/lib/arrow/get-type-info.js +0 -24
  164. package/dist/esm/lib/arrow/get-type-info.js.map +0 -1
  165. package/dist/esm/lib/batches/base-table-batch-aggregator.js +0 -74
  166. package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +0 -1
  167. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js +0 -100
  168. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
  169. package/dist/esm/lib/batches/row-table-batch-aggregator.js +0 -95
  170. package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +0 -1
  171. package/dist/esm/lib/batches/table-batch-aggregator.js +0 -2
  172. package/dist/esm/lib/batches/table-batch-aggregator.js.map +0 -1
  173. package/dist/esm/lib/batches/table-batch-builder.js +0 -182
  174. package/dist/esm/lib/batches/table-batch-builder.js.map +0 -1
  175. package/dist/esm/lib/schema/impl/enum.js +0 -49
  176. package/dist/esm/lib/schema/impl/enum.js.map +0 -1
  177. package/dist/esm/lib/schema/impl/field.js +0 -35
  178. package/dist/esm/lib/schema/impl/field.js.map +0 -1
  179. package/dist/esm/lib/schema/impl/schema.js +0 -92
  180. package/dist/esm/lib/schema/impl/schema.js.map +0 -1
  181. package/dist/esm/lib/schema/impl/type.js +0 -498
  182. package/dist/esm/lib/schema/impl/type.js.map +0 -1
  183. package/dist/esm/lib/schema/schema.js +0 -5
  184. package/dist/esm/lib/schema/schema.js.map +0 -1
  185. package/dist/esm/lib/schema-utils/deduce-column-type.js +0 -23
  186. package/dist/esm/lib/schema-utils/deduce-column-type.js.map +0 -1
  187. package/dist/esm/lib/utils/assert.js +0 -6
  188. package/dist/esm/lib/utils/assert.js.map +0 -1
  189. package/dist/esm/lib/utils/async-queue.js +0 -119
  190. package/dist/esm/lib/utils/async-queue.js.map +0 -1
  191. package/dist/esm/lib/utils/row-utils.js +0 -35
  192. package/dist/esm/lib/utils/row-utils.js.map +0 -1
  193. package/dist/esm/types.js +0 -2
  194. package/dist/esm/types.js.map +0 -1
@@ -1,153 +1,182 @@
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"));
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import BaseTableBatchAggregator from './base-table-batch-aggregator';
3
+ import RowTableBatchAggregator from './row-table-batch-aggregator';
4
+ import ColumnarTableBatchAggregator from './columnar-table-batch-aggregator';
9
5
  const DEFAULT_OPTIONS = {
10
- shape: 'array-row-table',
11
- batchSize: 'auto',
12
- batchDebounceMs: 0,
13
- limit: 0,
14
- _limitMB: 0
6
+ shape: 'array-row-table',
7
+ batchSize: 'auto',
8
+ batchDebounceMs: 0,
9
+ limit: 0,
10
+ _limitMB: 0
15
11
  };
16
12
  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 };
13
+ export default class TableBatchBuilder {
14
+ constructor(schema, options) {
15
+ _defineProperty(this, "schema", void 0);
16
+
17
+ _defineProperty(this, "options", void 0);
18
+
19
+ _defineProperty(this, "aggregator", null);
20
+
21
+ _defineProperty(this, "batchCount", 0);
22
+
23
+ _defineProperty(this, "bytesUsed", 0);
24
+
25
+ _defineProperty(this, "isChunkComplete", false);
26
+
27
+ _defineProperty(this, "lastBatchEmittedMs", Date.now());
28
+
29
+ _defineProperty(this, "totalLength", 0);
30
+
31
+ _defineProperty(this, "totalBytes", 0);
32
+
33
+ _defineProperty(this, "rowBytes", 0);
34
+
35
+ this.schema = schema;
36
+ this.options = { ...DEFAULT_OPTIONS,
37
+ ...options
38
+ };
39
+ }
40
+
41
+ limitReached() {
42
+ var _this$options, _this$options2;
43
+
44
+ if (Boolean((_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.limit) && this.totalLength >= this.options.limit) {
45
+ return true;
30
46
  }
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;
47
+
48
+ if (Boolean((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
49
+ return true;
39
50
  }
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
- }
51
+
52
+ return false;
53
+ }
54
+
55
+ addRow(row) {
56
+ if (this.limitReached()) {
57
+ return;
54
58
  }
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);
59
+
60
+ this.totalLength++;
61
+ this.rowBytes = this.rowBytes || this._estimateRowMB(row);
62
+ this.totalBytes += this.rowBytes;
63
+
64
+ if (Array.isArray(row)) {
65
+ this.addArrayRow(row);
66
+ } else {
67
+ this.addObjectRow(row);
62
68
  }
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);
69
+ }
70
+
71
+ addArrayRow(row) {
72
+ if (!this.aggregator) {
73
+ const TableBatchType = this._getTableBatchType();
74
+
75
+ this.aggregator = new TableBatchType(this.schema, this.options);
70
76
  }
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;
77
+
78
+ this.aggregator.addArrayRow(row);
79
+ }
80
+
81
+ addObjectRow(row) {
82
+ if (!this.aggregator) {
83
+ const TableBatchType = this._getTableBatchType();
84
+
85
+ this.aggregator = new TableBatchType(this.schema, this.options);
80
86
  }
81
- getFullBatch(options) {
82
- return this._isFull() ? this._getBatch(options) : null;
87
+
88
+ this.aggregator.addObjectRow(row);
89
+ }
90
+
91
+ chunkComplete(chunk) {
92
+ if (chunk instanceof ArrayBuffer) {
93
+ this.bytesUsed += chunk.byteLength;
83
94
  }
84
- getFinalBatch(options) {
85
- return this._getBatch(options);
95
+
96
+ if (typeof chunk === 'string') {
97
+ this.bytesUsed += chunk.length;
86
98
  }
87
- // INTERNAL
88
- _estimateRowMB(row) {
89
- return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
99
+
100
+ this.isChunkComplete = true;
101
+ }
102
+
103
+ getFullBatch(options) {
104
+ return this._isFull() ? this._getBatch(options) : null;
105
+ }
106
+
107
+ getFinalBatch(options) {
108
+ return this._getBatch(options);
109
+ }
110
+
111
+ _estimateRowMB(row) {
112
+ return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
113
+ }
114
+
115
+ _isFull() {
116
+ if (!this.aggregator || this.aggregator.rowCount() === 0) {
117
+ return false;
90
118
  }
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;
119
+
120
+ if (this.options.batchSize === 'auto') {
121
+ if (!this.isChunkComplete) {
122
+ return false;
123
+ }
124
+ } else if (this.options.batchSize > this.aggregator.rowCount()) {
125
+ return false;
114
126
  }
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;
127
+
128
+ if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
129
+ return false;
133
130
  }
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
- }
131
+
132
+ this.isChunkComplete = false;
133
+ this.lastBatchEmittedMs = Date.now();
134
+ return true;
135
+ }
136
+
137
+ _getBatch(options) {
138
+ if (!this.aggregator) {
139
+ return null;
140
+ }
141
+
142
+ if (options !== null && options !== void 0 && options.bytesUsed) {
143
+ this.bytesUsed = options.bytesUsed;
144
+ }
145
+
146
+ const normalizedBatch = this.aggregator.getBatch();
147
+ normalizedBatch.count = this.batchCount;
148
+ normalizedBatch.bytesUsed = this.bytesUsed;
149
+ Object.assign(normalizedBatch, options);
150
+ this.batchCount++;
151
+ this.aggregator = null;
152
+ return normalizedBatch;
153
+ }
154
+
155
+ _getTableBatchType() {
156
+ switch (this.options.shape) {
157
+ case 'row-table':
158
+ return BaseTableBatchAggregator;
159
+
160
+ case 'array-row-table':
161
+ case 'object-row-table':
162
+ return RowTableBatchAggregator;
163
+
164
+ case 'columnar-table':
165
+ return ColumnarTableBatchAggregator;
166
+
167
+ case 'arrow-table':
168
+ if (!TableBatchBuilder.ArrowBatch) {
169
+ throw new Error(ERR_MESSAGE);
170
+ }
171
+
172
+ return TableBatchBuilder.ArrowBatch;
173
+
174
+ default:
175
+ throw new Error(ERR_MESSAGE);
151
176
  }
177
+ }
178
+
152
179
  }
153
- exports.default = TableBatchBuilder;
180
+
181
+ _defineProperty(TableBatchBuilder, "ArrowBatch", void 0);
182
+ //# sourceMappingURL=table-batch-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/batches/table-batch-builder.ts"],"names":["BaseTableBatchAggregator","RowTableBatchAggregator","ColumnarTableBatchAggregator","DEFAULT_OPTIONS","shape","batchSize","batchDebounceMs","limit","_limitMB","ERR_MESSAGE","TableBatchBuilder","constructor","schema","options","Date","now","limitReached","Boolean","totalLength","totalBytes","addRow","row","rowBytes","_estimateRowMB","Array","isArray","addArrayRow","addObjectRow","aggregator","TableBatchType","_getTableBatchType","chunkComplete","chunk","ArrayBuffer","bytesUsed","byteLength","length","isChunkComplete","getFullBatch","_isFull","_getBatch","getFinalBatch","Object","keys","rowCount","lastBatchEmittedMs","normalizedBatch","getBatch","count","batchCount","assign","ArrowBatch","Error"],"mappings":";AAGA,OAAOA,wBAAP,MAAqC,+BAArC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,4BAAP,MAAyC,mCAAzC;AAgBA,MAAMC,eAAmD,GAAG;AAC1DC,EAAAA,KAAK,EAAE,iBADmD;AAE1DC,EAAAA,SAAS,EAAE,MAF+C;AAG1DC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rB,UAAL,GAAkB,IAAlB;AACA,WAAOkB,eAAP;AACD;;AAEOhB,EAAAA,kBAAkB,GAA0B;AAClD,YAAQ,KAAKjB,OAAL,CAAaT,KAArB;AACE,WAAK,WAAL;AACE,eAAOJ,wBAAP;;AACF,WAAK,iBAAL;AACA,WAAK,kBAAL;AACE,eAAOC,uBAAP;;AACF,WAAK,gBAAL;AACE,eAAOC,4BAAP;;AACF,WAAK,aAAL;AACE,YAAI,CAACQ,iBAAiB,CAACyC,UAAvB,EAAmC;AACjC,gBAAM,IAAIC,KAAJ,CAAU3C,WAAV,CAAN;AACD;;AACD,eAAOC,iBAAiB,CAACyC,UAAzB;;AACF;AACE,cAAM,IAAIC,KAAJ,CAAU3C,WAAV,CAAN;AAdJ;AAgBD;;AA1JoC;;gBAAlBC,iB","sourcesContent":["import type {Schema} from '../schema/schema';\nimport type {TableBatch} from '../../category/table/table-types';\nimport type {TableBatchAggregator, TableBatchConstructor} from './table-batch-aggregator';\nimport BaseTableBatchAggregator from './base-table-batch-aggregator';\nimport RowTableBatchAggregator from './row-table-batch-aggregator';\nimport ColumnarTableBatchAggregator from './columnar-table-batch-aggregator';\n\n// TODO define interface instead\ntype TableBatchBuilderOptions = {\n shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';\n batchSize?: number | 'auto';\n batchDebounceMs?: number;\n limit: number;\n _limitMB: number;\n};\n\ntype GetBatchOptions = {\n bytesUsed?: number;\n [key: string]: any;\n};\n\nconst DEFAULT_OPTIONS: Required<TableBatchBuilderOptions> = {\n shape: 'array-row-table',\n batchSize: 'auto',\n batchDebounceMs: 0,\n limit: 0,\n _limitMB: 0\n};\n\nconst ERR_MESSAGE = 'TableBatchBuilder';\n\n/** Incrementally builds batches from a stream of rows */\nexport default class TableBatchBuilder {\n schema: Schema;\n options: Required<TableBatchBuilderOptions>;\n\n private aggregator: TableBatchAggregator | null = null;\n private batchCount: number = 0;\n private bytesUsed: number = 0;\n private isChunkComplete: boolean = false;\n private lastBatchEmittedMs: number = Date.now();\n private totalLength: number = 0;\n private totalBytes: number = 0;\n private rowBytes: number = 0;\n\n static ArrowBatch?: TableBatchConstructor;\n\n constructor(schema: Schema, options?: TableBatchBuilderOptions) {\n this.schema = schema;\n this.options = {...DEFAULT_OPTIONS, ...options};\n }\n\n limitReached(): boolean {\n if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {\n return true;\n }\n if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {\n return true;\n }\n return false;\n }\n\n /** @deprecated Use addArrayRow or addObjectRow */\n addRow(row: any[] | {[columnName: string]: any}): void {\n if (this.limitReached()) {\n return;\n }\n this.totalLength++;\n this.rowBytes = this.rowBytes || this._estimateRowMB(row);\n this.totalBytes += this.rowBytes;\n if (Array.isArray(row)) {\n this.addArrayRow(row);\n } else {\n this.addObjectRow(row);\n }\n }\n\n /** Add one row to the batch */\n protected addArrayRow(row: any[]) {\n if (!this.aggregator) {\n const TableBatchType = this._getTableBatchType();\n this.aggregator = new TableBatchType(this.schema, this.options);\n }\n this.aggregator.addArrayRow(row);\n }\n\n /** Add one row to the batch */\n protected addObjectRow(row: {[columnName: string]: any}): void {\n if (!this.aggregator) {\n const TableBatchType = this._getTableBatchType();\n this.aggregator = new TableBatchType(this.schema, this.options);\n }\n this.aggregator.addObjectRow(row);\n }\n\n /** Mark an incoming raw memory chunk has completed */\n chunkComplete(chunk: ArrayBuffer | string): void {\n if (chunk instanceof ArrayBuffer) {\n this.bytesUsed += chunk.byteLength;\n }\n if (typeof chunk === 'string') {\n this.bytesUsed += chunk.length;\n }\n this.isChunkComplete = true;\n }\n\n getFullBatch(options?: GetBatchOptions): TableBatch | null {\n return this._isFull() ? this._getBatch(options) : null;\n }\n\n getFinalBatch(options?: GetBatchOptions): TableBatch | null {\n return this._getBatch(options);\n }\n\n // INTERNAL\n\n _estimateRowMB(row: any[] | object): number {\n return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;\n }\n\n private _isFull(): boolean {\n // No batch, not ready\n if (!this.aggregator || this.aggregator.rowCount() === 0) {\n return false;\n }\n\n // if batchSize === 'auto' we wait for chunk to complete\n // if batchSize === number, ensure we have enough rows\n if (this.options.batchSize === 'auto') {\n if (!this.isChunkComplete) {\n return false;\n }\n } else if (this.options.batchSize > this.aggregator.rowCount()) {\n return false;\n }\n\n // Debounce batches\n if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {\n return false;\n }\n\n // Emit batch\n this.isChunkComplete = false;\n this.lastBatchEmittedMs = Date.now();\n return true;\n }\n\n /**\n * bytesUsed can be set via chunkComplete or via getBatch*\n */\n private _getBatch(options?: GetBatchOptions): TableBatch | null {\n if (!this.aggregator) {\n return null;\n }\n\n // TODO - this can overly increment bytes used?\n if (options?.bytesUsed) {\n this.bytesUsed = options.bytesUsed;\n }\n const normalizedBatch = this.aggregator.getBatch() as TableBatch;\n normalizedBatch.count = this.batchCount;\n normalizedBatch.bytesUsed = this.bytesUsed;\n Object.assign(normalizedBatch, options);\n\n this.batchCount++;\n this.aggregator = null;\n return normalizedBatch;\n }\n\n private _getTableBatchType(): TableBatchConstructor {\n switch (this.options.shape) {\n case 'row-table':\n return BaseTableBatchAggregator;\n case 'array-row-table':\n case 'object-row-table':\n return RowTableBatchAggregator;\n case 'columnar-table':\n return ColumnarTableBatchAggregator;\n case 'arrow-table':\n if (!TableBatchBuilder.ArrowBatch) {\n throw new Error(ERR_MESSAGE);\n }\n return TableBatchBuilder.ArrowBatch;\n default:\n throw new Error(ERR_MESSAGE);\n }\n }\n}\n"],"file":"table-batch-builder.js"}
@@ -1,97 +1,49 @@
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;
1
+ export let Type;
2
+
33
3
  (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 = {}));
4
+ Type[Type["NONE"] = 0] = "NONE";
5
+ Type[Type["Null"] = 1] = "Null";
6
+ Type[Type["Int"] = 2] = "Int";
7
+ Type[Type["Float"] = 3] = "Float";
8
+ Type[Type["Binary"] = 4] = "Binary";
9
+ Type[Type["Utf8"] = 5] = "Utf8";
10
+ Type[Type["Bool"] = 6] = "Bool";
11
+ Type[Type["Decimal"] = 7] = "Decimal";
12
+ Type[Type["Date"] = 8] = "Date";
13
+ Type[Type["Time"] = 9] = "Time";
14
+ Type[Type["Timestamp"] = 10] = "Timestamp";
15
+ Type[Type["Interval"] = 11] = "Interval";
16
+ Type[Type["List"] = 12] = "List";
17
+ Type[Type["Struct"] = 13] = "Struct";
18
+ Type[Type["Union"] = 14] = "Union";
19
+ Type[Type["FixedSizeBinary"] = 15] = "FixedSizeBinary";
20
+ Type[Type["FixedSizeList"] = 16] = "FixedSizeList";
21
+ Type[Type["Map"] = 17] = "Map";
22
+ Type[Type["Dictionary"] = -1] = "Dictionary";
23
+ Type[Type["Int8"] = -2] = "Int8";
24
+ Type[Type["Int16"] = -3] = "Int16";
25
+ Type[Type["Int32"] = -4] = "Int32";
26
+ Type[Type["Int64"] = -5] = "Int64";
27
+ Type[Type["Uint8"] = -6] = "Uint8";
28
+ Type[Type["Uint16"] = -7] = "Uint16";
29
+ Type[Type["Uint32"] = -8] = "Uint32";
30
+ Type[Type["Uint64"] = -9] = "Uint64";
31
+ Type[Type["Float16"] = -10] = "Float16";
32
+ Type[Type["Float32"] = -11] = "Float32";
33
+ Type[Type["Float64"] = -12] = "Float64";
34
+ Type[Type["DateDay"] = -13] = "DateDay";
35
+ Type[Type["DateMillisecond"] = -14] = "DateMillisecond";
36
+ Type[Type["TimestampSecond"] = -15] = "TimestampSecond";
37
+ Type[Type["TimestampMillisecond"] = -16] = "TimestampMillisecond";
38
+ Type[Type["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
39
+ Type[Type["TimestampNanosecond"] = -18] = "TimestampNanosecond";
40
+ Type[Type["TimeSecond"] = -19] = "TimeSecond";
41
+ Type[Type["TimeMillisecond"] = -20] = "TimeMillisecond";
42
+ Type[Type["TimeMicrosecond"] = -21] = "TimeMicrosecond";
43
+ Type[Type["TimeNanosecond"] = -22] = "TimeNanosecond";
44
+ Type[Type["DenseUnion"] = -23] = "DenseUnion";
45
+ Type[Type["SparseUnion"] = -24] = "SparseUnion";
46
+ Type[Type["IntervalDayTime"] = -25] = "IntervalDayTime";
47
+ Type[Type["IntervalYearMonth"] = -26] = "IntervalYearMonth";
48
+ })(Type || (Type = {}));
49
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/schema/impl/enum.ts"],"names":["Type"],"mappings":"AA6BA,WAAYA,IAAZ;;WAAYA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;AAAAA,EAAAA,I,CAAAA,I;GAAAA,I,KAAAA,I","sourcesContent":["// This code is adapted from ArrowJS https://github.com/apache/arrow\n// under Apache license http://www.apache.org/licenses/LICENSE-2.0\n\n/**\n * Main data type enumeration.\n *\n * Data types in this library are all *logical*. They can be expressed as\n * either a primitive physical type (bytes or bits of some fixed size), a\n * nested type consisting of other data types, or another data type (e.g. a\n * timestamp encoded as an int64).\n *\n * **Note**: Only enum values 0-17 (NONE through Map) are written to an Arrow\n * IPC payload.\n *\n * The rest of the values are specified here so TypeScript can narrow the type\n * signatures further beyond the base Arrow Types. The Arrow DataTypes include\n * metadata like `bitWidth` that impact the type signatures of the values we\n * accept and return.\n *\n * For example, the `Int8Vector` reads 1-byte numbers from an `Int8Array`, an\n * `Int32Vector` reads a 4-byte number from an `Int32Array`, and an `Int64Vector`\n * reads a pair of 4-byte lo, hi 32-bit integers as a zero-copy slice from the\n * underlying `Int32Array`.\n *\n * Library consumers benefit by knowing the narrowest type, since we can ensure\n * the types across all public methods are propagated, and never bail to `any`.\n * These values are _never_ used at runtime, and they will _never_ be written\n * to the flatbuffers metadata of serialized Arrow IPC payloads.\n */\nexport enum Type {\n /** The default placeholder type */\n NONE = 0,\n /** A NULL type having no physical storage */\n Null = 1,\n /** Signed or unsigned 8, 16, 32, or 64-bit little-endian integer */\n Int = 2,\n /** 2, 4, or 8-byte floating point value */\n Float = 3,\n /** Variable-length bytes (no guarantee of UTF8-ness) */\n Binary = 4,\n /** UTF8 variable-length string as List<Char> */\n Utf8 = 5,\n /** Boolean as 1 bit, LSB bit-packed ordering */\n Bool = 6,\n /** Precision-and-scale-based decimal type. Storage type depends on the parameters. */\n Decimal = 7,\n /** int32_t days or int64_t milliseconds since the UNIX epoch */\n Date = 8,\n /** Time as signed 32 or 64-bit integer, representing either seconds, milliseconds, microseconds, or nanoseconds since midnight since midnight */\n Time = 9,\n /** Exact timestamp encoded with int64 since UNIX epoch (Default unit millisecond) */\n Timestamp = 10,\n /** YEAR_MONTH or DAY_TIME interval in SQL style */\n Interval = 11,\n /** A list of some logical data type */\n List = 12,\n /** Struct of logical types */\n Struct = 13,\n /** Union of logical types */\n Union = 14,\n /** Fixed-size binary. Each value occupies the same number of bytes */\n FixedSizeBinary = 15,\n /** Fixed-size list. Each value occupies the same number of bytes */\n FixedSizeList = 16,\n /** Map of named logical types */\n Map = 17,\n\n /** Dictionary aka Category type */\n Dictionary = -1,\n Int8 = -2,\n Int16 = -3,\n Int32 = -4,\n Int64 = -5,\n Uint8 = -6,\n Uint16 = -7,\n Uint32 = -8,\n Uint64 = -9,\n Float16 = -10,\n Float32 = -11,\n Float64 = -12,\n DateDay = -13,\n DateMillisecond = -14,\n TimestampSecond = -15,\n TimestampMillisecond = -16,\n TimestampMicrosecond = -17,\n TimestampNanosecond = -18,\n TimeSecond = -19,\n TimeMillisecond = -20,\n TimeMicrosecond = -21,\n TimeNanosecond = -22,\n DenseUnion = -23,\n SparseUnion = -24,\n IntervalDayTime = -25,\n IntervalYearMonth = -26\n}\n"],"file":"enum.js"}
@@ -1,32 +1,35 @@
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
- }
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ export default class Field {
3
+ constructor(name, type, nullable = false, metadata = new Map()) {
4
+ _defineProperty(this, "name", void 0);
5
+
6
+ _defineProperty(this, "type", void 0);
7
+
8
+ _defineProperty(this, "nullable", void 0);
9
+
10
+ _defineProperty(this, "metadata", void 0);
11
+
12
+ this.name = name;
13
+ this.type = type;
14
+ this.nullable = nullable;
15
+ this.metadata = metadata;
16
+ }
17
+
18
+ get typeId() {
19
+ return this.type && this.type.typeId;
20
+ }
21
+
22
+ clone() {
23
+ return new Field(this.name, this.type, this.nullable, this.metadata);
24
+ }
25
+
26
+ compareTo(other) {
27
+ return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
28
+ }
29
+
30
+ toString() {
31
+ return "".concat(this.type).concat(this.nullable ? ', nullable' : '').concat(this.metadata ? ", metadata: ".concat(this.metadata) : '');
32
+ }
33
+
31
34
  }
32
- exports.default = Field;
35
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/schema/impl/field.ts"],"names":["Field","constructor","name","type","nullable","metadata","Map","typeId","clone","compareTo","other","toString"],"mappings":";AAQA,eAAe,MAAMA,KAAN,CAAY;AAMzBC,EAAAA,WAAW,CACTC,IADS,EAETC,IAFS,EAGTC,QAAQ,GAAG,KAHF,EAITC,QAA6B,GAAG,IAAIC,GAAJ,EAJvB,EAKT;AAAA;;AAAA;;AAAA;;AAAA;;AACA,SAAKJ,IAAL,GAAYA,IAAZ;AACA,SAAKC,IAAL,GAAYA,IAAZ;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACD;;AAES,MAANE,MAAM,GAAW;AACnB,WAAO,KAAKJ,IAAL,IAAa,KAAKA,IAAL,CAAUI,MAA9B;AACD;;AAEDC,EAAAA,KAAK,GAAU;AACb,WAAO,IAAIR,KAAJ,CAAU,KAAKE,IAAf,EAAqB,KAAKC,IAA1B,EAAgC,KAAKC,QAArC,EAA+C,KAAKC,QAApD,CAAP;AACD;;AAEDI,EAAAA,SAAS,CAACC,KAAD,EAAuB;AAC9B,WACE,KAAKR,IAAL,KAAcQ,KAAK,CAACR,IAApB,IACA,KAAKC,IAAL,KAAcO,KAAK,CAACP,IADpB,IAEA,KAAKC,QAAL,KAAkBM,KAAK,CAACN,QAFxB,IAGA,KAAKC,QAAL,KAAkBK,KAAK,CAACL,QAJ1B;AAMD;;AAEDM,EAAAA,QAAQ,GAAW;AACjB,qBAAU,KAAKR,IAAf,SAAsB,KAAKC,QAAL,GAAgB,YAAhB,GAA+B,EAArD,SACE,KAAKC,QAAL,yBAA+B,KAAKA,QAApC,IAAiD,EADnD;AAGD;;AAvCwB","sourcesContent":["import {DataType} from './type';\n\n/**\n * ArrowJS `Field` API-compatible class for row-based tables\n * https://loaders.gl/arrowjs/docs/api-reference/field\n * A field holds name, nullable, and metadata information about a table \"column\"\n * A Schema is essentially a list of fields\n */\nexport default class Field {\n name: string;\n type: DataType;\n nullable: boolean;\n metadata: Map<string, string>;\n\n constructor(\n name: string,\n type: DataType,\n nullable = false,\n metadata: Map<string, string> = new Map()\n ) {\n this.name = name;\n this.type = type;\n this.nullable = nullable;\n this.metadata = metadata;\n }\n\n get typeId(): number {\n return this.type && this.type.typeId;\n }\n\n clone(): Field {\n return new Field(this.name, this.type, this.nullable, this.metadata);\n }\n\n compareTo(other: this): boolean {\n return (\n this.name === other.name &&\n this.type === other.type &&\n this.nullable === other.nullable &&\n this.metadata === other.metadata\n );\n }\n\n toString(): string {\n return `${this.type}${this.nullable ? ', nullable' : ''}${\n this.metadata ? `, metadata: ${this.metadata}` : ''\n }`;\n }\n}\n"],"file":"field.js"}