16#ifndef LLVM_CAS_ONDISKGRAPHDB_H
17#define LLVM_CAS_ONDISKGRAPHDB_H
33 return InternalRef(
Offset.get());
37 return LHS.Data ==
RHS.Data;
57 return InternalRef4B(
Offset);
66 InternalRef4B(
uint32_t Data) : Data(Data) {}
73 size_t size()
const {
return Size; }
74 bool empty()
const {
return !Size; }
161 Begin = &PlaceHolder;
165 : Begin(Refs.
begin()), Size(Refs.
size()) {}
168 : Begin(Refs.
begin()), Size(Refs.
size()) {}
186 return LHS.Opaque ==
RHS.Opaque;
207 return LHS.Opaque ==
RHS.Opaque;
220 std::random_access_iterator_tag, ObjectID> {
361 enum class ObjectPresence {
369 bool CheckUpstream)
const;
373 auto Presence = getObjectPresence(
Ref, CheckUpstream);
379 case ObjectPresence::Missing:
381 case ObjectPresence::InPrimaryDB:
383 case ObjectPresence::OnlyInUpstreamDB:
391 Expected<std::optional<ObjectHandle>> faultInFromUpstream(ObjectID PrimaryID);
394 Error importFullTree(ObjectID PrimaryID, ObjectHandle UpstreamNode);
396 Error importSingleNode(ObjectID PrimaryID, ObjectHandle UpstreamNode);
399 Expected<IndexProxy> indexHash(ArrayRef<uint8_t> Hash);
402 void getStandalonePath(StringRef FileSuffix,
const IndexProxy &
I,
403 SmallVectorImpl<char> &Path)
const;
409 static InternalRef getInternalRef(ObjectID
Ref) {
413 static ObjectID getExternalReference(InternalRef
Ref) {
417 static ObjectID getExternalReference(
const IndexProxy &
I);
419 static InternalRef makeInternalRef(FileOffset IndexOffset);
421 Expected<ArrayRef<uint8_t>>
getDigest(InternalRef
Ref)
const;
425 Expected<IndexProxy> getIndexProxyFromRef(InternalRef
Ref)
const;
428 getIndexProxyFromPointer(OnDiskTrieRawHashMap::ConstOnDiskPtr
P)
const;
430 InternalRefArrayRef getInternalRefs(ObjectHandle Node)
const;
435 std::atomic<uint64_t> &standaloneStorageSize()
const;
438 void recordStandaloneSizeIncrease(
size_t SizeIncrease);
440 uint64_t getStandaloneStorageSize()
const;
443 OnDiskGraphDB(StringRef RootPath, OnDiskTrieRawHashMap Index,
444 OnDiskDataAllocator DataPool, OnDiskGraphDB *UpstreamDB,
450 OnDiskTrieRawHashMap Index;
455 OnDiskDataAllocator DataPool;
458 void *StandaloneData =
nullptr;
461 std::string RootPath;
464 OnDiskGraphDB *UpstreamDB =
nullptr;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file declares interface for OnDiskDataAllocator, a file backed data pool can be used to allocate...
This file declares interface for OnDiskTrieRawHashMap, a thread-safe and (mostly) lock-free hash map ...
This file defines the PointerUnion class, which is a discriminated union of pointer types.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
FileOffset is a wrapper around uint64_t to represent the offset of data from the beginning of the fil...
Compact 4 byte reference inside OnDiskGraphDB for smaller references.
FileOffset getFileOffset() const
uint32_t getRawData() const
static std::optional< InternalRef4B > tryToShrink(InternalRef Ref)
Shrink to 4B reference.
ptrdiff_t operator-(const iterator &RHS) const
InternalRef operator[](ptrdiff_t N) const
InternalRef operator*() const
friend class InternalRefArrayRef
bool operator==(const iterator &RHS) const
iterator & operator+=(ptrdiff_t N)
uint64_t getOpaqueData() const
iterator & operator-=(ptrdiff_t N)
static iterator fromOpaqueData(uint64_t Opaque)
bool operator<(const iterator &RHS) const
Array of internal node references.
InternalRef operator[](ptrdiff_t N) const
Array accessor.
ArrayRef< uint8_t > getBuffer() const
InternalRefArrayRef(std::nullopt_t=std::nullopt)
InternalRefArrayRef(ArrayRef< InternalRef4B > Refs)
bool operator==(const InternalRefArrayRef &RHS) const
InternalRefArrayRef(ArrayRef< InternalRef > Refs)
Standard 8 byte reference inside OnDiskGraphDB.
uint64_t getRawData() const
friend bool operator==(InternalRef LHS, InternalRef RHS)
FileOffset getFileOffset() const
static InternalRef getFromRawData(uint64_t Data)
static InternalRef getFromOffset(FileOffset Offset)
Handle for a loaded node object.
uint64_t getOpaqueData() const
static ObjectHandle fromFileOffset(FileOffset Offset)
static ObjectHandle fromMemory(uintptr_t Ptr)
ObjectHandle(uint64_t Opaque)
friend bool operator!=(const ObjectHandle &LHS, const ObjectHandle &RHS)
friend bool operator==(const ObjectHandle &LHS, const ObjectHandle &RHS)
friend bool operator!=(const ObjectID &LHS, const ObjectID &RHS)
uint64_t getOpaqueData() const
friend bool operator==(const ObjectID &LHS, const ObjectID &RHS)
static ObjectID fromOpaqueData(uint64_t Opaque)
On-disk CAS nodes database, independent of a particular hashing algorithm.
FaultInPolicy
How to fault-in nodes if an upstream database is used.
@ FullTree
Copy the the entire graph of a node.
@ SingleNode
Copy only the requested node.
void print(raw_ostream &OS) const
Expected< bool > isMaterialized(ObjectID Ref)
Check whether the object associated with Ref is stored in the CAS.
Error validate(bool Deep, HashingFuncT Hasher) const
Validate the OnDiskGraphDB.
bool containsObject(ObjectID Ref) const
Check whether the object associated with Ref is stored in the CAS.
object_refs_range getObjectRefs(ObjectHandle Node) const
unsigned getHardStorageLimitUtilization() const
Error store(ObjectID ID, ArrayRef< ObjectID > Refs, ArrayRef< char > Data)
Associate data & references with a particular object ID.
ArrayRef< uint8_t > getDigest(ObjectID Ref) const
static Expected< std::unique_ptr< OnDiskGraphDB > > open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB=nullptr, FaultInPolicy Policy=FaultInPolicy::FullTree)
Open the on-disk store from a directory.
std::optional< ObjectID > getExistingReference(ArrayRef< uint8_t > Digest)
Get an existing reference to the object Digest.
size_t getStorageSize() const
Expected< ObjectID > getReference(ArrayRef< uint8_t > Hash)
Form a reference for the provided hash.
function_ref< void( ArrayRef< ArrayRef< uint8_t > >, ArrayRef< char >, SmallVectorImpl< uint8_t > &)> HashingFuncT
Hashing function type for validation.
ArrayRef< char > getObjectData(ObjectHandle Node) const
object_refs_iterator & operator-=(ptrdiff_t N)
bool operator<(const object_refs_iterator &RHS) const
object_refs_iterator & operator+=(ptrdiff_t N)
ptrdiff_t operator-(const object_refs_iterator &RHS) const
uint64_t getOpaqueData() const
bool operator==(const object_refs_iterator &RHS) const
ObjectID operator[](ptrdiff_t N) const
ObjectID operator*() const
object_refs_iterator()=default
static object_refs_iterator fromOpaqueData(uint64_t Opaque)
object_refs_iterator(InternalRefArrayRef::iterator I)
An efficient, type-erasing, non-owning reference to a callable.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
iterator operator+(std::ptrdiff_t n) const
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
llvm::iterator_range< object_refs_iterator > object_refs_range
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Ref
The access may reference the value stored in memory.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void consumeError(Error Err)
Consume a Error without doing anything.
Proxy for an on-disk index record.