yiguolei commented on code in PR #9368:
URL: https://github.com/apache/incubator-doris/pull/9368#discussion_r867299163
##########
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:
I think it is affordable. And it is better than add a boolean variable to
indicate which method to use because it need modify too many invoking place and
the method is not very clear.
--
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]