-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { snappyUncompressor } from 'hysnappy' | ||
import lz4 from 'lz4' | ||
import pako from 'pako' | ||
|
||
/** | ||
* @typedef {import('hyparquet').Compressors} Compressors | ||
* @type {import('hyparquet').Compressors} | ||
*/ | ||
export const compressors = { | ||
SNAPPY: snappyUncompressor(), | ||
GZIP: (/** @type {Uint8Array} */ input) => pako.ungzip(input), | ||
GZIP: input => pako.ungzip(input), | ||
BROTLI: () => new Uint8Array(), // TODO | ||
ZSTD: () => new Uint8Array(), // TODO | ||
LZ4: (input, outputLength) => { | ||
const out = Buffer.alloc(outputLength) | ||
lz4.decodeBlock(Buffer.from(input), out) | ||
return out | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
[ | ||
1593604800, | ||
[97, 98, 99], | ||
42 | ||
], | ||
[ | ||
1593604800, | ||
[100, 101, 102], | ||
7.7 | ||
], | ||
[ | ||
1593604801, | ||
[97, 98, 99], | ||
42.125 | ||
], | ||
[ | ||
1593604801, | ||
[100, 101, 102], | ||
7.7 | ||
] | ||
] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import fs from 'fs' | ||
import { parquetRead, toJson } from 'hyparquet' | ||
import { describe, expect, it } from 'vitest' | ||
import { compressors } from '../src/index.js' | ||
|
||
describe('lz4 compressor', () => { | ||
it('should read lz4 compressed parquet file', async () => { | ||
const buffer = fs.readFileSync('test/files/non_hadoop_lz4_compressed.parquet') | ||
const file = new Uint8Array(buffer).buffer | ||
const expected = fs.readFileSync('test/files/non_hadoop_lz4_compressed.json').toString() | ||
|
||
await parquetRead({ file, compressors, onComplete: data => { | ||
expect(data.length).toBe(4) | ||
expect(toJson(data)).toEqual(JSON.parse(expected)) | ||
} }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters