aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-05-17 10:55:56 +0200
committerGitHub Enterprise <[email protected]>2024-05-17 10:55:56 +0200
commitbaf9891624b758b686e6b1c284013bea08794d69 (patch)
tree732f00270fa5264565a8535cea911d034fc12ba9 /src/zenstore/include
parentsafer partial requests (#82) (diff)
downloadzen-baf9891624b758b686e6b1c284013bea08794d69.tar.xz
zen-baf9891624b758b686e6b1c284013bea08794d69.zip
refactor BlockStore IterateChunks (#77)
Improvement: Refactored IterateChunks to allow reuse in diskcachelayer and hide public GetBlockFile() function in BlockStore
Diffstat (limited to 'src/zenstore/include')
-rw-r--r--src/zenstore/include/zenstore/blockstore.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h
index 7ef2f7baa..a1e497533 100644
--- a/src/zenstore/include/zenstore/blockstore.h
+++ b/src/zenstore/include/zenstore/blockstore.h
@@ -110,7 +110,6 @@ private:
};
class BlockStoreCompactState;
-class WorkerThreadPool;
class BlockStore
{
@@ -130,9 +129,10 @@ public:
typedef std::function<void(const MovedChunksArray& MovedChunks, const ChunkIndexArray& RemovedChunks)> ReclaimCallback;
typedef std::function<bool(const MovedChunksArray& MovedChunks, uint64_t FreedDiskSpace)> CompactCallback;
typedef std::function<uint64_t()> ClaimDiskReserveCallback;
- typedef std::function<void(size_t ChunkIndex, const void* Data, uint64_t Size)> IterateChunksSmallSizeCallback;
- typedef std::function<void(size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size)> IterateChunksLargeSizeCallback;
+ typedef std::function<bool(size_t ChunkIndex, const void* Data, uint64_t Size)> IterateChunksSmallSizeCallback;
+ typedef std::function<bool(size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size)> IterateChunksLargeSizeCallback;
typedef std::function<void(const BlockStoreLocation& Location)> WriteChunkCallback;
+ typedef std::function<bool(uint32_t BlockIndex, std::span<const size_t> ChunkIndexes)> IterateChunksCallback;
struct BlockUsageInfo
{
@@ -178,10 +178,12 @@ public:
const ReclaimCallback& ChangeCallback = [](const MovedChunksArray&, const ChunkIndexArray&) {},
const ClaimDiskReserveCallback& DiskReserveCallback = []() { return 0; });
- void IterateChunks(const std::vector<BlockStoreLocation>& ChunkLocations,
- const IterateChunksSmallSizeCallback& AsyncSmallSizeCallback,
- const IterateChunksLargeSizeCallback& AsyncLargeSizeCallback,
- WorkerThreadPool* OptionalWorkerPool);
+ bool IterateChunks(const std::span<const BlockStoreLocation>& ChunkLocations, const IterateChunksCallback& Callback);
+
+ bool IterateBlock(std::span<const BlockStoreLocation> ChunkLocations,
+ std::span<const size_t> ChunkIndexes,
+ const IterateChunksSmallSizeCallback& SmallSizeCallback,
+ const IterateChunksLargeSizeCallback& LargeSizeCallback);
void CompactBlocks(
const BlockStoreCompactState& CompactState,
@@ -190,14 +192,11 @@ public:
const ClaimDiskReserveCallback& DiskReserveCallback = []() { return 0; },
std::string_view LogPrefix = {});
- static const char* GetBlockFileExtension();
- static std::filesystem::path GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint32_t BlockIndex);
-
inline uint64_t TotalSize() const { return m_TotalSize.load(std::memory_order::relaxed); }
- Ref<BlockStoreFile> GetBlockFile(uint32_t BlockIndex);
-
private:
+ static const char* GetBlockFileExtension();
+ static std::filesystem::path GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint32_t BlockIndex);
uint32_t GetFreeBlockIndex(uint32_t StartProbeIndex, RwLock::ExclusiveLockScope&, std::filesystem::path& OutBlockPath) const;
std::unordered_map<uint32_t, Ref<BlockStoreFile>> m_ChunkBlocks;