@loaders.gl/parquet 4.4.2 → 5.0.0-alpha.1
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/bundled.d.ts +6 -0
- package/dist/bundled.d.ts.map +1 -0
- package/dist/bundled.js +7 -0
- package/dist/bundled.js.map +1 -0
- package/dist/geoparquet-loader-with-parser.d.ts +34 -0
- package/dist/geoparquet-loader-with-parser.d.ts.map +1 -0
- package/dist/geoparquet-loader-with-parser.js +52 -0
- package/dist/geoparquet-loader-with-parser.js.map +1 -0
- package/dist/geoparquet-loader.d.ts +61 -0
- package/dist/geoparquet-loader.d.ts.map +1 -0
- package/dist/geoparquet-loader.js +30 -0
- package/dist/geoparquet-loader.js.map +1 -0
- package/dist/index.cjs +5879 -5643
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/constants.js +2 -2
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/encoders/encode-arrow-to-parquet.d.ts +2 -2
- package/dist/lib/encoders/encode-arrow-to-parquet.d.ts.map +1 -1
- package/dist/lib/encoders/encode-arrow-to-parquet.js +3 -10
- package/dist/lib/encoders/encode-arrow-to-parquet.js.map +1 -1
- package/dist/lib/encoders/encode-table-to-parquet-js.d.ts +5 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.d.ts.map +1 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.js +149 -0
- package/dist/lib/encoders/encode-table-to-parquet-js.js.map +1 -0
- package/dist/lib/geo/geospatial-metadata.d.ts +67 -0
- package/dist/lib/geo/geospatial-metadata.d.ts.map +1 -0
- package/dist/lib/geo/geospatial-metadata.js +357 -0
- package/dist/lib/geo/geospatial-metadata.js.map +1 -0
- package/dist/lib/parsers/get-parquet-schema.d.ts.map +1 -1
- package/dist/lib/parsers/get-parquet-schema.js +3 -1
- package/dist/lib/parsers/get-parquet-schema.js.map +1 -1
- package/dist/lib/parsers/parse-geoparquet-to-geojson.d.ts +4 -4
- package/dist/lib/parsers/parse-geoparquet-to-geojson.d.ts.map +1 -1
- package/dist/lib/parsers/parse-geoparquet-to-geojson.js +19 -6
- package/dist/lib/parsers/parse-geoparquet-to-geojson.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-tables.d.ts +50 -0
- package/dist/lib/parsers/parse-parquet-tables.d.ts.map +1 -0
- package/dist/lib/parsers/parse-parquet-tables.js +101 -0
- package/dist/lib/parsers/parse-parquet-tables.js.map +1 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.d.ts +6 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.d.ts.map +1 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.js +23 -0
- package/dist/lib/parsers/parse-parquet-to-arrow-js.js.map +1 -0
- package/dist/lib/parsers/parse-parquet-to-arrow.d.ts +7 -7
- package/dist/lib/parsers/parse-parquet-to-arrow.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-arrow.js +45 -32
- package/dist/lib/parsers/parse-parquet-to-arrow.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-columns.d.ts +3 -3
- package/dist/lib/parsers/parse-parquet-to-columns.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-columns.js +1 -4
- package/dist/lib/parsers/parse-parquet-to-columns.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-json.d.ts +3 -3
- package/dist/lib/parsers/parse-parquet-to-json.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-json.js +77 -26
- package/dist/lib/parsers/parse-parquet-to-json.js.map +1 -1
- package/dist/lib/utils/load-wasm.d.ts +2 -2
- package/dist/lib/utils/load-wasm.d.ts.map +1 -1
- package/dist/lib/utils/load-wasm.js +7 -7
- package/dist/lib/utils/load-wasm.js.map +1 -1
- package/dist/lib/utils/make-stream-iterator.js +1 -1
- package/dist/lib/utils/make-stream-iterator.js.map +1 -1
- package/dist/lib/utils/normalize-parquet-options.d.ts +5 -0
- package/dist/lib/utils/normalize-parquet-options.d.ts.map +1 -0
- package/dist/lib/utils/normalize-parquet-options.js +11 -0
- package/dist/lib/utils/normalize-parquet-options.js.map +1 -0
- package/dist/parquet-format.d.ts +2 -0
- package/dist/parquet-format.d.ts.map +1 -1
- package/dist/parquet-format.js +2 -0
- package/dist/parquet-format.js.map +1 -1
- package/dist/parquet-js-loader.d.ts +57 -0
- package/dist/parquet-js-loader.d.ts.map +1 -0
- package/dist/parquet-js-loader.js +33 -0
- package/dist/parquet-js-loader.js.map +1 -0
- package/dist/parquet-js-writer.d.ts +34 -0
- package/dist/parquet-js-writer.d.ts.map +1 -0
- package/dist/parquet-js-writer.js +28 -0
- package/dist/parquet-js-writer.js.map +1 -0
- package/dist/parquet-loader-options.d.ts +56 -0
- package/dist/parquet-loader-options.d.ts.map +1 -0
- package/dist/parquet-loader-options.js +11 -0
- package/dist/parquet-loader-options.js.map +1 -0
- package/dist/parquet-loader-with-parser.d.ts +33 -0
- package/dist/parquet-loader-with-parser.d.ts.map +1 -0
- package/dist/parquet-loader-with-parser.js +40 -0
- package/dist/parquet-loader-with-parser.js.map +1 -0
- package/dist/parquet-loader.d.ts +62 -0
- package/dist/parquet-loader.d.ts.map +1 -0
- package/dist/parquet-loader.js +53 -0
- package/dist/parquet-loader.js.map +1 -0
- package/dist/parquet-wasm-loader-with-parser.d.ts +40 -0
- package/dist/parquet-wasm-loader-with-parser.d.ts.map +1 -0
- package/dist/parquet-wasm-loader-with-parser.js +68 -0
- package/dist/parquet-wasm-loader-with-parser.js.map +1 -0
- package/dist/parquet-writer.d.ts +10 -0
- package/dist/parquet-writer.d.ts.map +1 -0
- package/dist/parquet-writer.js +29 -0
- package/dist/parquet-writer.js.map +1 -0
- package/dist/parquet_wasm_bg.wasm +0 -0
- package/dist/parquetjs/codecs/declare.d.ts +2 -2
- package/dist/parquetjs/codecs/declare.d.ts.map +1 -1
- package/dist/parquetjs/codecs/dictionary.js +1 -1
- package/dist/parquetjs/codecs/dictionary.js.map +1 -1
- package/dist/parquetjs/codecs/plain.d.ts +1 -1
- package/dist/parquetjs/codecs/plain.d.ts.map +1 -1
- package/dist/parquetjs/codecs/plain.js +36 -41
- package/dist/parquetjs/codecs/plain.js.map +1 -1
- package/dist/parquetjs/codecs/rle.d.ts +1 -1
- package/dist/parquetjs/codecs/rle.d.ts.map +1 -1
- package/dist/parquetjs/codecs/rle.js +16 -21
- package/dist/parquetjs/codecs/rle.js.map +1 -1
- package/dist/parquetjs/compression.d.ts +2 -3
- package/dist/parquetjs/compression.d.ts.map +1 -1
- package/dist/parquetjs/compression.js +4 -105
- package/dist/parquetjs/compression.js.map +1 -1
- package/dist/parquetjs/encoder/parquet-encoder.d.ts +4 -4
- package/dist/parquetjs/encoder/parquet-encoder.d.ts.map +1 -1
- package/dist/parquetjs/encoder/parquet-encoder.js +38 -33
- package/dist/parquetjs/encoder/parquet-encoder.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js +1 -1
- package/dist/parquetjs/parquet-thrift/ColumnIndex.js.map +1 -1
- package/dist/parquetjs/parquet-thrift/index.d.ts +0 -1
- package/dist/parquetjs/parquet-thrift/index.d.ts.map +1 -1
- package/dist/parquetjs/parquet-thrift/index.js +0 -1
- package/dist/parquetjs/parquet-thrift/index.js.map +1 -1
- package/dist/parquetjs/parser/decoders.d.ts +1 -1
- package/dist/parquetjs/parser/decoders.d.ts.map +1 -1
- package/dist/parquetjs/parser/decoders.js +4 -22
- package/dist/parquetjs/parser/decoders.js.map +1 -1
- package/dist/parquetjs/parser/parquet-reader.d.ts +1 -1
- package/dist/parquetjs/parser/parquet-reader.d.ts.map +1 -1
- package/dist/parquetjs/parser/parquet-reader.js +9 -9
- package/dist/parquetjs/parser/parquet-reader.js.map +1 -1
- package/dist/parquetjs/schema/declare.d.ts +1 -1
- package/dist/parquetjs/schema/declare.d.ts.map +1 -1
- package/dist/parquetjs/schema/types.d.ts.map +1 -1
- package/dist/parquetjs/schema/types.js +36 -35
- package/dist/parquetjs/schema/types.js.map +1 -1
- package/dist/parquetjs/utils/binary-utils.d.ts +39 -0
- package/dist/parquetjs/utils/binary-utils.d.ts.map +1 -0
- package/dist/parquetjs/utils/binary-utils.js +102 -0
- package/dist/parquetjs/utils/binary-utils.js.map +1 -0
- package/dist/parquetjs/utils/file-utils.d.ts +1 -1
- package/dist/parquetjs/utils/file-utils.d.ts.map +1 -1
- package/dist/parquetjs/utils/file-utils.js +3 -3
- package/dist/parquetjs/utils/file-utils.js.map +1 -1
- package/dist/parquetjs/utils/read-utils.d.ts +4 -4
- package/dist/parquetjs/utils/read-utils.d.ts.map +1 -1
- package/dist/parquetjs/utils/read-utils.js +12 -17
- package/dist/parquetjs/utils/read-utils.js.map +1 -1
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.d.ts +78 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.d.ts.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.js +213 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.js.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.d.ts +78 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.d.ts.map +1 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.js +276 -0
- package/dist/parquetjs/utils/uint8-array-compact-protocol.js.map +1 -0
- package/dist/parquetjs/utils/uint8-array-transport.d.ts +25 -0
- package/dist/parquetjs/utils/uint8-array-transport.d.ts.map +1 -0
- package/dist/parquetjs/utils/uint8-array-transport.js +62 -0
- package/dist/parquetjs/utils/uint8-array-transport.js.map +1 -0
- package/dist/unbundled.d.ts +6 -0
- package/dist/unbundled.d.ts.map +1 -0
- package/dist/unbundled.js +7 -0
- package/dist/unbundled.js.map +1 -0
- package/package.json +21 -25
- package/src/bundled.ts +9 -0
- package/src/geoparquet-loader-with-parser.ts +95 -0
- package/src/geoparquet-loader.ts +54 -0
- package/src/index.ts +7 -25
- package/src/lib/constants.ts +1 -1
- package/src/lib/encoders/encode-arrow-to-parquet.ts +9 -15
- package/src/lib/encoders/encode-table-to-parquet-js.ts +199 -0
- package/src/lib/geo/geospatial-metadata.ts +507 -0
- package/src/lib/parsers/get-parquet-schema.ts +3 -1
- package/src/lib/parsers/parse-geoparquet-to-geojson.ts +27 -14
- package/src/lib/parsers/parse-parquet-tables.ts +137 -0
- package/src/lib/parsers/parse-parquet-to-arrow-js.ts +36 -0
- package/src/lib/parsers/parse-parquet-to-arrow.ts +63 -36
- package/src/lib/parsers/parse-parquet-to-columns.ts +6 -7
- package/src/lib/parsers/parse-parquet-to-json.ts +101 -33
- package/src/lib/utils/load-wasm.ts +16 -9
- package/src/lib/utils/make-stream-iterator.ts +1 -1
- package/src/lib/utils/normalize-parquet-options.ts +14 -0
- package/src/parquet-format.ts +2 -0
- package/src/parquet-js-loader.ts +43 -0
- package/src/parquet-js-writer.ts +52 -0
- package/src/parquet-loader-options.ts +63 -0
- package/src/parquet-loader-with-parser.ts +68 -0
- package/src/parquet-loader.ts +79 -0
- package/src/parquet-wasm-loader-with-parser.ts +115 -0
- package/src/parquet-writer.ts +44 -0
- package/src/parquetjs/codecs/declare.ts +2 -2
- package/src/parquetjs/codecs/dictionary.ts +1 -1
- package/src/parquetjs/codecs/plain.ts +67 -53
- package/src/parquetjs/codecs/rle.ts +20 -26
- package/src/parquetjs/compression.ts +7 -114
- package/src/parquetjs/encoder/parquet-encoder.ts +49 -43
- package/src/parquetjs/parquet-thrift/ColumnIndex.ts +1 -1
- package/src/parquetjs/parquet-thrift/index.ts +0 -2
- package/src/parquetjs/parser/decoders.ts +5 -23
- package/src/parquetjs/parser/parquet-reader.ts +10 -12
- package/src/parquetjs/schema/declare.ts +1 -1
- package/src/parquetjs/schema/types.ts +48 -40
- package/src/parquetjs/utils/binary-utils.ts +127 -0
- package/src/parquetjs/utils/file-utils.ts +4 -4
- package/src/parquetjs/utils/read-utils.ts +19 -34
- package/src/parquetjs/utils/uint8-array-compact-protocol-writer.ts +254 -0
- package/src/parquetjs/utils/uint8-array-compact-protocol.ts +322 -0
- package/src/parquetjs/utils/uint8-array-transport.ts +79 -0
- package/src/unbundled.ts +9 -0
- package/dist/parquet-arrow-loader.d.ts +0 -43
- package/dist/parquet-arrow-loader.d.ts.map +0 -1
- package/dist/parquet-arrow-loader.js +0 -49
- package/dist/parquet-arrow-loader.js.map +0 -1
- package/dist/parquet-arrow-writer.d.ts +0 -9
- package/dist/parquet-arrow-writer.d.ts.map +0 -1
- package/dist/parquet-arrow-writer.js +0 -23
- package/dist/parquet-arrow-writer.js.map +0 -1
- package/dist/parquet-json-loader.d.ts +0 -148
- package/dist/parquet-json-loader.d.ts.map +0 -1
- package/dist/parquet-json-loader.js +0 -106
- package/dist/parquet-json-loader.js.map +0 -1
- package/dist/parquet-json-writer.d.ts +0 -19
- package/dist/parquet-json-writer.d.ts.map +0 -1
- package/dist/parquet-json-writer.js +0 -20
- package/dist/parquet-json-writer.js.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.browser.d.ts +0 -3
- package/dist/polyfills/buffer/buffer-polyfill.browser.d.ts.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.browser.js +0 -12
- package/dist/polyfills/buffer/buffer-polyfill.browser.js.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.node.d.ts +0 -3
- package/dist/polyfills/buffer/buffer-polyfill.node.d.ts.map +0 -1
- package/dist/polyfills/buffer/buffer-polyfill.node.js +0 -17
- package/dist/polyfills/buffer/buffer-polyfill.node.js.map +0 -1
- package/dist/polyfills/buffer/buffer.d.ts +0 -222
- package/dist/polyfills/buffer/buffer.d.ts.map +0 -1
- package/dist/polyfills/buffer/buffer.js +0 -1868
- package/dist/polyfills/buffer/buffer.js.map +0 -1
- package/dist/polyfills/buffer/index.d.ts +0 -4
- package/dist/polyfills/buffer/index.d.ts.map +0 -1
- package/dist/polyfills/buffer/index.js +0 -9
- package/dist/polyfills/buffer/index.js.map +0 -1
- package/dist/polyfills/buffer/install-buffer-polyfill.d.ts +0 -2
- package/dist/polyfills/buffer/install-buffer-polyfill.d.ts.map +0 -1
- package/dist/polyfills/buffer/install-buffer-polyfill.js +0 -10
- package/dist/polyfills/buffer/install-buffer-polyfill.js.map +0 -1
- package/dist/workers/parquet-json-worker.d.ts +0 -2
- package/dist/workers/parquet-json-worker.d.ts.map +0 -1
- package/dist/workers/parquet-json-worker.js +0 -7
- package/dist/workers/parquet-json-worker.js.map +0 -1
- package/src/parquet-arrow-loader.ts +0 -74
- package/src/parquet-arrow-writer.ts +0 -33
- package/src/parquet-json-loader.ts +0 -160
- package/src/parquet-json-writer.ts +0 -27
- package/src/parquetjs/modules.d.ts +0 -25
- package/src/polyfills/buffer/buffer-polyfill.browser.ts +0 -14
- package/src/polyfills/buffer/buffer-polyfill.node.ts +0 -19
- package/src/polyfills/buffer/buffer.ts +0 -2205
- package/src/polyfills/buffer/index.ts +0 -11
- package/src/polyfills/buffer/install-buffer-polyfill.ts +0 -12
- package/src/workers/parquet-json-worker.ts +0 -8
package/src/parquet-format.ts
CHANGED
|
@@ -7,6 +7,8 @@ import type {Format} from '@loaders.gl/loader-utils';
|
|
|
7
7
|
export const ParquetFormat = {
|
|
8
8
|
name: 'Apache Parquet',
|
|
9
9
|
category: 'table',
|
|
10
|
+
encoding: 'parquet',
|
|
11
|
+
format: 'parquet',
|
|
10
12
|
extensions: ['parquet'],
|
|
11
13
|
mimeTypes: ['application/octet-stream'],
|
|
12
14
|
binary: true,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {ObjectRowTable, ObjectRowTableBatch} from '@loaders.gl/schema';
|
|
7
|
+
|
|
8
|
+
import {ParquetFormat} from './parquet-format';
|
|
9
|
+
import type {ParquetJSLoaderOptions} from './parquet-loader-options';
|
|
10
|
+
|
|
11
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
12
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
13
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
14
|
+
|
|
15
|
+
/** Default option bag for the experimental parquetjs plain-row loader. */
|
|
16
|
+
const DEFAULT_PARQUET_JS_OPTIONS = {
|
|
17
|
+
backend: 'typescript' as const,
|
|
18
|
+
columns: undefined,
|
|
19
|
+
preserveBinary: false
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Preloads the parser-bearing parquetjs loader implementation. */
|
|
23
|
+
async function preload() {
|
|
24
|
+
const {ParquetLoaderWithParser} = await import('./parquet-loader-with-parser');
|
|
25
|
+
return ParquetLoaderWithParser;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Metadata-only plain-row Parquet loader backed by the experimental parquetjs implementation. */
|
|
29
|
+
export const ParquetJSLoader = {
|
|
30
|
+
...ParquetFormat,
|
|
31
|
+
|
|
32
|
+
dataType: null as unknown as ObjectRowTable,
|
|
33
|
+
batchType: null as unknown as ObjectRowTableBatch,
|
|
34
|
+
|
|
35
|
+
id: 'parquet-js',
|
|
36
|
+
module: 'parquet',
|
|
37
|
+
version: VERSION,
|
|
38
|
+
worker: false,
|
|
39
|
+
options: {
|
|
40
|
+
parquet: DEFAULT_PARQUET_JS_OPTIONS
|
|
41
|
+
},
|
|
42
|
+
preload
|
|
43
|
+
} as const satisfies Loader<ObjectRowTable, ObjectRowTableBatch, ParquetJSLoaderOptions>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WriterOptions, WriterWithEncoder} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {ObjectRowTable, Table, TableBatch} from '@loaders.gl/schema';
|
|
7
|
+
import {convertTable, deduceTableSchema} from '@loaders.gl/schema-utils';
|
|
8
|
+
|
|
9
|
+
import {normalizeParquetOptions} from './lib/utils/normalize-parquet-options';
|
|
10
|
+
import {encodeTableToParquetJs} from './lib/encoders/encode-table-to-parquet-js';
|
|
11
|
+
import {ParquetFormat} from './parquet-format';
|
|
12
|
+
|
|
13
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
14
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
15
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
16
|
+
|
|
17
|
+
/** Encoder-specific options for the experimental parquetjs writer. */
|
|
18
|
+
type ParquetJSWriterEncoderOptions = {
|
|
19
|
+
rowGroupSize?: number;
|
|
20
|
+
pageSize?: number;
|
|
21
|
+
useDataPageV2?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Public options for the parquetjs-backed plain-table writer. */
|
|
25
|
+
export type ParquetJSWriterOptions = WriterOptions & {
|
|
26
|
+
parquet?: {
|
|
27
|
+
[Key in keyof ParquetJSWriterEncoderOptions]?: ParquetJSWriterEncoderOptions[Key];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Default option bag for the experimental parquetjs writer. */
|
|
32
|
+
const DEFAULT_PARQUET_JS_OPTIONS = {};
|
|
33
|
+
|
|
34
|
+
/** Plain-row Parquet writer backed by the experimental parquetjs implementation. */
|
|
35
|
+
export const ParquetJSWriter = {
|
|
36
|
+
...ParquetFormat,
|
|
37
|
+
id: 'parquet-js',
|
|
38
|
+
module: 'parquet',
|
|
39
|
+
version: VERSION,
|
|
40
|
+
options: {
|
|
41
|
+
parquet: DEFAULT_PARQUET_JS_OPTIONS
|
|
42
|
+
},
|
|
43
|
+
async encode(table: Table, options?: ParquetJSWriterOptions) {
|
|
44
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
45
|
+
const objectRowTable = convertTable({...table, schema}, 'object-row-table') as ObjectRowTable;
|
|
46
|
+
return await encodeTableToParquetJs(
|
|
47
|
+
{...table, schema},
|
|
48
|
+
objectRowTable,
|
|
49
|
+
normalizeParquetOptions(options, DEFAULT_PARQUET_JS_OPTIONS)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
} as const satisfies WriterWithEncoder<Table, TableBatch, ParquetJSWriterOptions>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {LoaderOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
|
|
7
|
+
/** Shared row-level options supported by both Parquet backends. */
|
|
8
|
+
type ParquetCommonLoaderOptions = {
|
|
9
|
+
limit?: number;
|
|
10
|
+
offset?: number;
|
|
11
|
+
batchSize?: number;
|
|
12
|
+
columns?: string[];
|
|
13
|
+
preserveBinary?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Additional options supported by the wasm-backed Parquet reader. */
|
|
17
|
+
type ParquetWasmLoaderOptions = ParquetCommonLoaderOptions & {
|
|
18
|
+
rowGroups?: number[];
|
|
19
|
+
concurrency?: number;
|
|
20
|
+
wasmUrl?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Internal superset of Parquet loader options that retains backend selection. */
|
|
24
|
+
type ParquetInternalLoaderOptions = ParquetWasmLoaderOptions & {
|
|
25
|
+
shape?: 'object-row-table' | 'arrow-table';
|
|
26
|
+
backend?: 'wasm' | 'typescript';
|
|
27
|
+
/** @deprecated Use `backend` instead. */
|
|
28
|
+
implementation?: 'wasm' | 'js';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Public options for the wasm-backed `ParquetLoader` and `GeoParquetLoader`. */
|
|
32
|
+
export type ParquetLoaderOptions = LoaderOptions & {
|
|
33
|
+
parquet?: {
|
|
34
|
+
shape?: 'object-row-table' | 'arrow-table';
|
|
35
|
+
backend?: 'wasm' | 'typescript';
|
|
36
|
+
/** @deprecated Use `backend` instead. */
|
|
37
|
+
implementation?: 'wasm' | 'js';
|
|
38
|
+
} & {
|
|
39
|
+
[Key in keyof ParquetWasmLoaderOptions]?: ParquetWasmLoaderOptions[Key];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Public options for the experimental parquetjs-backed `ParquetJSLoader`. */
|
|
44
|
+
export type ParquetJSLoaderOptions = LoaderOptions & {
|
|
45
|
+
parquet?: {backend?: 'typescript'} & {
|
|
46
|
+
[Key in keyof ParquetCommonLoaderOptions]?: ParquetCommonLoaderOptions[Key];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Internal options used by shared Parquet helpers that need backend selection. */
|
|
51
|
+
export type ParquetLoaderImplementationOptions = LoaderOptions & {
|
|
52
|
+
parquet?: {
|
|
53
|
+
[Key in keyof ParquetInternalLoaderOptions]?: ParquetInternalLoaderOptions[Key];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Shared default option bag for the wasm-backed Parquet loaders. */
|
|
58
|
+
export const PARQUET_LOADER_DEFAULT_OPTIONS = {
|
|
59
|
+
backend: 'wasm',
|
|
60
|
+
columns: undefined,
|
|
61
|
+
preserveBinary: false,
|
|
62
|
+
shape: 'object-row-table'
|
|
63
|
+
} as const;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {BlobFile, concatenateArrayBuffersAsync} from '@loaders.gl/loader-utils';
|
|
7
|
+
import type {
|
|
8
|
+
ArrowTable,
|
|
9
|
+
ArrowTableBatch,
|
|
10
|
+
ObjectRowTable,
|
|
11
|
+
ObjectRowTableBatch
|
|
12
|
+
} from '@loaders.gl/schema';
|
|
13
|
+
import type {ReadableFile} from '@loaders.gl/loader-utils';
|
|
14
|
+
|
|
15
|
+
import {parseParquetFile, parseParquetFileInBatches} from './lib/parsers/parse-parquet-to-json';
|
|
16
|
+
import {normalizeParquetOptions} from './lib/utils/normalize-parquet-options';
|
|
17
|
+
import type {
|
|
18
|
+
ParquetLoaderImplementationOptions,
|
|
19
|
+
ParquetLoaderOptions
|
|
20
|
+
} from './parquet-loader-options';
|
|
21
|
+
import {ParquetLoader as ParquetLoaderMetadata} from './parquet-loader';
|
|
22
|
+
|
|
23
|
+
const {preload: _ParquetLoaderPreload, ...ParquetLoaderMetadataWithoutPreload} =
|
|
24
|
+
ParquetLoaderMetadata;
|
|
25
|
+
|
|
26
|
+
/** Default option bag for the experimental parquetjs plain-row loader. */
|
|
27
|
+
const DEFAULT_PARQUET_JS_OPTIONS = {
|
|
28
|
+
backend: 'typescript' as const,
|
|
29
|
+
columns: undefined,
|
|
30
|
+
preserveBinary: false
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Parser-bearing TypeScript-only Parquet loader implementation. */
|
|
34
|
+
export const ParquetLoaderWithParser = {
|
|
35
|
+
...ParquetLoaderMetadataWithoutPreload,
|
|
36
|
+
parse(arrayBuffer: ArrayBuffer, options?: ParquetLoaderOptions) {
|
|
37
|
+
return parseParquetFile(new BlobFile(arrayBuffer), getParquetOptions(options));
|
|
38
|
+
},
|
|
39
|
+
parseFile(file: ReadableFile, options?: ParquetLoaderOptions) {
|
|
40
|
+
return parseParquetFile(file, getParquetOptions(options));
|
|
41
|
+
},
|
|
42
|
+
parseFileInBatches(file: ReadableFile, options?: ParquetLoaderOptions) {
|
|
43
|
+
return parseParquetFileInBatches(file, getParquetOptions(options));
|
|
44
|
+
},
|
|
45
|
+
async *parseInBatches(
|
|
46
|
+
asyncIterator:
|
|
47
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
48
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
49
|
+
options?: ParquetLoaderOptions,
|
|
50
|
+
_context?: unknown
|
|
51
|
+
) {
|
|
52
|
+
const arrayBuffer = await concatenateArrayBuffersAsync(asyncIterator);
|
|
53
|
+
yield* parseParquetFileInBatches(new BlobFile(arrayBuffer), getParquetOptions(options));
|
|
54
|
+
}
|
|
55
|
+
} as const satisfies LoaderWithParser<
|
|
56
|
+
ObjectRowTable | ArrowTable,
|
|
57
|
+
ObjectRowTableBatch | ArrowTableBatch,
|
|
58
|
+
ParquetLoaderOptions
|
|
59
|
+
>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Normalizes caller options for the parquetjs-backed loader.
|
|
63
|
+
* @param options caller-supplied loader options
|
|
64
|
+
* @returns normalized options with parquetjs defaults applied
|
|
65
|
+
*/
|
|
66
|
+
function getParquetOptions(options?: ParquetLoaderOptions): ParquetLoaderImplementationOptions {
|
|
67
|
+
return normalizeParquetOptions(options, DEFAULT_PARQUET_JS_OPTIONS);
|
|
68
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {
|
|
7
|
+
ObjectRowTable,
|
|
8
|
+
ObjectRowTableBatch,
|
|
9
|
+
ArrowTable,
|
|
10
|
+
ArrowTableBatch
|
|
11
|
+
} from '@loaders.gl/schema';
|
|
12
|
+
|
|
13
|
+
import {ParquetFormat} from './parquet-format';
|
|
14
|
+
import {
|
|
15
|
+
PARQUET_LOADER_DEFAULT_OPTIONS,
|
|
16
|
+
type ParquetLoaderOptions as SharedParquetLoaderOptions
|
|
17
|
+
} from './parquet-loader-options';
|
|
18
|
+
|
|
19
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
20
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
21
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
22
|
+
|
|
23
|
+
/** Options for the parquet loader */
|
|
24
|
+
export type ParquetLoaderOptions = SharedParquetLoaderOptions;
|
|
25
|
+
|
|
26
|
+
/** Preloads the parser-bearing Parquet loader implementation selected by `parquet.backend`. */
|
|
27
|
+
async function preloadParquetLoader(_url: string, options?: LoaderOptions) {
|
|
28
|
+
const parquetOptions = options as ParquetLoaderOptions | undefined;
|
|
29
|
+
switch (getParquetBackend(parquetOptions)) {
|
|
30
|
+
case 'wasm': {
|
|
31
|
+
const {ParquetWASMLoaderWithParser} = await import('./parquet-wasm-loader-with-parser');
|
|
32
|
+
return ParquetWASMLoaderWithParser;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
case 'typescript': {
|
|
36
|
+
if (parquetOptions?.parquet?.shape === 'arrow-table') {
|
|
37
|
+
throw new Error('ParquetLoader: backend "typescript" does not support shape "arrow-table"');
|
|
38
|
+
}
|
|
39
|
+
const {ParquetLoaderWithParser} = await import('./parquet-loader-with-parser');
|
|
40
|
+
return ParquetLoaderWithParser;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`ParquetLoader: unsupported backend "${parquetOptions?.parquet?.backend}"`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Metadata-only Parquet table loader supporting object-row and Arrow table output. */
|
|
49
|
+
export const ParquetLoader = {
|
|
50
|
+
...ParquetFormat,
|
|
51
|
+
|
|
52
|
+
dataType: null as unknown as ObjectRowTable | ArrowTable,
|
|
53
|
+
batchType: null as unknown as ObjectRowTableBatch | ArrowTableBatch,
|
|
54
|
+
|
|
55
|
+
id: 'parquet',
|
|
56
|
+
module: 'parquet',
|
|
57
|
+
version: VERSION,
|
|
58
|
+
worker: false,
|
|
59
|
+
options: {
|
|
60
|
+
parquet: {
|
|
61
|
+
...PARQUET_LOADER_DEFAULT_OPTIONS
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
preload: preloadParquetLoader
|
|
65
|
+
} as const satisfies Loader<
|
|
66
|
+
ObjectRowTable | ArrowTable,
|
|
67
|
+
ObjectRowTableBatch | ArrowTableBatch,
|
|
68
|
+
ParquetLoaderOptions
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
function getParquetBackend(options?: ParquetLoaderOptions): 'wasm' | 'typescript' {
|
|
72
|
+
if (options?.parquet?.backend) {
|
|
73
|
+
return options.parquet.backend;
|
|
74
|
+
}
|
|
75
|
+
if (options?.parquet?.implementation === 'js') {
|
|
76
|
+
return 'typescript';
|
|
77
|
+
}
|
|
78
|
+
return ParquetLoader.options.parquet.backend;
|
|
79
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {concatenateArrayBuffersAsync} from '@loaders.gl/loader-utils';
|
|
7
|
+
import type {
|
|
8
|
+
ObjectRowTable,
|
|
9
|
+
ObjectRowTableBatch,
|
|
10
|
+
ArrowTable,
|
|
11
|
+
ArrowTableBatch
|
|
12
|
+
// ColumnarTable,
|
|
13
|
+
// ColumnarTableBatch
|
|
14
|
+
} from '@loaders.gl/schema';
|
|
15
|
+
import {BlobFile} from '@loaders.gl/loader-utils';
|
|
16
|
+
import type {ReadableFile} from '@loaders.gl/loader-utils';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
parseParquetArrowTable,
|
|
20
|
+
parseParquetArrowTableInBatches,
|
|
21
|
+
parseParquetObjectRowTable,
|
|
22
|
+
parseParquetObjectRowTableInBatches
|
|
23
|
+
} from './lib/parsers/parse-parquet-tables';
|
|
24
|
+
import {normalizeParquetOptions} from './lib/utils/normalize-parquet-options';
|
|
25
|
+
import {ParquetLoader as ParquetLoaderMetadata, type ParquetLoaderOptions} from './parquet-loader';
|
|
26
|
+
|
|
27
|
+
const {preload: _ParquetLoaderPreload, ...ParquetLoaderMetadataWithoutPreload} =
|
|
28
|
+
ParquetLoaderMetadata;
|
|
29
|
+
|
|
30
|
+
export type {ParquetLoaderOptions} from './parquet-loader';
|
|
31
|
+
|
|
32
|
+
/** WASM-backed Parquet table loader supporting object-row and Arrow table output. */
|
|
33
|
+
export const ParquetWASMLoaderWithParser = {
|
|
34
|
+
...ParquetLoaderMetadataWithoutPreload,
|
|
35
|
+
parse(arrayBuffer: ArrayBuffer, options?: ParquetLoaderOptions) {
|
|
36
|
+
return parseParquetTable(new BlobFile(arrayBuffer), options);
|
|
37
|
+
},
|
|
38
|
+
parseFile(file, options?: ParquetLoaderOptions) {
|
|
39
|
+
return parseParquetTable(file, options);
|
|
40
|
+
},
|
|
41
|
+
parseFileInBatches(file, options?: ParquetLoaderOptions) {
|
|
42
|
+
return parseParquetTableInBatches(file, options);
|
|
43
|
+
},
|
|
44
|
+
async *parseInBatches(
|
|
45
|
+
asyncIterator:
|
|
46
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
47
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
48
|
+
options?: ParquetLoaderOptions,
|
|
49
|
+
_context?: unknown
|
|
50
|
+
) {
|
|
51
|
+
const arrayBuffer = await concatenateArrayBuffersAsync(asyncIterator);
|
|
52
|
+
yield* parseParquetTableInBatches(new BlobFile(arrayBuffer), options);
|
|
53
|
+
}
|
|
54
|
+
} as const satisfies LoaderWithParser<
|
|
55
|
+
ObjectRowTable | ArrowTable,
|
|
56
|
+
ObjectRowTableBatch | ArrowTableBatch,
|
|
57
|
+
ParquetLoaderOptions
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Parses a Parquet file using the canonical wasm-backed table loader.
|
|
62
|
+
* @param file readable file abstraction
|
|
63
|
+
* @param options optional loader options
|
|
64
|
+
* @returns object-row or Arrow table output depending on `parquet.shape`
|
|
65
|
+
*/
|
|
66
|
+
async function parseParquetTable(
|
|
67
|
+
file: BlobFile | ReadableFile,
|
|
68
|
+
options?: ParquetLoaderOptions
|
|
69
|
+
): Promise<ObjectRowTable | ArrowTable> {
|
|
70
|
+
const parquetOptions = getParquetOptions(options);
|
|
71
|
+
|
|
72
|
+
if (parquetOptions.parquet?.shape === 'arrow-table') {
|
|
73
|
+
return await parseParquetArrowTable(file, parquetOptions);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return await parseParquetObjectRowTable(file, parquetOptions);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Parses a Parquet file into streamed table batches using the canonical wasm-backed loader.
|
|
81
|
+
* @param file readable file abstraction
|
|
82
|
+
* @param options optional loader options
|
|
83
|
+
* @returns async iterable of object-row or Arrow batches
|
|
84
|
+
*/
|
|
85
|
+
async function* parseParquetTableInBatches(
|
|
86
|
+
file: BlobFile | ReadableFile,
|
|
87
|
+
options?: ParquetLoaderOptions
|
|
88
|
+
): AsyncIterable<ObjectRowTableBatch | ArrowTableBatch> {
|
|
89
|
+
const parquetOptions = getParquetOptions(options);
|
|
90
|
+
|
|
91
|
+
if (parquetOptions.parquet?.shape === 'arrow-table') {
|
|
92
|
+
yield* parseParquetArrowTableInBatches(file, parquetOptions);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
yield* parseParquetObjectRowTableInBatches(file, parquetOptions);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Normalizes caller options for the canonical wasm-backed Parquet loaders.
|
|
101
|
+
* @param options caller-supplied loader options
|
|
102
|
+
* @returns normalized loader options
|
|
103
|
+
*/
|
|
104
|
+
export function getParquetOptions(options?: ParquetLoaderOptions): ParquetLoaderOptions {
|
|
105
|
+
return normalizeParquetOptions(
|
|
106
|
+
{
|
|
107
|
+
...options,
|
|
108
|
+
parquet: {
|
|
109
|
+
...(options?.parquet || {}),
|
|
110
|
+
backend: 'wasm'
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
ParquetWASMLoaderWithParser.options.parquet
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WriterOptions, WriterWithEncoder} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {ArrowTable, Table, TableBatch} from '@loaders.gl/schema';
|
|
7
|
+
import {convertTable, deduceTableSchema} from '@loaders.gl/schema-utils';
|
|
8
|
+
|
|
9
|
+
import {encodeArrowToParquet} from './lib/encoders/encode-arrow-to-parquet';
|
|
10
|
+
import {ensureGeoParquetMetadataOnArrowTable} from './lib/geo/geospatial-metadata';
|
|
11
|
+
import {normalizeParquetOptions} from './lib/utils/normalize-parquet-options';
|
|
12
|
+
import {ParquetFormat} from './parquet-format';
|
|
13
|
+
import {VERSION, PARQUET_WASM_URL} from './lib/constants';
|
|
14
|
+
|
|
15
|
+
/** Public options for the wasm-backed Parquet writer. */
|
|
16
|
+
export type ParquetWriterOptions = WriterOptions & {
|
|
17
|
+
parquet?: {
|
|
18
|
+
wasmUrl?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Plain-row Parquet writer that converts tables to Arrow before wasm encoding. */
|
|
23
|
+
export const ParquetWriter = {
|
|
24
|
+
...ParquetFormat,
|
|
25
|
+
id: 'parquet',
|
|
26
|
+
module: 'parquet',
|
|
27
|
+
version: VERSION,
|
|
28
|
+
options: {
|
|
29
|
+
parquet: {
|
|
30
|
+
wasmUrl: PARQUET_WASM_URL
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
encode(table: Table, options?: ParquetWriterOptions) {
|
|
34
|
+
const arrowTable =
|
|
35
|
+
table.shape === 'arrow-table'
|
|
36
|
+
? (table as ArrowTable)
|
|
37
|
+
: (convertTable(
|
|
38
|
+
{...table, schema: table.schema || deduceTableSchema(table)},
|
|
39
|
+
'arrow-table'
|
|
40
|
+
) as ArrowTable);
|
|
41
|
+
const parquetOptions = normalizeParquetOptions(options, ParquetWriter.options.parquet);
|
|
42
|
+
return encodeArrowToParquet(ensureGeoParquetMetadataOnArrowTable(arrowTable), parquetOptions);
|
|
43
|
+
}
|
|
44
|
+
} as const satisfies WriterWithEncoder<Table, TableBatch, ParquetWriterOptions>;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {PrimitiveType} from '../schema/declare';
|
|
8
8
|
|
|
9
9
|
export interface CursorBuffer {
|
|
10
|
-
buffer:
|
|
10
|
+
buffer: Uint8Array;
|
|
11
11
|
offset: number;
|
|
12
12
|
size?: number;
|
|
13
13
|
}
|
|
@@ -19,7 +19,7 @@ export interface ParquetCodecOptions {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface ParquetCodecKit {
|
|
22
|
-
encodeValues(type: PrimitiveType, values: any[], opts?: ParquetCodecOptions):
|
|
22
|
+
encodeValues(type: PrimitiveType, values: any[], opts?: ParquetCodecOptions): Uint8Array;
|
|
23
23
|
decodeValues(
|
|
24
24
|
type: PrimitiveType,
|
|
25
25
|
cursor: CursorBuffer,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {decodeValues as decodeRleValues} from './rle';
|
|
8
8
|
|
|
9
9
|
export function decodeValues(type, cursor, count, opts) {
|
|
10
|
-
opts.bitWidth = cursor.buffer
|
|
10
|
+
opts.bitWidth = cursor.buffer[cursor.offset];
|
|
11
11
|
cursor.offset += 1;
|
|
12
12
|
return decodeRleValues(type, cursor, count, {...opts, disableEnvelope: true});
|
|
13
13
|
}
|