aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-11-01 20:00:04 +0100
committerStefan Boberg <[email protected]>2021-11-01 20:00:04 +0100
commite64410bfcc85add1a5caa8309cde2aaa5e15baa0 (patch)
treea61a203c35179dd8175a9c5d0db3fcd5d2f725e6
parentprojectstore: Implemented project/oplog discovery so we can take any persiste... (diff)
downloadzen-e64410bfcc85add1a5caa8309cde2aaa5e15baa0.tar.xz
zen-e64410bfcc85add1a5caa8309cde2aaa5e15baa0.zip
cid: Added RemapCid() for use in GC
-rw-r--r--zenstore/cidstore.cpp17
-rw-r--r--zenstore/include/zenstore/cidstore.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp
index eaad0f5a8..c91f69ff7 100644
--- a/zenstore/cidstore.cpp
+++ b/zenstore/cidstore.cpp
@@ -73,6 +73,17 @@ struct CidStore::Impl
m_LogFile.Append({.Uncompressed = DecompressedId, .Compressed = CompressedHash});
}
+ IoHash RemapCid(const IoHash& DecompressedId)
+ {
+ RwLock::SharedLockScope _(m_Lock);
+ if (auto It = m_CidMap.find(DecompressedId); It != m_CidMap.end())
+ {
+ return It->second;
+ }
+
+ return IoHash::Zero;
+ }
+
IoBuffer FindChunkByCid(const IoHash& DecompressedId)
{
IoHash CompressedHash;
@@ -254,6 +265,12 @@ CidStore::FindChunkByCid(const IoHash& DecompressedId)
return m_Impl->FindChunkByCid(DecompressedId);
}
+IoHash
+CidStore::RemapCid(const IoHash& DecompressedId)
+{
+ return m_Impl->RemapCid(DecompressedId);
+}
+
bool
CidStore::ContainsChunk(const IoHash& DecompressedId)
{
diff --git a/zenstore/include/zenstore/cidstore.h b/zenstore/include/zenstore/cidstore.h
index acfedbc64..a69569bd2 100644
--- a/zenstore/include/zenstore/cidstore.h
+++ b/zenstore/include/zenstore/cidstore.h
@@ -57,6 +57,8 @@ public:
// TODO: add batch filter support
+ IoHash RemapCid(const IoHash& DecompressedId);
+
private:
struct Impl;
std::unique_ptr<Impl> m_Impl;