From 6303cc9b45d106995d2466fe87a3615d068992ce Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 2 Jul 2024 09:39:46 -0400 Subject: [PATCH 01/20] For node, use zlib for brotli --- lib/compression.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/compression.ts b/lib/compression.ts index 1dd1367b..e8451f7d 100644 --- a/lib/compression.ts +++ b/lib/compression.ts @@ -1,6 +1,5 @@ import zlib from 'zlib'; import snappy from 'snappyjs'; -import { compress as brotliCompress, decompress as brotliDecompress } from 'brotli-wasm'; type PARQUET_COMPRESSION_METHODS = Record< string, @@ -54,16 +53,7 @@ function deflate_snappy(value: ArrayBuffer | Buffer | Uint8Array) { } async function deflate_brotli(value: Uint8Array) { - const compressedContent = await brotliCompress( - value /*, { - mode: 0, - quality: 8, - lgwin: 22 - } - */ - ); - - return Buffer.from(compressedContent); + return zlib.brotliCompressSync(value); } /** @@ -91,8 +81,7 @@ function inflate_snappy(value: ArrayBuffer | Buffer | Uint8Array) { } async function inflate_brotli(value: Uint8Array) { - const uncompressedContent = await brotliDecompress(value); - return Buffer.from(uncompressedContent); + return zlib.brotliDecompressSync(value); } function buffer_from_result(result: ArrayBuffer | Buffer | Uint8Array): Buffer { From 4080b3f83918ff91bfd88ca44081017eb95f0d08 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 2 Jul 2024 12:40:28 -0400 Subject: [PATCH 02/20] Adding an html output to the example --- examples/server/views/parquetFiles.ejs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/server/views/parquetFiles.ejs b/examples/server/views/parquetFiles.ejs index 5477ea28..8e543f21 100644 --- a/examples/server/views/parquetFiles.ejs +++ b/examples/server/views/parquetFiles.ejs @@ -11,31 +11,38 @@ - - - - - diff --git a/test/browser/main.ts b/test/browser/main.ts index c2a88470..47c3659d 100644 --- a/test/browser/main.ts +++ b/test/browser/main.ts @@ -121,5 +121,127 @@ describe('Browser tests', function () { await reader.close(); }); }); + + it('can read brotli compressed data', async function () { + // Data from test/test-files/sample_brotli_compressed.parquet + const uint8Array = [ + 80, 65, 82, 49, 21, 4, 21, 80, 21, 34, 76, 21, 10, 21, 0, 18, 0, 0, 27, 39, 0, 0, 4, 238, 248, 108, 160, 17, 74, + 10, 145, 22, 229, 106, 14, 21, 0, 21, 22, 21, 30, 44, 21, 10, 21, 16, 21, 6, 21, 6, 28, 24, 8, 5, 0, 0, 0, 0, 0, + 0, 0, 24, 8, 1, 0, 0, 0, 0, 0, 0, 0, 22, 0, 40, 8, 5, 0, 0, 0, 0, 0, 0, 0, 24, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 5, 128, 2, 0, 0, 0, 10, 1, 3, 3, 136, 70, 0, 3, 38, 222, 1, 28, 21, 4, 25, 53, 0, 6, 16, 25, 24, 2, 105, + 100, 21, 8, 22, 10, 22, 252, 1, 22, 214, 1, 38, 70, 38, 8, 28, 24, 8, 5, 0, 0, 0, 0, 0, 0, 0, 24, 8, 1, 0, 0, 0, + 0, 0, 0, 0, 22, 0, 40, 8, 5, 0, 0, 0, 0, 0, 0, 0, 24, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 25, 44, 21, 4, 21, 0, 21, 2, + 0, 21, 0, 21, 16, 21, 2, 0, 0, 0, 21, 4, 21, 86, 21, 94, 76, 21, 10, 21, 0, 18, 0, 0, 11, 21, 128, 5, 0, 0, 0, + 65, 108, 105, 99, 101, 3, 0, 0, 0, 66, 111, 98, 7, 0, 0, 0, 67, 104, 97, 114, 108, 105, 101, 5, 0, 0, 0, 68, 97, + 118, 105, 100, 3, 0, 0, 0, 69, 118, 101, 3, 21, 0, 21, 22, 21, 30, 44, 21, 10, 21, 16, 21, 6, 21, 6, 28, 54, 0, + 40, 3, 69, 118, 101, 24, 5, 65, 108, 105, 99, 101, 0, 0, 0, 11, 5, 128, 2, 0, 0, 0, 10, 1, 3, 3, 136, 70, 0, 3, + 38, 240, 4, 28, 21, 12, 25, 53, 0, 6, 16, 25, 24, 4, 110, 97, 109, 101, 21, 8, 22, 10, 22, 202, 1, 22, 218, 1, + 38, 144, 4, 38, 150, 3, 28, 54, 0, 40, 3, 69, 118, 101, 24, 5, 65, 108, 105, 99, 101, 0, 25, 44, 21, 4, 21, 0, + 21, 2, 0, 21, 0, 21, 16, 21, 2, 0, 0, 0, 21, 4, 21, 80, 21, 44, 76, 21, 10, 21, 0, 18, 0, 0, 27, 39, 0, 0, 4, + 54, 224, 18, 77, 150, 101, 57, 27, 104, 132, 146, 66, 164, 69, 185, 154, 3, 21, 0, 21, 22, 21, 30, 44, 21, 10, + 21, 16, 21, 6, 21, 6, 28, 24, 8, 45, 0, 0, 0, 0, 0, 0, 0, 24, 8, 25, 0, 0, 0, 0, 0, 0, 0, 22, 0, 40, 8, 45, 0, + 0, 0, 0, 0, 0, 0, 24, 8, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 5, 128, 2, 0, 0, 0, 10, 1, 3, 3, 136, 70, 0, 3, + 38, 216, 7, 28, 21, 4, 25, 53, 0, 6, 16, 25, 24, 3, 97, 103, 101, 21, 8, 22, 10, 22, 252, 1, 22, 224, 1, 38, + 192, 6, 38, 248, 5, 28, 24, 8, 45, 0, 0, 0, 0, 0, 0, 0, 24, 8, 25, 0, 0, 0, 0, 0, 0, 0, 22, 0, 40, 8, 45, 0, 0, + 0, 0, 0, 0, 0, 24, 8, 25, 0, 0, 0, 0, 0, 0, 0, 0, 25, 44, 21, 4, 21, 0, 21, 2, 0, 21, 0, 21, 16, 21, 2, 0, 0, 0, + 21, 4, 25, 76, 53, 0, 24, 6, 115, 99, 104, 101, 109, 97, 21, 6, 0, 21, 4, 37, 2, 24, 2, 105, 100, 0, 21, 12, 37, + 2, 24, 4, 110, 97, 109, 101, 37, 0, 76, 28, 0, 0, 0, 21, 4, 37, 2, 24, 3, 97, 103, 101, 0, 22, 10, 25, 28, 25, + 60, 38, 222, 1, 28, 21, 4, 25, 53, 0, 6, 16, 25, 24, 2, 105, 100, 21, 8, 22, 10, 22, 252, 1, 22, 214, 1, 38, 70, + 38, 8, 28, 24, 8, 5, 0, 0, 0, 0, 0, 0, 0, 24, 8, 1, 0, 0, 0, 0, 0, 0, 0, 22, 0, 40, 8, 5, 0, 0, 0, 0, 0, 0, 0, + 24, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 25, 44, 21, 4, 21, 0, 21, 2, 0, 21, 0, 21, 16, 21, 2, 0, 0, 0, 38, 240, 4, 28, + 21, 12, 25, 53, 0, 6, 16, 25, 24, 4, 110, 97, 109, 101, 21, 8, 22, 10, 22, 202, 1, 22, 218, 1, 38, 144, 4, 38, + 150, 3, 28, 54, 0, 40, 3, 69, 118, 101, 24, 5, 65, 108, 105, 99, 101, 0, 25, 44, 21, 4, 21, 0, 21, 2, 0, 21, 0, + 21, 16, 21, 2, 0, 0, 0, 38, 216, 7, 28, 21, 4, 25, 53, 0, 6, 16, 25, 24, 3, 97, 103, 101, 21, 8, 22, 10, 22, + 252, 1, 22, 224, 1, 38, 192, 6, 38, 248, 5, 28, 24, 8, 45, 0, 0, 0, 0, 0, 0, 0, 24, 8, 25, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 40, 8, 45, 0, 0, 0, 0, 0, 0, 0, 24, 8, 25, 0, 0, 0, 0, 0, 0, 0, 0, 25, 44, 21, 4, 21, 0, 21, 2, 0, 21, 0, + 21, 16, 21, 2, 0, 0, 0, 22, 194, 5, 22, 10, 38, 8, 22, 144, 5, 20, 0, 0, 25, 44, 24, 6, 112, 97, 110, 100, 97, + 115, 24, 251, 4, 123, 34, 105, 110, 100, 101, 120, 95, 99, 111, 108, 117, 109, 110, 115, 34, 58, 32, 91, 123, + 34, 107, 105, 110, 100, 34, 58, 32, 34, 114, 97, 110, 103, 101, 34, 44, 32, 34, 110, 97, 109, 101, 34, 58, 32, + 110, 117, 108, 108, 44, 32, 34, 115, 116, 97, 114, 116, 34, 58, 32, 48, 44, 32, 34, 115, 116, 111, 112, 34, 58, + 32, 53, 44, 32, 34, 115, 116, 101, 112, 34, 58, 32, 49, 125, 93, 44, 32, 34, 99, 111, 108, 117, 109, 110, 95, + 105, 110, 100, 101, 120, 101, 115, 34, 58, 32, 91, 123, 34, 110, 97, 109, 101, 34, 58, 32, 110, 117, 108, 108, + 44, 32, 34, 102, 105, 101, 108, 100, 95, 110, 97, 109, 101, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 112, 97, + 110, 100, 97, 115, 95, 116, 121, 112, 101, 34, 58, 32, 34, 117, 110, 105, 99, 111, 100, 101, 34, 44, 32, 34, + 110, 117, 109, 112, 121, 95, 116, 121, 112, 101, 34, 58, 32, 34, 111, 98, 106, 101, 99, 116, 34, 44, 32, 34, + 109, 101, 116, 97, 100, 97, 116, 97, 34, 58, 32, 123, 34, 101, 110, 99, 111, 100, 105, 110, 103, 34, 58, 32, 34, + 85, 84, 70, 45, 56, 34, 125, 125, 93, 44, 32, 34, 99, 111, 108, 117, 109, 110, 115, 34, 58, 32, 91, 123, 34, + 110, 97, 109, 101, 34, 58, 32, 34, 105, 100, 34, 44, 32, 34, 102, 105, 101, 108, 100, 95, 110, 97, 109, 101, 34, + 58, 32, 34, 105, 100, 34, 44, 32, 34, 112, 97, 110, 100, 97, 115, 95, 116, 121, 112, 101, 34, 58, 32, 34, 105, + 110, 116, 54, 52, 34, 44, 32, 34, 110, 117, 109, 112, 121, 95, 116, 121, 112, 101, 34, 58, 32, 34, 105, 110, + 116, 54, 52, 34, 44, 32, 34, 109, 101, 116, 97, 100, 97, 116, 97, 34, 58, 32, 110, 117, 108, 108, 125, 44, 32, + 123, 34, 110, 97, 109, 101, 34, 58, 32, 34, 110, 97, 109, 101, 34, 44, 32, 34, 102, 105, 101, 108, 100, 95, 110, + 97, 109, 101, 34, 58, 32, 34, 110, 97, 109, 101, 34, 44, 32, 34, 112, 97, 110, 100, 97, 115, 95, 116, 121, 112, + 101, 34, 58, 32, 34, 117, 110, 105, 99, 111, 100, 101, 34, 44, 32, 34, 110, 117, 109, 112, 121, 95, 116, 121, + 112, 101, 34, 58, 32, 34, 111, 98, 106, 101, 99, 116, 34, 44, 32, 34, 109, 101, 116, 97, 100, 97, 116, 97, 34, + 58, 32, 110, 117, 108, 108, 125, 44, 32, 123, 34, 110, 97, 109, 101, 34, 58, 32, 34, 97, 103, 101, 34, 44, 32, + 34, 102, 105, 101, 108, 100, 95, 110, 97, 109, 101, 34, 58, 32, 34, 97, 103, 101, 34, 44, 32, 34, 112, 97, 110, + 100, 97, 115, 95, 116, 121, 112, 101, 34, 58, 32, 34, 105, 110, 116, 54, 52, 34, 44, 32, 34, 110, 117, 109, 112, + 121, 95, 116, 121, 112, 101, 34, 58, 32, 34, 105, 110, 116, 54, 52, 34, 44, 32, 34, 109, 101, 116, 97, 100, 97, + 116, 97, 34, 58, 32, 110, 117, 108, 108, 125, 93, 44, 32, 34, 99, 114, 101, 97, 116, 111, 114, 34, 58, 32, 123, + 34, 108, 105, 98, 114, 97, 114, 121, 34, 58, 32, 34, 112, 121, 97, 114, 114, 111, 119, 34, 44, 32, 34, 118, 101, + 114, 115, 105, 111, 110, 34, 58, 32, 34, 49, 55, 46, 48, 46, 48, 34, 125, 44, 32, 34, 112, 97, 110, 100, 97, + 115, 95, 118, 101, 114, 115, 105, 111, 110, 34, 58, 32, 34, 50, 46, 50, 46, 50, 34, 125, 0, 24, 12, 65, 82, 82, + 79, 87, 58, 115, 99, 104, 101, 109, 97, 24, 192, 9, 47, 47, 47, 47, 47, 52, 103, 68, 65, 65, 65, 81, 65, 65, 65, + 65, 65, 65, 65, 75, 65, 65, 52, 65, 66, 103, 65, 70, 65, 65, 103, 65, 67, 103, 65, 65, 65, 65, 65, 66, 66, 65, + 65, 81, 65, 65, 65, 65, 65, 65, 65, 75, 65, 65, 119, 65, 65, 65, 65, 69, 65, 65, 103, 65, 67, 103, 65, 65, 65, + 76, 65, 67, 65, 65, 65, 69, 65, 65, 65, 65, 65, 81, 65, 65, 65, 65, 119, 65, 65, 65, 65, 73, 65, 65, 119, 65, + 66, 65, 65, 73, 65, 65, 103, 65, 65, 65, 67, 73, 65, 103, 65, 65, 66, 65, 65, 65, 65, 72, 115, 67, 65, 65, 66, + 55, 73, 109, 108, 117, 90, 71, 86, 52, 88, 50, 78, 118, 98, 72, 86, 116, 98, 110, 77, 105, 79, 105, 66, 98, 101, + 121, 74, 114, 97, 87, 53, 107, 73, 106, 111, 103, 73, 110, 74, 104, 98, 109, 100, 108, 73, 105, 119, 103, 73, + 109, 53, 104, 98, 87, 85, 105, 79, 105, 66, 117, 100, 87, 120, 115, 76, 67, 65, 105, 99, 51, 82, 104, 99, 110, + 81, 105, 79, 105, 65, 119, 76, 67, 65, 105, 99, 51, 82, 118, 99, 67, 73, 54, 73, 68, 85, 115, 73, 67, 74, 122, + 100, 71, 86, 119, 73, 106, 111, 103, 77, 88, 49, 100, 76, 67, 65, 105, 89, 50, 57, 115, 100, 87, 49, 117, 88, + 50, 108, 117, 90, 71, 86, 52, 90, 88, 77, 105, 79, 105, 66, 98, 101, 121, 74, 117, 89, 87, 49, 108, 73, 106, + 111, 103, 98, 110, 86, 115, 98, 67, 119, 103, 73, 109, 90, 112, 90, 87, 120, 107, 88, 50, 53, 104, 98, 87, 85, + 105, 79, 105, 66, 117, 100, 87, 120, 115, 76, 67, 65, 105, 99, 71, 70, 117, 90, 71, 70, 122, 88, 51, 82, 53, 99, + 71, 85, 105, 79, 105, 65, 105, 100, 87, 53, 112, 89, 50, 57, 107, 90, 83, 73, 115, 73, 67, 74, 117, 100, 87, 49, + 119, 101, 86, 57, 48, 101, 88, 66, 108, 73, 106, 111, 103, 73, 109, 57, 105, 97, 109, 86, 106, 100, 67, 73, 115, + 73, 67, 74, 116, 90, 88, 82, 104, 90, 71, 70, 48, 89, 83, 73, 54, 73, 72, 115, 105, 90, 87, 53, 106, 98, 50, 82, + 112, 98, 109, 99, 105, 79, 105, 65, 105, 86, 86, 82, 71, 76, 84, 103, 105, 102, 88, 49, 100, 76, 67, 65, 105, + 89, 50, 57, 115, 100, 87, 49, 117, 99, 121, 73, 54, 73, 70, 116, 55, 73, 109, 53, 104, 98, 87, 85, 105, 79, 105, + 65, 105, 97, 87, 81, 105, 76, 67, 65, 105, 90, 109, 108, 108, 98, 71, 82, 102, 98, 109, 70, 116, 90, 83, 73, 54, + 73, 67, 74, 112, 90, 67, 73, 115, 73, 67, 74, 119, 89, 87, 53, 107, 89, 88, 78, 102, 100, 72, 108, 119, 90, 83, + 73, 54, 73, 67, 74, 112, 98, 110, 81, 50, 78, 67, 73, 115, 73, 67, 74, 117, 100, 87, 49, 119, 101, 86, 57, 48, + 101, 88, 66, 108, 73, 106, 111, 103, 73, 109, 108, 117, 100, 68, 89, 48, 73, 105, 119, 103, 73, 109, 49, 108, + 100, 71, 70, 107, 89, 88, 82, 104, 73, 106, 111, 103, 98, 110, 86, 115, 98, 72, 48, 115, 73, 72, 115, 105, 98, + 109, 70, 116, 90, 83, 73, 54, 73, 67, 74, 117, 89, 87, 49, 108, 73, 105, 119, 103, 73, 109, 90, 112, 90, 87, + 120, 107, 88, 50, 53, 104, 98, 87, 85, 105, 79, 105, 65, 105, 98, 109, 70, 116, 90, 83, 73, 115, 73, 67, 74, + 119, 89, 87, 53, 107, 89, 88, 78, 102, 100, 72, 108, 119, 90, 83, 73, 54, 73, 67, 74, 49, 98, 109, 108, 106, 98, + 50, 82, 108, 73, 105, 119, 103, 73, 109, 53, 49, 98, 88, 66, 53, 88, 51, 82, 53, 99, 71, 85, 105, 79, 105, 65, + 105, 98, 50, 74, 113, 90, 87, 78, 48, 73, 105, 119, 103, 73, 109, 49, 108, 100, 71, 70, 107, 89, 88, 82, 104, + 73, 106, 111, 103, 98, 110, 86, 115, 98, 72, 48, 115, 73, 72, 115, 105, 98, 109, 70, 116, 90, 83, 73, 54, 73, + 67, 74, 104, 90, 50, 85, 105, 76, 67, 65, 105, 90, 109, 108, 108, 98, 71, 82, 102, 98, 109, 70, 116, 90, 83, 73, + 54, 73, 67, 74, 104, 90, 50, 85, 105, 76, 67, 65, 105, 99, 71, 70, 117, 90, 71, 70, 122, 88, 51, 82, 53, 99, 71, + 85, 105, 79, 105, 65, 105, 97, 87, 53, 48, 78, 106, 81, 105, 76, 67, 65, 105, 98, 110, 86, 116, 99, 72, 108, + 102, 100, 72, 108, 119, 90, 83, 73, 54, 73, 67, 74, 112, 98, 110, 81, 50, 78, 67, 73, 115, 73, 67, 74, 116, 90, + 88, 82, 104, 90, 71, 70, 48, 89, 83, 73, 54, 73, 71, 53, 49, 98, 71, 120, 57, 88, 83, 119, 103, 73, 109, 78, + 121, 90, 87, 70, 48, 98, 51, 73, 105, 79, 105, 66, 55, 73, 109, 120, 112, 89, 110, 74, 104, 99, 110, 107, 105, + 79, 105, 65, 105, 99, 72, 108, 104, 99, 110, 74, 118, 100, 121, 73, 115, 73, 67, 74, 50, 90, 88, 74, 122, 97, + 87, 57, 117, 73, 106, 111, 103, 73, 106, 69, 51, 76, 106, 65, 117, 77, 67, 74, 57, 76, 67, 65, 105, 99, 71, 70, + 117, 90, 71, 70, 122, 88, 51, 90, 108, 99, 110, 78, 112, 98, 50, 52, 105, 79, 105, 65, 105, 77, 105, 52, 121, + 76, 106, 73, 105, 102, 81, 65, 71, 65, 65, 65, 65, 99, 71, 70, 117, 90, 71, 70, 122, 65, 65, 65, 68, 65, 65, 65, + 65, 100, 65, 65, 65, 65, 68, 81, 65, 65, 65, 65, 69, 65, 65, 65, 65, 113, 80, 47, 47, 47, 119, 65, 65, 65, 81, + 73, 81, 65, 65, 65, 65, 70, 65, 65, 65, 65, 65, 81, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 119, 65, 65, 65, 71, + 70, 110, 90, 81, 67, 89, 47, 47, 47, 47, 65, 65, 65, 65, 65, 85, 65, 65, 65, 65, 68, 85, 47, 47, 47, 47, 65, 65, + 65, 66, 66, 82, 65, 65, 65, 65, 65, 99, 65, 65, 65, 65, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 69, 65, 65, + 65, 65, 98, 109, 70, 116, 90, 81, 65, 65, 65, 65, 65, 69, 65, 65, 81, 65, 66, 65, 65, 65, 65, 66, 65, 65, 70, + 65, 65, 73, 65, 65, 89, 65, 66, 119, 65, 77, 65, 65, 65, 65, 69, 65, 65, 81, 65, 65, 65, 65, 65, 65, 65, 66, 65, + 104, 65, 65, 65, 65, 65, 99, 65, 65, 65, 65, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 65, 65, 65, 65, 97, + 87, 81, 65, 65, 65, 103, 65, 68, 65, 65, 73, 65, 65, 99, 65, 67, 65, 65, 65, 65, 65, 65, 65, 65, 65, 70, 65, 65, + 65, 65, 65, 0, 24, 32, 112, 97, 114, 113, 117, 101, 116, 45, 99, 112, 112, 45, 97, 114, 114, 111, 119, 32, 118, + 101, 114, 115, 105, 111, 110, 32, 49, 55, 46, 48, 46, 48, 25, 60, 28, 0, 0, 28, 0, 0, 28, 0, 0, 0, 208, 8, 0, 0, + 80, 65, 82, 49, + ]; + const brotliCompressedBuffer = buffer.Buffer.from(uint8Array); + const reader = await parquetjs.ParquetReader.openBuffer(brotliCompressedBuffer); + const data: any[] = []; + for await (const record of reader) { + data.push(record); + } + assert.equal(data.length, 5); + after(async function () { + await reader.close(); + }); + }); }); }); diff --git a/test/lib/codec/rle.test.ts b/test/lib/codec/rle.test.ts new file mode 100644 index 00000000..bc2c81fa --- /dev/null +++ b/test/lib/codec/rle.test.ts @@ -0,0 +1,18 @@ +// import chai, { expect } from 'chai'; +// import { decodeRunBitpacked } from '../../../lib/codec/rle'; +// import type { Cursor } from '../../../lib/codec/types'; + +// const _assert = chai.assert; + +// describe('RLE Codec', function () { +// describe('#decodeRunBitpacked', function () { +// it.only('can decode a known bitpack value', function () { +// const cursor: Cursor = { +// buffer: Buffer.from([7, 251, 127, 127, 28, 1, 9, 254, 251, 191, 63]), +// offset: 0, +// }; +// const result = decodeRunBitpacked(cursor, 24, { bitWidth: 1 }); +// expect(result).equals([]); +// }); +// }); +// }); diff --git a/test/reference-test/read-all.test.ts b/test/reference-test/read-all.test.ts index 35c85d27..104735f7 100644 --- a/test/reference-test/read-all.test.ts +++ b/test/reference-test/read-all.test.ts @@ -27,7 +27,7 @@ export const unsupported = [ 'delta_encoding_optional_column.parquet', // DELTA_BINARY_PACKED unsupported 'delta_encoding_required_column.parquet', // DELTA_BINARY_PACKED unsupported 'delta_length_byte_array.parquet', // ZSTD unsupported, DELTA_BINARY_PACKED unsupported - 'large_string_map.brotli.parquet', // Failes as the large string is > 1 GB + 'large_string_map.brotli.parquet', // Fails as the large string is > 1 GB ]; describe('Read Test for all files', function () { diff --git a/test/test-files.js b/test/test-files.js index 116a4bda..22927ff4 100644 --- a/test/test-files.js +++ b/test/test-files.js @@ -216,6 +216,15 @@ describe('test-files', function () { } }); + describe('Brotli compression', function () { + // The browser test is separate: in test/browser/main.ts + it('works for Node', async function () { + const data = await readData('sample_brotli_compressed.parquet'); + assert.deepEqual(data[0], { id: '1', name: 'Alice', age: '25' }); + assert.deepEqual(data[1], { id: '2', name: 'Bob', age: '30' }); + }); + }); + describe('RLE', function () { // Tracked in https://github.com/LibertyDSNP/parquetjs/issues/113 it.skip('rle_boolean_encoding.parquet loads', async function () { diff --git a/test/test-files/sample_brotli_compressed.parquet b/test/test-files/sample_brotli_compressed.parquet new file mode 100644 index 0000000000000000000000000000000000000000..f5d5af8b1ed49abf573486155cbec743d083297a GIT binary patch literal 2851 zcmcIm&2Jh<6dw#G)Um2G>LO6A%33Kj2b=;nPKk0Eu)#|)F*s&ntJc~t!{Xg#4T~|h zEalKck7*A%^wdNDiQb|fd+MpGdZ=>gwdyfad+2+!Kn*5RBQ*=mypP%Ue(yJLM(ojQ zk_&Kq9ADy=IC7hiJ0B7f_~VuN?R&+gufo5#-{lAw=01pn`xY1Ef-8~GBJrL`$TyP0 zWlLwJ{OAk+>We)K#GdcqzIPee^clBKAM*RP60C z7ye-}yc7$CpDn&mNHiV^IyNT}}Jjt(p%wJvsGmU~bG<<&w z#mF{;!m!=V4aUM0hKczK1SIG(4oF62dGob2%nR0;L~mB^wOr8c*DD$sXEIH&+yAX3 zwxeBLb~{~0v}q_^xjRIjouS=pxGwPQ`)4tCbMO;Q~m)OwTJ{H=YreGIa zilv!?F=z@_x}}H*xTdd(XT4I68tQtrrP>v+(ZNVRRdd3ouyxQAa>aA4P#a*J-Fi|( zexv)^q$3i-(6wWgB zee9p|P!jVAWnI9Yh5b5n8qm+Gea!Y3VuD;e)rPDeQc}HmE{mBy>-+ZhdZ|tOySZY9 z_4Nd!WU6-AQBoT$#;&n3EVTvWs6q>Pw8pi7h-aE=IBc;)3Fnp4lRY@^cswftGr}Q9 zg^g@LUmU{{g`w(Ov)m literal 0 HcmV?d00001 From 6c5d024dbf7cc8c341ebe525ae38aea507bfb84e Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:04:43 -0400 Subject: [PATCH 11/20] Add example file to example server --- examples/server/views/parquetFiles.ejs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/server/views/parquetFiles.ejs b/examples/server/views/parquetFiles.ejs index 601058fc..09866217 100644 --- a/examples/server/views/parquetFiles.ejs +++ b/examples/server/views/parquetFiles.ejs @@ -63,6 +63,7 @@
  • +
  • Search fruits-bloomfilter.parquet "name" column for

    From 870e78d3d7e35454b130db7fbc571c77279c6da9 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:17:26 -0400 Subject: [PATCH 12/20] Fix serve issue --- esbuild-serve.mjs | 5 +++-- .../files/sample_brotli_compressed.parquet | Bin 0 -> 2851 bytes 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 examples/server/public/files/sample_brotli_compressed.parquet diff --git a/esbuild-serve.mjs b/esbuild-serve.mjs index 17be8dc5..0359557b 100644 --- a/esbuild-serve.mjs +++ b/esbuild-serve.mjs @@ -5,8 +5,9 @@ */ import { compressionBrowserPlugin } from './esbuild-plugins.mjs'; import watPlugin from 'esbuild-plugin-wat'; +import esbuild from 'esbuild'; // esbuild has TypeScript support by default. It will use .tsconfig -require('esbuild') +esbuild .context({ entryPoints: ['parquet.ts'], outfile: 'main.js', @@ -22,7 +23,7 @@ require('esbuild') .then((context) => { context .serve({ - servedir: __dirname, + servedir: './', }) .then((server) => { console.log('serving parquetjs', server); diff --git a/examples/server/public/files/sample_brotli_compressed.parquet b/examples/server/public/files/sample_brotli_compressed.parquet new file mode 100644 index 0000000000000000000000000000000000000000..f5d5af8b1ed49abf573486155cbec743d083297a GIT binary patch literal 2851 zcmcIm&2Jh<6dw#G)Um2G>LO6A%33Kj2b=;nPKk0Eu)#|)F*s&ntJc~t!{Xg#4T~|h zEalKck7*A%^wdNDiQb|fd+MpGdZ=>gwdyfad+2+!Kn*5RBQ*=mypP%Ue(yJLM(ojQ zk_&Kq9ADy=IC7hiJ0B7f_~VuN?R&+gufo5#-{lAw=01pn`xY1Ef-8~GBJrL`$TyP0 zWlLwJ{OAk+>We)K#GdcqzIPee^clBKAM*RP60C z7ye-}yc7$CpDn&mNHiV^IyNT}}Jjt(p%wJvsGmU~bG<<&w z#mF{;!m!=V4aUM0hKczK1SIG(4oF62dGob2%nR0;L~mB^wOr8c*DD$sXEIH&+yAX3 zwxeBLb~{~0v}q_^xjRIjouS=pxGwPQ`)4tCbMO;Q~m)OwTJ{H=YreGIa zilv!?F=z@_x}}H*xTdd(XT4I68tQtrrP>v+(ZNVRRdd3ouyxQAa>aA4P#a*J-Fi|( zexv)^q$3i-(6wWgB zee9p|P!jVAWnI9Yh5b5n8qm+Gea!Y3VuD;e)rPDeQc}HmE{mBy>-+ZhdZ|tOySZY9 z_4Nd!WU6-AQBoT$#;&n3EVTvWs6q>Pw8pi7h-aE=IBc;)3Fnp4lRY@^cswftGr}Q9 zg^g@LUmU{{g`w(Ov)m literal 0 HcmV?d00001 From 8b0ba53306a0cbd41b99675a5aab775673d76037 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:23:15 -0400 Subject: [PATCH 13/20] Docs fix --- esbuild-plugins.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/esbuild-plugins.mjs b/esbuild-plugins.mjs index 5df9980b..365290b2 100644 --- a/esbuild-plugins.mjs +++ b/esbuild-plugins.mjs @@ -1,7 +1,6 @@ import path from 'node:path'; /** - * this plugin resolves to a browser version of compression.ts that - * does not include LZO comprssion. + * this plugin resolves to a browser version of compression.ts that uses different code for browsers */ export const compressionBrowserPlugin = { name: 'compressionBrowser', From 1a8026c7e94317144b7a7288cd940ed7d996f051 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:26:29 -0400 Subject: [PATCH 14/20] Remove unneeded logs --- lib/browser/brotli.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/browser/brotli.ts b/lib/browser/brotli.ts index 9a186524..66c0a980 100644 --- a/lib/browser/brotli.ts +++ b/lib/browser/brotli.ts @@ -14,12 +14,10 @@ function mergeUint8Arrays(arrs: Uint8Array[], totalLength: number): Uint8Array { output.set(arr, priorLength); priorLength += arr.length; } - console.log('output Length', output.length); return output; } export async function compress(input: Uint8Array): Promise { - console.log('Compress Input Length: ', input.length); // Get a stream for your input: const inputStream = new ReadableStream({ start(controller) { @@ -81,7 +79,6 @@ export async function compress(input: Uint8Array): Promise { } export async function inflate(input: Uint8Array): Promise { - console.log('Inflate Input Length: ', input.length); // Get a stream for your input: const inputStream = new ReadableStream({ start(controller) { From 9ddc9fb248a5d28ac2dc660fe9a25d6d4526ef7a Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:27:10 -0400 Subject: [PATCH 15/20] Remove comment --- lib/browser/compression.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/browser/compression.ts b/lib/browser/compression.ts index 96f2294d..725a2794 100644 --- a/lib/browser/compression.ts +++ b/lib/browser/compression.ts @@ -91,7 +91,6 @@ function inflate_snappy(value: ArrayBuffer | Buffer | Uint8Array) { } async function inflate_brotli(value: Uint8Array) { - // //testing return buffer_from_result(await brotli.inflate(value)); } From 5ec71df7040ac9dc4416de571619ec5dd032238c Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:27:51 -0400 Subject: [PATCH 16/20] Remove bad test --- test/lib/codec/rle.test.ts | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 test/lib/codec/rle.test.ts diff --git a/test/lib/codec/rle.test.ts b/test/lib/codec/rle.test.ts deleted file mode 100644 index bc2c81fa..00000000 --- a/test/lib/codec/rle.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -// import chai, { expect } from 'chai'; -// import { decodeRunBitpacked } from '../../../lib/codec/rle'; -// import type { Cursor } from '../../../lib/codec/types'; - -// const _assert = chai.assert; - -// describe('RLE Codec', function () { -// describe('#decodeRunBitpacked', function () { -// it.only('can decode a known bitpack value', function () { -// const cursor: Cursor = { -// buffer: Buffer.from([7, 251, 127, 127, 28, 1, 9, 254, 251, 191, 63]), -// offset: 0, -// }; -// const result = decodeRunBitpacked(cursor, 24, { bitWidth: 1 }); -// expect(result).equals([]); -// }); -// }); -// }); From c6c19009cad4487bfb69a6ea82440f344c8f5fb9 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:50:34 -0400 Subject: [PATCH 17/20] Fix lint issues --- eslint.config.mjs | 3 +++ test/browser/main.ts | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 7676fb11..2b666d45 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -10,6 +10,9 @@ export default tseslint.config( mochaPlugin.configs.flat.recommended, ...tseslint.configs.strict, ...tseslint.configs.stylistic, + { + ignores: ['dist/*', 'test/browser/main.js'], + }, { rules: { // TODO: Fix/ignore in tests and remove diff --git a/test/browser/main.ts b/test/browser/main.ts index 47c3659d..a0d47755 100644 --- a/test/browser/main.ts +++ b/test/browser/main.ts @@ -5,6 +5,12 @@ const buffer = require('buffer'); describe('Browser tests', function () { describe('reader', function () { + let reader; + + after(async function () { + if (reader) await reader.close(); + }); + it('can read snappy compressed data', async function () { // Data from test/test-files/snappy-compressed.parquet const uint8Array = [ @@ -25,16 +31,12 @@ describe('Browser tests', function () { 101, 116, 106, 115, 0, 163, 0, 0, 0, 80, 65, 82, 49, ]; const snappyCompressedBuffer = buffer.Buffer.from(uint8Array); - const reader = await parquetjs.ParquetReader.openBuffer(snappyCompressedBuffer); + reader = await parquetjs.ParquetReader.openBuffer(snappyCompressedBuffer); const data: any[] = []; for await (const record of reader) { data.push(record); } assert.equal(data.length, 4); - - after(async function () { - await reader.close(); - }); }); it('can read gzip compressed data', async function () { @@ -110,16 +112,12 @@ describe('Browser tests', function () { 57, 100, 53, 53, 97, 51, 41, 0, 71, 1, 0, 0, 80, 65, 82, 49, ]; const gzipCompressedBuffer = buffer.Buffer.from(uint8Array); - const reader = await parquetjs.ParquetReader.openBuffer(gzipCompressedBuffer); + reader = await parquetjs.ParquetReader.openBuffer(gzipCompressedBuffer); const data: any[] = []; for await (const record of reader) { data.push(record); } assert.equal(data.length, 25); - - after(async function () { - await reader.close(); - }); }); it('can read brotli compressed data', async function () { @@ -233,15 +231,12 @@ describe('Browser tests', function () { 80, 65, 82, 49, ]; const brotliCompressedBuffer = buffer.Buffer.from(uint8Array); - const reader = await parquetjs.ParquetReader.openBuffer(brotliCompressedBuffer); + reader = await parquetjs.ParquetReader.openBuffer(brotliCompressedBuffer); const data: any[] = []; for await (const record of reader) { data.push(record); } assert.equal(data.length, 5); - after(async function () { - await reader.close(); - }); }); }); }); From 23e281c904dfdbaea778e99b06c2fe1fded2badd Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:50:59 -0400 Subject: [PATCH 18/20] Update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5ffd9c3e..28fda3cb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ dist !test/reference-test/files/*.parquet examples/server/package-lock.json test/browser/*.js +main.js +main.js.map From 45be2f3aaab0169c5d9a68d60fba136da60a231d Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 11:54:02 -0400 Subject: [PATCH 19/20] Update test for merge --- test/test-files.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-files.js b/test/test-files.js index 22927ff4..15da0578 100644 --- a/test/test-files.js +++ b/test/test-files.js @@ -220,8 +220,8 @@ describe('test-files', function () { // The browser test is separate: in test/browser/main.ts it('works for Node', async function () { const data = await readData('sample_brotli_compressed.parquet'); - assert.deepEqual(data[0], { id: '1', name: 'Alice', age: '25' }); - assert.deepEqual(data[1], { id: '2', name: 'Bob', age: '30' }); + assert.deepEqual(data[0], { id: 1n, name: 'Alice', age: 25n }); + assert.deepEqual(data[1], { id: 2n, name: 'Bob', age: 30n }); }); }); From 3d4146b404e878d48b448b05cee539d9be7c1ce8 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Tue, 10 Sep 2024 17:06:53 -0400 Subject: [PATCH 20/20] Update esbuild.mjs --- esbuild.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esbuild.mjs b/esbuild.mjs index ea63fc55..7c623fc3 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -11,7 +11,7 @@ const baseConfig = { global: 'window', }, inject: ['./esbuild-shims.mjs'], - minify: false, + minify: true, mainFields: ['browser', 'module', 'main'], platform: 'browser', // default plugins: [compressionBrowserPlugin, watPlugin()],