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

#pragma once

#include <zencore/uid.h>

#include <optional>
#include <string_view>

ZEN_THIRD_PARTY_INCLUDES_START
#include <tsl/robin_set.h>
ZEN_THIRD_PARTY_INCLUDES_END

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:
	inline bool		   Contains(const Oid& OplogId) const { return Set.contains(OplogId); }
	static inline bool IsNonPackage(std::string_view OplogKey)
	{
		// A referencedset always includes all non-package keys
		return OplogKey.empty() || !OplogKey.starts_with('/');
	}
	void Clear();

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

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

private:
	tsl::robin_set<Oid, Oid::Hasher> Set;
};

}  // namespace zen