diff options
| author | Dan Engelbrecht <[email protected]> | 2024-12-05 14:21:12 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-12-05 14:21:12 +0100 |
| commit | d1c9573ef4b54e03b66a9507a57104591078d35b (patch) | |
| tree | 38dbcbe99a5b76d322d1634014bc390e75b01c20 /src/zenstore/compactcas.cpp | |
| parent | Unity build fixes (#253) (diff) | |
| download | zen-d1c9573ef4b54e03b66a9507a57104591078d35b.tar.xz zen-d1c9573ef4b54e03b66a9507a57104591078d35b.zip | |
projectstore getchunks rpc with modtag (#244)
Feature: Project store "getchunks" rpc call /prj/{project}/oplog/{log}/rpc extended to accept both CAS (RawHash) and Id (Oid) identifiers as well as partial ranges
Diffstat (limited to 'src/zenstore/compactcas.cpp')
| -rw-r--r-- | src/zenstore/compactcas.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 9aa4ff613..50af7246e 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -329,31 +329,33 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes, { ZEN_MEMSCOPE(GetCasContainerTag()); - const size_t ChunkCount = ChunkHashes.size(); - if (ChunkCount < 3) + const size_t ChunkCount = ChunkHashes.size(); + std::vector<size_t> FoundChunkIndexes; + std::vector<BlockStoreLocation> FoundChunkLocations; + FoundChunkIndexes.reserve(ChunkCount); + FoundChunkLocations.reserve(ChunkCount); { + RwLock::SharedLockScope _(m_LocationMapLock); for (size_t ChunkIndex = 0; ChunkIndex < ChunkCount; ChunkIndex++) { - IoBuffer Chunk = FindChunk(ChunkHashes[ChunkIndex]); - if (!AsyncCallback(ChunkIndex, Chunk)) + if (auto KeyIt = m_LocationMap.find(ChunkHashes[ChunkIndex]); KeyIt != m_LocationMap.end()) { - return false; + FoundChunkIndexes.push_back(ChunkIndex); + FoundChunkLocations.push_back(m_Locations[KeyIt->second].Get(m_PayloadAlignment)); } } - return true; } - std::vector<size_t> FoundChunkIndexes; - std::vector<BlockStoreLocation> FoundChunkLocations; - FoundChunkIndexes.reserve(ChunkCount); - FoundChunkLocations.reserve(ChunkCount); - RwLock::SharedLockScope _(m_LocationMapLock); - for (size_t ChunkIndex = 0; ChunkIndex < ChunkCount; ChunkIndex++) + if (FoundChunkLocations.size() < 3) { - if (auto KeyIt = m_LocationMap.find(ChunkHashes[ChunkIndex]); KeyIt != m_LocationMap.end()) + for (size_t ChunkIndex : FoundChunkIndexes) { - FoundChunkIndexes.push_back(ChunkIndex); - FoundChunkLocations.push_back(m_Locations[KeyIt->second].Get(m_PayloadAlignment)); + IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); + if (!AsyncCallback(ChunkIndex, Chunk)) + { + return false; + } } + return true; } auto DoOneBlock = [&](std::span<const size_t> ChunkIndexes) { |