16#ifndef LLVM_CAS_ONDISKGRAPHDB_H
17#define LLVM_CAS_ONDISKGRAPHDB_H
39 return InternalRef(
Offset.get());
43 return LHS.Data ==
RHS.Data;
63 return InternalRef4B(
Offset);
72 InternalRef4B(
uint32_t Data) : Data(Data) {}
79 size_t size()
const {
return Size; }
80 bool empty()
const {
return !Size; }
167 Begin = &PlaceHolder;
171 : Begin(Refs.
begin()), Size(Refs.
size()) {}
174 : Begin(Refs.
begin()), Size(Refs.
size()) {}
192 return LHS.Opaque ==
RHS.Opaque;
213 return LHS.Opaque ==
RHS.Opaque;
226 std::random_access_iterator_tag, ObjectID> {
310 auto Presence = getObjectPresence(
Ref, CheckUpstream);
316 case ObjectPresence::Missing:
318 case ObjectPresence::InPrimaryDB:
320 case ObjectPresence::OnlyInUpstreamDB:
368 LLVM_ABI std::unique_ptr<MemoryBuffer>
370 bool RequiresNullTerminator)
const;
428 std::shared_ptr<OnDiskCASLogger>
Logger =
nullptr,
437 enum class ObjectPresence {
445 bool CheckUpstream)
const;
458 enum class InternalUpstreamImportKind { Leaf, Leaf0 };
461 std::optional<InternalUpstreamImportKind> ImportKind);
474 static InternalRef getInternalRef(ObjectID
Ref) {
478 static ObjectID getExternalReference(InternalRef
Ref) {
482 static ObjectID getExternalReference(
const IndexProxy &
I);
484 static InternalRef makeInternalRef(FileOffset IndexOffset);
490 Expected<IndexProxy> getIndexProxyFromRef(InternalRef
Ref)
const;
493 getIndexProxyFromPointer(OnDiskTrieRawHashMap::ConstOnDiskPtr
P)
const;
495 LLVM_ABI InternalRefArrayRef getInternalRefs(ObjectHandle Node)
const;
500 std::atomic<uint64_t> &standaloneStorageSize()
const;
503 void recordStandaloneSizeIncrease(
size_t SizeIncrease);
505 uint64_t getStandaloneStorageSize()
const;
508 OnDiskGraphDB(StringRef RootPath, OnDiskTrieRawHashMap Index,
509 OnDiskDataAllocator DataPool, OnDiskGraphDB *UpstreamDB,
510 FaultInPolicy Policy, std::shared_ptr<OnDiskCASLogger> Logger);
515 OnDiskTrieRawHashMap Index;
520 OnDiskDataAllocator DataPool;
523 void *StandaloneData =
nullptr;
526 std::string RootPath;
529 OnDiskGraphDB *UpstreamDB =
nullptr;
535 std::shared_ptr<OnDiskCASLogger> Logger;
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 OnDiskCASLogger, an interface that can be used to log CAS events to ...
This file declares interface for OnDiskDataAllocator, a file backed data pool can be used to allocate...
static void getStandalonePath(StringRef RootPath, StringRef Prefix, FileOffset IndexOffset, SmallVectorImpl< char > &Path)
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.
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.
Logging utility - given an ordered specification of features, and assuming a scalar reward,...
This interface provides simple read-only access to a block of memory, and provides simple methods for...
A discriminated union of two or more pointer types, with the discriminator in the low bits of the poi...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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...
Handle to a loaded object in a ObjectStore instance.
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 LLVM_ABI ObjectHandle fromFileOffset(FileOffset Offset)
static LLVM_ABI 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.
LLVM_ABI void print(raw_ostream &OS) const
LLVM_ABI Error validateObjectID(ObjectID ID) const
Checks that ID exists in the index.
LLVM_ABI std::unique_ptr< MemoryBuffer > getStandaloneMemoryBuffer(ObjectHandle Node, StringRef Name, bool RequiresNullTerminator) const
Get a MemoryBuffer for Node's data that stays valid after this database is destroyed.
LLVM_ABI Expected< bool > isMaterialized(ObjectID Ref)
Check whether the object associated with Ref is stored in the CAS.
LLVM_ABI Error validate(bool Deep, HashingFuncT Hasher) const
Validate the OnDiskGraphDB.
object_refs_range getObjectRefs(ObjectHandle Node) const
LLVM_ABI unsigned getHardStorageLimitUtilization() const
LLVM_ABI 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
LLVM_ABI FileBackedData getInternalFileBackedObjectData(ObjectHandle Node) const
Provides access to the underlying file path, that represents an object leaf node, when available.
LLVM_ABI Error storeFile(ObjectID ID, StringRef FilePath)
Associates the data of a file with a particular object ID.
LLVM_ABI size_t getStorageSize() const
static LLVM_ABI Expected< std::unique_ptr< OnDiskGraphDB > > open(StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB=nullptr, std::shared_ptr< OnDiskCASLogger > Logger=nullptr, FaultInPolicy Policy=FaultInPolicy::FullTree)
Open the on-disk store from a directory.
bool containsObject(ObjectID Ref, bool CheckUpstream=true) const
Check whether the object associated with Ref is stored in the CAS.
LLVM_ABI ~OnDiskGraphDB()
LLVM_ABI 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.
LLVM_ABI ArrayRef< char > getObjectData(ObjectHandle Node) const
LLVM_ABI std::optional< ObjectID > getExistingReference(ArrayRef< uint8_t > Digest, bool CheckUpstream=true)
Get an existing reference to the object Digest.
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.
llvm::iterator_range< object_refs_iterator > object_refs_range
This is an optimization pass for GlobalISel generic memory operations.
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.
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.
std::string FilePath
The file path of the object node.
bool IsFileNulTerminated
Whether the file of the object leaf node has an extra nul appended at the end.
Encapsulates file info for an underlying object node.
std::optional< FileInfoTy > FileInfo
File information for the object, if available.
ArrayRef< char > Data
The data of the object node.