Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Lloyd-Pottiger <[email protected]>
  • Loading branch information
Lloyd-Pottiger committed Aug 30, 2024
1 parent 50d62a3 commit 5eb8d70
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/Index/VectorIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionHelpers.h>
#include <Storages/DeltaMerge/File/dtpb/dmfile.pb.h>
#include <Storages/DeltaMerge/Index/VectorIndex.h>
#include <Storages/DeltaMerge/Index/VectorIndexHNSW/Index.h>
#include <Storages/DeltaMerge/dtpb/dmfile.pb.h>
#include <TiDB/Schema/VectorIndex.h>
#include <tipb/executor.pb.h>

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/Index/VectorIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <IO/Buffer/ReadBuffer.h>
#include <IO/Buffer/WriteBuffer.h>
#include <Storages/DeltaMerge/BitmapFilter/BitmapFilterView.h>
#include <Storages/DeltaMerge/File/dtpb/dmfile.pb.h>
#include <Storages/DeltaMerge/Index/VectorIndex_fwd.h>
#include <Storages/DeltaMerge/dtpb/dmfile.pb.h>
#include <TiDB/Schema/VectorIndex.h>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include <Functions/FunctionHelpers.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <Storages/DeltaMerge/File/dtpb/dmfile.pb.h>
#include <Storages/DeltaMerge/Index/VectorIndexHNSW/Index.h>
#include <Storages/DeltaMerge/Index/VectorSearchPerf.h>
#include <Storages/DeltaMerge/dtpb/dmfile.pb.h>
#include <tipb/executor.pb.h>

#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#pragma once

#include <Storages/DeltaMerge/File/dtpb/dmfile.pb.h>
#include <Storages/DeltaMerge/Index/VectorIndex.h>
#include <Storages/DeltaMerge/dtpb/dmfile.pb.h>
#include <VectorSearch/USearch.h>

namespace DB::DM
Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/S3/FileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ bool FileCache::reserveSpaceImpl(FileType reserve_for, UInt64 size, EvictMode ev
if (evict == EvictMode::TryEvict || evict == EvictMode::ForceEvict)
{
UInt64 min_evict_size = size - (cache_capacity - cache_used);
LOG_DEBUG( //
LOG_DEBUG(
log,
"tryEvictFile for {} min_evict_size={} evict_mode={}",
magic_enum::enum_name(reserve_for),
Expand Down Expand Up @@ -652,7 +652,7 @@ bool FileCache::finalizeReservedSize(FileType reserve_for, UInt64 reserved_size,
if (content_length > reserved_size)
{
// Need more space.
return reserveSpace(reserve_for, content_length - reserved_size, /*try_evict*/ EvictMode::TryEvict);
return reserveSpace(reserve_for, content_length - reserved_size, EvictMode::TryEvict);
}
else if (content_length < reserved_size)
{
Expand Down
64 changes: 31 additions & 33 deletions dbms/src/Storages/S3/tests/gtest_filecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <chrono>
#include <filesystem>
#include <fstream>
#include <numeric>
#include <random>
#include <thread>

Expand Down Expand Up @@ -229,7 +228,7 @@ class FileCacheTest : public ::testing::Test

String tmp_dir;
UInt64 cache_capacity = 100 * 1024 * 1024;
UInt64 cache_level = 5;
const UInt64 cache_level = 5;
UInt64 cache_min_age_seconds = 30 * 60;
LoggerPtr log;
PathCapacityMetricsPtr capacity_metrics;
Expand Down Expand Up @@ -445,12 +444,12 @@ try
ASSERT_EQ(FileCache::getFileType(unknow_fname1), FileType::Unknow);

{
UInt64 cache_level_ = 0;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 0;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_FALSE(file_cache.canCache(FileType::Meta));
Expand All @@ -464,12 +463,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 1;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 1;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -483,12 +482,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 2;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 2;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -502,12 +501,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 3;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 3;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -521,12 +520,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 4;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 4;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -540,12 +539,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 5;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 5;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -559,12 +558,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 6;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 6;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -578,12 +577,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 7;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 7;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -597,12 +596,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 8;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 8;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand All @@ -616,12 +615,12 @@ try
ASSERT_FALSE(file_cache.canCache(FileType::ColData));
}
{
UInt64 cache_level_ = 9;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level_);
const UInt64 cache_level = 9;
auto cache_dir = fmt::format("{}/filetype{}", tmp_dir, cache_level);
StorageRemoteCacheConfig cache_config{
.dir = cache_dir,
.capacity = cache_capacity,
.dtfile_level = cache_level_};
.dtfile_level = cache_level};
FileCache file_cache(capacity_metrics, cache_config);
ASSERT_FALSE(file_cache.canCache(FileType::Unknow));
ASSERT_TRUE(file_cache.canCache(FileType::Meta));
Expand Down Expand Up @@ -879,7 +878,6 @@ try
}
CATCH


TEST_F(FileCacheTest, ForceEvict)
try
{
Expand Down

0 comments on commit 5eb8d70

Please sign in to comment.