yiguolei commented on code in PR #9368:
URL: https://github.com/apache/incubator-doris/pull/9368#discussion_r866533398


##########
be/src/olap/tablet.cpp:
##########
@@ -1446,4 +1437,99 @@ void Tablet::reset_compaction(CompactionType 
compaction_type) {
     }
 }
 
+Status Tablet::create_initial_rowset(const int64_t req_version) {
+    Status res = Status::OK();
+    if (req_version < 1) {
+        LOG(WARNING) << "init version of tablet should at least 1. req.ver=" 
<< req_version;
+        return Status::OLAPInternalError(OLAP_ERR_CE_CMD_PARAMS_ERROR);
+    }
+    Version version(0, req_version);
+    RowsetSharedPtr new_rowset;
+    do {
+        // there is no data in init rowset, so overlapping info is unknown.
+        std::unique_ptr<RowsetWriter> rs_writer;
+        res = create_rowset_writer(version, VISIBLE, OVERLAP_UNKNOWN, 
&rs_writer);
+        if (!res.ok()) {
+            LOG(WARNING) << "failed to init rowset writer for tablet " << 
full_name();
+            break;
+        }
+        res = rs_writer->flush();
+        if (!res.ok()) {
+            LOG(WARNING) << "failed to flush rowset writer for tablet " << 
full_name();
+            break;
+        }
+
+        new_rowset = rs_writer->build();
+        res = add_rowset(new_rowset);
+        if (!res.ok()) {
+            LOG(WARNING) << "failed to add rowset for tablet " << full_name();
+            break;
+        }
+    } while (0);
+
+    // Unregister index and delete files(index and data) if failed
+    if (!res.ok()) {
+        LOG(WARNING) << "fail to create initial rowset. res=" << res << " 
version=" << req_version;
+        StorageEngine::instance()->add_unused_rowset(new_rowset);
+        return res;
+    }
+    set_cumulative_layer_point(req_version + 1);
+    return res;
+}
+
+Status Tablet::create_rowset_writer(const Version& version, const 
RowsetStatePB& rowset_state,

Review Comment:
   It could not be one method, because one method is for load purpose so it 
have load id and txn id, and the other method is for existing rowset so it have 
version.
   Although we could combine there 2 method to a single method, but has to add 
a boolean variable to indicate which variable is useful and user has to set 
default value during call this method.  I am not preferred with this way.



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