diff --git a/package.json b/package.json index 1155739..d0d0549 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "eslint-plugin-import": "2.29.1", "eslint-plugin-jsdoc": "48.2.0", "http-server": "14.1.1", - "hysnappy": "0.2.0", + "hysnappy": "0.3.0", "typescript": "5.3.3", "vitest": "1.3.1" } diff --git a/src/column.js b/src/column.js index d5e2456..143dc29 100644 --- a/src/column.js +++ b/src/column.js @@ -182,8 +182,7 @@ export function decompressPage(compressedBytes, uncompressed_page_size, codec, c if (codec === 'UNCOMPRESSED') { page = compressedBytes } else if (customDecompressor) { - page = new Uint8Array(uncompressed_page_size) - customDecompressor(compressedBytes, page) + page = customDecompressor(compressedBytes, uncompressed_page_size) } else if (codec === 'SNAPPY') { page = new Uint8Array(uncompressed_page_size) snappyUncompress(compressedBytes, page) diff --git a/src/types.d.ts b/src/types.d.ts index 7fbedbb..8a97668 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -134,7 +134,7 @@ export type CompressionCodec = 'LZ4_RAW' export type Compressors = { - [K in CompressionCodec]?: (input: Uint8Array, output: Uint8Array) => void + [K in CompressionCodec]?: (input: Uint8Array, outputLength: number) => Uint8Array } interface KeyValue { diff --git a/test/read.test.js b/test/read.test.js index 869a36c..93bf14e 100644 --- a/test/read.test.js +++ b/test/read.test.js @@ -10,9 +10,9 @@ import { fileToAsyncBuffer, fileToJson } from './helpers.js' * @type {Compressors} */ const compressors = { - GZIP: (/** @type {Uint8Array} */ input, /** @type {Uint8Array} */ output) => { + GZIP: (/** @type {Uint8Array} */ input, /** @type {number} */ outputLength) => { const result = gunzipSync(input) - output.set(result) + return new Uint8Array(result.buffer, result.byteOffset, outputLength) }, }