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


##########
be/src/olap/task/engine_checksum_task.cpp:
##########
@@ -38,7 +39,52 @@ Status EngineChecksumTask::_compute_checksum() {
     LOG(INFO) << "begin to process compute checksum."
               << "tablet_id=" << _tablet_id << ", schema_hash=" << _schema_hash
               << ", version=" << _version;
-    return Status::InternalError("Not implemented yet");
+
+    if (_checksum == nullptr) {

Review Comment:
   warning: use of undeclared identifier '_checksum' [clang-diagnostic-error]
   ```cpp
       if (_checksum == nullptr) {
           ^
   ```
   



##########
be/src/olap/task/engine_checksum_task.cpp:
##########
@@ -38,7 +39,52 @@
     LOG(INFO) << "begin to process compute checksum."
               << "tablet_id=" << _tablet_id << ", schema_hash=" << _schema_hash
               << ", version=" << _version;
-    return Status::InternalError("Not implemented yet");
+
+    if (_checksum == nullptr) {
+        return Status::InvalidArgument("invalid checksum which is nullptr");
+    }
+
+    TabletSharedPtr tablet = 
StorageEngine::instance()->tablet_manager()->get_tablet(_tablet_id);
+    if (nullptr == tablet) {
+        return Status::InternalError("could not find tablet {}", _tablet_id);
+    }
+
+    std::vector<RowsetSharedPtr> input_rowsets;
+    Version version(0, _version);
+    Status acquire_reader_st = tablet->capture_consistent_rowsets(version, 
&input_rowsets);
+    if (acquire_reader_st != Status::OK()) {
+        LOG(WARNING) << "fail to captute consistent rowsets. tablet=" << 
tablet->full_name()
+                     << "res=" << acquire_reader_st;
+        return acquire_reader_st;
+    }
+    vectorized::BlockReader reader;
+    TabletReader::ReaderParams reader_params;
+    vectorized::Block block;
+    RETURN_NOT_OK(TabletReader::init_reader_params_and_create_block(
+            tablet, READER_CHECKSUM, input_rowsets, &reader_params, &block))
+
+    auto res = reader.init(reader_params);
+    if (!res.ok()) {
+        LOG(WARNING) << "initiate reader fail. res = " << res;
+        return res;
+    }
+
+    bool eof = false;
+    SipHash block_hash;
+    uint64_t rows = 0;
+    while (!eof) {
+        RETURN_IF_ERROR(reader.next_block_with_aggregation(&block, nullptr, 
nullptr, &eof));
+        rows += block.rows();
+
+        block.update_hash(block_hash);
+        block.clear_column_data();
+    }
+    uint64_t checksum64 = block_hash.get64();
+    *_checksum = (checksum64 >> 32) ^ (checksum64 & 0xffffffff);
+
+    LOG(INFO) << "success to finish compute checksum. tablet_id = " << 
_tablet_id
+              << ", rows = " << rows << ", checksum=" << *_checksum;

Review Comment:
   warning: use of undeclared identifier '_checksum' [clang-diagnostic-error]
   ```cpp
                 << ", rows = " << rows << ", checksum=" << *_checksum;
                                                             ^
   ```
   



##########
be/src/olap/task/engine_checksum_task.cpp:
##########
@@ -38,7 +39,52 @@
     LOG(INFO) << "begin to process compute checksum."
               << "tablet_id=" << _tablet_id << ", schema_hash=" << _schema_hash
               << ", version=" << _version;
-    return Status::InternalError("Not implemented yet");
+
+    if (_checksum == nullptr) {
+        return Status::InvalidArgument("invalid checksum which is nullptr");
+    }
+
+    TabletSharedPtr tablet = 
StorageEngine::instance()->tablet_manager()->get_tablet(_tablet_id);
+    if (nullptr == tablet) {
+        return Status::InternalError("could not find tablet {}", _tablet_id);
+    }
+
+    std::vector<RowsetSharedPtr> input_rowsets;
+    Version version(0, _version);
+    Status acquire_reader_st = tablet->capture_consistent_rowsets(version, 
&input_rowsets);
+    if (acquire_reader_st != Status::OK()) {
+        LOG(WARNING) << "fail to captute consistent rowsets. tablet=" << 
tablet->full_name()
+                     << "res=" << acquire_reader_st;
+        return acquire_reader_st;
+    }
+    vectorized::BlockReader reader;
+    TabletReader::ReaderParams reader_params;
+    vectorized::Block block;
+    RETURN_NOT_OK(TabletReader::init_reader_params_and_create_block(
+            tablet, READER_CHECKSUM, input_rowsets, &reader_params, &block))
+
+    auto res = reader.init(reader_params);
+    if (!res.ok()) {
+        LOG(WARNING) << "initiate reader fail. res = " << res;
+        return res;
+    }
+
+    bool eof = false;
+    SipHash block_hash;
+    uint64_t rows = 0;
+    while (!eof) {
+        RETURN_IF_ERROR(reader.next_block_with_aggregation(&block, nullptr, 
nullptr, &eof));
+        rows += block.rows();
+
+        block.update_hash(block_hash);
+        block.clear_column_data();
+    }
+    uint64_t checksum64 = block_hash.get64();
+    *_checksum = (checksum64 >> 32) ^ (checksum64 & 0xffffffff);

Review Comment:
   warning: use of undeclared identifier '_checksum' [clang-diagnostic-error]
   ```cpp
       *_checksum = (checksum64 >> 32) ^ (checksum64 & 0xffffffff);
        ^
   ```
   



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