Skip to content

Commit

Permalink
Rename cache dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
JinheLin committed Mar 7, 2023
1 parent 18bdf2f commit 12d3a6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions dbms/src/Server/StorageConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,30 +602,30 @@ void StorageRemoteCacheConfig::initCacheDir() const
{
if (isCacheEnabled())
{
std::filesystem::create_directories(getStableCacheDir());
std::filesystem::create_directories(getDeltaCacheDir());
std::filesystem::create_directories(getDTFileCacheDir());
std::filesystem::create_directories(getPageCacheDir());
}
}

String StorageRemoteCacheConfig::getStableCacheDir() const
String StorageRemoteCacheConfig::getDTFileCacheDir() const
{
std::filesystem::path cache_root(dir);
// {dir}/stable
return cache_root /= "stable";
// {dir}/dtfile
return cache_root /= "dtfile";
}
String StorageRemoteCacheConfig::getDeltaCacheDir() const
String StorageRemoteCacheConfig::getPageCacheDir() const
{
std::filesystem::path cache_root(dir);
// {dir}/delta
return cache_root /= "delta";
// {dir}/page
return cache_root /= "page";
}

UInt64 StorageRemoteCacheConfig::getStableCapacity() const
UInt64 StorageRemoteCacheConfig::getDTFileCapacity() const
{
return capacity - getDeltaCapacity();
return capacity - getPageCapacity();
}

UInt64 StorageRemoteCacheConfig::getDeltaCapacity() const
UInt64 StorageRemoteCacheConfig::getPageCapacity() const
{
return capacity * delta_rate;
}
Expand Down
8 changes: 4 additions & 4 deletions dbms/src/Server/StorageConfigParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ struct StorageRemoteCacheConfig

bool isCacheEnabled() const;
void initCacheDir() const;
String getStableCacheDir() const;
String getDeltaCacheDir() const;
UInt64 getStableCapacity() const;
UInt64 getDeltaCapacity() const;
String getDTFileCacheDir() const;
String getPageCacheDir() const;
UInt64 getDTFileCapacity() const;
UInt64 getPageCapacity() const;
void parse(const String & content, const LoggerPtr & log);
};

Expand Down
8 changes: 4 additions & 4 deletions dbms/src/Server/tests/gtest_storage_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,10 @@ delta_rate = 1.1
ASSERT_EQ(remote_cache_config.capacity, 10000000);
ASSERT_EQ(remote_cache_config.dtfile_level, 11);
ASSERT_DOUBLE_EQ(remote_cache_config.delta_rate, 0.33);
ASSERT_EQ(remote_cache_config.getStableCacheDir(), "/tmp/StorageConfigTest/RemoteCacheConfig/0/stable");
ASSERT_EQ(remote_cache_config.getDeltaCacheDir(), "/tmp/StorageConfigTest/RemoteCacheConfig/0/delta");
ASSERT_EQ(remote_cache_config.getStableCapacity() + remote_cache_config.getDeltaCapacity(), remote_cache_config.capacity);
ASSERT_DOUBLE_EQ(remote_cache_config.getStableCapacity() * 1.0 / remote_cache_config.capacity, 1.0 - remote_cache_config.delta_rate);
ASSERT_EQ(remote_cache_config.getDTFileCacheDir(), "/tmp/StorageConfigTest/RemoteCacheConfig/0/dtfile");
ASSERT_EQ(remote_cache_config.getPageCacheDir(), "/tmp/StorageConfigTest/RemoteCacheConfig/0/page");
ASSERT_EQ(remote_cache_config.getDTFileCapacity() + remote_cache_config.getPageCapacity(), remote_cache_config.capacity);
ASSERT_DOUBLE_EQ(remote_cache_config.getDTFileCapacity() * 1.0 / remote_cache_config.capacity, 1.0 - remote_cache_config.delta_rate);
ASSERT_TRUE(remote_cache_config.isCacheEnabled());
}
else
Expand Down

0 comments on commit 12d3a6b

Please sign in to comment.