charlesdong1991 commented on code in PR #606:
URL: https://github.com/apache/fluss-rust/pull/606#discussion_r3369021946
##########
bindings/cpp/src/table.cpp:
##########
@@ -1405,6 +1561,65 @@ Result Lookuper::Lookup(const GenericRow& pk_row,
LookupResult& out) {
return utils::make_ok();
}
+// ============================================================================
+// PrefixLookuper
+// ============================================================================
+
+PrefixLookuper::PrefixLookuper() noexcept = default;
+
+PrefixLookuper::PrefixLookuper(ffi::PrefixLookuper* lookuper) noexcept :
lookuper_(lookuper) {}
+
+PrefixLookuper::~PrefixLookuper() noexcept { Destroy(); }
+
+void PrefixLookuper::Destroy() noexcept {
+ if (lookuper_) {
+ ffi::delete_prefix_lookuper(lookuper_);
+ lookuper_ = nullptr;
+ }
+}
+
+PrefixLookuper::PrefixLookuper(PrefixLookuper&& other) noexcept :
lookuper_(other.lookuper_) {
+ other.lookuper_ = nullptr;
+}
+
+PrefixLookuper& PrefixLookuper::operator=(PrefixLookuper&& other) noexcept {
+ if (this != &other) {
+ Destroy();
+ lookuper_ = other.lookuper_;
+ other.lookuper_ = nullptr;
+ }
+ return *this;
+}
+
+bool PrefixLookuper::Available() const { return lookuper_ != nullptr; }
+
+Result PrefixLookuper::PrefixLookup(const GenericRow& prefix_row,
PrefixLookupResult& out) {
+ if (!Available()) {
+ return utils::make_client_error("PrefixLookuper not available");
+ }
+ if (!prefix_row.Available()) {
+ return utils::make_client_error("GenericRow not available");
+ }
+
+ auto result_box = lookuper_->prefix_lookup(*prefix_row.inner_);
+ if (result_box->plv_has_error()) {
+ return utils::make_error(result_box->plv_error_code(),
+ std::string(result_box->plv_error_message()));
+ }
+
+ // Wrap the raw pointer immediately so it's never leaked on exception, then
+ // build the column map eagerly — shared by all PrefixRowViews.
Review Comment:
very very nit question for myself: is "never leaked" comment only referring
to result_box.into_raw? or the whole line below?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]