diff options
| author | Stefan Boberg <[email protected]> | 2021-05-24 19:26:40 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-24 19:26:40 +0200 |
| commit | e70e2b4453a27d9d1caf77224ffd6335c50981fb (patch) | |
| tree | 05d469aa1c3ab6c1840fd4732696c708d1a2a07d /zenstore | |
| parent | Validate payloads using embedded CompressedBuffer hash (diff) | |
| download | zen-e70e2b4453a27d9d1caf77224ffd6335c50981fb.tar.xz zen-e70e2b4453a27d9d1caf77224ffd6335c50981fb.zip | |
Added CidStore, currently used to track relationships between compressed and uncompressed chunk hashes
This first implementation is in-memory only, persistence is next
Diffstat (limited to 'zenstore')
| -rw-r--r-- | zenstore/cidstore.cpp | 33 | ||||
| -rw-r--r-- | zenstore/include/zenstore/cidstore.h | 34 | ||||
| -rw-r--r-- | zenstore/zenstore.vcxproj | 2 | ||||
| -rw-r--r-- | zenstore/zenstore.vcxproj.filters | 2 |
4 files changed, 71 insertions, 0 deletions
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp new file mode 100644 index 000000000..6e558e639 --- /dev/null +++ b/zenstore/cidstore.cpp @@ -0,0 +1,33 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "zenstore/cidstore.h" +#include "zenstore/CAS.h" + +namespace zen { + +CidStore::CidStore(CasStore& InCasStore) : m_CasStore(InCasStore) +{ +} + +CidStore::~CidStore() +{ +} + +void +CidStore::AddCompressedCid(const IoHash& DecompressedId, const IoHash& Compressed) +{ + m_CidMap.insert_or_assign(DecompressedId, Compressed); +} + +IoBuffer +CidStore::FindChunkByCid(const IoHash& DecompressedId) +{ + if (auto It = m_CidMap.find(DecompressedId); It != m_CidMap.end()) + { + return m_CasStore.FindChunk(It->second); + } + + return IoBuffer(); +} + +} // namespace zen diff --git a/zenstore/include/zenstore/cidstore.h b/zenstore/include/zenstore/cidstore.h new file mode 100644 index 000000000..0c8f51740 --- /dev/null +++ b/zenstore/include/zenstore/cidstore.h @@ -0,0 +1,34 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <tsl/robin_map.h> +#include <zencore/iohash.h> + +namespace zen { + +class CasStore; +class IoBuffer; + +/** Content Store + * + * Data in the content store is referenced by content identifiers (CIDs), rather than their + * literal hash. This is required to map uncompressed hashes to compressed hashes and may + * be used to deal with other indirections in the future. + * + */ +class CidStore +{ +public: + CidStore(CasStore& InCasStore); + ~CidStore(); + + void AddCompressedCid(const IoHash& DecompressedId, const IoHash& Compressed); + IoBuffer FindChunkByCid(const IoHash& DecompressedId); + +private: + CasStore& m_CasStore; + tsl::robin_map<IoHash, IoHash, IoHash::Hasher> m_CidMap; +}; + +} // namespace zen diff --git a/zenstore/zenstore.vcxproj b/zenstore/zenstore.vcxproj index 5384bf3eb..0e4caa92c 100644 --- a/zenstore/zenstore.vcxproj +++ b/zenstore/zenstore.vcxproj @@ -14,6 +14,7 @@ <ClCompile Include="basicfile.cpp" /> <ClCompile Include="CAS.cpp" /> <ClCompile Include="caslog.cpp" /> + <ClCompile Include="cidstore.cpp" /> <ClCompile Include="compactcas.cpp" /> <ClCompile Include="filecas.cpp" /> <ClCompile Include="gc.cpp" /> @@ -23,6 +24,7 @@ <ClInclude Include="compactcas.h" /> <ClInclude Include="filecas.h" /> <ClInclude Include="include\zenstore\basicfile.h" /> + <ClInclude Include="include\zenstore\cidstore.h" /> <ClInclude Include="include\zenstore\gc.h" /> <ClInclude Include="include\zenstore\scrub.h" /> <ClInclude Include="include\zenstore\CAS.h" /> diff --git a/zenstore/zenstore.vcxproj.filters b/zenstore/zenstore.vcxproj.filters index 8f08ca6cf..3dfb89dbf 100644 --- a/zenstore/zenstore.vcxproj.filters +++ b/zenstore/zenstore.vcxproj.filters @@ -8,6 +8,7 @@ <ClCompile Include="gc.cpp" /> <ClCompile Include="scrub.cpp" /> <ClCompile Include="basicfile.cpp" /> + <ClCompile Include="cidstore.cpp" /> </ItemGroup> <ItemGroup> <ClInclude Include="compactcas.h" /> @@ -17,5 +18,6 @@ <ClInclude Include="include\zenstore\gc.h" /> <ClInclude Include="include\zenstore\scrub.h" /> <ClInclude Include="include\zenstore\basicfile.h" /> + <ClInclude Include="include\zenstore\cidstore.h" /> </ItemGroup> </Project>
\ No newline at end of file |