diff options
| author | Dan Engelbrecht <[email protected]> | 2024-04-24 13:53:54 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-04-24 13:53:54 +0200 |
| commit | 1c0ddc112a6c18d411f1f3ae6d236ecc2bedcfaa (patch) | |
| tree | cfafeecb830a44a6d0870a217edabcc62d37669c /src/zenstore/filecas.cpp | |
| parent | remove obsolete code (diff) | |
| download | zen-1c0ddc112a6c18d411f1f3ae6d236ecc2bedcfaa.tar.xz zen-1c0ddc112a6c18d411f1f3ae6d236ecc2bedcfaa.zip | |
iterate cas chunks (#59)
- Improvement: Reworked GetChunkInfos in oplog store to reduce disk thrashing and improve performance
Diffstat (limited to 'src/zenstore/filecas.cpp')
| -rw-r--r-- | src/zenstore/filecas.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp index 7fbc2b9ad..88d64eb45 100644 --- a/src/zenstore/filecas.cpp +++ b/src/zenstore/filecas.cpp @@ -809,6 +809,37 @@ FileCasStrategy::FilterChunks(HashKeySet& InOutChunks) InOutChunks.RemoveHashesIf([&](const IoHash& Hash) { return HaveChunk(Hash); }); } +bool +FileCasStrategy::IterateChunks(std::span<IoHash> ChunkHashes, const std::function<bool(size_t Index, const IoBuffer& Payload)>& Callback) +{ + std::vector<size_t> FoundChunkIndexes; + { + RwLock::SharedLockScope _(m_Lock); + for (size_t ChunkIndex = 0; ChunkIndex < ChunkHashes.size(); ChunkIndex++) + { + if (auto KeyIt = m_Index.find(ChunkHashes[ChunkIndex]); KeyIt != m_Index.end()) + { + FoundChunkIndexes.push_back(ChunkIndex); + } + } + } + bool Continue = true; + for (size_t ChunkIndex : FoundChunkIndexes) + { + ShardingHelper Name(m_RootDirectory.c_str(), ChunkHashes[ChunkIndex]); + IoBuffer Payload = IoBufferBuilder::MakeFromFile(Name.ShardedPath.c_str()); + if (Payload) + { + Continue = Callback(ChunkIndex, std::move(Payload)); + if (!Continue) + { + break; + } + } + } + return Continue; +} + void FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&& Payload)>&& Callback) { |