From d1c9573ef4b54e03b66a9507a57104591078d35b Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 5 Dec 2024 14:21:12 +0100 Subject: 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 --- src/zenstore/compactcas.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/zenstore/compactcas.cpp') 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 ChunkHashes, { ZEN_MEMSCOPE(GetCasContainerTag()); - const size_t ChunkCount = ChunkHashes.size(); - if (ChunkCount < 3) + const size_t ChunkCount = ChunkHashes.size(); + std::vector FoundChunkIndexes; + std::vector 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 FoundChunkIndexes; - std::vector 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 ChunkIndexes) { -- cgit v1.2.3