csun5285 commented on code in PR #54032: URL: https://github.com/apache/doris/pull/54032#discussion_r2278190836
########## be/src/cloud/cloud_index_change_compaction.cpp: ########## @@ -0,0 +1,558 @@ +// 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 "cloud/cloud_index_change_compaction.h" + +#include "cloud/cloud_meta_mgr.h" +#include "cloud/config.h" +#include "common/status.h" +#include "cpp/sync_point.h" + +namespace doris { + +CloudIndexChangeCompaction::~CloudIndexChangeCompaction() = default; + +CloudIndexChangeCompaction::CloudIndexChangeCompaction(CloudStorageEngine& engine, + CloudTabletSPtr tablet, bool is_drop, + std::vector<TOlapTableIndex>& alter_indexes) + : CloudCompactionMixin(engine, tablet, + "CloudIndexChangeCompaction:" + std::to_string(tablet->tablet_id())), + _is_drop(is_drop), + _alter_indexes(alter_indexes) {} + +Status CloudIndexChangeCompaction::prepare_compact() { + TEST_SYNC_POINT_RETURN_WITH_VALUE("CloudIndexChangeCompaction::prepare_compact", Status::OK()); + + std::set<int64_t> alter_index_ids; + for (auto index : _alter_indexes) { + alter_index_ids.insert(index.index_id); + } + + if (alter_index_ids.size() == 0) { + LOG(WARNING) << "[index_change] no index is specified."; + return Status::InternalError("no specified index."); + } else { + VLOG_DEBUG << "[index_change] alter_index_ids size=" << alter_index_ids.size(); + } + + if (_tablet->tablet_state() != TABLET_RUNNING) { + LOG(WARNING) << "[index_change] tablet state is not running. tablet_id=" + << _tablet->tablet_id(); + return Status::InternalError("invalid tablet state. tablet_id={}", _tablet->tablet_id()); + } + + RETURN_IF_ERROR(cloud_tablet()->sync_rowsets()); + + { + std::shared_lock rlock(_tablet->get_header_lock()); + _base_compaction_cnt = cloud_tablet()->base_compaction_cnt(); + _cumulative_compaction_cnt = cloud_tablet()->cumulative_compaction_cnt(); + } + + bool is_base_rowset = false; + auto input_rowset = DORIS_TRY(cloud_tablet()->pick_a_rowset_for_index_change( + alter_index_ids, _is_drop, is_base_rowset)); + if (input_rowset == nullptr) { + return Status::OK(); Review Comment: 这里得返回错误,或者特殊的错误,_input_rowsets 被假定为不能是空的 ########## fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java: ########## @@ -2116,9 +2122,6 @@ public int getAsInt() { BuildIndexClause buildIndexClause = (BuildIndexClause) alterClause; IndexDef indexDef = buildIndexClause.getIndexDef(); Index index = buildIndexClause.getIndex(); - if (Config.isCloudMode()) { Review Comment: 这得区分下,存算一体不能build ngram ########## fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java: ########## @@ -2146,8 +2149,8 @@ public int getAsInt() { } } // only inverted index with local mode can do light drop index change - if (found != null && found.getIndexType() == IndexDef.IndexType.INVERTED - && Config.isNotCloudMode()) { + if (found != null && (found.getIndexType() == IndexDef.IndexType.INVERTED + || found.getIndexType() == IndexType.NGRAM_BF)) { Review Comment: 同上 -- 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]
