blob: 47b6e63cc71a98894cf93b018e57bfade4ca17e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <zencore/iobuffer.h>
#include <zencore/iohash.h>
#include <zenstore/cidstore.h>
#include <zenstore/hashkeyset.h>
#include <memory>
namespace zen {
class GcManager;
class ScrubContext;
/** CAS storage interface
This uses the hash of the stored data (after decompression) as the key
*/
class CasStore
{
public:
virtual ~CasStore() = default;
inline const CidStoreConfiguration& Config() { return m_Config; }
struct InsertResult
{
bool New = false;
};
enum class InsertMode
{
kCopyOnly,
kMayBeMovedInPlace
};
virtual void Initialize(const CidStoreConfiguration& Config) = 0;
virtual InsertResult InsertChunk(IoBuffer Data, const IoHash& ChunkHash, InsertMode Mode = InsertMode::kMayBeMovedInPlace) = 0;
virtual std::vector<InsertResult> InsertChunks(std::span<IoBuffer> Data,
std::span<IoHash> ChunkHashes,
InsertMode Mode = InsertMode::kMayBeMovedInPlace) = 0;
virtual IoBuffer FindChunk(const IoHash& ChunkHash) = 0;
virtual bool ContainsChunk(const IoHash& ChunkHash) = 0;
virtual void FilterChunks(HashKeySet& InOutChunks) = 0;
virtual bool IterateChunks(std::span<IoHash> DecompressedIds,
const std::function<bool(size_t Index, const IoBuffer& Payload)>& AsyncCallback,
WorkerThreadPool* OptionalWorkerPool,
uint64_t LargeSizeLimit) = 0;
virtual void Flush() = 0;
virtual CidStoreSize TotalSize() const = 0;
#if ZEN_WITH_TESTS
virtual void Scrub(ScrubContext& Ctx) = 0;
#endif // ZEN_WITH_TESTS
protected:
CidStoreConfiguration m_Config;
};
std::unique_ptr<CasStore> CreateCasStore(GcManager& Gc);
void CAS_forcelink();
} // namespace zen
|