You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2022/07/29 06:44:54 UTC

[doris] branch master updated: [feature-wip](unique-key-merge-on-write) some followup of #11057 (#11290)

This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 018665aba2 [feature-wip](unique-key-merge-on-write) some followup of #11057 (#11290)
018665aba2 is described below

commit 018665aba2d0fffae83111d356a696b3294380b1
Author: zhannngchen <48...@users.noreply.github.com>
AuthorDate: Fri Jul 29 14:44:48 2022 +0800

    [feature-wip](unique-key-merge-on-write) some followup of #11057 (#11290)
---
 be/src/olap/rowset/beta_rowset_writer.cpp | 8 ++++++++
 be/src/olap/rowset/beta_rowset_writer.h   | 2 ++
 be/src/olap/tablet.cpp                    | 6 +++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/rowset/beta_rowset_writer.cpp b/be/src/olap/rowset/beta_rowset_writer.cpp
index 5a0625a870..228fcee95b 100644
--- a/be/src/olap/rowset/beta_rowset_writer.cpp
+++ b/be/src/olap/rowset/beta_rowset_writer.cpp
@@ -249,6 +249,7 @@ RowsetSharedPtr BetaRowsetWriter::build() {
     } else {
         _rowset_meta->set_rowset_state(VISIBLE);
     }
+    _rowset_meta->set_segments_key_bounds(_segments_encoded_key_bounds);
 
     if (_rowset_meta->oldest_write_timestamp() == -1) {
         _rowset_meta->set_oldest_write_timestamp(UnixSeconds());
@@ -319,6 +320,13 @@ Status BetaRowsetWriter::_flush_segment_writer(std::unique_ptr<segment_v2::Segme
     }
     _total_data_size += segment_size;
     _total_index_size += index_size;
+    KeyBoundsPB key_bounds;
+    Slice min_key = (*writer)->min_encoded_key();
+    Slice max_key = (*writer)->max_encoded_key();
+    DCHECK_LE(min_key.compare(max_key), 0);
+    key_bounds.set_min_key(min_key.to_string());
+    key_bounds.set_max_key(max_key.to_string());
+    _segments_encoded_key_bounds.emplace_back(key_bounds);
     writer->reset();
     return Status::OK();
 }
diff --git a/be/src/olap/rowset/beta_rowset_writer.h b/be/src/olap/rowset/beta_rowset_writer.h
index 96a513f5fe..e046f3d101 100644
--- a/be/src/olap/rowset/beta_rowset_writer.h
+++ b/be/src/olap/rowset/beta_rowset_writer.h
@@ -101,6 +101,8 @@ private:
     bool _is_pending = false;
     bool _already_built = false;
 
+    // for unique key table with merge-on-write
+    std::vector<KeyBoundsPB> _segments_encoded_key_bounds;
     // record rows number of every segment
     std::vector<uint32_t> _segment_num_rows;
 };
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 290753de9e..75e64f875e 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -1897,7 +1897,11 @@ Status Tablet::lookup_row_key(const Slice& encoded_key, RowLocation* row_locatio
             return s;
         }
         loc.rowset_id = rs.first->rowset_id();
-        // Check delete bitmap, if the row
+        if (version >= 0 && _tablet_meta->delete_bitmap().contains_agg(
+                                    {loc.rowset_id, loc.segment_id, version}, loc.row_id)) {
+            // The key is deleted, we don't need to search for it any more.
+            break;
+        }
         *row_location = loc;
         // find it and return
         return s;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org