yiguolei commented on code in PR #9890: URL: https://github.com/apache/incubator-doris/pull/9890#discussion_r885701904
########## be/src/olap/convert_rowset.cpp: ########## @@ -0,0 +1,169 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "olap/convert_rowset.h" + +#include "util/trace.h" +namespace doris { +Status ConvertRowset::prepare_convert() { + if (!_tablet->init_succeeded()) { + return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR); + } + // reuse cumulative compaction lock + std::unique_lock<std::mutex> lock(_tablet->get_cumulative_compaction_lock(), std::try_to_lock); + if (!lock.owns_lock()) { + LOG(INFO) << "The tablet is under cumulative compaction. tablet=" << _tablet->full_name(); + return Status::OLAPInternalError(OLAP_ERR_CE_TRY_CE_LOCK_ERROR); + } + TRACE("got cumulative compaction lock"); + + pick_rowsets_to_convert(); + TRACE("rowsets picked"); + + TRACE_COUNTER_INCREMENT("input_rowsets_count", _input_rowsets.size()); + _tablet->set_clone_occurred(false); + + return Status::OK(); +} +void ConvertRowset::pick_rowsets_to_convert() { + _tablet->pick_rowsets_to_convert(&_input_rowsets); +} + +Status ConvertRowset::do_convert() { + RETURN_NOT_OK(construct_input_rowset_readers()); + + Merger::Statistics stats; + Status res; + for (size_t i = 0; i < _input_rowsets.size(); ++i) { + OlapStopWatch watch; + + Version output_version = + Version(_input_rowsets[i]->start_version(), _input_rowsets[i]->end_version()); + std::unique_ptr<RowsetWriter> output_rs_writer; + _tablet->create_rowset_writer(output_version, VISIBLE, NONOVERLAPPING, &output_rs_writer); + res = Merger::merge_rowsets(_tablet, ReaderType::READER_CUMULATIVE_COMPACTION, + {_input_rs_readers[i]}, output_rs_writer.get(), &stats); + + if (!res.ok()) { + LOG(WARNING) << "fail to convert rowset. res=" << res + << ", tablet=" << _tablet->full_name() + << ", output_version=" << output_version; + } else { + TRACE("convert rowset finished"); + + auto output_rowset = output_rs_writer->build(); + if (output_rowset == nullptr) { + LOG(WARNING) << "rowset writer build failed. writer version:" + << ", output_version=" << output_version; + return Status::OLAPInternalError(OLAP_ERR_MALLOC_ERROR); + } + + TRACE_COUNTER_INCREMENT("output_rowset_data_size", output_rowset->data_disk_size()); + TRACE_COUNTER_INCREMENT("output_row_num", output_rowset->num_rows()); + TRACE_COUNTER_INCREMENT("output_segments_num", output_rowset->num_segments()); + TRACE("output rowset built"); + + RETURN_NOT_OK(check_correctness(_input_rowsets[i], output_rowset, stats)); + TRACE("check correctness finished"); + + _modify_rowsets(_input_rowsets[i], output_rowset); + TRACE("modify rowsets finished"); + + int64_t current_max_version; Review Comment: 86 到 101 行没用,删掉吧 -- 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]
