dataroaring commented on code in PR #11557:
URL: https://github.com/apache/doris/pull/11557#discussion_r939902461


##########
be/src/olap/memtable.cpp:
##########
@@ -406,6 +407,22 @@ Status MemTable::flush() {
     
DorisMetrics::instance()->memtable_flush_duration_us->increment(duration_ns / 
1000);

Review Comment:
   I suggest that put code generating delete bitmap in a function, e.g. 
generate_delete_bitmap, and  metric memtable_flush_duration_us should include 
time consumed to delete bitmap.



##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -272,6 +272,38 @@ RowsetSharedPtr BetaRowsetWriter::build() {
     return rowset;
 }
 
+RowsetSharedPtr BetaRowsetWriter::build_tmp() {
+    std::shared_ptr<RowsetMeta> rowset_meta_ = std::make_shared<RowsetMeta>();
+    *rowset_meta_ = *_rowset_meta;
+
+    rowset_meta_->set_num_rows(_num_rows_written);
+    rowset_meta_->set_total_disk_size(_total_data_size);
+    rowset_meta_->set_data_disk_size(_total_data_size);
+    rowset_meta_->set_index_disk_size(_total_index_size);
+    // TODO write zonemap to meta
+    rowset_meta_->set_empty(_num_rows_written == 0);
+    rowset_meta_->set_creation_time(time(nullptr));
+    rowset_meta_->set_num_segments(_num_segment);
+    if (_num_segment <= 1) {
+        rowset_meta_->set_segments_overlap(NONOVERLAPPING);
+    }
+    if (_is_pending) {
+        rowset_meta_->set_rowset_state(COMMITTED);
+    } else {
+        rowset_meta_->set_rowset_state(VISIBLE);
+    }
+    rowset_meta_->set_segments_key_bounds(_segments_encoded_key_bounds);
+
+    RowsetSharedPtr rowset;
+    auto status = RowsetFactory::create_rowset(_context.tablet_schema, 
_context.tablet_path,
+                                               rowset_meta_, &rowset);
+    if (!status.ok()) {
+        LOG(WARNING) << "rowset init failed when build new rowset, res=" << 
status;
+        return nullptr;
+    }
+    return rowset;
+}

Review Comment:
   a lot of copied code here, maybe we should put common codes between build 
and built_tmp to a function named build_rowset_meta(), and build calls it like 
build_rowset_meta(&_rowset_meta).



##########
be/src/olap/txn_manager.cpp:
##########
@@ -168,6 +168,32 @@ Status TxnManager::prepare_txn(TPartitionId partition_id, 
TTransactionId transac
     return Status::OK();
 }
 
+Status TxnManager::set_txn_related_delete_bitmap(TPartitionId partition_id,
+                                                 TTransactionId 
transaction_id, TTabletId tablet_id,
+                                                 SchemaHash schema_hash, 
TabletUid tablet_uid,
+                                                 bool 
unique_key_merge_on_write,
+                                                 DeleteBitmapPtr delete_bitmap,
+                                                 const RowsetIdUnorderedSet& 
rowset_ids) {
+    pair<int64_t, int64_t> key(partition_id, transaction_id);
+    TabletInfo tablet_info(tablet_id, schema_hash, tablet_uid);
+
+    std::unique_lock<std::mutex> txn_lock(_get_txn_lock(transaction_id));
+    {
+        // get tx
+        std::shared_lock rdlock(_get_txn_map_lock(transaction_id));
+        txn_tablet_map_t& txn_tablet_map = _get_txn_tablet_map(transaction_id);
+        auto it = txn_tablet_map.find(key);
+        DCHECK(it != txn_tablet_map.end());
+        auto load_itr = it->second.find(tablet_info);
+        DCHECK(load_itr != it->second.end());
+        TabletTxnInfo& load_info = load_itr->second;
+        load_info.unique_key_merge_on_write = unique_key_merge_on_write;
+        load_info.delete_bitmap = delete_bitmap;
+        load_info.rowset_ids = rowset_ids;
+    }
+    return Status::OK();

Review Comment:
   the function always return OK, so it should be a void function.



##########
be/src/olap/rowset/rowset_tree.h:
##########
@@ -76,7 +76,7 @@ class RowsetTree {
     //
     // The returned pointers are guaranteed to be valid at least until this
     // RowsetTree object is Reset().

Review Comment:
   please update the comment related to rowset_ids.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to