@loaders.gl/arrow 4.0.1 → 4.0.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 (57) hide show
  1. package/dist/arrow-worker.js +33 -25
  2. package/dist/arrow-writer.d.ts +2 -2
  3. package/dist/arrow-writer.d.ts.map +1 -1
  4. package/dist/arrow-writer.js +6 -3
  5. package/dist/arrow-writer.js.map +1 -1
  6. package/dist/dist.dev.js +60 -29
  7. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +18 -2
  8. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -1
  9. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js +18 -19
  10. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js.map +1 -1
  11. package/dist/geoarrow/convert-geoarrow-to-geojson.js.map +1 -1
  12. package/dist/geoarrow/get-arrow-bounds.d.ts.map +1 -1
  13. package/dist/geoarrow/get-arrow-bounds.js +1 -1
  14. package/dist/geoarrow/get-arrow-bounds.js.map +1 -1
  15. package/dist/index.cjs +177 -137
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/lib/arrow-table-batch.d.ts +2 -2
  21. package/dist/lib/arrow-table-batch.d.ts.map +1 -1
  22. package/dist/lib/arrow-table-batch.js +7 -7
  23. package/dist/lib/arrow-table-batch.js.map +1 -1
  24. package/dist/lib/arrow-table.d.ts +3 -3
  25. package/dist/lib/arrow-table.d.ts.map +1 -1
  26. package/dist/lib/arrow-table.js.map +1 -1
  27. package/dist/lib/encode-arrow.js +5 -5
  28. package/dist/lib/encode-arrow.js.map +1 -1
  29. package/dist/lib/parse-arrow-in-batches.js +3 -3
  30. package/dist/lib/parse-arrow-in-batches.js.map +1 -1
  31. package/dist/lib/parse-arrow-sync.js +2 -2
  32. package/dist/lib/parse-arrow-sync.js.map +1 -1
  33. package/dist/schema/arrow-type-utils.d.ts +2 -2
  34. package/dist/schema/arrow-type-utils.d.ts.map +1 -1
  35. package/dist/schema/arrow-type-utils.js +9 -9
  36. package/dist/schema/arrow-type-utils.js.map +1 -1
  37. package/dist/schema/convert-arrow-schema.d.ts +7 -7
  38. package/dist/schema/convert-arrow-schema.d.ts.map +1 -1
  39. package/dist/schema/convert-arrow-schema.js +113 -86
  40. package/dist/schema/convert-arrow-schema.js.map +1 -1
  41. package/dist/tables/convert-arrow-to-table.d.ts +2 -2
  42. package/dist/tables/convert-arrow-to-table.d.ts.map +1 -1
  43. package/dist/tables/convert-arrow-to-table.js.map +1 -1
  44. package/package.json +5 -5
  45. package/src/arrow-writer.ts +8 -5
  46. package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +26 -26
  47. package/src/geoarrow/convert-geoarrow-to-geojson.ts +7 -7
  48. package/src/geoarrow/get-arrow-bounds.ts +1 -2
  49. package/src/index.ts +6 -1
  50. package/src/lib/arrow-table-batch.ts +13 -23
  51. package/src/lib/arrow-table.ts +3 -3
  52. package/src/lib/encode-arrow.ts +8 -8
  53. package/src/lib/parse-arrow-in-batches.ts +4 -4
  54. package/src/lib/parse-arrow-sync.ts +2 -2
  55. package/src/schema/arrow-type-utils.ts +10 -29
  56. package/src/schema/convert-arrow-schema.ts +126 -145
  57. package/src/tables/convert-arrow-to-table.ts +2 -2
@@ -1,7 +1,7 @@
1
1
  // loaders.gl, MIT license
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
- import {Data, Vector} from 'apache-arrow';
4
+ import * as arrow from 'apache-arrow';
5
5
  import {BinaryFeatureCollection as BinaryFeatures} from '@loaders.gl/schema';
6
6
  import {GeoArrowEncoding} from '@loaders.gl/gis';
7
7
  import {updateBoundsFromGeoArrowSamples} from './get-arrow-bounds';
@@ -24,7 +24,7 @@ type BinaryGeometryContent = {
24
24
  };
25
25
 
26
26
  // binary geometry template, see deck.gl BinaryGeometry
27
- const BINARY_GEOMETRY_TEMPLATE = {
27
+ export const BINARY_GEOMETRY_TEMPLATE = {
28
28
  globalFeatureIds: {value: new Uint32Array(0), size: 1},
29
29
  positions: {value: new Float32Array(0), size: 2},
30
30
  properties: [],
@@ -40,7 +40,7 @@ const BINARY_GEOMETRY_TEMPLATE = {
40
40
  * @returns BinaryDataFromGeoArrow
41
41
  */
42
42
  export function getBinaryGeometriesFromArrow(
43
- geoColumn: Vector,
43
+ geoColumn: arrow.Vector,
44
44
  geoEncoding: GeoArrowEncoding
45
45
  ): BinaryDataFromGeoArrow {
46
46
  const featureTypes = {
@@ -50,20 +50,18 @@ export function getBinaryGeometriesFromArrow(
50
50
  };
51
51
 
52
52
  const chunks = geoColumn.data;
53
- const bounds: [number, number, number, number] = [Infinity, Infinity, -Infinity, -Infinity];
53
+ let bounds: [number, number, number, number] = [Infinity, Infinity, -Infinity, -Infinity];
54
54
  let globalFeatureIdOffset = 0;
55
55
  const binaryGeometries: BinaryFeatures[] = [];
56
56
 
57
- for (let c = 0; c < chunks.length; c++) {
58
- const geometries = chunks[c];
57
+ chunks.forEach((chunk) => {
59
58
  const {featureIds, flatCoordinateArray, nDim, geomOffset} = getBinaryGeometriesFromChunk(
60
- geometries,
59
+ chunk,
61
60
  geoEncoding
62
61
  );
63
62
 
64
- const numOfVertices = flatCoordinateArray.length / nDim;
65
- const globalFeatureIds = new Uint32Array(numOfVertices);
66
- for (let i = 0; i < numOfVertices; i++) {
63
+ const globalFeatureIds = new Uint32Array(featureIds.length);
64
+ for (let i = 0; i < featureIds.length; i++) {
67
65
  globalFeatureIds[i] = featureIds[i] + globalFeatureIdOffset;
68
66
  }
69
67
 
@@ -74,14 +72,13 @@ export function getBinaryGeometriesFromArrow(
74
72
  size: nDim
75
73
  },
76
74
  featureIds: {value: featureIds, size: 1},
77
- // eslint-disable-next-line no-loop-func
78
- properties: [...Array(geometries.length).keys()].map((i) => ({
75
+ properties: [...Array(chunk.length).keys()].map((i) => ({
79
76
  index: i + globalFeatureIdOffset
80
77
  }))
81
78
  };
82
79
 
83
80
  // TODO: check if chunks are sequentially accessed
84
- globalFeatureIdOffset += geometries.length;
81
+ globalFeatureIdOffset += chunk.length;
85
82
 
86
83
  // NOTE: deck.gl defines the BinaryFeatures structure must have points, lines, polygons even if they are empty
87
84
  binaryGeometries.push({
@@ -114,8 +111,8 @@ export function getBinaryGeometriesFromArrow(
114
111
  }
115
112
  });
116
113
 
117
- updateBoundsFromGeoArrowSamples(flatCoordinateArray, nDim, bounds);
118
- }
114
+ bounds = updateBoundsFromGeoArrowSamples(flatCoordinateArray, nDim, bounds);
115
+ });
119
116
 
120
117
  return {binaryGeometries, bounds, featureTypes};
121
118
  }
@@ -127,7 +124,7 @@ export function getBinaryGeometriesFromArrow(
127
124
  * @returns BinaryGeometryContent
128
125
  */
129
126
  function getBinaryGeometriesFromChunk(
130
- chunk: Data,
127
+ chunk: arrow.Data,
131
128
  geoEncoding: GeoArrowEncoding
132
129
  ): BinaryGeometryContent {
133
130
  switch (geoEncoding) {
@@ -151,10 +148,14 @@ function getBinaryGeometriesFromChunk(
151
148
  * @param geoEncoding the geo encoding of the geoarrow polygon column
152
149
  * @returns BinaryGeometryContent
153
150
  */
154
- function getBinaryPolygonsFromChunk(chunk: Data, geoEncoding: string): BinaryGeometryContent {
151
+ function getBinaryPolygonsFromChunk(chunk: arrow.Data, geoEncoding: string): BinaryGeometryContent {
155
152
  const isMultiPolygon = geoEncoding === 'geoarrow.multipolygon';
156
153
 
157
154
  const polygonData = isMultiPolygon ? chunk.children[0] : chunk;
155
+ const polygonOffset = polygonData.valueOffsets;
156
+ const partData = isMultiPolygon
157
+ ? chunk.valueOffsets.map((i) => polygonOffset.at(i) || i)
158
+ : chunk.valueOffsets;
158
159
  const ringData = polygonData.children[0];
159
160
  const pointData = ringData.children[0];
160
161
  const coordData = pointData.children[0];
@@ -162,17 +163,16 @@ function getBinaryPolygonsFromChunk(chunk: Data, geoEncoding: string): BinaryGeo
162
163
  const geomOffset = ringData.valueOffsets;
163
164
  const flatCoordinateArray = coordData.values;
164
165
 
165
- const geometryIndicies = new Uint16Array(chunk.length + 1);
166
- for (let i = 0; i < chunk.length; i++) {
167
- geometryIndicies[i] = geomOffset[chunk.valueOffsets[i]];
166
+ const geometryIndicies = new Uint16Array(polygonOffset.length);
167
+ for (let i = 0; i < polygonOffset.length; i++) {
168
+ geometryIndicies[i] = geomOffset[polygonOffset[i]];
168
169
  }
169
- geometryIndicies[chunk.length] = flatCoordinateArray.length / nDim;
170
170
 
171
171
  const numOfVertices = flatCoordinateArray.length / nDim;
172
172
  const featureIds = new Uint32Array(numOfVertices);
173
- for (let i = 0; i < chunk.length - 1; i++) {
174
- const startIdx = geomOffset[chunk.valueOffsets[i]];
175
- const endIdx = geomOffset[chunk.valueOffsets[i + 1]];
173
+ for (let i = 0; i < partData.length - 1; i++) {
174
+ const startIdx = geomOffset[partData[i]];
175
+ const endIdx = geomOffset[partData[i + 1]];
176
176
  for (let j = startIdx; j < endIdx; j++) {
177
177
  featureIds[j] = i;
178
178
  }
@@ -193,7 +193,7 @@ function getBinaryPolygonsFromChunk(chunk: Data, geoEncoding: string): BinaryGeo
193
193
  * @param geoEncoding the geo encoding of the geoarrow column
194
194
  * @returns BinaryGeometryContent
195
195
  */
196
- function getBinaryLinesFromChunk(chunk: Data, geoEncoding: string): BinaryGeometryContent {
196
+ function getBinaryLinesFromChunk(chunk: arrow.Data, geoEncoding: string): BinaryGeometryContent {
197
197
  const isMultiLineString = geoEncoding === 'geoarrow.multilinestring';
198
198
 
199
199
  const lineData = isMultiLineString ? chunk.children[0] : chunk;
@@ -232,7 +232,7 @@ function getBinaryLinesFromChunk(chunk: Data, geoEncoding: string): BinaryGeomet
232
232
  * @param geoEncoding geo encoding of the geoarrow column
233
233
  * @returns BinaryGeometryContent
234
234
  */
235
- function getBinaryPointsFromChunk(chunk: Data, geoEncoding: string): BinaryGeometryContent {
235
+ function getBinaryPointsFromChunk(chunk: arrow.Data, geoEncoding: string): BinaryGeometryContent {
236
236
  const isMultiPoint = geoEncoding === 'geoarrow.multipoint';
237
237
 
238
238
  const pointData = isMultiPoint ? chunk.children[0] : chunk;
@@ -1,7 +1,7 @@
1
1
  // loaders.gl, MIT license
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
- import {Vector} from 'apache-arrow';
4
+ import * as arrow from 'apache-arrow';
5
5
  import {
6
6
  Feature,
7
7
  MultiPolygon,
@@ -71,7 +71,7 @@ export function parseGeometryFromArrow(rawData: RawArrowFeature): Feature | null
71
71
  /**
72
72
  * convert Arrow MultiPolygon to geojson Feature
73
73
  */
74
- function arrowMultiPolygonToFeature(arrowMultiPolygon: Vector): MultiPolygon {
74
+ function arrowMultiPolygonToFeature(arrowMultiPolygon: arrow.Vector): MultiPolygon {
75
75
  const multiPolygon: Position[][][] = [];
76
76
  for (let m = 0; m < arrowMultiPolygon.length; m++) {
77
77
  const arrowPolygon = arrowMultiPolygon.get(m);
@@ -98,7 +98,7 @@ function arrowMultiPolygonToFeature(arrowMultiPolygon: Vector): MultiPolygon {
98
98
  /**
99
99
  * convert Arrow Polygon to geojson Feature
100
100
  */
101
- function arrowPolygonToFeature(arrowPolygon: Vector): Polygon {
101
+ function arrowPolygonToFeature(arrowPolygon: arrow.Vector): Polygon {
102
102
  const polygon: Position[][] = [];
103
103
  for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {
104
104
  const arrowRing = arrowPolygon.get(i);
@@ -120,7 +120,7 @@ function arrowPolygonToFeature(arrowPolygon: Vector): Polygon {
120
120
  /**
121
121
  * convert Arrow MultiPoint to geojson MultiPoint
122
122
  */
123
- function arrowMultiPointToFeature(arrowMultiPoint: Vector): MultiPoint {
123
+ function arrowMultiPointToFeature(arrowMultiPoint: arrow.Vector): MultiPoint {
124
124
  const multiPoint: Position[] = [];
125
125
  for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {
126
126
  const arrowPoint = arrowMultiPoint.get(i);
@@ -139,7 +139,7 @@ function arrowMultiPointToFeature(arrowMultiPoint: Vector): MultiPoint {
139
139
  /**
140
140
  * convert Arrow Point to geojson Point
141
141
  */
142
- function arrowPointToFeature(arrowPoint: Vector): Point {
142
+ function arrowPointToFeature(arrowPoint: arrow.Vector): Point {
143
143
  const point: Position = Array.from(arrowPoint);
144
144
  const geometry: Point = {
145
145
  type: 'Point',
@@ -151,7 +151,7 @@ function arrowPointToFeature(arrowPoint: Vector): Point {
151
151
  /**
152
152
  * convert Arrow MultiLineString to geojson MultiLineString
153
153
  */
154
- function arrowMultiLineStringToFeature(arrowMultiLineString: Vector): MultiLineString {
154
+ function arrowMultiLineStringToFeature(arrowMultiLineString: arrow.Vector): MultiLineString {
155
155
  const multiLineString: Position[][] = [];
156
156
  for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {
157
157
  const arrowLineString = arrowMultiLineString.get(i);
@@ -175,7 +175,7 @@ function arrowMultiLineStringToFeature(arrowMultiLineString: Vector): MultiLineS
175
175
  /**
176
176
  * convert Arrow LineString to geojson LineString
177
177
  */
178
- function arrowLineStringToFeature(arrowLineString: Vector): LineString {
178
+ function arrowLineStringToFeature(arrowLineString: arrow.Vector): LineString {
179
179
  const lineString: Position[] = [];
180
180
  for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
181
181
  const arrowCoord = arrowLineString.get(i);
@@ -23,7 +23,7 @@ export function updateBoundsFromGeoArrowSamples(
23
23
  for (let i = 0; i < numberOfFeatures; i += sampleStep) {
24
24
  const lng = flatCoords[i * nDim];
25
25
  const lat = flatCoords[i * nDim + 1];
26
- if (lng < bounds[0]) {
26
+ if (lng < newBounds[0]) {
27
27
  newBounds[0] = lng;
28
28
  }
29
29
  if (lat < newBounds[1]) {
@@ -36,6 +36,5 @@ export function updateBoundsFromGeoArrowSamples(
36
36
  newBounds[3] = lat;
37
37
  }
38
38
  }
39
-
40
39
  return newBounds;
41
40
  }
package/src/index.ts CHANGED
@@ -65,6 +65,11 @@ export type {GeoArrowEncoding} from '@loaders.gl/gis';
65
65
  // getGeoArrowEncoding
66
66
 
67
67
  export type {BinaryDataFromGeoArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';
68
- export {getBinaryGeometriesFromArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';
68
+ export {
69
+ BINARY_GEOMETRY_TEMPLATE,
70
+ getBinaryGeometriesFromArrow
71
+ } from './geoarrow/convert-geoarrow-to-binary-geometry';
69
72
 
70
73
  export {parseGeometryFromArrow} from './geoarrow/convert-geoarrow-to-geojson';
74
+
75
+ export {updateBoundsFromGeoArrowSamples} from './geoarrow/get-arrow-bounds';
@@ -1,19 +1,9 @@
1
1
  import {ColumnarTableBatchAggregator} from '@loaders.gl/schema';
2
2
  import type {ArrowTableBatch} from './arrow-table';
3
- import {
4
- Table as ApacheArrowTable,
5
- Schema,
6
- Field,
7
- RecordBatch,
8
- Struct,
9
- makeVector,
10
- makeData,
11
- Vector,
12
- Float32
13
- } from 'apache-arrow';
3
+ import * as arrow from 'apache-arrow';
14
4
 
15
5
  export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
16
- arrowSchema: Schema | null;
6
+ arrowSchema: arrow.Schema | null;
17
7
 
18
8
  constructor(schema, options) {
19
9
  super(schema, options);
@@ -30,10 +20,10 @@ export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
30
20
  const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);
31
21
 
32
22
  // Create the record batch
33
- const recordBatch = new RecordBatch(
23
+ const recordBatch = new arrow.RecordBatch(
34
24
  this.arrowSchema,
35
- makeData({
36
- type: new Struct(this.arrowSchema.fields),
25
+ arrow.makeData({
26
+ type: new arrow.Struct(this.arrowSchema.fields),
37
27
  children: arrowVectors.map(({data}) => data[0])
38
28
  })
39
29
  );
@@ -41,7 +31,7 @@ export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
41
31
  return {
42
32
  shape: 'arrow-table',
43
33
  batchType: 'data',
44
- data: new ApacheArrowTable([recordBatch]),
34
+ data: new arrow.Table([recordBatch]),
45
35
  length: batch.length
46
36
  };
47
37
  }
@@ -51,15 +41,15 @@ export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
51
41
  }
52
42
 
53
43
  // Convert from a simple loaders.gl schema to an Arrow schema
54
- function getArrowSchema(schema): Schema {
55
- const arrowFields: Field[] = [];
44
+ function getArrowSchema(schema): arrow.Schema {
45
+ const arrowFields: arrow.Field[] = [];
56
46
  for (const key in schema) {
57
47
  const field = schema[key];
58
48
  if (field.type === Float32Array) {
59
49
  // TODO - just store the original field as metadata?
60
50
  const metadata = new Map(); // field;
61
- // arrow: new Field(name, nullable, metadata)
62
- const arrowField = new Field(field.name, new Float32(), field.nullable, metadata);
51
+ // arrow: new arrow.Field(name, nullable, metadata)
52
+ const arrowField = new arrow.Field(field.name, new arrow.Float32(), field.nullable, metadata);
63
53
  arrowFields.push(arrowField);
64
54
  }
65
55
  }
@@ -67,16 +57,16 @@ function getArrowSchema(schema): Schema {
67
57
  throw new Error('No arrow convertible fields');
68
58
  }
69
59
 
70
- return new Schema(arrowFields);
60
+ return new arrow.Schema(arrowFields);
71
61
  }
72
62
 
73
63
  // Convert from simple loaders.gl arrays to arrow vectors
74
- function getArrowVectors(arrowSchema, data): Vector[] {
64
+ function getArrowVectors(arrowSchema, data): arrow.Vector[] {
75
65
  const arrowVectors: any[] = [];
76
66
  for (const field of arrowSchema.fields) {
77
67
  const vector = data[field.name];
78
68
  if (vector instanceof Float32Array) {
79
- const arrowVector = makeVector(vector);
69
+ const arrowVector = arrow.makeVector(vector);
80
70
  arrowVectors.push(arrowVector);
81
71
  }
82
72
  }
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
4
  import type {Batch, Schema} from '@loaders.gl/schema';
5
- import type {Table as ApacheArrowTable} from 'apache-arrow';
5
+ import type * as arrow from 'apache-arrow';
6
6
 
7
7
  /**
8
8
  * A table organized as an Apache Arrow table
@@ -11,7 +11,7 @@ import type {Table as ApacheArrowTable} from 'apache-arrow';
11
11
  export type ArrowTable = {
12
12
  shape: 'arrow-table';
13
13
  schema?: Schema;
14
- data: ApacheArrowTable;
14
+ data: arrow.Table;
15
15
  };
16
16
 
17
17
  /**
@@ -22,6 +22,6 @@ export type ArrowTableBatch = Batch & {
22
22
  shape: 'arrow-table';
23
23
  schemaType?: 'explicit' | 'deduced';
24
24
  schema?: Schema;
25
- data: ApacheArrowTable; // ApacheRecordBatch;
25
+ data: arrow.Table; // ApacheRecordBatch;
26
26
  length: number;
27
27
  };
@@ -1,4 +1,4 @@
1
- import {Table, Vector, tableToIPC, vectorFromArray} from 'apache-arrow';
1
+ import * as arrow from 'apache-arrow';
2
2
  import {AnyArrayType, VECTOR_TYPES} from '../types';
3
3
 
4
4
  export type ColumnarTable = {
@@ -15,28 +15,28 @@ export type ColumnarTable = {
15
15
  * @returns - encoded ArrayBuffer
16
16
  */
17
17
  export function encodeArrowSync(data: ColumnarTable): ArrayBuffer {
18
- const vectors: Record<string, Vector> = {};
18
+ const vectors: Record<string, arrow.Vector> = {};
19
19
  for (const arrayData of data) {
20
20
  const arrayVector = createVector(arrayData.array, arrayData.type);
21
21
  vectors[arrayData.name] = arrayVector;
22
22
  }
23
- const table = new Table(vectors);
24
- const arrowBuffer = tableToIPC(table);
23
+ const table = new arrow.Table(vectors);
24
+ const arrowBuffer = arrow.tableToIPC(table);
25
25
  return arrowBuffer;
26
26
  }
27
27
 
28
28
  /**
29
- * Create Arrow Vector from given data and vector type
29
+ * Create Arrow arrow.Vector from given data and vector type
30
30
  * @param array {import('../types').AnyArrayType} - columns data
31
31
  * @param type {number} - the writer options
32
32
  * @return a vector of one of vector's types defined in the Apache Arrow library
33
33
  */
34
- function createVector(array, type): Vector {
34
+ function createVector(array, type): arrow.Vector {
35
35
  switch (type) {
36
36
  case VECTOR_TYPES.DATE:
37
- return vectorFromArray(array);
37
+ return arrow.vectorFromArray(array);
38
38
  case VECTOR_TYPES.FLOAT:
39
39
  default:
40
- return vectorFromArray(array);
40
+ return arrow.vectorFromArray(array);
41
41
  }
42
42
  }
@@ -1,6 +1,6 @@
1
1
  // TODO - this import defeats the sophisticated typescript checking in ArrowJS
2
2
  import type {ArrowTableBatch} from './arrow-table';
3
- import {RecordBatchReader, Table as ApacheArrowTable} from 'apache-arrow';
3
+ import * as arrow from 'apache-arrow';
4
4
  // import {isIterable} from '@loaders.gl/core';
5
5
 
6
6
  /**
@@ -8,7 +8,7 @@ import {RecordBatchReader, Table as ApacheArrowTable} from 'apache-arrow';
8
8
  export function parseArrowInBatches(
9
9
  asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>
10
10
  ): AsyncIterable<ArrowTableBatch> {
11
- // Creates the appropriate RecordBatchReader subclasses from the input
11
+ // Creates the appropriate arrow.RecordBatchReader subclasses from the input
12
12
  // This will also close the underlying source in case of early termination or errors
13
13
 
14
14
  // As an optimization, return a non-async iterator
@@ -28,13 +28,13 @@ export function parseArrowInBatches(
28
28
 
29
29
  async function* makeArrowAsyncIterator(): AsyncIterator<ArrowTableBatch> {
30
30
  // @ts-ignore
31
- const readers = RecordBatchReader.readAll(asyncIterator);
31
+ const readers = arrow.RecordBatchReader.readAll(asyncIterator);
32
32
  for await (const reader of readers) {
33
33
  for await (const recordBatch of reader) {
34
34
  const arrowTabledBatch: ArrowTableBatch = {
35
35
  shape: 'arrow-table',
36
36
  batchType: 'data',
37
- data: new ApacheArrowTable([recordBatch]),
37
+ data: new arrow.Table([recordBatch]),
38
38
  length: recordBatch.data.length
39
39
  };
40
40
  // processBatch(recordBatch);
@@ -1,7 +1,7 @@
1
1
  import type {ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';
2
2
  import type {ArrowTable} from './arrow-table';
3
3
  import {convertTable} from '@loaders.gl/schema';
4
- import {tableFromIPC} from 'apache-arrow';
4
+ import * as arrow from 'apache-arrow';
5
5
  import type {ArrowLoaderOptions} from '../arrow-loader';
6
6
  import {
7
7
  convertApacheArrowToArrowTable,
@@ -13,7 +13,7 @@ export default function parseArrowSync(
13
13
  arrayBuffer,
14
14
  options?: ArrowLoaderOptions
15
15
  ): ArrowTable | ColumnarTable | ObjectRowTable {
16
- const apacheArrowTable = tableFromIPC([new Uint8Array(arrayBuffer)]);
16
+ const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
17
17
  const arrowTable = convertApacheArrowToArrowTable(apacheArrowTable);
18
18
 
19
19
  const shape = options?.arrow?.shape || 'arrow-table';
@@ -2,46 +2,27 @@
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
4
  import type {TypedArray} from '@loaders.gl/schema';
5
- import {
6
- DataType,
7
- Float32,
8
- Float64,
9
- Int16,
10
- Int32,
11
- Int8,
12
- Uint16,
13
- Uint32,
14
- Uint8
15
- // Int8Vector,
16
- // Uint8Vector,
17
- // Int16Vector,
18
- // Uint16Vector,
19
- // Int32Vector,
20
- // Uint32Vector,
21
- // Float32Vector,
22
- // Float64Vector
23
- } from 'apache-arrow';
24
- // import {AbstractVector} from 'apache-arrow/vector';
5
+ import * as arrow from 'apache-arrow';
25
6
 
26
7
  /** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */
27
- export function getArrowType(array: TypedArray): DataType {
8
+ export function getArrowType(array: TypedArray): arrow.DataType {
28
9
  switch (array.constructor) {
29
10
  case Int8Array:
30
- return new Int8();
11
+ return new arrow.Int8();
31
12
  case Uint8Array:
32
- return new Uint8();
13
+ return new arrow.Uint8();
33
14
  case Int16Array:
34
- return new Int16();
15
+ return new arrow.Int16();
35
16
  case Uint16Array:
36
- return new Uint16();
17
+ return new arrow.Uint16();
37
18
  case Int32Array:
38
- return new Int32();
19
+ return new arrow.Int32();
39
20
  case Uint32Array:
40
- return new Uint32();
21
+ return new arrow.Uint32();
41
22
  case Float32Array:
42
- return new Float32();
23
+ return new arrow.Float32();
43
24
  case Float64Array:
44
- return new Float64();
25
+ return new arrow.Float64();
45
26
  default:
46
27
  throw new Error('array type not supported');
47
28
  }