yujun777 commented on code in PR #29818: URL: https://github.com/apache/doris/pull/29818#discussion_r1449804495
########## be/src/olap/storage_engine.cpp: ########## @@ -448,45 +450,89 @@ Status StorageEngine::set_cluster_id(int32_t cluster_id) { return Status::OK(); } +StorageEngine::Disk_remaining_level get_available_level(double disk_usage_percent) { + assert(disk_usage_percent <= 1); + if (disk_usage_percent < 0.7) { + return StorageEngine::Disk_remaining_level::LOW; + } else if (disk_usage_percent < 0.85) { + return StorageEngine::Disk_remaining_level::MID; + } + return StorageEngine::Disk_remaining_level::HIGH; +} + std::vector<DataDir*> StorageEngine::get_stores_for_create_tablet( - TStorageMedium::type storage_medium) { + int64 partition_id, TStorageMedium::type storage_medium) { + struct DirInfo { + DataDir* data_dir; + + StorageEngine::Disk_remaining_level available_level; + + bool operator<(const DirInfo& other) const { + if (available_level != other.available_level) { + return available_level < other.available_level; + } + return data_dir->path_hash() < other.data_dir->path_hash(); + } + }; + + std::vector<DirInfo> dir_infos; + int curr_index = 0; + std::vector<DataDir*> stores; { std::lock_guard<std::mutex> l(_store_lock); + + auto key = CreateTabletIdxCache::get_key(partition_id, storage_medium); + curr_index = _create_tablet_idx_lru_cache->get_index(key); + // -1, lru can't find key + if (curr_index == -1) { + auto init_num = rand() % 100; + curr_index = init_num; + _create_tablet_idx_lru_cache->set_index(key, init_num); + } else { + int64_t next_index = curr_index + 1; + // int64 overflow + if (next_index < 0) { + curr_index = 0; + } + _create_tablet_idx_lru_cache->set_index(key, next_index); + } + Review Comment: ``` curr_index = _create_tablet_idx_lru_cache->get_index(key); // -1, lru can't find key if (curr_index == -1) { curr_index = std::max(0, _last_use_index[medium] + 1); } _last_use_index[medium] = curr_index; _create_tablet_idx_lru_cache->set_index(key, std::max(0, curr_index + 1)); ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org