Skip to content

Commit 63fbb46

Browse files
committed
HPCC-33560 Reuse the compressor when building hybrid indexes
Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
1 parent f1bd78c commit 63fbb46

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
@@ -372,9 +372,7 @@ bool CBlockCompressedWriteNode::add(offset_t pos, const void *indata, size32_t i
372372
bool isVariable = keyHdr->isVariable();
373373
bool hasFilepos = !context.zeroFilePos;
374374
size32_t fixedKeySize = isVariable ? 0 : (hasFilepos ? keyLen + sizeof(offset_t) : keyLen);
375-
376-
ICompressHandler * handler = queryCompressHandler(context.compressionMethod);
377-
compressor.open(keyPtr, maxBytes-hdr.keyBytes, handler, context.compressionOptions, isVariable, fixedKeySize);
375+
compressor.open(keyPtr, maxBytes-hdr.keyBytes, context.compressor, isVariable, fixedKeySize);
378376
}
379377

380378
unsigned writeOptions = (context.zeroFilePos ? KeyCompressor::NoFilePosition : KeyCompressor::TrailingFilePosition);
@@ -400,6 +398,15 @@ void CBlockCompressedWriteNode::finalize()
400398

401399
//=========================================================================================================
402400

401+
void CBlockCompressedBuildContext::initCompressor()
402+
{
403+
compressionHandler = queryCompressHandler(compressionMethod);
404+
if (!compressionHandler)
405+
throw MakeStringException(0, "Unknown compression method %d", (int)compressionMethod);
406+
407+
compressor.setown(compressionHandler->getCompressor(compressionOptions.str()));
408+
}
409+
403410
HybridIndexCompressor::HybridIndexCompressor(unsigned keyedSize, const CKeyHdr* keyHdr, IHThorIndexWriteArg *helper, const char * compression, bool isTLK)
404411
{
405412
//Process options for leaf (block-compressed) nodes
@@ -438,9 +445,7 @@ HybridIndexCompressor::HybridIndexCompressor(unsigned keyedSize, const CKeyHdr*
438445
if (colon)
439446
processOptionString(colon+1, processOption);
440447

441-
leafContext.compressionHandler = queryCompressHandler(leafContext.compressionMethod);
442-
if (!leafContext.compressionHandler)
443-
throw MakeStringException(0, "Unknown compression method %d", (int)leafContext.compressionMethod);
448+
leafContext.initCompressor();
444449

445450
if (!isTLK && helper && (helper->getFlags() & TIWzerofilepos))
446451
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)