-
Notifications
You must be signed in to change notification settings - Fork 89
refactor(clp-s): Replace usages of new in ArchiveWriter with smart pointers (fixes #1922).
#1973
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: main
Are you sure you want to change the base?
refactor(clp-s): Replace usages of new in ArchiveWriter with smart pointers (fixes #1922).
#1973
Conversation
WalkthroughThe pull request refactors memory management in ArchiveWriter and SchemaWriter: raw pointers for SchemaWriter and BaseColumnWriter are replaced with std::unique_ptr, ownership is transferred via make_unique/move, and manual delete/destructor cleanup is removed in favour of RAII. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/core/src/clp_s/ArchiveWriter.cpp (1)
252-266: 🧹 Nitpick | 🔵 Trivial
SchemaWriteritself is still managed with rawnew/delete.
SchemaWriteris allocated withnewon line 259, stored as a raw pointer inm_id_to_schema_writer, and manuallydeleted on line 430. This leaves dangling pointers in the map between thedeletecalls instore_tables()and theclear()on line 125. Consider convertingm_id_to_schema_writerto storestd::unique_ptr<SchemaWriter>as a follow-up to complete the smart pointer migration.
new in ArchiveWriter with smart pointers (fixes #1922).
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/core/src/clp_s/ArchiveWriter.hpp (1)
1-11: 🧹 Nitpick | 🔵 TrivialConsider adding
#include <memory>directly.This header now uses
std::unique_ptrdirectly in the member declaration on line 350, but relies on<memory>being transitively included viaSchemaWriter.hpp. Adding a direct#include <memory>would make the dependency explicit and prevent breakage ifSchemaWriter.hppever stops including it.Proposed fix
`#include` <optional> +#include <memory> `#include` <string>
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/core/src/clp_s/ArchiveWriter.hpp (1)
279-279: 🧹 Nitpick | 🔵 TrivialConsider taking
SchemaWriter&instead ofSchemaWriter*for the non-owning parameter.The function is always called with a valid (non-null) pointer obtained from
unique_ptr::get()at line 257. A reference parameter would better express the non-null contract and follow modern C++ conventions for non-owning parameters.
Description
This PR addresses #1922. It addresses raw new usage in two places:
std::make_uniqueinstead of rawnew's to instantiate column writers (e.g.,TimestampColumnWriter,ClpStringColumnWriter, etc.) incomponents/core/src/clp_s/ArchiveWriter.cpp.append_messagewe replacestd::map<int32_t, SchemaWriter*> with std::map<int32_t, std::unique_ptr<SchemaWriter>>.Checklist
breaking change.
Validation performed
Summary by CodeRabbit