@loaders.gl/schema 4.2.0-alpha.3 → 4.2.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 (134) hide show
  1. package/dist/dist.dev.js +190 -161
  2. package/dist/dist.min.js +9 -0
  3. package/dist/index.cjs +64 -73
  4. package/dist/index.cjs.map +7 -0
  5. package/dist/index.d.ts +30 -30
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +9 -1
  8. package/dist/lib/mesh/convert-mesh.d.ts +2 -2
  9. package/dist/lib/mesh/convert-mesh.d.ts.map +1 -1
  10. package/dist/lib/mesh/convert-mesh.js +33 -18
  11. package/dist/lib/mesh/deduce-mesh-schema.d.ts +2 -2
  12. package/dist/lib/mesh/deduce-mesh-schema.d.ts.map +1 -1
  13. package/dist/lib/mesh/deduce-mesh-schema.js +54 -40
  14. package/dist/lib/mesh/mesh-to-arrow-table.js +46 -1
  15. package/dist/lib/mesh/mesh-utils.d.ts +2 -2
  16. package/dist/lib/mesh/mesh-utils.d.ts.map +1 -1
  17. package/dist/lib/mesh/mesh-utils.js +41 -28
  18. package/dist/lib/table/arrow-api/arrow-like-field.d.ts +1 -1
  19. package/dist/lib/table/arrow-api/arrow-like-field.d.ts.map +1 -1
  20. package/dist/lib/table/arrow-api/arrow-like-field.js +30 -25
  21. package/dist/lib/table/arrow-api/arrow-like-schema.d.ts +2 -2
  22. package/dist/lib/table/arrow-api/arrow-like-schema.d.ts.map +1 -1
  23. package/dist/lib/table/arrow-api/arrow-like-schema.js +69 -56
  24. package/dist/lib/table/arrow-api/arrow-like-table.d.ts +2 -2
  25. package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
  26. package/dist/lib/table/arrow-api/arrow-like-table.js +53 -45
  27. package/dist/lib/table/arrow-api/arrow-like-type.d.ts +3 -3
  28. package/dist/lib/table/arrow-api/arrow-like-type.d.ts.map +1 -1
  29. package/dist/lib/table/arrow-api/arrow-like-type.js +357 -321
  30. package/dist/lib/table/arrow-api/enum.js +97 -48
  31. package/dist/lib/table/arrow-api/get-type-info.d.ts +1 -1
  32. package/dist/lib/table/arrow-api/get-type-info.d.ts.map +1 -1
  33. package/dist/lib/table/arrow-api/get-type-info.js +20 -14
  34. package/dist/lib/table/arrow-api/index.d.ts +4 -4
  35. package/dist/lib/table/arrow-api/index.d.ts.map +1 -1
  36. package/dist/lib/table/arrow-api/index.js +3 -1
  37. package/dist/lib/table/batches/base-table-batch-aggregator.d.ts +3 -3
  38. package/dist/lib/table/batches/base-table-batch-aggregator.d.ts.map +1 -1
  39. package/dist/lib/table/batches/base-table-batch-aggregator.js +53 -52
  40. package/dist/lib/table/batches/columnar-table-batch-aggregator.d.ts +3 -3
  41. package/dist/lib/table/batches/columnar-table-batch-aggregator.d.ts.map +1 -1
  42. package/dist/lib/table/batches/columnar-table-batch-aggregator.js +81 -67
  43. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +3 -3
  44. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -1
  45. package/dist/lib/table/batches/row-table-batch-aggregator.js +74 -67
  46. package/dist/lib/table/batches/table-batch-aggregator.d.ts +2 -2
  47. package/dist/lib/table/batches/table-batch-aggregator.d.ts.map +1 -1
  48. package/dist/lib/table/batches/table-batch-aggregator.js +3 -1
  49. package/dist/lib/table/batches/table-batch-builder.d.ts +3 -3
  50. package/dist/lib/table/batches/table-batch-builder.d.ts.map +1 -1
  51. package/dist/lib/table/batches/table-batch-builder.js +128 -116
  52. package/dist/lib/table/simple-table/convert-table.d.ts +1 -1
  53. package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -1
  54. package/dist/lib/table/simple-table/convert-table.js +97 -62
  55. package/dist/lib/table/simple-table/data-type.d.ts +2 -2
  56. package/dist/lib/table/simple-table/data-type.d.ts.map +1 -1
  57. package/dist/lib/table/simple-table/data-type.js +79 -76
  58. package/dist/lib/table/simple-table/make-table-from-batches.js +70 -67
  59. package/dist/lib/table/simple-table/make-table.d.ts +1 -1
  60. package/dist/lib/table/simple-table/make-table.d.ts.map +1 -1
  61. package/dist/lib/table/simple-table/make-table.js +85 -41
  62. package/dist/lib/table/simple-table/row-utils.js +38 -31
  63. package/dist/lib/table/simple-table/table-accessors.d.ts +1 -1
  64. package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -1
  65. package/dist/lib/table/simple-table/table-accessors.js +314 -270
  66. package/dist/lib/table/simple-table/table-column.d.ts +1 -1
  67. package/dist/lib/table/simple-table/table-column.d.ts.map +1 -1
  68. package/dist/lib/table/simple-table/table-column.js +36 -3
  69. package/dist/lib/table/simple-table/table-schema.d.ts +2 -2
  70. package/dist/lib/table/simple-table/table-schema.d.ts.map +1 -1
  71. package/dist/lib/table/simple-table/table-schema.js +69 -56
  72. package/dist/lib/utils/assert.js +6 -4
  73. package/dist/lib/utils/async-queue.js +76 -82
  74. package/dist/types/batch.d.ts +1 -1
  75. package/dist/types/batch.d.ts.map +1 -1
  76. package/dist/types/batch.js +3 -1
  77. package/dist/types/binary-geometries.d.ts +1 -1
  78. package/dist/types/binary-geometries.d.ts.map +1 -1
  79. package/dist/types/binary-geometries.js +3 -1
  80. package/dist/types/category-gis.d.ts +2 -2
  81. package/dist/types/category-gis.d.ts.map +1 -1
  82. package/dist/types/category-gis.js +3 -1
  83. package/dist/types/category-image.js +3 -1
  84. package/dist/types/category-mesh.d.ts +3 -3
  85. package/dist/types/category-mesh.d.ts.map +1 -1
  86. package/dist/types/category-mesh.js +3 -1
  87. package/dist/types/category-table.d.ts +3 -3
  88. package/dist/types/category-table.d.ts.map +1 -1
  89. package/dist/types/category-table.js +3 -1
  90. package/dist/types/category-texture.d.ts +1 -1
  91. package/dist/types/category-texture.d.ts.map +1 -1
  92. package/dist/types/category-texture.js +3 -1
  93. package/dist/types/flat-geometries.js +3 -1
  94. package/dist/types/schema.js +3 -1
  95. package/dist/types/types.js +3 -1
  96. package/package.json +8 -4
  97. package/src/index.ts +1 -1
  98. package/dist/index.js.map +0 -1
  99. package/dist/lib/mesh/convert-mesh.js.map +0 -1
  100. package/dist/lib/mesh/deduce-mesh-schema.js.map +0 -1
  101. package/dist/lib/mesh/mesh-to-arrow-table.js.map +0 -1
  102. package/dist/lib/mesh/mesh-utils.js.map +0 -1
  103. package/dist/lib/table/arrow-api/arrow-like-field.js.map +0 -1
  104. package/dist/lib/table/arrow-api/arrow-like-schema.js.map +0 -1
  105. package/dist/lib/table/arrow-api/arrow-like-table.js.map +0 -1
  106. package/dist/lib/table/arrow-api/arrow-like-type.js.map +0 -1
  107. package/dist/lib/table/arrow-api/enum.js.map +0 -1
  108. package/dist/lib/table/arrow-api/get-type-info.js.map +0 -1
  109. package/dist/lib/table/arrow-api/index.js.map +0 -1
  110. package/dist/lib/table/batches/base-table-batch-aggregator.js.map +0 -1
  111. package/dist/lib/table/batches/columnar-table-batch-aggregator.js.map +0 -1
  112. package/dist/lib/table/batches/row-table-batch-aggregator.js.map +0 -1
  113. package/dist/lib/table/batches/table-batch-aggregator.js.map +0 -1
  114. package/dist/lib/table/batches/table-batch-builder.js.map +0 -1
  115. package/dist/lib/table/simple-table/convert-table.js.map +0 -1
  116. package/dist/lib/table/simple-table/data-type.js.map +0 -1
  117. package/dist/lib/table/simple-table/make-table-from-batches.js.map +0 -1
  118. package/dist/lib/table/simple-table/make-table.js.map +0 -1
  119. package/dist/lib/table/simple-table/row-utils.js.map +0 -1
  120. package/dist/lib/table/simple-table/table-accessors.js.map +0 -1
  121. package/dist/lib/table/simple-table/table-column.js.map +0 -1
  122. package/dist/lib/table/simple-table/table-schema.js.map +0 -1
  123. package/dist/lib/utils/assert.js.map +0 -1
  124. package/dist/lib/utils/async-queue.js.map +0 -1
  125. package/dist/types/batch.js.map +0 -1
  126. package/dist/types/binary-geometries.js.map +0 -1
  127. package/dist/types/category-gis.js.map +0 -1
  128. package/dist/types/category-image.js.map +0 -1
  129. package/dist/types/category-mesh.js.map +0 -1
  130. package/dist/types/category-table.js.map +0 -1
  131. package/dist/types/category-texture.js.map +0 -1
  132. package/dist/types/flat-geometries.js.map +0 -1
  133. package/dist/types/schema.js.map +0 -1
  134. package/dist/types/types.js.map +0 -1
@@ -1,48 +1,97 @@
1
- export let Type = function (Type) {
2
- Type[Type["NONE"] = 0] = "NONE";
3
- Type[Type["Null"] = 1] = "Null";
4
- Type[Type["Int"] = 2] = "Int";
5
- Type[Type["Float"] = 3] = "Float";
6
- Type[Type["Binary"] = 4] = "Binary";
7
- Type[Type["Utf8"] = 5] = "Utf8";
8
- Type[Type["Bool"] = 6] = "Bool";
9
- Type[Type["Decimal"] = 7] = "Decimal";
10
- Type[Type["Date"] = 8] = "Date";
11
- Type[Type["Time"] = 9] = "Time";
12
- Type[Type["Timestamp"] = 10] = "Timestamp";
13
- Type[Type["Interval"] = 11] = "Interval";
14
- Type[Type["List"] = 12] = "List";
15
- Type[Type["Struct"] = 13] = "Struct";
16
- Type[Type["Union"] = 14] = "Union";
17
- Type[Type["FixedSizeBinary"] = 15] = "FixedSizeBinary";
18
- Type[Type["FixedSizeList"] = 16] = "FixedSizeList";
19
- Type[Type["Map"] = 17] = "Map";
20
- Type[Type["Dictionary"] = -1] = "Dictionary";
21
- Type[Type["Int8"] = -2] = "Int8";
22
- Type[Type["Int16"] = -3] = "Int16";
23
- Type[Type["Int32"] = -4] = "Int32";
24
- Type[Type["Int64"] = -5] = "Int64";
25
- Type[Type["Uint8"] = -6] = "Uint8";
26
- Type[Type["Uint16"] = -7] = "Uint16";
27
- Type[Type["Uint32"] = -8] = "Uint32";
28
- Type[Type["Uint64"] = -9] = "Uint64";
29
- Type[Type["Float16"] = -10] = "Float16";
30
- Type[Type["Float32"] = -11] = "Float32";
31
- Type[Type["Float64"] = -12] = "Float64";
32
- Type[Type["DateDay"] = -13] = "DateDay";
33
- Type[Type["DateMillisecond"] = -14] = "DateMillisecond";
34
- Type[Type["TimestampSecond"] = -15] = "TimestampSecond";
35
- Type[Type["TimestampMillisecond"] = -16] = "TimestampMillisecond";
36
- Type[Type["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
37
- Type[Type["TimestampNanosecond"] = -18] = "TimestampNanosecond";
38
- Type[Type["TimeSecond"] = -19] = "TimeSecond";
39
- Type[Type["TimeMillisecond"] = -20] = "TimeMillisecond";
40
- Type[Type["TimeMicrosecond"] = -21] = "TimeMicrosecond";
41
- Type[Type["TimeNanosecond"] = -22] = "TimeNanosecond";
42
- Type[Type["DenseUnion"] = -23] = "DenseUnion";
43
- Type[Type["SparseUnion"] = -24] = "SparseUnion";
44
- Type[Type["IntervalDayTime"] = -25] = "IntervalDayTime";
45
- Type[Type["IntervalYearMonth"] = -26] = "IntervalYearMonth";
46
- return Type;
47
- }({});
48
- //# sourceMappingURL=enum.js.map
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // This code is adapted from ArrowJS https://github.com/apache/arrow
5
+ // under Apache license http://www.apache.org/licenses/LICENSE-2.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
+ export 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 || (Type = {}));
@@ -1,4 +1,4 @@
1
- import { Type } from './arrow-like-type';
1
+ import { Type } from "./arrow-like-type.js";
2
2
  /**
3
3
  * Gets type information from an Arrow type object or "mock" Arrow type object
4
4
  * @param arrowTypeLike Arrow Type or type object of similar shape
@@ -1 +1 @@
1
- {"version":3,"file":"get-type-info.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/arrow-api/get-type-info.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,GAAG,GAAG;IAC/C,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAQA"}
1
+ {"version":3,"file":"get-type-info.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/arrow-api/get-type-info.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAC,6BAA0B;AAEvC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,GAAG,GAAG;IAC/C,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAQA"}
@@ -1,21 +1,27 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { Type } from "./arrow-like-type.js";
5
+ /**
6
+ * Gets type information from an Arrow type object or "mock" Arrow type object
7
+ * @param arrowTypeLike Arrow Type or type object of similar shape
8
+ */
2
9
  export function getTypeInfo(arrowTypeLike) {
3
- return {
4
- typeId: arrowTypeLike.typeId,
5
- ArrayType: arrowTypeLike.ArrayType,
6
- typeName: arrowTypeLike.toString(),
7
- typeEnumName: getTypeKey(arrowTypeLike.typeId),
8
- precision: arrowTypeLike.precision
9
- };
10
+ return {
11
+ typeId: arrowTypeLike.typeId,
12
+ ArrayType: arrowTypeLike.ArrayType,
13
+ typeName: arrowTypeLike.toString(),
14
+ typeEnumName: getTypeKey(arrowTypeLike.typeId),
15
+ precision: arrowTypeLike.precision
16
+ };
10
17
  }
11
18
  let ReverseType = null;
12
19
  function getTypeKey(typeKey) {
13
- if (!ReverseType) {
14
- ReverseType = {};
15
- for (const key in Type) {
16
- ReverseType[Type[key]] = key;
20
+ if (!ReverseType) {
21
+ ReverseType = {};
22
+ for (const key in Type) {
23
+ ReverseType[Type[key]] = key;
24
+ }
17
25
  }
18
- }
19
- return ReverseType[typeKey];
26
+ return ReverseType[typeKey];
20
27
  }
21
- //# sourceMappingURL=get-type-info.js.map
@@ -1,5 +1,5 @@
1
- export { ArrowLikeField as Field } from './arrow-like-field';
2
- export { ArrowLikeSchema as Schema } from './arrow-like-schema';
3
- export { ArrowLikeTable as Table } from './arrow-like-table';
4
- export * from './arrow-like-type';
1
+ export { ArrowLikeField as Field } from "./arrow-like-field.js";
2
+ export { ArrowLikeSchema as Schema } from "./arrow-like-schema.js";
3
+ export { ArrowLikeTable as Table } from "./arrow-like-table.js";
4
+ export * from "./arrow-like-type.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/arrow-api/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,IAAI,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,eAAe,IAAI,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAC,cAAc,IAAI,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAC3D,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/table/arrow-api/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,IAAI,KAAK,EAAC,8BAA2B;AAC3D,OAAO,EAAC,eAAe,IAAI,MAAM,EAAC,+BAA4B;AAC9D,OAAO,EAAC,cAAc,IAAI,KAAK,EAAC,8BAA2B;AAC3D,qCAAkC"}
@@ -1,5 +1,7 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  export { ArrowLikeField as Field } from "./arrow-like-field.js";
2
5
  export { ArrowLikeSchema as Schema } from "./arrow-like-schema.js";
3
6
  export { ArrowLikeTable as Table } from "./arrow-like-table.js";
4
7
  export * from "./arrow-like-type.js";
5
- //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import type { Schema } from '../../../types/schema';
2
- import type { TableBatch } from '../../../types/category-table';
3
- import { TableBatchAggregator, TableBatchOptions } from './table-batch-aggregator';
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
4
  export declare class BaseTableBatchAggregator implements TableBatchAggregator {
5
5
  schema: Schema;
6
6
  options: TableBatchOptions;
@@ -1 +1 @@
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,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;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
+ {"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,59 +1,60 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  const DEFAULT_ROW_COUNT = 100;
2
5
  export class BaseTableBatchAggregator {
3
- constructor(schema, options) {
4
- this.schema = void 0;
5
- this.options = void 0;
6
- this.shape = void 0;
7
- this.length = 0;
8
- this.rows = null;
9
- this.cursor = 0;
10
- this._headers = [];
11
- this.options = options;
12
- this.schema = schema;
13
- if (!Array.isArray(schema)) {
14
- this._headers = [];
15
- for (const key in schema) {
16
- this._headers[schema[key].index] = schema[key].name;
17
- }
6
+ constructor(schema, options) {
7
+ this.length = 0;
8
+ this.rows = null;
9
+ this.cursor = 0;
10
+ this._headers = [];
11
+ this.options = options;
12
+ this.schema = schema;
13
+ // schema is an array if there're no headers
14
+ // object if there are headers
15
+ if (!Array.isArray(schema)) {
16
+ this._headers = [];
17
+ for (const key in schema) {
18
+ this._headers[schema[key].index] = schema[key].name;
19
+ }
20
+ }
18
21
  }
19
- }
20
- rowCount() {
21
- return this.length;
22
- }
23
- addArrayRow(row, cursor) {
24
- if (Number.isFinite(cursor)) {
25
- this.cursor = cursor;
22
+ rowCount() {
23
+ return this.length;
26
24
  }
27
- this.shape = 'array-row-table';
28
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
29
- this.rows[this.length] = row;
30
- this.length++;
31
- }
32
- addObjectRow(row, cursor) {
33
- if (Number.isFinite(cursor)) {
34
- this.cursor = cursor;
25
+ addArrayRow(row, cursor) {
26
+ if (Number.isFinite(cursor)) {
27
+ this.cursor = cursor;
28
+ }
29
+ this.shape = 'array-row-table';
30
+ this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
31
+ this.rows[this.length] = row;
32
+ this.length++;
35
33
  }
36
- this.shape = 'object-row-table';
37
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
38
- this.rows[this.length] = row;
39
- this.length++;
40
- }
41
- getBatch() {
42
- let rows = this.rows;
43
- if (!rows) {
44
- return null;
34
+ addObjectRow(row, cursor) {
35
+ if (Number.isFinite(cursor)) {
36
+ this.cursor = cursor;
37
+ }
38
+ this.shape = 'object-row-table';
39
+ this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
40
+ this.rows[this.length] = row;
41
+ this.length++;
42
+ }
43
+ getBatch() {
44
+ let rows = this.rows;
45
+ if (!rows) {
46
+ return null;
47
+ }
48
+ rows = rows.slice(0, this.length);
49
+ this.rows = null;
50
+ const batch = {
51
+ shape: this.shape || 'array-row-table',
52
+ batchType: 'data',
53
+ data: rows,
54
+ length: this.length,
55
+ schema: this.schema,
56
+ cursor: this.cursor
57
+ };
58
+ return batch;
45
59
  }
46
- rows = rows.slice(0, this.length);
47
- this.rows = null;
48
- const batch = {
49
- shape: this.shape || 'array-row-table',
50
- batchType: 'data',
51
- data: rows,
52
- length: this.length,
53
- schema: this.schema,
54
- cursor: this.cursor
55
- };
56
- return batch;
57
- }
58
60
  }
59
- //# sourceMappingURL=base-table-batch-aggregator.js.map
@@ -1,6 +1,6 @@
1
- import type { Schema } from '../../../types/schema';
2
- import type { ColumnarTableBatch, ArrowTableBatch } from '../../../types/category-table';
3
- import { TableBatchAggregator } from './table-batch-aggregator';
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
4
  type ColumnarTableBatchOptions = {};
5
5
  export declare class ColumnarTableBatchAggregator implements TableBatchAggregator {
6
6
  schema: Schema;
@@ -1 +1 @@
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,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;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
+ {"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,76 +1,90 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  const DEFAULT_ROW_COUNT = 100;
2
5
  export class ColumnarTableBatchAggregator {
3
- constructor(schema, options) {
4
- this.schema = void 0;
5
- this.length = 0;
6
- this.allocated = 0;
7
- this.columns = {};
8
- this.schema = schema;
9
- this._reallocateColumns();
10
- }
11
- rowCount() {
12
- return this.length;
13
- }
14
- addArrayRow(row) {
15
- this._reallocateColumns();
16
- let i = 0;
17
- for (const fieldName in this.columns) {
18
- this.columns[fieldName][this.length] = row[i++];
6
+ constructor(schema, options) {
7
+ this.length = 0;
8
+ this.allocated = 0;
9
+ this.columns = {};
10
+ this.schema = schema;
11
+ this._reallocateColumns();
19
12
  }
20
- this.length++;
21
- }
22
- addObjectRow(row) {
23
- this._reallocateColumns();
24
- for (const fieldName in row) {
25
- this.columns[fieldName][this.length] = row[fieldName];
13
+ rowCount() {
14
+ return this.length;
26
15
  }
27
- this.length++;
28
- }
29
- getBatch() {
30
- this._pruneColumns();
31
- const columns = Array.isArray(this.schema) ? this.columns : {};
32
- if (!Array.isArray(this.schema)) {
33
- for (const fieldName in this.schema) {
34
- const field = this.schema[fieldName];
35
- columns[field.name] = this.columns[field.index];
36
- }
16
+ addArrayRow(row) {
17
+ // If user keeps pushing rows beyond batch size, reallocate
18
+ this._reallocateColumns();
19
+ let i = 0;
20
+ // TODO what if no csv header, columns not populated?
21
+ for (const fieldName in this.columns) {
22
+ this.columns[fieldName][this.length] = row[i++];
23
+ }
24
+ this.length++;
37
25
  }
38
- this.columns = {};
39
- const batch = {
40
- shape: 'columnar-table',
41
- batchType: 'data',
42
- data: columns,
43
- schema: this.schema,
44
- length: this.length
45
- };
46
- return batch;
47
- }
48
- _reallocateColumns() {
49
- if (this.length < this.allocated) {
50
- return;
26
+ addObjectRow(row) {
27
+ // If user keeps pushing rows beyond batch size, reallocate
28
+ this._reallocateColumns();
29
+ for (const fieldName in row) {
30
+ this.columns[fieldName][this.length] = row[fieldName];
31
+ }
32
+ this.length++;
51
33
  }
52
- this.allocated = this.allocated > 0 ? this.allocated *= 2 : DEFAULT_ROW_COUNT;
53
- this.columns = {};
54
- for (const fieldName in this.schema) {
55
- const field = this.schema[fieldName];
56
- const ArrayType = field.type || Float32Array;
57
- const oldColumn = this.columns[field.index];
58
- if (oldColumn && ArrayBuffer.isView(oldColumn)) {
59
- const typedArray = new ArrayType(this.allocated);
60
- typedArray.set(oldColumn);
61
- this.columns[field.index] = typedArray;
62
- } else if (oldColumn) {
63
- oldColumn.length = this.allocated;
64
- this.columns[field.index] = oldColumn;
65
- } else {
66
- this.columns[field.index] = new ArrayType(this.allocated);
67
- }
34
+ getBatch() {
35
+ this._pruneColumns();
36
+ const columns = Array.isArray(this.schema) ? this.columns : {};
37
+ // schema is an array if there're no headers
38
+ // object if there are headers
39
+ // columns should match schema format
40
+ if (!Array.isArray(this.schema)) {
41
+ for (const fieldName in this.schema) {
42
+ const field = this.schema[fieldName];
43
+ columns[field.name] = this.columns[field.index];
44
+ }
45
+ }
46
+ this.columns = {};
47
+ const batch = {
48
+ shape: 'columnar-table',
49
+ batchType: 'data',
50
+ data: columns,
51
+ schema: this.schema,
52
+ length: this.length
53
+ };
54
+ return batch;
68
55
  }
69
- }
70
- _pruneColumns() {
71
- for (const [columnName, column] of Object.entries(this.columns)) {
72
- this.columns[columnName] = column.slice(0, this.length);
56
+ // HELPERS
57
+ _reallocateColumns() {
58
+ if (this.length < this.allocated) {
59
+ return;
60
+ }
61
+ // @ts-ignore TODO
62
+ this.allocated = this.allocated > 0 ? (this.allocated *= 2) : DEFAULT_ROW_COUNT;
63
+ this.columns = {};
64
+ for (const fieldName in this.schema) {
65
+ const field = this.schema[fieldName];
66
+ const ArrayType = field.type || Float32Array;
67
+ const oldColumn = this.columns[field.index];
68
+ if (oldColumn && ArrayBuffer.isView(oldColumn)) {
69
+ // Copy the old data to the new array
70
+ const typedArray = new ArrayType(this.allocated);
71
+ typedArray.set(oldColumn);
72
+ this.columns[field.index] = typedArray;
73
+ }
74
+ else if (oldColumn) {
75
+ // Plain array
76
+ oldColumn.length = this.allocated;
77
+ this.columns[field.index] = oldColumn;
78
+ }
79
+ else {
80
+ // Create new
81
+ this.columns[field.index] = new ArrayType(this.allocated);
82
+ }
83
+ }
84
+ }
85
+ _pruneColumns() {
86
+ for (const [columnName, column] of Object.entries(this.columns)) {
87
+ this.columns[columnName] = column.slice(0, this.length);
88
+ }
73
89
  }
74
- }
75
90
  }
76
- //# sourceMappingURL=columnar-table-batch-aggregator.js.map
@@ -1,6 +1,6 @@
1
- import type { Schema } from '../../../types/schema';
2
- import type { TableBatch } from '../../../types/category-table';
3
- import { TableBatchAggregator, TableBatchOptions } from './table-batch-aggregator';
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
4
  export declare class RowTableBatchAggregator implements TableBatchAggregator {
5
5
  schema: Schema | null;
6
6
  options: TableBatchOptions;
@@ -1 +1 @@
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,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;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
+ {"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"}