78 lines
2.9 KiB
C++
78 lines
2.9 KiB
C++
// 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/calc_delete_bitmap_executor.h"
|
|
|
|
#include <gen_cpp/olap_file.pb.h>
|
|
|
|
#include <ostream>
|
|
|
|
#include "common/config.h"
|
|
#include "common/logging.h"
|
|
#include "olap/memtable.h"
|
|
#include "olap/tablet.h"
|
|
#include "util/time.h"
|
|
|
|
namespace doris {
|
|
using namespace ErrorCode;
|
|
|
|
Status CalcDeleteBitmapToken::submit(TabletSharedPtr tablet, RowsetSharedPtr cur_rowset,
|
|
const segment_v2::SegmentSharedPtr& cur_segment,
|
|
const std::vector<RowsetSharedPtr>& target_rowsets,
|
|
int64_t end_version, DeleteBitmapPtr delete_bitmap,
|
|
RowsetWriter* rowset_writer) {
|
|
{
|
|
std::shared_lock rlock(_lock);
|
|
RETURN_IF_ERROR(_status);
|
|
}
|
|
|
|
return _thread_token->submit_func([=, this]() {
|
|
auto st = tablet->calc_segment_delete_bitmap(cur_rowset, cur_segment, target_rowsets,
|
|
delete_bitmap, end_version, rowset_writer);
|
|
if (!st.ok()) {
|
|
LOG(WARNING) << "failed to calc segment delete bitmap, tablet_id: "
|
|
<< tablet->tablet_id() << " rowset: " << cur_rowset->rowset_id()
|
|
<< " seg_id: " << cur_segment->id() << " version: " << end_version
|
|
<< " error: " << st;
|
|
std::lock_guard wlock(_lock);
|
|
if (_status.ok()) {
|
|
_status = st;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
Status CalcDeleteBitmapToken::wait() {
|
|
_thread_token->wait();
|
|
// all tasks complete here, don't need lock;
|
|
return _status;
|
|
}
|
|
|
|
void CalcDeleteBitmapExecutor::init() {
|
|
static_cast<void>(ThreadPoolBuilder("TabletCalcDeleteBitmapThreadPool")
|
|
.set_min_threads(1)
|
|
.set_max_threads(config::calc_delete_bitmap_max_thread)
|
|
.build(&_thread_pool));
|
|
}
|
|
|
|
std::unique_ptr<CalcDeleteBitmapToken> CalcDeleteBitmapExecutor::create_token() {
|
|
return std::make_unique<CalcDeleteBitmapToken>(
|
|
_thread_pool->new_token(ThreadPool::ExecutionMode::CONCURRENT));
|
|
}
|
|
|
|
} // namespace doris
|