Skip to content

Commit a1bcea9

Browse files
authored
Merge pull request #20770 from ghalliday/issue33560
HPCC-33560 Reuse the compressor when building hybrid indexes Reviewed-By: James McMullan <James.McMullan@lexisnexis.com> Merged-by: Gavin Halliday <gavin.halliday@lexisnexisrisk.com>
2 parents d4d2e5f + 63fbb46 commit a1bcea9

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

system/jhtree/jhblockcompressed.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,7 @@ bool CBlockCompressedWriteNode::add(offset_t pos, const void *indata, size32_t i
353353
bool isVariable = keyHdr->isVariable();
354354
bool hasFilepos = !context.zeroFilePos;
355355
size32_t fixedKeySize = isVariable ? 0 : (hasFilepos ? keyLen + sizeof(offset_t) : keyLen);
356-
357-
ICompressHandler * handler = queryCompressHandler(context.compressionMethod);
358-
compressor.open(keyPtr, maxBytes-hdr.keyBytes, handler, context.compressionOptions, isVariable, fixedKeySize);
356+
compressor.open(keyPtr, maxBytes-hdr.keyBytes, context.compressor, isVariable, fixedKeySize);
359357
}
360358

361359
unsigned writeOptions = (context.zeroFilePos ? KeyCompressor::NoFilePosition : KeyCompressor::TrailingFilePosition);
@@ -381,6 +379,15 @@ void CBlockCompressedWriteNode::finalize()
381379

382380
//=========================================================================================================
383381

382+
void CBlockCompressedBuildContext::initCompressor()
383+
{
384+
compressionHandler = queryCompressHandler(compressionMethod);
385+
if (!compressionHandler)
386+
throw MakeStringException(0, "Unknown compression method %d", (int)compressionMethod);
387+
388+
compressor.setown(compressionHandler->getCompressor(compressionOptions.str()));
389+
}
390+
384391
HybridIndexCompressor::HybridIndexCompressor(unsigned keyedSize, const CKeyHdr* keyHdr, IHThorIndexWriteArg *helper, const char * compression, bool isTLK)
385392
{
386393
//Process options for leaf (block-compressed) nodes
@@ -419,9 +426,7 @@ HybridIndexCompressor::HybridIndexCompressor(unsigned keyedSize, const CKeyHdr*
419426
if (colon)
420427
processOptionString(colon+1, processOption);
421428

422-
leafContext.compressionHandler = queryCompressHandler(leafContext.compressionMethod);
423-
if (!leafContext.compressionHandler)
424-
throw MakeStringException(0, "Unknown compression method %d", (int)leafContext.compressionMethod);
429+
leafContext.initCompressor();
425430

426431
if (!isTLK && helper && (helper->getFlags() & TIWzerofilepos))
427432
leafContext.zeroFilePos = true;

system/jhtree/jhblockcompressed.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ class CJHNewBlobNode final : public CJHBlobNode
8181

8282
struct CBlockCompressedBuildContext
8383
{
84+
public:
85+
void initCompressor();
86+
87+
public:
8488
ICompressHandler* compressionHandler = nullptr;
89+
Owned<ICompressor> compressor;
8590
StringBuffer compressionOptions;
8691
CompressionMethod compressionMethod = COMPRESS_METHOD_ZSTDS6;
8792
bool zeroFilePos = false;

0 commit comments

Comments
 (0)