@loaders.gl/parquet 3.1.0-alpha.5 → 3.1.0-beta.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.
- package/dist/bundle.d.ts +1 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/dist.min.js +27 -13
- package/dist/dist.min.js.map +7 -1
- package/dist/es5/index.js +6 -26
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/parquet-loader.js +1 -1
- package/dist/es5/parquet-loader.js.map +1 -1
- package/dist/es5/parquet-writer.js +1 -1
- package/dist/es5/parquet-writer.js.map +1 -1
- package/dist/es5/parquetjs/codecs/rle.js +1 -1
- package/dist/es5/parquetjs/codecs/rle.js.map +1 -1
- package/dist/es5/parquetjs/compression.js +1 -12
- package/dist/es5/parquetjs/compression.js.map +1 -1
- package/dist/es5/parquetjs/parser/decoders.js +1 -1
- package/dist/es5/parquetjs/parser/decoders.js.map +1 -1
- package/dist/es5/parquetjs/parser/parquet-envelope-reader.js +0 -13
- package/dist/es5/parquetjs/parser/parquet-envelope-reader.js.map +1 -1
- package/dist/es5/parquetjs/parser/parquet-reader.js +0 -13
- package/dist/es5/parquetjs/parser/parquet-reader.js.map +1 -1
- package/dist/es5/parquetjs/utils/file-utils.js +0 -53
- package/dist/es5/parquetjs/utils/file-utils.js.map +1 -1
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/parquet-loader.js +1 -1
- package/dist/esm/parquet-loader.js.map +1 -1
- package/dist/esm/parquet-writer.js +1 -1
- package/dist/esm/parquet-writer.js.map +1 -1
- package/dist/esm/parquetjs/codecs/rle.js +1 -1
- package/dist/esm/parquetjs/codecs/rle.js.map +1 -1
- package/dist/esm/parquetjs/compression.js +1 -10
- package/dist/esm/parquetjs/compression.js.map +1 -1
- package/dist/esm/parquetjs/parser/decoders.js +1 -1
- package/dist/esm/parquetjs/parser/decoders.js.map +1 -1
- package/dist/esm/parquetjs/parser/parquet-envelope-reader.js +0 -9
- package/dist/esm/parquetjs/parser/parquet-envelope-reader.js.map +1 -1
- package/dist/esm/parquetjs/parser/parquet-reader.js +0 -13
- package/dist/esm/parquetjs/parser/parquet-reader.js.map +1 -1
- package/dist/esm/parquetjs/utils/file-utils.js +0 -45
- package/dist/esm/parquetjs/utils/file-utils.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/lib/convert-schema.d.ts +1 -0
- package/dist/lib/convert-schema.d.ts.map +1 -0
- package/dist/lib/convert-schema.js +70 -0
- package/dist/lib/parse-parquet.d.ts +1 -0
- package/dist/lib/parse-parquet.d.ts.map +1 -0
- package/dist/lib/parse-parquet.js +28 -0
- package/dist/lib/read-array-buffer.d.ts +1 -0
- package/dist/lib/read-array-buffer.d.ts.map +1 -0
- package/dist/lib/read-array-buffer.js +29 -0
- package/dist/parquet-loader.d.ts +1 -0
- package/dist/parquet-loader.d.ts.map +1 -0
- package/dist/parquet-loader.js +27 -0
- package/dist/parquet-worker.js +27 -13
- package/dist/parquet-worker.js.map +7 -1
- package/dist/parquet-writer.d.ts +1 -0
- package/dist/parquet-writer.d.ts.map +1 -0
- package/dist/parquet-writer.js +21 -0
- package/dist/parquetjs/codecs/declare.d.ts +1 -0
- package/dist/parquetjs/codecs/declare.d.ts.map +1 -0
- package/dist/parquetjs/codecs/declare.js +2 -0
- package/dist/parquetjs/codecs/dictionary.d.ts +1 -0
- package/dist/parquetjs/codecs/dictionary.d.ts.map +1 -0
- package/dist/parquetjs/codecs/dictionary.js +14 -0
- package/dist/parquetjs/codecs/index.d.ts +1 -0
- package/dist/parquetjs/codecs/index.d.ts.map +1 -0
- package/dist/parquetjs/codecs/index.js +51 -0
- package/dist/parquetjs/codecs/plain.d.ts +1 -0
- package/dist/parquetjs/codecs/plain.d.ts.map +1 -0
- package/dist/parquetjs/codecs/plain.js +211 -0
- package/dist/parquetjs/codecs/rle.d.ts +1 -0
- package/dist/parquetjs/codecs/rle.d.ts.map +1 -0
- package/dist/parquetjs/codecs/rle.js +145 -0
- package/dist/parquetjs/compression.d.ts +1 -0
- package/dist/parquetjs/compression.d.ts.map +1 -0
- package/dist/parquetjs/compression.js +168 -0
- package/dist/parquetjs/encoder/writer.d.ts +1 -0
- package/dist/parquetjs/encoder/writer.d.ts.map +1 -0
- package/dist/parquetjs/encoder/writer.js +478 -0
- package/dist/parquetjs/file.d.ts +1 -0
- package/dist/parquetjs/file.d.ts.map +1 -0
- package/dist/parquetjs/file.js +99 -0
- package/dist/parquetjs/parquet-thrift/BoundaryOrder.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/BoundaryOrder.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/BoundaryOrder.js +15 -0
- package/dist/parquetjs/parquet-thrift/BsonType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/BsonType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/BsonType.js +58 -0
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnChunk.js +207 -0
- package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js +213 -0
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnMetaData.js +398 -0
- package/dist/parquetjs/parquet-thrift/ColumnOrder.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnOrder.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ColumnOrder.js +104 -0
- package/dist/parquetjs/parquet-thrift/CompressionCodec.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/CompressionCodec.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/CompressionCodec.js +20 -0
- package/dist/parquetjs/parquet-thrift/ConvertedType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/ConvertedType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ConvertedType.js +34 -0
- package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/DataPageHeader.js +166 -0
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js +226 -0
- package/dist/parquetjs/parquet-thrift/DateType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/DateType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/DateType.js +58 -0
- package/dist/parquetjs/parquet-thrift/DecimalType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/DecimalType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/DecimalType.js +105 -0
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js +122 -0
- package/dist/parquetjs/parquet-thrift/Encoding.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/Encoding.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/Encoding.js +20 -0
- package/dist/parquetjs/parquet-thrift/EnumType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/EnumType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/EnumType.js +58 -0
- package/dist/parquetjs/parquet-thrift/FieldRepetitionType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/FieldRepetitionType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/FieldRepetitionType.js +15 -0
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/FileMetaData.js +256 -0
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/IndexPageHeader.js +58 -0
- package/dist/parquetjs/parquet-thrift/IntType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/IntType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/IntType.js +105 -0
- package/dist/parquetjs/parquet-thrift/JsonType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/JsonType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/JsonType.js +58 -0
- package/dist/parquetjs/parquet-thrift/KeyValue.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/KeyValue.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/KeyValue.js +102 -0
- package/dist/parquetjs/parquet-thrift/ListType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/ListType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/ListType.js +58 -0
- package/dist/parquetjs/parquet-thrift/LogicalType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/LogicalType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/LogicalType.js +380 -0
- package/dist/parquetjs/parquet-thrift/MapType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/MapType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/MapType.js +58 -0
- package/dist/parquetjs/parquet-thrift/MicroSeconds.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/MicroSeconds.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/MicroSeconds.js +58 -0
- package/dist/parquetjs/parquet-thrift/MilliSeconds.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/MilliSeconds.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/MilliSeconds.js +58 -0
- package/dist/parquetjs/parquet-thrift/NullType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/NullType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/NullType.js +58 -0
- package/dist/parquetjs/parquet-thrift/OffsetIndex.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/OffsetIndex.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/OffsetIndex.js +97 -0
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/PageEncodingStats.js +127 -0
- package/dist/parquetjs/parquet-thrift/PageHeader.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/PageHeader.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/PageHeader.js +216 -0
- package/dist/parquetjs/parquet-thrift/PageLocation.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/PageLocation.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/PageLocation.js +141 -0
- package/dist/parquetjs/parquet-thrift/PageType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/PageType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/PageType.js +16 -0
- package/dist/parquetjs/parquet-thrift/RowGroup.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/RowGroup.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/RowGroup.js +182 -0
- package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/SchemaElement.js +239 -0
- package/dist/parquetjs/parquet-thrift/SortingColumn.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/SortingColumn.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/SortingColumn.js +127 -0
- package/dist/parquetjs/parquet-thrift/Statistics.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/Statistics.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/Statistics.js +176 -0
- package/dist/parquetjs/parquet-thrift/StringType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/StringType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/StringType.js +58 -0
- package/dist/parquetjs/parquet-thrift/TimeType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/TimeType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/TimeType.js +106 -0
- package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/TimeUnit.js +127 -0
- package/dist/parquetjs/parquet-thrift/TimestampType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/TimestampType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/TimestampType.js +106 -0
- package/dist/parquetjs/parquet-thrift/Type.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/Type.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/Type.js +20 -0
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js +58 -0
- package/dist/parquetjs/parquet-thrift/UUIDType.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/UUIDType.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/UUIDType.js +58 -0
- package/dist/parquetjs/parquet-thrift/index.d.ts +1 -0
- package/dist/parquetjs/parquet-thrift/index.d.ts.map +1 -0
- package/dist/parquetjs/parquet-thrift/index.js +61 -0
- package/dist/parquetjs/parser/decoders.d.ts +1 -0
- package/dist/parquetjs/parser/decoders.d.ts.map +1 -0
- package/dist/parquetjs/parser/decoders.js +318 -0
- package/dist/parquetjs/parser/parquet-cursor.d.ts +1 -0
- package/dist/parquetjs/parser/parquet-cursor.d.ts.map +1 -0
- package/dist/parquetjs/parser/parquet-cursor.js +74 -0
- package/dist/parquetjs/parser/parquet-envelope-reader.d.ts +1 -1
- package/dist/parquetjs/parser/parquet-envelope-reader.d.ts.map +1 -0
- package/dist/parquetjs/parser/parquet-envelope-reader.js +136 -0
- package/dist/parquetjs/parser/parquet-reader.d.ts +1 -5
- package/dist/parquetjs/parser/parquet-reader.d.ts.map +1 -0
- package/dist/parquetjs/parser/parquet-reader.js +134 -0
- package/dist/parquetjs/schema/declare.d.ts +1 -0
- package/dist/parquetjs/schema/declare.d.ts.map +1 -0
- package/dist/parquetjs/schema/declare.js +10 -0
- package/dist/parquetjs/schema/schema.d.ts +1 -0
- package/dist/parquetjs/schema/schema.d.ts.map +1 -0
- package/dist/parquetjs/schema/schema.js +162 -0
- package/dist/parquetjs/schema/shred.d.ts +1 -0
- package/dist/parquetjs/schema/shred.d.ts.map +1 -0
- package/dist/parquetjs/schema/shred.js +225 -0
- package/dist/parquetjs/schema/types.d.ts +1 -0
- package/dist/parquetjs/schema/types.d.ts.map +1 -0
- package/dist/parquetjs/schema/types.js +418 -0
- package/dist/parquetjs/utils/buffer-utils.d.ts +1 -0
- package/dist/parquetjs/utils/buffer-utils.d.ts.map +1 -0
- package/dist/parquetjs/utils/buffer-utils.js +22 -0
- package/dist/parquetjs/utils/file-utils.d.ts +1 -4
- package/dist/parquetjs/utils/file-utils.d.ts.map +1 -0
- package/dist/parquetjs/utils/file-utils.js +46 -0
- package/dist/parquetjs/utils/read-utils.d.ts +1 -0
- package/dist/parquetjs/utils/read-utils.d.ts.map +1 -0
- package/dist/parquetjs/utils/read-utils.js +109 -0
- package/dist/workers/parquet-worker.d.ts +1 -0
- package/dist/workers/parquet-worker.d.ts.map +1 -0
- package/dist/workers/parquet-worker.js +5 -0
- package/package.json +7 -8
- package/src/index.ts +3 -3
- package/src/parquetjs/codecs/rle.ts +1 -1
- package/src/parquetjs/compression.ts +10 -10
- package/src/parquetjs/parser/decoders.ts +1 -1
- package/src/parquetjs/parser/parquet-envelope-reader.ts +0 -11
- package/src/parquetjs/parser/parquet-reader.ts +0 -16
- package/src/parquetjs/utils/file-utils.ts +0 -49
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
exports.osopen = exports.osclose = exports.oswrite = exports.load = void 0;
|
|
7
|
+
// Forked from https://github.com/kbajalc/parquets under MIT license (Copyright (c) 2017 ironSource Ltd.)
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
function load(name) {
|
|
10
|
+
return (module || global).require(name);
|
|
11
|
+
}
|
|
12
|
+
exports.load = load;
|
|
13
|
+
function oswrite(os, buf) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
os.write(buf, (err) => {
|
|
16
|
+
if (err) {
|
|
17
|
+
reject(err);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
resolve();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.oswrite = oswrite;
|
|
26
|
+
function osclose(os) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
os.close((err) => {
|
|
29
|
+
if (err) {
|
|
30
|
+
reject(err);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
resolve();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.osclose = osclose;
|
|
39
|
+
function osopen(path, opts) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const outputStream = fs_1.default.createWriteStream(path, opts);
|
|
42
|
+
outputStream.once('open', (fd) => resolve(outputStream));
|
|
43
|
+
outputStream.once('error', (err) => reject(err));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.osopen = osopen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-utils.d.ts","sourceRoot":"","sources":["../../../src/parquetjs/utils/read-utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAM3D;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAYhD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,UAWlE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAOxE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;;;EAW9D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;;;EAW5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAKD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAmBpE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parquet-worker.d.ts","sourceRoot":"","sources":["../../src/workers/parquet-worker.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/parquet",
|
|
3
|
-
"version": "3.1.0-
|
|
3
|
+
"version": "3.1.0-beta.5",
|
|
4
4
|
"description": "Framework-independent loader for Apache Parquet files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,9 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"pre-build": "npm run build-worker && npm run build-bundle",
|
|
32
|
-
"
|
|
33
|
-
"build-
|
|
34
|
-
"build-worker": "webpack --entry ./src/workers/parquet-worker.ts --output ./dist/parquet-worker.js --config ../../scripts/webpack/worker.js"
|
|
32
|
+
"build-bundle": "esbuild src/bundle.ts --outfile=dist/dist.min.js --bundle --minify --sourcemap --external:{util,fs,path,crypto}",
|
|
33
|
+
"build-worker": "esbuild src/workers/parquet-worker.ts --outfile=dist/parquet-worker.js --bundle --minify --sourcemap --external:{util,fs,path,crypto}"
|
|
35
34
|
},
|
|
36
35
|
"browser": {
|
|
37
36
|
"child_process": false,
|
|
@@ -40,9 +39,9 @@
|
|
|
40
39
|
"lzo": false
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@loaders.gl/compression": "3.1.0-
|
|
44
|
-
"@loaders.gl/loader-utils": "3.1.0-
|
|
45
|
-
"@loaders.gl/schema": "3.1.0-
|
|
42
|
+
"@loaders.gl/compression": "3.1.0-beta.5",
|
|
43
|
+
"@loaders.gl/loader-utils": "3.1.0-beta.5",
|
|
44
|
+
"@loaders.gl/schema": "3.1.0-beta.5",
|
|
46
45
|
"async-mutex": "^0.2.2",
|
|
47
46
|
"brotli": "^1.3.2",
|
|
48
47
|
"bson": "^1.0.4",
|
|
@@ -63,5 +62,5 @@
|
|
|
63
62
|
"@types/thrift": "^0.10.8",
|
|
64
63
|
"@types/varint": "^5.0.0"
|
|
65
64
|
},
|
|
66
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "5d66468457cc878d2dbff3d7807d737ceb181c9a"
|
|
67
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -22,10 +22,10 @@ export {ParquetWriter as _ParquetWriter} from './parquet-writer';
|
|
|
22
22
|
|
|
23
23
|
export {preloadCompressions} from './parquetjs/compression';
|
|
24
24
|
|
|
25
|
-
export {ParquetEnvelopeReader} from './parquetjs/parser/parquet-envelope-reader';
|
|
26
|
-
export {ParquetReader} from './parquetjs/parser/parquet-reader';
|
|
27
|
-
export {ParquetWriter, ParquetEnvelopeWriter, ParquetTransformer} from './parquetjs/encoder/writer';
|
|
28
25
|
export {ParquetSchema} from './parquetjs/schema/schema';
|
|
26
|
+
export {ParquetReader} from './parquetjs/parser/parquet-reader';
|
|
27
|
+
export {ParquetEnvelopeReader} from './parquetjs/parser/parquet-envelope-reader';
|
|
28
|
+
// export {ParquetWriter, ParquetEnvelopeWriter, ParquetTransformer} from './parquetjs/encoder/writer';
|
|
29
29
|
export {convertParquetToArrowSchema} from './lib/convert-schema';
|
|
30
30
|
|
|
31
31
|
// TESTS
|
|
@@ -19,23 +19,23 @@ import {toArrayBuffer, toBuffer} from './utils/buffer-utils';
|
|
|
19
19
|
// TODO switch to worker compression to avoid bundling...
|
|
20
20
|
|
|
21
21
|
// import brotli from 'brotli'; - brotli has problems with decompress in browsers
|
|
22
|
-
import brotliDecompress from 'brotli/decompress';
|
|
22
|
+
// import brotliDecompress from 'brotli/decompress';
|
|
23
23
|
import lz4js from 'lz4js';
|
|
24
24
|
import lzo from 'lzo';
|
|
25
|
-
import {ZstdCodec} from 'zstd-codec';
|
|
25
|
+
// import {ZstdCodec} from 'zstd-codec';
|
|
26
26
|
|
|
27
27
|
// Inject large dependencies through Compression constructor options
|
|
28
28
|
const modules = {
|
|
29
29
|
// brotli has problems with decompress in browsers
|
|
30
|
-
brotli: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
30
|
+
// brotli: {
|
|
31
|
+
// decompress: brotliDecompress,
|
|
32
|
+
// compress: () => {
|
|
33
|
+
// throw new Error('brotli compress');
|
|
34
|
+
// }
|
|
35
|
+
// },
|
|
36
36
|
lz4js,
|
|
37
|
-
lzo
|
|
38
|
-
'zstd-codec': ZstdCodec
|
|
37
|
+
lzo
|
|
38
|
+
// 'zstd-codec': ZstdCodec
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// See https://github.com/apache/parquet-format/blob/master/Compression.md
|
|
@@ -95,7 +95,7 @@ export async function decodePage(
|
|
|
95
95
|
options: ParquetOptions
|
|
96
96
|
): Promise<ParquetPageData> {
|
|
97
97
|
let page;
|
|
98
|
-
const {pageHeader, length} =
|
|
98
|
+
const {pageHeader, length} = decodePageHeader(cursor.buffer, cursor.offset);
|
|
99
99
|
cursor.offset += length;
|
|
100
100
|
|
|
101
101
|
const pageType = getThriftEnum(PageType, pageHeader.type);
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
PrimitiveType,
|
|
10
10
|
ParquetOptions
|
|
11
11
|
} from '../schema/declare';
|
|
12
|
-
import {fstat, fopen, fread, fclose} from '../utils/file-utils';
|
|
13
12
|
import {decodeFileMetadata, getThriftEnum, fieldIndexOf} from '../utils/read-utils';
|
|
14
13
|
import {decodeDataPages, decodePage} from './decoders';
|
|
15
14
|
|
|
@@ -31,16 +30,6 @@ export class ParquetEnvelopeReader {
|
|
|
31
30
|
public fileSize: number;
|
|
32
31
|
public defaultDictionarySize: number;
|
|
33
32
|
|
|
34
|
-
static async openFile(filePath: string): Promise<ParquetEnvelopeReader> {
|
|
35
|
-
const fileStat = await fstat(filePath);
|
|
36
|
-
const fileDescriptor = await fopen(filePath);
|
|
37
|
-
|
|
38
|
-
const readFn = fread.bind(undefined, fileDescriptor);
|
|
39
|
-
const closeFn = fclose.bind(undefined, fileDescriptor);
|
|
40
|
-
|
|
41
|
-
return new ParquetEnvelopeReader(readFn, closeFn, fileStat.size);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
33
|
static async openBuffer(buffer: Buffer): Promise<ParquetEnvelopeReader> {
|
|
45
34
|
const readFn = (position: number, length: number) =>
|
|
46
35
|
Promise.resolve(buffer.slice(position, position + length));
|
|
@@ -53,22 +53,6 @@ export class ParquetReader<T> implements AsyncIterable<T> {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Open the parquet file pointed to by the specified path and return a new
|
|
58
|
-
* parquet reader
|
|
59
|
-
*/
|
|
60
|
-
static async openFile<T>(filePath: string): Promise<ParquetReader<T>> {
|
|
61
|
-
const envelopeReader = await ParquetEnvelopeReader.openFile(filePath);
|
|
62
|
-
try {
|
|
63
|
-
await envelopeReader.readHeader();
|
|
64
|
-
const metadata = await envelopeReader.readFooter();
|
|
65
|
-
return new ParquetReader<T>(metadata, envelopeReader);
|
|
66
|
-
} catch (err) {
|
|
67
|
-
await envelopeReader.close();
|
|
68
|
-
throw err;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
56
|
static async openBuffer<T>(buffer: Buffer): Promise<ParquetReader<T>> {
|
|
73
57
|
const envelopeReader = await ParquetEnvelopeReader.openBuffer(buffer);
|
|
74
58
|
try {
|
|
@@ -14,55 +14,6 @@ export interface WriteStreamOptions {
|
|
|
14
14
|
start?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function fopen(filePath: string): Promise<number> {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
fs.open(filePath, 'r', (err, fd) => {
|
|
20
|
-
if (err) {
|
|
21
|
-
reject(err);
|
|
22
|
-
} else {
|
|
23
|
-
resolve(fd);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function fstat(filePath: string): Promise<fs.Stats> {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
fs.stat(filePath, (err, stat) => {
|
|
32
|
-
if (err) {
|
|
33
|
-
reject(err);
|
|
34
|
-
} else {
|
|
35
|
-
resolve(stat);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function fread(fd: number, position: number, length: number): Promise<Buffer> {
|
|
42
|
-
const buffer = Buffer.alloc(length);
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
fs.read(fd, buffer, 0, length, position, (err, bytesRead, buf) => {
|
|
45
|
-
if (err || bytesRead !== length) {
|
|
46
|
-
reject(err || Error('read failed'));
|
|
47
|
-
} else {
|
|
48
|
-
resolve(buf);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function fclose(fd: number): Promise<void> {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
fs.close(fd, (err) => {
|
|
57
|
-
if (err) {
|
|
58
|
-
reject(err);
|
|
59
|
-
} else {
|
|
60
|
-
resolve();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
17
|
export function oswrite(os: Writable, buf: Buffer): Promise<void> {
|
|
67
18
|
return new Promise((resolve, reject) => {
|
|
68
19
|
os.write(buf, (err) => {
|