-
Notifications
You must be signed in to change notification settings - Fork 0
Add optional binary store compression support to CStoreHelper #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: jakesmith <902700+jakesmith@users.noreply.github.com>
jakesmith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - see comments.
dali/base/dasds.cpp
Outdated
| { | ||
| unsigned xmlCrc{0}; | ||
| unsigned binaryCrc{0}; | ||
| bool binaryCompressed{false}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from bool to unsigned flags field with FLAG_BINARY_COMPRESSED bit for future expandability. Commit 5abace8
dali/base/dasds.cpp
Outdated
|
|
||
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - don't use default params, they're error prone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed default parameter from save method. Commit 5abace8
dali/base/dasds.cpp
Outdated
| switch(sz) | ||
| { | ||
| case sizeof(CrcInfo): | ||
| case sizeof(CrcInfo): // New format with compression flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - let's change comment to says it is the "current format"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comment to say "Current format with flags". Commit 5abace8
dali/base/dasds.cpp
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed padding since we now use unsigned flags instead of bool. Commit 5abace8
dali/base/dasds.cpp
Outdated
| } | ||
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - don't use default params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
dali/base/dasds.cpp
Outdated
| if (compressor) | ||
| { | ||
| LOG(MCdebugProgress, "Using LZ4 compression for binary store"); | ||
| Owned<ISerialOutputStream> compressedStream = createCompressingOutputStream(bufOutStream, compressor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed compression code structure with proper stream layering as suggested. Commit 5abace8
dali/base/dasds.cpp
Outdated
| Owned<ISerialOutputStream> compressedStream = createCompressingOutputStream(bufOutStream, compressor); | ||
| root->serializeToStream(*compressedStream); | ||
| compressedStream->flush(); | ||
| compressedStream.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - no need for the above 2 lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the unnecessary flush and clear lines as requested. Commit 5abace8
dali/base/dasds.cpp
Outdated
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed duplicate binaryCompressed declaration, now using the one from line 5920. Commit 5abace8
dali/base/dasds.cpp
Outdated
| } | ||
| else | ||
| { | ||
| WARNLOG("Failed to create expander for compressed binary store"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - this should not be allow to continue, throw an exception here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.