aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/projectstore/oplogreferencedset.h
blob: 297fd29d59fa2185d38877a11cb7385815ad9167 (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
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <zencore/uid.h>

#include <optional>
#include <string_view>
#include <unordered_set>

namespace zen {

class IoBuffer;

/**
 * @brief  Records which keys in the oplog (entry["op"]["key"]) are in the ReferencedSet reported by the client that uploaded the oplog.
 *
 * An oplog can contain ops from an earlier incremental cook result that are no longer referenced in the most recent cook;
 * the OplogReferencedSet allows clients that need to view only referenced-by-head-cook entries to trim the oplog down to
 * those entries.
 *
 * Keys are case-sensitive; client must ensure that capitalization matches between the ReferencedSet and the oplog keys.
 */
class OplogReferencedSet
{
public:
	void Emplace(Oid OplogId);
	bool Contains(Oid OplogId, std::string_view OplogKey);
	void Clear();

	static std::optional<OplogReferencedSet> LoadFromChunk(const IoBuffer& ChunkData);

	static constexpr std::string_view ReferencedSetOplogKey = "ReferencedSet";

private:
	std::unordered_set<Oid> Set;
};

}  // namespace zen