Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/result/ArrowResultHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class ArrowResultHandler implements IResultsProvider<ArrowBatch>
this.isLZ4Compressed = lz4Compressed ?? false;

if (this.isLZ4Compressed && !LZ4()) {
throw new HiveDriverError('Cannot handle LZ4 compressed result: module `lz4` not installed');
throw new HiveDriverError('Cannot handle LZ4 compressed result: module `lz4-napi` not installed');
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/result/CloudFetchResultHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class CloudFetchResultHandler implements IResultsProvider<ArrowBa
this.isLZ4Compressed = lz4Compressed ?? false;

if (this.isLZ4Compressed && !LZ4()) {
throw new HiveDriverError('Cannot handle LZ4 compressed result: module `lz4` not installed');
throw new HiveDriverError('Cannot handle LZ4 compressed result: module `lz4-napi` not installed');
}
}

Expand Down
14 changes: 10 additions & 4 deletions lib/utils/lz4.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import type LZ4Namespace from 'lz4';

type LZ4Module = typeof LZ4Namespace;
interface LZ4Module {
encode(data: Buffer): Buffer;
decode(data: Buffer): Buffer;
}

function tryLoadLZ4Module(): LZ4Module | undefined {
try {
return require('lz4'); // eslint-disable-line global-require
// eslint-disable-next-line global-require
const lz4napi = require('lz4-napi');
return {
encode: lz4napi.compressFrameSync,
decode: lz4napi.decompressFrameSync,
};
} catch (err) {
if (!(err instanceof Error) || !('code' in err)) {
// eslint-disable-next-line no-console
Expand Down
Loading
Loading