@loaders.gl/parquet 4.0.0-alpha.22 → 4.0.0-alpha.24

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 (104) hide show
  1. package/dist/dist.min.js +17 -17
  2. package/dist/dist.min.js.map +3 -3
  3. package/dist/es5/index.js +0 -3
  4. package/dist/es5/index.js.map +1 -1
  5. package/dist/es5/parquet-loader.js +1 -1
  6. package/dist/es5/parquet-wasm-loader.js +1 -1
  7. package/dist/es5/parquet-wasm-writer.js +1 -1
  8. package/dist/es5/parquet-writer.js +2 -3
  9. package/dist/es5/parquet-writer.js.map +1 -1
  10. package/dist/esm/index.js +0 -1
  11. package/dist/esm/index.js.map +1 -1
  12. package/dist/esm/parquet-loader.js +1 -1
  13. package/dist/esm/parquet-wasm-loader.js +1 -1
  14. package/dist/esm/parquet-wasm-writer.js +1 -1
  15. package/dist/esm/parquet-writer.js +2 -3
  16. package/dist/esm/parquet-writer.js.map +1 -1
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/parquet-worker.js +17 -17
  20. package/dist/parquet-worker.js.map +3 -3
  21. package/dist/parquet-writer.d.ts.map +1 -1
  22. package/package.json +11 -9
  23. package/src/index.ts +0 -3
  24. package/src/parquet-writer.ts +1 -3
  25. package/dist/bundle.js +0 -5
  26. package/dist/constants.js +0 -18
  27. package/dist/index.js +0 -58
  28. package/dist/lib/arrow/convert-columns-to-row-group.js +0 -1
  29. package/dist/lib/arrow/convert-row-group-to-columns.js +0 -12
  30. package/dist/lib/arrow/convert-schema-from-parquet.js +0 -86
  31. package/dist/lib/arrow/convert-schema-to-parquet.js +0 -71
  32. package/dist/lib/geo/decode-geo-metadata.js +0 -77
  33. package/dist/lib/geo/geoparquet-schema.js +0 -69
  34. package/dist/lib/parsers/parse-parquet-to-columns.js +0 -46
  35. package/dist/lib/parsers/parse-parquet-to-rows.js +0 -37
  36. package/dist/lib/wasm/encode-parquet-wasm.js +0 -30
  37. package/dist/lib/wasm/load-wasm/index.js +0 -5
  38. package/dist/lib/wasm/load-wasm/load-wasm-browser.js +0 -38
  39. package/dist/lib/wasm/load-wasm/load-wasm-node.js +0 -31
  40. package/dist/lib/wasm/parse-parquet-wasm.js +0 -27
  41. package/dist/parquet-loader.js +0 -41
  42. package/dist/parquet-wasm-loader.js +0 -26
  43. package/dist/parquet-wasm-writer.js +0 -24
  44. package/dist/parquet-writer.js +0 -22
  45. package/dist/parquetjs/codecs/declare.js +0 -2
  46. package/dist/parquetjs/codecs/dictionary.js +0 -14
  47. package/dist/parquetjs/codecs/index.js +0 -55
  48. package/dist/parquetjs/codecs/plain.js +0 -211
  49. package/dist/parquetjs/codecs/rle.js +0 -145
  50. package/dist/parquetjs/compression.js +0 -183
  51. package/dist/parquetjs/encoder/parquet-encoder.js +0 -484
  52. package/dist/parquetjs/parquet-thrift/BoundaryOrder.js +0 -15
  53. package/dist/parquetjs/parquet-thrift/BsonType.js +0 -62
  54. package/dist/parquetjs/parquet-thrift/ColumnChunk.js +0 -211
  55. package/dist/parquetjs/parquet-thrift/ColumnIndex.js +0 -217
  56. package/dist/parquetjs/parquet-thrift/ColumnMetaData.js +0 -402
  57. package/dist/parquetjs/parquet-thrift/ColumnOrder.js +0 -108
  58. package/dist/parquetjs/parquet-thrift/CompressionCodec.js +0 -20
  59. package/dist/parquetjs/parquet-thrift/ConvertedType.js +0 -34
  60. package/dist/parquetjs/parquet-thrift/DataPageHeader.js +0 -170
  61. package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js +0 -230
  62. package/dist/parquetjs/parquet-thrift/DateType.js +0 -62
  63. package/dist/parquetjs/parquet-thrift/DecimalType.js +0 -109
  64. package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js +0 -126
  65. package/dist/parquetjs/parquet-thrift/Encoding.js +0 -20
  66. package/dist/parquetjs/parquet-thrift/EnumType.js +0 -62
  67. package/dist/parquetjs/parquet-thrift/FieldRepetitionType.js +0 -15
  68. package/dist/parquetjs/parquet-thrift/FileMetaData.js +0 -260
  69. package/dist/parquetjs/parquet-thrift/IndexPageHeader.js +0 -62
  70. package/dist/parquetjs/parquet-thrift/IntType.js +0 -109
  71. package/dist/parquetjs/parquet-thrift/JsonType.js +0 -62
  72. package/dist/parquetjs/parquet-thrift/KeyValue.js +0 -106
  73. package/dist/parquetjs/parquet-thrift/ListType.js +0 -62
  74. package/dist/parquetjs/parquet-thrift/LogicalType.js +0 -384
  75. package/dist/parquetjs/parquet-thrift/MapType.js +0 -62
  76. package/dist/parquetjs/parquet-thrift/MicroSeconds.js +0 -62
  77. package/dist/parquetjs/parquet-thrift/MilliSeconds.js +0 -62
  78. package/dist/parquetjs/parquet-thrift/NullType.js +0 -62
  79. package/dist/parquetjs/parquet-thrift/OffsetIndex.js +0 -101
  80. package/dist/parquetjs/parquet-thrift/PageEncodingStats.js +0 -131
  81. package/dist/parquetjs/parquet-thrift/PageHeader.js +0 -220
  82. package/dist/parquetjs/parquet-thrift/PageLocation.js +0 -145
  83. package/dist/parquetjs/parquet-thrift/PageType.js +0 -16
  84. package/dist/parquetjs/parquet-thrift/RowGroup.js +0 -186
  85. package/dist/parquetjs/parquet-thrift/SchemaElement.js +0 -243
  86. package/dist/parquetjs/parquet-thrift/SortingColumn.js +0 -131
  87. package/dist/parquetjs/parquet-thrift/Statistics.js +0 -180
  88. package/dist/parquetjs/parquet-thrift/StringType.js +0 -62
  89. package/dist/parquetjs/parquet-thrift/TimeType.js +0 -110
  90. package/dist/parquetjs/parquet-thrift/TimeUnit.js +0 -131
  91. package/dist/parquetjs/parquet-thrift/TimestampType.js +0 -110
  92. package/dist/parquetjs/parquet-thrift/Type.js +0 -20
  93. package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js +0 -62
  94. package/dist/parquetjs/parquet-thrift/UUIDType.js +0 -62
  95. package/dist/parquetjs/parquet-thrift/index.js +0 -65
  96. package/dist/parquetjs/parser/decoders.js +0 -318
  97. package/dist/parquetjs/parser/parquet-reader.js +0 -200
  98. package/dist/parquetjs/schema/declare.js +0 -12
  99. package/dist/parquetjs/schema/schema.js +0 -162
  100. package/dist/parquetjs/schema/shred.js +0 -355
  101. package/dist/parquetjs/schema/types.js +0 -416
  102. package/dist/parquetjs/utils/file-utils.js +0 -43
  103. package/dist/parquetjs/utils/read-utils.js +0 -109
  104. package/dist/workers/parquet-worker.js +0 -5
@@ -1,416 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromPrimitive = exports.toPrimitive = exports.PARQUET_LOGICAL_TYPES = void 0;
4
- // Forked from https://github.com/kbajalc/parquets under MIT license (Copyright (c) 2017 ironSource Ltd.)
5
- /* eslint-disable camelcase */
6
- const bson_1 = require("@loaders.gl/bson");
7
- exports.PARQUET_LOGICAL_TYPES = {
8
- BOOLEAN: {
9
- primitiveType: 'BOOLEAN',
10
- toPrimitive: toPrimitive_BOOLEAN,
11
- fromPrimitive: fromPrimitive_BOOLEAN
12
- },
13
- INT32: {
14
- primitiveType: 'INT32',
15
- toPrimitive: toPrimitive_INT32
16
- },
17
- INT64: {
18
- primitiveType: 'INT64',
19
- toPrimitive: toPrimitive_INT64
20
- },
21
- INT96: {
22
- primitiveType: 'INT96',
23
- toPrimitive: toPrimitive_INT96
24
- },
25
- FLOAT: {
26
- primitiveType: 'FLOAT',
27
- toPrimitive: toPrimitive_FLOAT
28
- },
29
- DOUBLE: {
30
- primitiveType: 'DOUBLE',
31
- toPrimitive: toPrimitive_DOUBLE
32
- },
33
- BYTE_ARRAY: {
34
- primitiveType: 'BYTE_ARRAY',
35
- toPrimitive: toPrimitive_BYTE_ARRAY
36
- },
37
- FIXED_LEN_BYTE_ARRAY: {
38
- primitiveType: 'FIXED_LEN_BYTE_ARRAY',
39
- toPrimitive: toPrimitive_BYTE_ARRAY
40
- },
41
- UTF8: {
42
- primitiveType: 'BYTE_ARRAY',
43
- originalType: 'UTF8',
44
- toPrimitive: toPrimitive_UTF8,
45
- fromPrimitive: fromPrimitive_UTF8
46
- },
47
- TIME_MILLIS: {
48
- primitiveType: 'INT32',
49
- originalType: 'TIME_MILLIS',
50
- toPrimitive: toPrimitive_TIME_MILLIS
51
- },
52
- TIME_MICROS: {
53
- primitiveType: 'INT64',
54
- originalType: 'TIME_MICROS',
55
- toPrimitive: toPrimitive_TIME_MICROS
56
- },
57
- DATE: {
58
- primitiveType: 'INT32',
59
- originalType: 'DATE',
60
- toPrimitive: toPrimitive_DATE,
61
- fromPrimitive: fromPrimitive_DATE
62
- },
63
- TIMESTAMP_MILLIS: {
64
- primitiveType: 'INT64',
65
- originalType: 'TIMESTAMP_MILLIS',
66
- toPrimitive: toPrimitive_TIMESTAMP_MILLIS,
67
- fromPrimitive: fromPrimitive_TIMESTAMP_MILLIS
68
- },
69
- TIMESTAMP_MICROS: {
70
- primitiveType: 'INT64',
71
- originalType: 'TIMESTAMP_MICROS',
72
- toPrimitive: toPrimitive_TIMESTAMP_MICROS,
73
- fromPrimitive: fromPrimitive_TIMESTAMP_MICROS
74
- },
75
- UINT_8: {
76
- primitiveType: 'INT32',
77
- originalType: 'UINT_8',
78
- toPrimitive: toPrimitive_UINT8
79
- },
80
- UINT_16: {
81
- primitiveType: 'INT32',
82
- originalType: 'UINT_16',
83
- toPrimitive: toPrimitive_UINT16
84
- },
85
- UINT_32: {
86
- primitiveType: 'INT32',
87
- originalType: 'UINT_32',
88
- toPrimitive: toPrimitive_UINT32
89
- },
90
- UINT_64: {
91
- primitiveType: 'INT64',
92
- originalType: 'UINT_64',
93
- toPrimitive: toPrimitive_UINT64
94
- },
95
- INT_8: {
96
- primitiveType: 'INT32',
97
- originalType: 'INT_8',
98
- toPrimitive: toPrimitive_INT8
99
- },
100
- INT_16: {
101
- primitiveType: 'INT32',
102
- originalType: 'INT_16',
103
- toPrimitive: toPrimitive_INT16
104
- },
105
- INT_32: {
106
- primitiveType: 'INT32',
107
- originalType: 'INT_32',
108
- toPrimitive: toPrimitive_INT32
109
- },
110
- INT_64: {
111
- primitiveType: 'INT64',
112
- originalType: 'INT_64',
113
- toPrimitive: toPrimitive_INT64
114
- },
115
- JSON: {
116
- primitiveType: 'BYTE_ARRAY',
117
- originalType: 'JSON',
118
- toPrimitive: toPrimitive_JSON,
119
- fromPrimitive: fromPrimitive_JSON
120
- },
121
- BSON: {
122
- primitiveType: 'BYTE_ARRAY',
123
- originalType: 'BSON',
124
- toPrimitive: toPrimitive_BSON,
125
- fromPrimitive: fromPrimitive_BSON
126
- },
127
- INTERVAL: {
128
- primitiveType: 'FIXED_LEN_BYTE_ARRAY',
129
- originalType: 'INTERVAL',
130
- typeLength: 12,
131
- toPrimitive: toPrimitive_INTERVAL,
132
- fromPrimitive: fromPrimitive_INTERVAL
133
- },
134
- DECIMAL_INT32: {
135
- primitiveType: 'INT32',
136
- originalType: 'DECIMAL_INT32',
137
- toPrimitive: decimalToPrimitive_INT32,
138
- fromPrimitive: decimalFromPrimitive_INT
139
- },
140
- DECIMAL_INT64: {
141
- primitiveType: 'INT64',
142
- originalType: 'DECIMAL_INT64',
143
- toPrimitive: decimalToPrimitive_INT64,
144
- fromPrimitive: decimalFromPrimitive_INT
145
- },
146
- DECIMAL_BYTE_ARRAY: {
147
- primitiveType: 'BYTE_ARRAY',
148
- originalType: 'DECIMAL_BYTE_ARRAY',
149
- toPrimitive: decimalToPrimitive_BYTE_ARRAY,
150
- fromPrimitive: decimalFromPrimitive_BYTE_ARRAY
151
- },
152
- DECIMAL_FIXED_LEN_BYTE_ARRAY: {
153
- primitiveType: 'FIXED_LEN_BYTE_ARRAY',
154
- originalType: 'DECIMAL_FIXED_LEN_BYTE_ARRAY',
155
- toPrimitive: decimalToPrimitive_BYTE_ARRAY,
156
- fromPrimitive: decimalFromPrimitive_BYTE_ARRAY
157
- }
158
- };
159
- /**
160
- * Convert a value from it's native representation to the internal/underlying
161
- * primitive type
162
- */
163
- function toPrimitive(type, value, field) {
164
- if (!(type in exports.PARQUET_LOGICAL_TYPES)) {
165
- throw new Error(`invalid type: ${type}`);
166
- }
167
- return exports.PARQUET_LOGICAL_TYPES[type].toPrimitive(value, field);
168
- }
169
- exports.toPrimitive = toPrimitive;
170
- /**
171
- * Convert a value from it's internal/underlying primitive representation to
172
- * the native representation
173
- */
174
- function fromPrimitive(type, value, field) {
175
- if (!(type in exports.PARQUET_LOGICAL_TYPES)) {
176
- throw new Error(`invalid type: ${type}`);
177
- }
178
- if ('fromPrimitive' in exports.PARQUET_LOGICAL_TYPES[type]) {
179
- return exports.PARQUET_LOGICAL_TYPES[type].fromPrimitive?.(value, field);
180
- // tslint:disable-next-line:no-else-after-return
181
- }
182
- return value;
183
- }
184
- exports.fromPrimitive = fromPrimitive;
185
- function toPrimitive_BOOLEAN(value) {
186
- return Boolean(value);
187
- }
188
- function fromPrimitive_BOOLEAN(value) {
189
- return Boolean(value);
190
- }
191
- function toPrimitive_FLOAT(value) {
192
- const v = parseFloat(value);
193
- if (isNaN(v)) {
194
- throw new Error(`invalid value for FLOAT: ${value}`);
195
- }
196
- return v;
197
- }
198
- function toPrimitive_DOUBLE(value) {
199
- const v = parseFloat(value);
200
- if (isNaN(v)) {
201
- throw new Error(`invalid value for DOUBLE: ${value}`);
202
- }
203
- return v;
204
- }
205
- function toPrimitive_INT8(value) {
206
- const v = parseInt(value, 10);
207
- if (v < -0x80 || v > 0x7f || isNaN(v)) {
208
- throw new Error(`invalid value for INT8: ${value}`);
209
- }
210
- return v;
211
- }
212
- function toPrimitive_UINT8(value) {
213
- const v = parseInt(value, 10);
214
- if (v < 0 || v > 0xff || isNaN(v)) {
215
- throw new Error(`invalid value for UINT8: ${value}`);
216
- }
217
- return v;
218
- }
219
- function toPrimitive_INT16(value) {
220
- const v = parseInt(value, 10);
221
- if (v < -0x8000 || v > 0x7fff || isNaN(v)) {
222
- throw new Error(`invalid value for INT16: ${value}`);
223
- }
224
- return v;
225
- }
226
- function toPrimitive_UINT16(value) {
227
- const v = parseInt(value, 10);
228
- if (v < 0 || v > 0xffff || isNaN(v)) {
229
- throw new Error(`invalid value for UINT16: ${value}`);
230
- }
231
- return v;
232
- }
233
- function toPrimitive_INT32(value) {
234
- const v = parseInt(value, 10);
235
- if (v < -0x80000000 || v > 0x7fffffff || isNaN(v)) {
236
- throw new Error(`invalid value for INT32: ${value}`);
237
- }
238
- return v;
239
- }
240
- function decimalToPrimitive_INT32(value, field) {
241
- const primitiveValue = value * 10 ** (field.scale || 0);
242
- const v = Math.round(((primitiveValue * 10 ** -field.presision) % 1) * 10 ** field.presision);
243
- if (v < -0x80000000 || v > 0x7fffffff || isNaN(v)) {
244
- throw new Error(`invalid value for INT32: ${value}`);
245
- }
246
- return v;
247
- }
248
- function toPrimitive_UINT32(value) {
249
- const v = parseInt(value, 10);
250
- if (v < 0 || v > 0xffffffffffff || isNaN(v)) {
251
- throw new Error(`invalid value for UINT32: ${value}`);
252
- }
253
- return v;
254
- }
255
- function toPrimitive_INT64(value) {
256
- const v = parseInt(value, 10);
257
- if (isNaN(v)) {
258
- throw new Error(`invalid value for INT64: ${value}`);
259
- }
260
- return v;
261
- }
262
- function decimalToPrimitive_INT64(value, field) {
263
- const primitiveValue = value * 10 ** (field.scale || 0);
264
- const v = Math.round(((primitiveValue * 10 ** -field.presision) % 1) * 10 ** field.presision);
265
- if (isNaN(v)) {
266
- throw new Error(`invalid value for INT64: ${value}`);
267
- }
268
- return v;
269
- }
270
- function toPrimitive_UINT64(value) {
271
- const v = parseInt(value, 10);
272
- if (v < 0 || isNaN(v)) {
273
- throw new Error(`invalid value for UINT64: ${value}`);
274
- }
275
- return v;
276
- }
277
- function toPrimitive_INT96(value) {
278
- const v = parseInt(value, 10);
279
- if (isNaN(v)) {
280
- throw new Error(`invalid value for INT96: ${value}`);
281
- }
282
- return v;
283
- }
284
- function toPrimitive_BYTE_ARRAY(value) {
285
- return Buffer.from(value);
286
- }
287
- function decimalToPrimitive_BYTE_ARRAY(value) {
288
- // TBD
289
- return Buffer.from(value);
290
- }
291
- function toPrimitive_UTF8(value) {
292
- return Buffer.from(value, 'utf8');
293
- }
294
- function fromPrimitive_UTF8(value) {
295
- return value.toString();
296
- }
297
- function toPrimitive_JSON(value) {
298
- return Buffer.from(JSON.stringify(value));
299
- }
300
- function fromPrimitive_JSON(value) {
301
- return JSON.parse(value);
302
- }
303
- function toPrimitive_BSON(value) {
304
- const arrayBuffer = bson_1.BSONWriter.encodeSync?.(value);
305
- return Buffer.from(arrayBuffer);
306
- }
307
- function fromPrimitive_BSON(value) {
308
- return bson_1.BSONLoader.parseSync?.(value);
309
- }
310
- function toPrimitive_TIME_MILLIS(value) {
311
- const v = parseInt(value, 10);
312
- if (v < 0 || v > 0xffffffffffffffff || isNaN(v)) {
313
- throw new Error(`invalid value for TIME_MILLIS: ${value}`);
314
- }
315
- return v;
316
- }
317
- function toPrimitive_TIME_MICROS(value) {
318
- const v = parseInt(value, 10);
319
- if (v < 0 || isNaN(v)) {
320
- throw new Error(`invalid value for TIME_MICROS: ${value}`);
321
- }
322
- return v;
323
- }
324
- const kMillisPerDay = 86400000;
325
- function toPrimitive_DATE(value) {
326
- /* convert from date */
327
- if (value instanceof Date) {
328
- return value.getTime() / kMillisPerDay;
329
- }
330
- /* convert from integer */
331
- {
332
- const v = parseInt(value, 10);
333
- if (v < 0 || isNaN(v)) {
334
- throw new Error(`invalid value for DATE: ${value}`);
335
- }
336
- return v;
337
- }
338
- }
339
- function fromPrimitive_DATE(value) {
340
- return new Date(value * kMillisPerDay);
341
- }
342
- function toPrimitive_TIMESTAMP_MILLIS(value) {
343
- /* convert from date */
344
- if (value instanceof Date) {
345
- return value.getTime();
346
- }
347
- /* convert from integer */
348
- {
349
- const v = parseInt(value, 10);
350
- if (v < 0 || isNaN(v)) {
351
- throw new Error(`invalid value for TIMESTAMP_MILLIS: ${value}`);
352
- }
353
- return v;
354
- }
355
- }
356
- function fromPrimitive_TIMESTAMP_MILLIS(value) {
357
- return new Date(value);
358
- }
359
- function toPrimitive_TIMESTAMP_MICROS(value) {
360
- /* convert from date */
361
- if (value instanceof Date) {
362
- return value.getTime() * 1000;
363
- }
364
- /* convert from integer */
365
- {
366
- const v = parseInt(value, 10);
367
- if (v < 0 || isNaN(v)) {
368
- throw new Error(`invalid value for TIMESTAMP_MICROS: ${value}`);
369
- }
370
- return v;
371
- }
372
- }
373
- function fromPrimitive_TIMESTAMP_MICROS(value) {
374
- return new Date(value / 1000);
375
- }
376
- function toPrimitive_INTERVAL(value) {
377
- if (!value.months || !value.days || !value.milliseconds) {
378
- throw new Error('value for INTERVAL must be object { months: ..., days: ..., milliseconds: ... }');
379
- }
380
- const buf = Buffer.alloc(12);
381
- buf.writeUInt32LE(value.months, 0);
382
- buf.writeUInt32LE(value.days, 4);
383
- buf.writeUInt32LE(value.milliseconds, 8);
384
- return buf;
385
- }
386
- function fromPrimitive_INTERVAL(value) {
387
- const buf = Buffer.from(value);
388
- const months = buf.readUInt32LE(0);
389
- const days = buf.readUInt32LE(4);
390
- const millis = buf.readUInt32LE(8);
391
- return { months, days, milliseconds: millis };
392
- }
393
- function decimalFromPrimitive_INT(value, field) {
394
- const presisionInt = Math.round(((value * 10 ** -field.presision) % 1) * 10 ** field.presision);
395
- return presisionInt * 10 ** -(field.scale || 0);
396
- }
397
- function decimalFromPrimitive_BYTE_ARRAY(value, field) {
398
- let number = 0;
399
- if (value.length <= 4) {
400
- // Bytewise operators faster. Use them if it is possible
401
- for (let i = 0; i < value.length; i++) {
402
- // `value.length - i - 1` bytes have reverse order (big-endian)
403
- const component = value[i] << (8 * (value.length - i - 1));
404
- number += component;
405
- }
406
- }
407
- else {
408
- for (let i = 0; i < value.length; i++) {
409
- // `value.length - i - 1` bytes have reverse order (big-endian)
410
- const component = value[i] * 2 ** (8 * (value.length - 1 - i));
411
- number += component;
412
- }
413
- }
414
- const presisionInt = Math.round(((number * 10 ** -field.presision) % 1) * 10 ** field.presision);
415
- return presisionInt * 10 ** -(field.scale || 0);
416
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.osopen = exports.osclose = exports.oswrite = exports.load = void 0;
4
- // Forked from https://github.com/kbajalc/parquets under MIT license (Copyright (c) 2017 ironSource Ltd.)
5
- const loader_utils_1 = require("@loaders.gl/loader-utils");
6
- function load(name) {
7
- return (module || global).require(name);
8
- }
9
- exports.load = load;
10
- function oswrite(os, buf) {
11
- return new Promise((resolve, reject) => {
12
- os.write(buf, (err) => {
13
- if (err) {
14
- reject(err);
15
- }
16
- else {
17
- resolve();
18
- }
19
- });
20
- });
21
- }
22
- exports.oswrite = oswrite;
23
- function osclose(os) {
24
- return new Promise((resolve, reject) => {
25
- os.close((err) => {
26
- if (err) {
27
- reject(err);
28
- }
29
- else {
30
- resolve();
31
- }
32
- });
33
- });
34
- }
35
- exports.osclose = osclose;
36
- function osopen(path, opts) {
37
- return new Promise((resolve, reject) => {
38
- const outputStream = loader_utils_1.fs.createWriteStream(path, opts);
39
- outputStream.once('open', (fd) => resolve(outputStream));
40
- outputStream.once('error', (err) => reject(err));
41
- });
42
- }
43
- exports.osopen = osopen;
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fieldIndexOf = exports.getBitWidth = exports.decodePageHeader = exports.decodeFileMetadata = exports.getThriftEnum = exports.decodeThrift = exports.serializeThrift = void 0;
4
- const thrift_1 = require("thrift");
5
- const parquet_thrift_1 = require("../parquet-thrift");
6
- class UFramedTransport extends thrift_1.TFramedTransport {
7
- constructor() {
8
- super(...arguments);
9
- this.readPos = 0;
10
- }
11
- }
12
- /**
13
- * Helper function that serializes a thrift object into a buffer
14
- */
15
- function serializeThrift(obj) {
16
- const output = [];
17
- const transport = new thrift_1.TBufferedTransport(undefined, (buf) => {
18
- output.push(buf);
19
- });
20
- const protocol = new thrift_1.TCompactProtocol(transport);
21
- obj.write(protocol);
22
- transport.flush();
23
- return Buffer.concat(output);
24
- }
25
- exports.serializeThrift = serializeThrift;
26
- function decodeThrift(obj, buf, offset) {
27
- if (!offset) {
28
- // tslint:disable-next-line:no-parameter-reassignment
29
- offset = 0;
30
- }
31
- const transport = new UFramedTransport(buf);
32
- transport.readPos = offset;
33
- const protocol = new thrift_1.TCompactProtocol(transport);
34
- obj.read(protocol);
35
- return transport.readPos - offset;
36
- }
37
- exports.decodeThrift = decodeThrift;
38
- /**
39
- * FIXME not ideal that this is linear
40
- */
41
- function getThriftEnum(klass, value) {
42
- for (const k in klass) {
43
- if (klass[k] === value) {
44
- return k;
45
- }
46
- }
47
- throw new Error('Invalid ENUM value');
48
- }
49
- exports.getThriftEnum = getThriftEnum;
50
- function decodeFileMetadata(buf, offset) {
51
- if (!offset) {
52
- // tslint:disable-next-line:no-parameter-reassignment
53
- offset = 0;
54
- }
55
- const transport = new UFramedTransport(buf);
56
- transport.readPos = offset;
57
- const protocol = new thrift_1.TCompactProtocol(transport);
58
- const metadata = parquet_thrift_1.FileMetaData.read(protocol);
59
- return { length: transport.readPos - offset, metadata };
60
- }
61
- exports.decodeFileMetadata = decodeFileMetadata;
62
- function decodePageHeader(buf, offset) {
63
- if (!offset) {
64
- // tslint:disable-next-line:no-parameter-reassignment
65
- offset = 0;
66
- }
67
- const transport = new UFramedTransport(buf);
68
- transport.readPos = offset;
69
- const protocol = new thrift_1.TCompactProtocol(transport);
70
- const pageHeader = parquet_thrift_1.PageHeader.read(protocol);
71
- return { length: transport.readPos - offset, pageHeader };
72
- }
73
- exports.decodePageHeader = decodePageHeader;
74
- /**
75
- * Get the number of bits required to store a given value
76
- */
77
- function getBitWidth(val) {
78
- if (val === 0) {
79
- return 0;
80
- // tslint:disable-next-line:no-else-after-return
81
- }
82
- return Math.ceil(Math.log2(val + 1));
83
- }
84
- exports.getBitWidth = getBitWidth;
85
- // Supports MQTT path wildcards
86
- // + all immediate children
87
- // # all descendents
88
- function fieldIndexOf(arr, elem) {
89
- for (let j = 0; j < arr.length; j++) {
90
- if (arr[j].length > elem.length) {
91
- continue; // eslint-disable-line no-continue
92
- }
93
- let m = true;
94
- for (let i = 0; i < elem.length; i++) {
95
- if (arr[j][i] === elem[i] || arr[j][i] === '+' || arr[j][i] === '#') {
96
- continue; // eslint-disable-line no-continue
97
- }
98
- if (i >= arr[j].length && arr[j][arr[j].length - 1] === '#') {
99
- continue; // eslint-disable-line no-continue
100
- }
101
- m = false;
102
- break;
103
- }
104
- if (m)
105
- return j;
106
- }
107
- return -1;
108
- }
109
- exports.fieldIndexOf = fieldIndexOf;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_utils_1 = require("@loaders.gl/loader-utils");
4
- const index_1 = require("../index");
5
- (0, loader_utils_1.createLoaderWorker)(index_1.ParquetLoader);