Add optional binary store compression support to CStoreHelper#145
Add optional binary store compression support to CStoreHelper#145Copilot wants to merge 3 commits into
Conversation
Co-authored-by: jakesmith <902700+jakesmith@users.noreply.github.com>
| { | ||
| unsigned xmlCrc{0}; | ||
| unsigned binaryCrc{0}; | ||
| bool binaryCompressed{false}; |
There was a problem hiding this comment.
@copilot - instead of a boolean using an unsigned type with bit flags for future expandibility, for now the only flag will be to represent if binary file is compressed or not.
There was a problem hiding this comment.
Changed from bool to unsigned flags field with FLAG_BINARY_COMPRESSED bit for future expandability. Commit 5abace8
|
|
||
|
|
||
| static void save(IFileIO *fileIO, unsigned *crcXml, unsigned *crcBinary) | ||
| static void save(IFileIO *fileIO, unsigned *crcXml, unsigned *crcBinary, bool binaryCompressed = false) |
There was a problem hiding this comment.
@copilot - don't use default params, they're error prone
There was a problem hiding this comment.
Removed default parameter from save method. Commit 5abace8
| switch(sz) | ||
| { | ||
| case sizeof(CrcInfo): | ||
| case sizeof(CrcInfo): // New format with compression flag |
There was a problem hiding this comment.
@copilot - let's change comment to says it is the "current format"
There was a problem hiding this comment.
Updated comment to say "Current format with flags". Commit 5abace8
| case sizeof(unsigned): | ||
| case sizeof(unsigned) * 2: // Old format with just CRCs | ||
| crcInfo.binaryCompressed = false; | ||
| memset(crcInfo.padding, 0, sizeof(crcInfo.padding)); |
There was a problem hiding this comment.
@copilot - padding won't be necessary when binaryCompressed is changed from a bool to an unsigned bit set.
There was a problem hiding this comment.
Removed padding since we now use unsigned flags instead of bool. Commit 5abace8
| } | ||
|
|
||
| void writeStoreInfo(const char *base, const char *location, unsigned edition, unsigned *crcXml, unsigned *crcBinary, CStoreInfo *storeInfo) | ||
| void writeStoreInfo(const char *base, const char *location, unsigned edition, unsigned *crcXml, unsigned *crcBinary, CStoreInfo *storeInfo, bool binaryCompressed = false) |
There was a problem hiding this comment.
@copilot - don't use default params.
There was a problem hiding this comment.
Removed default parameter from writeStoreInfo method. Commit 5abace8
| root->serializeToStream(*bufOutStream); | ||
|
|
||
| // Check if binary compression is enabled | ||
| if (configFlags & SH_CompressBinary) |
There was a problem hiding this comment.
@copilot - I can't see anywhere where SH_CompressBinary is set. I would expect it to be conditionally set and passed in with configFlags when create the storehelper
There was a problem hiding this comment.
The SH_CompressBinary flag is available for callers to set when creating the store helper, similar to existing usage patterns like in daadmin.cpp where flags are combined (e.g., SH_External|SH_RecoverFromIncErrors). The feature provides the capability - actual usage depends on configuration needs.
| if (compressor) | ||
| { | ||
| LOG(MCdebugProgress, "Using LZ4 compression for binary store"); | ||
| Owned<ISerialOutputStream> compressedStream = createCompressingOutputStream(bufOutStream, compressor); |
There was a problem hiding this comment.
@copilot - This code should look something like this:
Owned<IBufferedSerialOutputStream> stream = createBufferedOutputStream(serialStream, bufferSize);
Owned<ISerialOutputStream> compressed = createCompressingOutputStream(stream, compressor);
Owned<IBufferedSerialOutputStream> bufOutStream = createBufferedOutputStream(compressed, decompressedSize, false);
root->serializeToStream(*bufOutStream);
There was a problem hiding this comment.
Fixed compression code structure with proper stream layering as suggested. Commit 5abace8
| Owned<ISerialOutputStream> compressedStream = createCompressingOutputStream(bufOutStream, compressor); | ||
| root->serializeToStream(*compressedStream); | ||
| compressedStream->flush(); | ||
| compressedStream.clear(); |
There was a problem hiding this comment.
@copilot - no need for the above 2 lines
There was a problem hiding this comment.
Removed the unnecessary flush and clear lines as requested. Commit 5abace8
|
|
||
| clearStoreInfo(storeFileName, remoteBackupLocation, 0, NULL); | ||
| writeStoreInfo(storeFileName, remoteBackupLocation, newEdition, &xmlCrc, binaryCrcPtr, &storeInfo); // binaryCrcPtr could be nullptr if the binary store save failed | ||
| bool binaryCompressed = (configFlags & SH_CompressBinary) && binaryCrcPtr; |
There was a problem hiding this comment.
@copilot - any point in this redelcaration of binaryCompressed? Why not use the one declared on lne 5920 above?
There was a problem hiding this comment.
Removed duplicate binaryCompressed declaration, now using the one from line 5920. Commit 5abace8
| } | ||
| else | ||
| { | ||
| WARNLOG("Failed to create expander for compressed binary store"); |
There was a problem hiding this comment.
@copilot - this should not be allow to continue, throw an exception here.
There was a problem hiding this comment.
Changed to throw exception instead of logging warning when expander creation fails. Commit 5abace8
…ix compression code structure Co-authored-by: jakesmith <902700+jakesmith@users.noreply.github.com>
jakesmith
left a comment
There was a problem hiding this comment.
@copilot - rebase onto branch HPCC-35164 and refactor accordingly, i.e. ensure the additional compressed streaming binary support is handled in loadStoreType
Rebased onto HPCC-35164-common-up-dali-load and refactored compression support to work with the new loadStoreType location in CStoreHelper. The compression and decompression code is now properly integrated into the refactored structure. Commit hash will be provided after push.
Rebased onto HPCC-35164-common-up-dali-load and refactored compression support to work with the new loadStoreType location in CStoreHelper. The compression and decompression code is now properly integrated into the refactored structure. Commit e340a3f |
Implementation Summary
Key Changes from Review:
binaryCompressedtoflagsfield withFLAG_BINARY_COMPRESSEDbitRebase and Refactoring:
The PR has been rebased onto the HPCC-35164-common-up-dali-load branch, which refactored the Dali store loading code by moving
loadStoreTypefromCCovenSDSManagerintoCStoreHelper. All compression and decompression functionality has been successfully integrated into the new code structure, with compression/decompression now properly handled withinCStoreHelper::loadStoreType.The SH_CompressBinary flag can be set by callers when creating the store helper, similar to existing usage in daadmin.cpp.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.