github-actions[bot] commented on code in PR #41362:
URL: https://github.com/apache/doris/pull/41362#discussion_r1797541896


##########
be/src/olap/tablet_reader.cpp:
##########
@@ -207,8 +207,12 @@ Status TabletReader::_capture_rs_readers(const 
ReaderParams& read_params) {
         }
         if (_tablet_schema->keys_type() == UNIQUE_KEYS &&
             _tablet->enable_unique_key_merge_on_write()) {
-            // unique keys with merge on write, no need to merge sort keys in 
rowset
-            need_ordered_result = false;
+            if (read_params.query_mow_in_mor) {
+                need_ordered_result = true;

Review Comment:
   warning: redundant boolean literal in conditional assignment 
[readability-simplify-boolean-expr]
   ```cpp
                   need_ordered_result = true;
                                         ^
   ```
   



##########
be/src/olap/base_tablet.cpp:
##########
@@ -128,6 +128,42 @@ BaseTablet::~BaseTablet() {
     g_total_tablet_num << -1;
 }
 
+Status BaseTablet::capture_sub_txn_rs_readers(int64_t version,

Review Comment:
   warning: method 'capture_sub_txn_rs_readers' can be made const 
[readability-make-member-function-const]
   
   be/src/olap/base_tablet.cpp:132:
   ```diff
   -                                               std::vector<RowSetSplits>* 
rs_splits) {
   +                                               std::vector<RowSetSplits>* 
rs_splits) const {
   ```
   



##########
be/src/vec/olap/vcollect_iterator.cpp:
##########
@@ -71,7 +71,11 @@ void VCollectIterator::init(TabletReader* reader, bool 
ori_data_overlapping, boo
         (_reader->_direct_mode || _reader->_tablet->keys_type() == 
KeysType::DUP_KEYS ||
          (_reader->_tablet->keys_type() == KeysType::UNIQUE_KEYS &&
           _reader->_tablet->enable_unique_key_merge_on_write()))) {
-        _merge = false;
+        if (_reader->_reader_context.query_mow_in_mor) {
+            _merge = true;

Review Comment:
   warning: redundant boolean literal in conditional assignment 
[readability-simplify-boolean-expr]
   
   be/src/vec/olap/vcollect_iterator.cpp:73:
   ```diff
   -         if (_reader->_reader_context.query_mow_in_mor) {
   -             _merge = true;
   -         } else {
   -             _merge = false;
   -         }
   +         _merge = 
static_cast<bool>(_reader->_reader_context.query_mow_in_mor);
   ```
   



##########
cloud/src/meta-service/meta_service.cpp:
##########
@@ -1410,6 +1410,108 @@
     return true;
 }
 
+void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* 
controller,
+                                     const GetTmpRowsetRequest* request,
+                                     GetTmpRowsetResponse* response,
+                                     ::google::protobuf::Closure* done) {
+    RPC_PREPROCESS(get_tmp_rowset);
+    instance_id = get_instance_id(resource_mgr_, request->cloud_unique_id());
+    if (instance_id.empty()) {
+        code = MetaServiceCode::INVALID_ARGUMENT;
+        msg = "empty instance_id";
+        LOG(INFO) << msg << ", cloud_unique_id=" << request->cloud_unique_id();
+        return;
+    }
+    RPC_RATE_LIMIT(get_tmp_rowset)
+    if (!request->has_index_id()) {
+        code = MetaServiceCode::INVALID_ARGUMENT;
+        msg = "empty index id";
+        return;
+    }
+    if (!request->has_tablet_id()) {
+        code = MetaServiceCode::INVALID_ARGUMENT;
+        msg = "empty tablet id";
+        return;
+    }
+    if (request->txn_ids().empty()) {
+        code = MetaServiceCode::INVALID_ARGUMENT;
+        msg = "empty txn ids";
+        return;
+    }
+    std::unique_ptr<Transaction> txn;
+    TxnErrorCode err = txn_kv_->create_txn(&txn);
+    if (err != TxnErrorCode::TXN_OK) {
+        code = cast_as<ErrCategory::CREATE>(err);
+        msg = "failed to create txn";
+        return;
+    }
+    std::vector<std::string> tmp_rowset_keys;
+    std::vector<std::optional<std::string>> tmp_rowset_values;
+    tmp_rowset_keys.reserve(request->txn_ids().size());
+    tmp_rowset_values.reserve(request->txn_ids().size());
+    int64_t tablet_id = request->tablet_id();
+    int64_t index_id = request->index_id();
+    // TODO avoid too many txn ids, should limit in fe
+    for (const auto& txn_id : request->txn_ids()) {
+        tmp_rowset_keys.push_back(meta_rowset_tmp_key({instance_id, txn_id, 
tablet_id}));
+    }
+    err = txn->batch_get(&tmp_rowset_values, tmp_rowset_keys);
+    if (err != TxnErrorCode::TXN_OK) {
+        code = cast_as<ErrCategory::READ>(err);
+        ss << "failed to batch get tmp rowset, instance_id=" << instance_id
+           << " tablet_id=" << tablet_id << " err=" << err;
+        msg = ss.str();
+        LOG(WARNING) << msg;
+        return;
+    }
+    // get referenced schema
+    std::unordered_map<int32_t, doris::TabletSchemaCloudPB*> version_to_schema;
+    for (size_t i = 0; i < tmp_rowset_keys.size(); ++i) {
+        if (!tmp_rowset_values[i].has_value()) [[unlikely]] {
+            code = MetaServiceCode::KV_TXN_GET_ERR;
+            ss << "failed to get tmp rowset, err=not found, instance_id=" << 
instance_id
+               << " tablet_id=" << tablet_id << " txn_id=" << 
request->txn_ids(i)
+               << " key=" << hex(tmp_rowset_keys[i]);
+            msg = ss.str();
+            LOG(WARNING) << msg;
+            return;
+        }
+        auto rowset_meta = response->add_rowset_meta();
+        if (!rowset_meta->ParseFromArray(tmp_rowset_values[i]->data(),
+                                         tmp_rowset_values[i]->size())) {
+            code = MetaServiceCode::PROTOBUF_PARSE_ERR;
+            ss << "malformed rowset meta value, instance_id=" << instance_id
+               << " tablet_id=" << tablet_id << " txn_id=" << 
request->txn_ids(i)
+               << " key=" << hex(tmp_rowset_keys[i]);
+            msg = ss.str();
+            LOG(WARNING) << msg;
+            return;
+        }
+        // set tablet schema
+        if (rowset_meta->has_tablet_schema()) continue;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
           if (rowset_meta->has_tablet_schema()) { continue;
   }
   ```
   



##########
cloud/src/meta-service/meta_service.cpp:
##########
@@ -1410,6 +1410,108 @@ static bool try_fetch_and_parse_schema(Transaction* 
txn, RowsetMetaCloudPB& rows
     return true;
 }
 
+void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* 
controller,

Review Comment:
   warning: function 'get_tmp_rowset' exceeds recommended size/complexity 
thresholds [readability-function-size]
   ```cpp
   void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* 
controller,
                         ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **cloud/src/meta-service/meta_service.cpp:1412:** 97 lines including 
whitespace and comments (threshold 80)
   ```cpp
   void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* 
controller,
                         ^
   ```
   
   </details>
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to