aboutsummaryrefslogtreecommitdiff
path: root/zenstore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-21 21:13:13 +0200
committerStefan Boberg <[email protected]>2021-10-21 21:13:13 +0200
commitcb1a2f52e37d9d92a908a8761a7f69d6d33cc4b1 (patch)
treea96e89cfc076d8e8a2f1ceca5d3985cdd3ba0c37 /zenstore/include
parentRemoved accidentally committed test code (diff)
downloadzen-cb1a2f52e37d9d92a908a8761a7f69d6d33cc4b1.tar.xz
zen-cb1a2f52e37d9d92a908a8761a7f69d6d33cc4b1.zip
filecas: Added commit log, chunk gc
Diffstat (limited to 'zenstore/include')
-rw-r--r--zenstore/include/zenstore/CAS.h12
-rw-r--r--zenstore/include/zenstore/caslog.h3
-rw-r--r--zenstore/include/zenstore/gc.h3
3 files changed, 17 insertions, 1 deletions
diff --git a/zenstore/include/zenstore/CAS.h b/zenstore/include/zenstore/CAS.h
index a387b905e..5b508baa0 100644
--- a/zenstore/include/zenstore/CAS.h
+++ b/zenstore/include/zenstore/CAS.h
@@ -11,6 +11,7 @@
#include <zencore/timer.h>
#include <atomic>
+#include <concepts>
#include <filesystem>
#include <functional>
#include <memory>
@@ -48,6 +49,17 @@ public:
inline [[nodiscard]] bool IsEmpty() const { return m_ChunkSet.empty(); }
inline [[nodiscard]] size_t GetSize() const { return m_ChunkSet.size(); }
+ inline void FilterChunks(std::span<const IoHash> Candidates, std::invocable<const IoHash&> auto MatchFunc)
+ {
+ for (const IoHash& Candidate : Candidates)
+ {
+ if (ContainsChunk(Candidate))
+ {
+ MatchFunc(Candidate);
+ }
+ }
+ }
+
private:
// Q: should we protect this with a lock, or is that a higher level concern?
std::unordered_set<IoHash> m_ChunkSet;
diff --git a/zenstore/include/zenstore/caslog.h b/zenstore/include/zenstore/caslog.h
index 00b987383..065a74b25 100644
--- a/zenstore/include/zenstore/caslog.h
+++ b/zenstore/include/zenstore/caslog.h
@@ -57,6 +57,8 @@ template<typename T>
class TCasLogFile : public CasLogFile
{
public:
+ void Open(std::filesystem::path FileName, bool IsCreate) { CasLogFile::Open(FileName, sizeof(T), IsCreate); }
+
// This should be called before the Replay() is called to do some basic sanity checking
bool Initialize() { return true; }
@@ -76,7 +78,6 @@ public:
CasLogFile::Append(&Record, sizeof Record);
}
- void Open(std::filesystem::path FileName, bool IsCreate) { CasLogFile::Open(FileName, sizeof(T), IsCreate); }
};
} // namespace zen
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index d51925a0c..ef62158ce 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -27,6 +27,9 @@ public:
void ContributeCids(std::span<const IoHash> Cid);
void ContributeCas(std::span<const IoHash> Hash);
+ void FilterCids(std::span<const IoHash> Cid, std::function<void(const IoHash&)> KeepFunc);
+ void FilterCas(std::span<const IoHash> Cas, std::function<void(const IoHash&)> KeepFunc);
+
private:
struct GcState;