fix(core): Remove the unused compressor type variable, its constant definition file, and update related CMake files.#723
Conversation
WalkthroughThis pull request removes the inclusion and usage of the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Decompressor
participant BaseDecompressor
Client->>Decompressor: Instantiate (default constructor)
Decompressor->>BaseDecompressor: Default initialization (no CompressorType)
Note right of Decompressor: Removal of explicit compressor type parameter
sequenceDiagram
participant Client
participant ZstdDecompressor
Client->>ZstdDecompressor: Create instance
ZstdDecompressor->>ZstdDecompressor: Initialize m_decompression_stream
alt Stream creation fails
ZstdDecompressor-->>Client: Log error and throw OperationFailed
else Stream creation succeeds
ZstdDecompressor-->>Client: Instance ready
end
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/core/src/clp/streaming_compression/lzma/Decompressor.hpp (1)
38-40: Track TODO for enabling move operations.The TODO comment indicates that move operations could be enabled once the base class is updated. This should be tracked to prevent technical debt and potential performance implications.
Would you like me to create an issue to track this TODO for enabling move operations once the base decompressor class is updated?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
components/core/CMakeLists.txt(0 hunks)components/core/src/clp/clg/CMakeLists.txt(0 hunks)components/core/src/clp/clo/CMakeLists.txt(0 hunks)components/core/src/clp/clp/CMakeLists.txt(0 hunks)components/core/src/clp/streaming_compression/Constants.hpp(0 hunks)components/core/src/clp/streaming_compression/Decompressor.hpp(1 hunks)components/core/src/clp/streaming_compression/lzma/Decompressor.hpp(1 hunks)components/core/src/clp/streaming_compression/passthrough/Decompressor.hpp(1 hunks)components/core/src/clp/streaming_compression/zstd/Decompressor.cpp(1 hunks)components/core/src/glt/glt/CMakeLists.txt(0 hunks)
💤 Files with no reviewable changes (6)
- components/core/src/glt/glt/CMakeLists.txt
- components/core/src/clp/streaming_compression/Constants.hpp
- components/core/src/clp/clg/CMakeLists.txt
- components/core/src/clp/clp/CMakeLists.txt
- components/core/CMakeLists.txt
- components/core/src/clp/clo/CMakeLists.txt
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ...
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Preferfalse == <expression>rather than!<expression>.
components/core/src/clp/streaming_compression/passthrough/Decompressor.hppcomponents/core/src/clp/streaming_compression/zstd/Decompressor.cppcomponents/core/src/clp/streaming_compression/Decompressor.hppcomponents/core/src/clp/streaming_compression/lzma/Decompressor.hpp
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: build-macos (macos-14, false)
- GitHub Check: build-macos (macos-13, false)
- GitHub Check: build-macos (macos-13, true)
- GitHub Check: build (macos-latest)
- GitHub Check: lint-check (ubuntu-latest)
- GitHub Check: lint-check (macos-latest)
🔇 Additional comments (7)
components/core/src/clp/streaming_compression/zstd/Decompressor.cpp (3)
12-19: LGTM! Constructor changes align with PR objectives.The removal of the CompressorType initialization simplifies the constructor while maintaining proper error handling.
52-54: LGTM! Proper coding guideline compliance.The code follows the guideline to prefer
false == <expression>over!<expression>.
232-234: LGTM! Proper coding guideline compliance.The code follows the guideline to prefer
false == <expression>over!<expression>.components/core/src/clp/streaming_compression/Decompressor.hpp (1)
26-26:Details
❓ Verification inconclusive
LGTM! Verify dynamic_cast usage.
The change to use a default constructor aligns with the PR objectives. The removal of the explicit type tracking in favour of dynamic_cast is a valid approach for runtime type identification.
Let's verify the dynamic_cast usage in derived classes:
🏁 Script executed:
#!/bin/bash # Description: Search for derived classes and their dynamic_cast usage # Find derived classes echo "Searching for derived classes of Decompressor..." ast-grep --pattern 'class $_ : public Decompressor' # Check dynamic_cast usage echo "Checking dynamic_cast usage..." rg "dynamic_cast<.*Decompressor.*>" -A 5Length of output: 274
LGTM with caveat – Please manually verify dynamic_cast usage in derived classes.
The updated default constructor and the removal of the explicit compressor type tracking align with the PR objectives. However, our automated script did not return any instances of dynamic_cast usage for Decompressor-derived classes. Please manually check that derived classes implement dynamic_cast for runtime type identification where needed.
- Confirm that any derived classes leverage dynamic_cast appropriately in place of type tracking.
components/core/src/clp/streaming_compression/lzma/Decompressor.hpp (2)
28-28: LGTM! Constructor change aligns with PR objectives.The change from an explicit constructor with CompressorType to a default constructor is appropriate, as it aligns with the removal of the unused CompressorType variable. Using dynamic_cast for type checking is a valid alternative.
50-51:Details
❓ Verification inconclusive
Verify the design intent of this class.
All operations in this class either return ErrorCode_Unsupported or throw OperationFailed exceptions. This suggests that the class might be:
- A placeholder implementation
- An incomplete implementation
- An intentional no-op implementation
Please clarify the intended behaviour.
Also applies to: 58-59, 65-66, 74-75, 83-84, 88-89, 98-102
🏁 Script executed:
#!/bin/bash # Search for actual implementations or usages of this class ast-grep --pattern 'class $_ : public ::clp::streaming_compression::Decompressor { $$$ }'Length of output: 93
Clarification needed on the design intent of the LZMA Decompressor class
It appears that all overridden methods (e.g. the try_read method on lines 50–51, as well as those on lines 58–59, 65–66, 74–75, 83–84, 88–89, and 98–102) either return an ErrorCode_Unsupported or throw an OperationFailed exception. This pattern suggests one of the following:
- A placeholder implementation,
- An incomplete implementation, or
- An intentional no-op.
Please confirm whether this behaviour is deliberate. If so, consider adding documentation to explain the rationale behind this design choice.
components/core/src/clp/streaming_compression/passthrough/Decompressor.hpp (1)
28-32:Details
✅ Verification successful
LGTM! Verify impact on derived classes.
The constructor changes align well with the PR objectives. The initialization of member variables is correct and maintains the class's invariants.
Let's verify the impact on derived classes:
🏁 Script executed:
#!/bin/bash # Description: Check for derived classes that might be affected by the constructor changes # Search for classes deriving from Decompressor ast-grep --pattern 'class $_ : public $$$Decompressor$$$' # Search for any remaining CompressorType usage rg -i 'compressor.*type'Length of output: 5178
LGTM – Changes Approved!
The updated default constructor in
components/core/src/clp/streaming_compression/passthrough/Decompressor.hppcorrectly removes the unusedCompressorTypeparameter and associated member variable while ensuring proper initialization of the remaining members. We verified that no derived classes in the codebase depend on the previous constructor signature (viaast-grep), and although references toCompressorTypestill exist in other modules (e.g. in the glt and clp_s directories), they do not impact the functionality of this specific change.
- The constructor now properly initializes:
m_input_typetoInputType::NotInitializedm_compressed_data_buftonullptrm_compressed_data_buf_lento0m_decompressed_stream_posto0Please ensure that any dependencies in other modules using
CompressorTypeare reassessed independently if needed.
Description
Removes the unused compressor/decompressor type variable due to its minimal usage in the code. For any code that wishes to determine the type of the compressor/decompressor given a base class pointer, we can use
dynamic_cast.Checklist
breaking change.
Validation performed
Summary by CodeRabbit
Refactor
Chores
These updates contribute to a more maintainable codebase and offer a refined underlying experience for end-users engaging with our streaming compression utilities.