diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-21 08:47:34 +0100 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:28:32 +0200 |
| commit | daeb93bf99215f70b265b9a04cc7d37f57197977 (patch) | |
| tree | b1991be7d279601bd4bdef04c01d23cefd7209c3 /zenstore/compactcas.cpp | |
| parent | add test that triggers direct removal of block in gc (diff) | |
| download | zen-daeb93bf99215f70b265b9a04cc7d37f57197977.tar.xz zen-daeb93bf99215f70b265b9a04cc7d37f57197977.zip | |
ChunkBlock takes prepared path
Diffstat (limited to 'zenstore/compactcas.cpp')
| -rw-r--r-- | zenstore/compactcas.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index b816869c3..8cf6fe229 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -109,7 +109,7 @@ namespace { struct CasContainerStrategy::ChunkBlock { - ChunkBlock(const std::filesystem::path& BlocksBasePath, uint32_t BlockIndex); + explicit ChunkBlock(const std::filesystem::path& BlockPath); ~ChunkBlock(); const std::filesystem::path GetPath() const; void Open(); @@ -130,8 +130,7 @@ private: IoBuffer m_IoBuffer; }; -CasContainerStrategy::ChunkBlock::ChunkBlock(const std::filesystem::path& BlocksBasePath, uint32_t BlockIndex) -: m_Path(BuildUcasPath(BlocksBasePath, BlockIndex)) +CasContainerStrategy::ChunkBlock::ChunkBlock(const std::filesystem::path& BlockPath) : m_Path(BlockPath) { } @@ -312,7 +311,8 @@ CasContainerStrategy::InsertChunk(const void* ChunkData, size_t ChunkSize, const { WriteBlockIndex++; } - WriteBlock = std::make_shared<ChunkBlock>(m_BlocksBasePath, WriteBlockIndex); + auto BlockPath = BuildUcasPath(m_BlocksBasePath, WriteBlockIndex); + WriteBlock = std::make_shared<ChunkBlock>(BlockPath); m_ChunkBlocks[WriteBlockIndex] = WriteBlock; m_WriteBlockIndex.store(WriteBlockIndex); } @@ -699,7 +699,8 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx) { NewBlockIndex++; } - NewBlockFile = std::make_shared<ChunkBlock>(m_BlocksBasePath, NewBlockIndex); + auto BlockPath = BuildUcasPath(m_BlocksBasePath, NewBlockIndex); + NewBlockFile = std::make_shared<ChunkBlock>(BlockPath); m_ChunkBlocks[NewBlockIndex] = NewBlockFile; } @@ -1026,15 +1027,17 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) SmallObjectFile.Read(Chunk.data(), Chunk.size(), ChunkLocation.GetOffset()); if (!NewBlockFile) { - NewBlockFile = std::make_unique<ChunkBlock>(m_BlocksBasePath, NewBlockIndex); + auto BlockPath = BuildUcasPath(m_BlocksBasePath, NewBlockIndex); + NewBlockFile = std::make_unique<ChunkBlock>(BlockPath); NewBlockFile->Create(m_MaxBlockSize); } else if (WriteOffset + Chunk.size() > m_MaxBlockSize) { uint64_t ChunkEnd = ChunkLocation.GetOffset() + Chunk.size(); SmallObjectFile.SetFileSize(ChunkEnd); - NewBlockIndex = NewBlockIndex + 1; - NewBlockFile = std::make_unique<ChunkBlock>(m_BlocksBasePath, NewBlockIndex); + NewBlockIndex = NewBlockIndex + 1; + auto BlockPath = BuildUcasPath(m_BlocksBasePath, NewBlockIndex); + NewBlockFile = std::make_unique<ChunkBlock>(BlockPath); NewBlockFile->Create(m_MaxBlockSize); WriteOffset = 0; } @@ -1146,7 +1149,8 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) std::filesystem::remove(Path); continue; } - auto SmallObjectFile = std::make_shared<ChunkBlock>(m_BlocksBasePath, BlockIndex); + auto BlockPath = BuildUcasPath(m_BlocksBasePath, BlockIndex); + auto SmallObjectFile = std::make_shared<ChunkBlock>(BlockPath); m_ChunkBlocks[BlockIndex] = SmallObjectFile; } } |