diff options
| author | Per Larsson <[email protected]> | 2022-11-23 14:09:30 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-11-23 14:09:30 +0100 |
| commit | ef9856d2d9c7ed73fa0440b8267c1767abc5585d (patch) | |
| tree | 1059a19901c7d8c91f64ee7830c2ae31e27edccc /zenserver/projectstore.h | |
| parent | 0.1.9-pre3 (diff) | |
| download | zen-ef9856d2d9c7ed73fa0440b8267c1767abc5585d.tar.xz zen-ef9856d2d9c7ed73fa0440b8267c1767abc5585d.zip | |
Map DDC cache key to content ID.
Diffstat (limited to 'zenserver/projectstore.h')
| -rw-r--r-- | zenserver/projectstore.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/zenserver/projectstore.h b/zenserver/projectstore.h index c62e7840d..94bfe5f03 100644 --- a/zenserver/projectstore.h +++ b/zenserver/projectstore.h @@ -21,6 +21,7 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { class CbPackage; +class ZenCacheStore; struct OplogEntry { @@ -63,14 +64,14 @@ class ProjectStore : public RefCounted, public GcStorage, public GcContributor struct OplogStorage; public: - ProjectStore(CidStore& Store, std::filesystem::path BasePath, GcManager& Gc); + ProjectStore(CidStore& Store, ZenCacheStore& CacheStore, std::filesystem::path BasePath, GcManager& Gc); ~ProjectStore(); struct Project; struct Oplog { - Oplog(std::string_view Id, Project* Project, CidStore& Store, std::filesystem::path BasePath); + Oplog(std::string_view Id, Project* Project, CidStore& CidStore, ZenCacheStore& CacheStore, std::filesystem::path BasePath); ~Oplog(); [[nodiscard]] static bool ExistsAt(std::filesystem::path BasePath); @@ -134,11 +135,21 @@ public: std::string ClientPath; }; + struct DerivedDataEntry + { + std::string Namespace; + std::string Bucket; + IoHash Hash; + IoHash Cid; + Oid ValueId; + }; + template<class V> using OidMap = tsl::robin_map<Oid, V, Oid::Hasher>; Project* m_OuterProject = nullptr; CidStore& m_CidStore; + ZenCacheStore& m_CacheStore; std::filesystem::path m_BasePath; std::filesystem::path m_TempPath; @@ -146,6 +157,7 @@ public: OidMap<IoHash> m_ChunkMap; // output data chunk id -> CAS address OidMap<IoHash> m_MetaMap; // meta chunk id -> CAS address OidMap<FileMapEntry> m_FileMap; // file id -> file map entry + OidMap<DerivedDataEntry> m_DerivedDataMap; // chunk id -> CAS address int32_t m_ManifestVersion; // File system manifest version std::map<int, OplogEntryAddress> m_OpAddressMap; // Index LSN -> op data in ops blob file OidMap<int> m_LatestOpMap; // op key -> latest op LSN for key @@ -160,6 +172,12 @@ public: std::string_view ClientPath); void AddChunkMapping(const RwLock::ExclusiveLockScope& OplogLock, Oid ChunkId, IoHash Hash); void AddMetaMapping(const RwLock::ExclusiveLockScope& OplogLock, Oid ChunkId, IoHash Hash); + bool AddDerivedDataMapping(const RwLock::ExclusiveLockScope& OplogLock, + std::string_view Namespace, + std::string_view KeyBucket, + const IoHash& KeyHash, + const Oid& ValueId, + const Oid& ChunkId); }; struct Project : public RefCounted @@ -178,7 +196,7 @@ public: std::vector<std::string> ScanForOplogs() const; bool IsExpired() const; - Project(ProjectStore* PrjStore, CidStore& Store, std::filesystem::path BasePath); + Project(ProjectStore* PrjStore, CidStore& CidStore, ZenCacheStore& CacheStore, std::filesystem::path BasePath); virtual ~Project(); void Read(); @@ -193,6 +211,7 @@ public: private: ProjectStore* m_ProjectStore; CidStore& m_CidStore; + ZenCacheStore& m_CacheStore; mutable RwLock m_ProjectLock; std::map<std::string, std::unique_ptr<Oplog>> m_Oplogs; std::vector<std::unique_ptr<Oplog>> m_DeletedOplogs; @@ -245,6 +264,7 @@ public: private: spdlog::logger& m_Log; CidStore& m_CidStore; + ZenCacheStore& m_CacheStore; std::filesystem::path m_ProjectBasePath; RwLock m_ProjectsLock; std::map<std::string, Ref<Project>> m_Projects; |