github-actions[bot] commented on code in PR #32804:
URL: https://github.com/apache/doris/pull/32804#discussion_r1537871834
##########
be/src/cloud/cloud_backend_service.cpp:
##########
@@ -45,4 +52,28 @@ Status
CloudBackendService::create_service(CloudStorageEngine& engine, ExecEnv*
return Status::OK();
}
+void CloudBackendService::sync_load_for_tablets(TSyncLoadForTabletsResponse&,
+ const
TSyncLoadForTabletsRequest& request) {
+ auto f = [this, tablet_ids = request.tablet_ids]() {
+ std::for_each(tablet_ids.cbegin(), tablet_ids.cend(), [this](int64_t
tablet_id) {
+ CloudTabletSPtr tablet;
+ auto result = _engine.tablet_mgr().get_tablet(tablet_id, true);
+ if (!result.has_value()) {
+ return;
+ }
+ Status st = result.value()->sync_rowsets(-1, true);
+ if (!st.ok()) {
+ LOG_WARNING("failed to sync load for tablet").error(st);
+ }
+ });
+ };
+}
+
+void
CloudBackendService::get_top_n_hot_partitions(TGetTopNHotPartitionsResponse&
response,
Review Comment:
warning: method 'get_top_n_hot_partitions' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void
CloudBackendService::get_top_n_hot_partitions(TGetTopNHotPartitionsResponse&
response,
```
##########
be/src/io/cache/block_file_cache_downloader.h:
##########
@@ -0,0 +1,108 @@
+// 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.
+// This file is copied from
+//
https://github.com/ClickHouse/ClickHouse/blob/master/src/Interpreters/Cache/FileCacheFactory.h
+// and modified by Doris
+
+#pragma once
+
+#include <gen_cpp/internal_service.pb.h>
Review Comment:
warning: 'gen_cpp/internal_service.pb.h' file not found
[clang-diagnostic-error]
```cpp
#include <gen_cpp/internal_service.pb.h>
^
```
##########
be/src/util/s3_util.h:
##########
@@ -19,6 +19,7 @@
#include <aws/core/Aws.h>
Review Comment:
warning: 'aws/core/Aws.h' file not found [clang-diagnostic-error]
```cpp
#include <aws/core/Aws.h>
^
```
##########
be/src/cloud/cloud_warm_up_manager.cpp:
##########
@@ -0,0 +1,211 @@
+// 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_warm_up_manager.h"
+
+#include <bthread/countdown_event.h>
+
+#include <algorithm>
+#include <cstddef>
+#include <tuple>
+
+#include "cloud/cloud_tablet_mgr.h"
+#include "common/logging.h"
+#include "io/cache/block_file_cache_downloader.h"
+#include "olap/rowset/beta_rowset.h"
+#include "olap/rowset/segment_v2/inverted_index_desc.h"
+#include "olap/tablet.h"
+#include "runtime/exec_env.h"
+#include "util/time.h"
+
+namespace doris {
+
+CloudWarmUpManager* CloudWarmUpManager::instance() {
+ return ExecEnv::GetInstance()->cloud_warm_up_manager();
+}
+
+CloudWarmUpManager::CloudWarmUpManager(CloudStorageEngine& engine) :
_engine(engine) {
+ _download_thread = std::thread(&CloudWarmUpManager::handle_jobs, this);
+}
+
+CloudWarmUpManager::~CloudWarmUpManager() {
+ {
+ std::lock_guard lock(_mtx);
+ _closed = true;
+ }
+ _cond.notify_all();
+ if (_download_thread.joinable()) {
+ _download_thread.join();
+ }
+}
+
+void CloudWarmUpManager::handle_jobs() {
+#ifndef BE_TEST
+ while (true) {
+ JobMeta* cur_job = nullptr;
+ {
+ std::unique_lock lock(_mtx);
+ _cond.wait(lock, [this]() { return _closed ||
!_pending_job_metas.empty(); });
+ if (_closed) break;
+ cur_job = &_pending_job_metas.front();
+ }
+ for (int64_t tablet_id : cur_job->tablet_ids) {
+ auto res = _engine.tablet_mgr().get_tablet(tablet_id);
+ if (!res.has_value()) {
+ LOG_WARNING("Warm up error ").tag("tablet_id",
tablet_id).error(res.error());
+ continue;
+ }
+ auto tablet = res.value();
+ auto st = tablet->sync_rowsets();
+ if (!st) {
+ LOG_WARNING("Warm up error ").tag("tablet_id",
tablet_id).error(st);
+ continue;
+ }
+ std::shared_ptr<bthread::CountdownEvent> wait =
+ std::make_shared<bthread::CountdownEvent>();
+ auto callback = [=](Status st) {
+ if (!st) {
+ LOG_WARNING("Warm up error ").error(st);
+ }
+ wait->signal();
+ };
+ auto tablet_meta = tablet->tablet_meta();
+ auto rs_metas = tablet_meta->snapshot_rs_metas();
+ for (auto& [_, rs] : rs_metas) {
+ for (int64_t seg_id = 0; seg_id < rs->num_segments();
seg_id++) {
+ io::S3FileMeta download_file_meta;
+ download_file_meta.file_size = 0;
+ download_file_meta.file_system = rs->fs();
+ std::string seg_path =
BetaRowset::remote_segment_path(rs->tablet_id(),
+
rs->rowset_id(), seg_id);
+ download_file_meta.path = seg_path;
+ // download_file_meta.expiration_time =
+ // tablet_meta->ttl_seconds() == 0
+ // ? 0
+ // : rs->newest_write_timestamp() +
tablet_meta->ttl_seconds();
+ if (download_file_meta.expiration_time <= UnixSeconds()) {
+ download_file_meta.expiration_time = 0;
+ }
+ download_file_meta.download_callback = callback;
+ wait->add_count();
+
io::FileCacheBlockDownloader::instance()->submit_download_task(
+ std::move(download_file_meta));
+ }
+ }
+ // TODO(liuchangliang): flow control
+ if (!wait->wait()) {
+ LOG_WARNING("Warm up tablet {} take a long time",
tablet_meta->tablet_id());
+ }
+ }
+ {
+ std::unique_lock lock(_mtx);
+ _finish_job.push_back(std::move(*cur_job));
+ _pending_job_metas.pop_front();
+ }
+ }
+#endif
+}
+
+JobMeta::JobMeta(const TJobMeta& meta)
+ : be_ip(meta.be_ip), brpc_port(meta.brpc_port),
tablet_ids(meta.tablet_ids) {
+ switch (meta.download_type) {
+ case TDownloadType::BE:
+ download_type = DownloadType::BE;
+ break;
+ case TDownloadType::S3:
+ download_type = DownloadType::S3;
+ break;
+ }
+}
+
+Status CloudWarmUpManager::check_and_set_job_id(int64_t job_id) {
+ std::lock_guard lock(_mtx);
+ if (_cur_job_id == 0) {
+ _cur_job_id = job_id;
+ }
+ Status st = Status::OK();
+ if (_cur_job_id != job_id) {
+ st = Status::InternalError("The job {} is running", _cur_job_id);
+ }
+ return st;
+}
+
+Status CloudWarmUpManager::check_and_set_batch_id(int64_t job_id, int64_t
batch_id, bool* retry) {
+ std::lock_guard lock(_mtx);
+ Status st = Status::OK();
+ if (_cur_job_id != 0 && _cur_job_id != job_id) {
+ st = Status::InternalError("The job {} is not current job, current job
is {}", job_id,
+ _cur_job_id);
+ return st;
+ }
+ if (_cur_job_id == 0) {
+ _cur_job_id = job_id;
+ }
+ if (_cur_batch_id == batch_id) {
+ *retry = true;
+ return st;
+ }
+ if (_pending_job_metas.empty()) {
+ _cur_batch_id = batch_id;
+ } else {
+ st = Status::InternalError("The batch {} is not finish",
_cur_batch_id);
+ }
+ return st;
+}
+
+void CloudWarmUpManager::add_job(const std::vector<TJobMeta>& job_metas) {
+ {
+ std::lock_guard lock(_mtx);
+ std::for_each(job_metas.begin(), job_metas.end(),
+ [this](const TJobMeta& meta) {
_pending_job_metas.emplace_back(meta); });
+ }
+ _cond.notify_all();
+}
+
+#ifdef BE_TEST
+void CloudWarmUpManager::consumer_job() {
+ {
+ std::unique_lock lock(_mtx);
+ _finish_job.push_back(_pending_job_metas.front());
+ _pending_job_metas.pop_front();
+ }
+}
+
+#endif
+
+std::tuple<int64_t, int64_t, int64_t, int64_t>
CloudWarmUpManager::get_current_job_state() {
Review Comment:
warning: method 'get_current_job_state' can be made static
[readability-convert-member-functions-to-static]
be/src/cloud/cloud_warm_up_manager.h:62:
```diff
- std::tuple<int64_t, int64_t, int64_t, int64_t> get_current_job_state();
+ static std::tuple<int64_t, int64_t, int64_t, int64_t>
get_current_job_state();
```
##########
be/src/cloud/cloud_tablet_hotspot.cpp:
##########
@@ -0,0 +1,196 @@
+// 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_tablet_hotspot.h"
+
+#include <chrono>
+#include <mutex>
+
+#include "cloud/config.h"
+#include "olap/tablet_fwd.h"
+#include "runtime/exec_env.h"
+
+namespace doris {
+
+void TabletHotspot::count(const BaseTabletSPtr& tablet) {
+ if (!config::is_cloud_mode()) return;
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
if (!config::is_cloud_mode()) { return;
}
```
##########
be/src/util/s3_rate_limiter.h:
##########
@@ -0,0 +1,79 @@
+// 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.
+
+#pragma once
+
+#include <bvar/bvar.h>
Review Comment:
warning: 'bvar/bvar.h' file not found [clang-diagnostic-error]
```cpp
#include <bvar/bvar.h>
^
```
##########
be/src/cloud/cloud_tablet_hotspot.cpp:
##########
@@ -0,0 +1,196 @@
+// 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_tablet_hotspot.h"
+
+#include <chrono>
+#include <mutex>
+
+#include "cloud/config.h"
+#include "olap/tablet_fwd.h"
+#include "runtime/exec_env.h"
+
+namespace doris {
+
+void TabletHotspot::count(const BaseTabletSPtr& tablet) {
Review Comment:
warning: method 'count' can be made static
[readability-convert-member-functions-to-static]
be/src/cloud/cloud_tablet_hotspot.h:55:
```diff
- void count(const BaseTabletSPtr& tablet);
+ static void count(const BaseTabletSPtr& tablet);
```
##########
be/src/cloud/cloud_tablet_hotspot.h:
##########
@@ -0,0 +1,74 @@
+// 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.
+
+#pragma once
+
+#include <atomic>
+#include <chrono>
+#include <condition_variable>
+#include <memory>
+
+#include "gen_cpp/BackendService.h"
Review Comment:
warning: 'gen_cpp/BackendService.h' file not found [clang-diagnostic-error]
```cpp
#include "gen_cpp/BackendService.h"
^
```
##########
be/src/cloud/cloud_warm_up_manager.cpp:
##########
@@ -0,0 +1,211 @@
+// 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_warm_up_manager.h"
+
+#include <bthread/countdown_event.h>
+
+#include <algorithm>
+#include <cstddef>
+#include <tuple>
+
+#include "cloud/cloud_tablet_mgr.h"
+#include "common/logging.h"
+#include "io/cache/block_file_cache_downloader.h"
+#include "olap/rowset/beta_rowset.h"
+#include "olap/rowset/segment_v2/inverted_index_desc.h"
+#include "olap/tablet.h"
+#include "runtime/exec_env.h"
+#include "util/time.h"
+
+namespace doris {
+
+CloudWarmUpManager* CloudWarmUpManager::instance() {
+ return ExecEnv::GetInstance()->cloud_warm_up_manager();
+}
+
+CloudWarmUpManager::CloudWarmUpManager(CloudStorageEngine& engine) :
_engine(engine) {
+ _download_thread = std::thread(&CloudWarmUpManager::handle_jobs, this);
+}
+
+CloudWarmUpManager::~CloudWarmUpManager() {
+ {
+ std::lock_guard lock(_mtx);
+ _closed = true;
+ }
+ _cond.notify_all();
+ if (_download_thread.joinable()) {
+ _download_thread.join();
+ }
+}
+
+void CloudWarmUpManager::handle_jobs() {
+#ifndef BE_TEST
+ while (true) {
+ JobMeta* cur_job = nullptr;
+ {
+ std::unique_lock lock(_mtx);
+ _cond.wait(lock, [this]() { return _closed ||
!_pending_job_metas.empty(); });
+ if (_closed) break;
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
if (_closed) { break;
}
```
##########
be/src/io/cache/block_file_cache_downloader.cpp:
##########
@@ -0,0 +1,411 @@
+// 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.
+// This file is copied from
+//
https://github.com/ClickHouse/ClickHouse/blob/master/src/Interpreters/Cache/FileCacheFactory.h
+// and modified by Doris
+
+#include "io/cache/block_file_cache_downloader.h"
+
+#include <aws/transfer/TransferHandle.h>
+#include <aws/transfer/TransferManager.h>
+#include <bthread/countdown_event.h>
+#include <bvar/bvar.h>
+#include <fmt/core.h>
+#include <gen_cpp/internal_service.pb.h>
+
+#include <memory>
+#include <mutex>
+#include <variant>
+
+#include "cloud/cloud_tablet_mgr.h"
+#include "common/config.h"
+#include "common/logging.h"
+#include "common/sync_point.h"
+#include "io/cache/block_file_cache.h"
+#include "io/cache/block_file_cache_factory.h"
+#include "io/cache/file_block.h"
+#include "io/cache/file_cache_common.h"
+#include "io/fs/err_utils.h"
+#include "io/fs/s3_common.h"
+#include "io/fs/s3_file_bufferpool.h"
+#include "io/fs/s3_file_system.h"
+#include "olap/rowset/beta_rowset.h"
+#include "olap/tablet.h"
+// #include "runtime/exec_env.h"
+#include "util/bvar_helper.h"
+#include "util/s3_util.h"
+
+using Aws::S3::Model::GetObjectRequest;
+
+namespace doris::io {
+
+namespace {
+bvar::Adder<uint64_t> file_cache_downloader_counter("file_cache_downloader",
"size");
+
+std::string s3_path(std::string_view bucket, std::string_view key) {
+ return fmt::format("s3://{}/{}", bucket, key);
+}
+
+Status _download_part(std::shared_ptr<::Aws::S3::S3Client> client, std::string
key_name,
+ std::string bucket, size_t offset, size_t size, Slice&
s) {
+ GetObjectRequest request;
+ request.WithBucket(bucket).WithKey(key_name);
+ request.SetRange(fmt::format("bytes={}-{}", offset, offset + size - 1));
+
request.SetResponseStreamFactory(AwsWriteableStreamFactory((void*)s.get_data(),
size));
+ SCOPED_BVAR_LATENCY(s3_bvar::s3_get_latency);
+ auto outcome =
SYNC_POINT_HOOK_RETURN_VALUE(DO_S3_GET_RATE_LIMIT(client->GetObject(request)),
+ "io::_download_part",
std::cref(request).get(), &s);
+
+ TEST_SYNC_POINT_CALLBACK("io::_download_part::error", &outcome);
+ if (!outcome.IsSuccess()) {
+ return s3fs_error(outcome.GetError(),
+ fmt::format("failed to read from {}",
s3_path(bucket, key_name)));
+ }
+ auto bytes_read = outcome.GetResult().GetContentLength();
+ if (bytes_read != size) {
+ return Status::InternalError("failed to read from {}(bytes read: {},
bytes req: {})",
+ s3_path(bucket, key_name), bytes_read,
size);
+ }
+ s.size = bytes_read;
+
+ return Status::OK();
+}
+
+// maybe we should move this logic inside s3 file bufferpool.cpp
+void _append_data_to_file_cache(FileBlocksHolderPtr holder, Slice data) {
+ size_t offset = 0;
+ std::for_each(
+ holder->file_blocks.begin(), holder->file_blocks.end(),
[&](FileBlockSPtr& file_block) {
+ if (file_block->is_downloader() && offset < data.size) {
+ size_t append_size = std::min(data.size - offset,
file_block->range().size());
+ Slice append_data(data.data + offset, append_size);
+ Status st;
+ st = file_block->append(append_data);
+ if (st.ok()) {
+ st = file_block->finalize();
+ }
+ if (!st.ok()) {
+ LOG_WARNING("failed to append data to file
cache").error(st);
+ }
+ }
+ offset += file_block->range().size();
+ });
+}
+
+} // namespace
+
+struct DownloadTaskExecutor {
+ DownloadTaskExecutor() = default;
+ ~DownloadTaskExecutor() = default;
+
+ void execute(std::shared_ptr<Aws::S3::S3Client> client, std::string
key_name, size_t offset,
Review Comment:
warning: function 'execute' exceeds recommended size/complexity thresholds
[readability-function-size]
```cpp
void execute(std::shared_ptr<Aws::S3::S3Client> client, std::string
key_name, size_t offset,
^
```
<details>
<summary>Additional context</summary>
**be/src/io/cache/block_file_cache_downloader.cpp:114:** 83 lines including
whitespace and comments (threshold 80)
```cpp
void execute(std::shared_ptr<Aws::S3::S3Client> client, std::string
key_name, size_t offset,
^
```
</details>
##########
be/src/cloud/cloud_tablet_hotspot.cpp:
##########
@@ -0,0 +1,196 @@
+// 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_tablet_hotspot.h"
+
+#include <chrono>
+#include <mutex>
+
+#include "cloud/config.h"
+#include "olap/tablet_fwd.h"
+#include "runtime/exec_env.h"
+
+namespace doris {
+
+void TabletHotspot::count(const BaseTabletSPtr& tablet) {
+ if (!config::is_cloud_mode()) return;
+ size_t slot_idx = tablet->tablet_id() % s_slot_size;
+ auto& slot = _tablets_hotspot[slot_idx];
+ std::lock_guard lock(slot.mtx);
+ HotspotCounterPtr counter;
+ if (auto iter = slot.map.find(tablet->tablet_id()); iter ==
slot.map.end()) {
+ counter = std::make_shared<HotspotCounter>(tablet->table_id(),
tablet->index_id(),
+ tablet->partition_id());
+ slot.map.insert(std::make_pair(tablet->tablet_id(), counter));
+ } else {
+ counter = iter->second;
+ }
+ counter->last_access_time = std::chrono::system_clock::now();
+ counter->cur_counter++;
+}
+
+TabletHotspot::TabletHotspot() {
+ _counter_thread = std::thread(&TabletHotspot::make_dot_point, this);
+}
+
+TabletHotspot::~TabletHotspot() {
+ {
+ std::lock_guard lock(_mtx);
+ _closed = true;
+ }
+ _cond.notify_all();
+ if (_counter_thread.joinable()) {
+ _counter_thread.join();
+ }
+}
+
+struct MapKeyHash {
+ int64_t operator()(const std::pair<int64_t, int64_t>& key) const {
+ return std::hash<int64_t> {}(key.first) + std::hash<int64_t>
{}(key.second);
+ }
+};
+struct TabletHotspotMapValue {
+ uint64_t qpd = 0;
+ uint64_t qpw = 0;
+ int64_t last_access_time;
+};
+
+using TabletHotspotMapKey = std::pair<int64_t, int64_t>;
+
+TabletHotspot* TabletHotspot::instance() {
+ // return ExecEnv::GetInstance()->tabletHotspot();
+ return nullptr;
+}
+
+void TabletHotspot::get_top_n_hot_partition(std::vector<THotTableMessage>*
hot_tables) {
Review Comment:
warning: method 'get_top_n_hot_partition' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void
TabletHotspot::get_top_n_hot_partition(std::vector<THotTableMessage>*
hot_tables) {
```
--
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]