15#ifndef LLVM_LIB_CAS_DATABASEFILE_H
16#define LLVM_LIB_CAS_DATABASEFILE_H
45 explicit operator bool()
const {
return H; }
49 template <
class T>
static void check() {
51 std::is_same<
decltype(T::Header::GenericHeader),
Header>::value,
52 "T::GenericHeader should be of type TableHandle::Header");
53 static_assert(
offsetof(
typename T::Header, GenericHeader) == 0,
54 "T::GenericHeader must be the head of T::Header");
56 template <
class T>
bool is()
const {
return T::Kind == H->Kind; }
60 return T(*Region, *
reinterpret_cast<typename T::Header *
>(H));
63 template <
class T>
T cast()
const {
69 auto *Begin =
reinterpret_cast<const char *
>(H) + H->NameRelOffset;
77 *reinterpret_cast<
Header *>(Region.
data() + HeaderOffset)) {
120 std::shared_ptr<OnDiskCASLogger>
Logger,
123 size_t size()
const {
return Alloc.size(); }
127 get(std::unique_ptr<MappedFileRegionArena>
Alloc) {
137 DatabaseFile(std::unique_ptr<MappedFileRegionArena>
Alloc)
138 : DatabaseFile(*
Alloc) {
139 OwnedAlloc = std::move(
Alloc);
143 MappedFileRegionArena &
Alloc;
144 std::unique_ptr<MappedFileRegionArena> OwnedAlloc;
148 StringRef TableName,
const Twine &Msg);
151 StringRef Path, StringRef TrieName);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Prepare AGPR Alloc
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define offsetof(TYPE, MEMBER)
This file declares interface for MappedFileRegionArena, a bump pointer allocator, backed by a memory-...
This file declares interface for OnDiskCASLogger, an interface that can be used to log CAS events to ...
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,...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Allocator for an owned mapped file region that supports thread-safe and process-safe bump pointer all...
sys::fs::mapped_file_region RegionT
Encapsulate a database file, which:
std::optional< TableHandle > findTable(StringRef Name)
Find a table. May return null.
static constexpr uint32_t getVersion()
MappedFileRegionArena & getAlloc()
static constexpr uint32_t getMagic()
MappedFileRegion & getRegion()
const Header & getHeader()
Error addTable(TableHandle Table)
Add a table.
static Expected< DatabaseFile > create(const Twine &Path, uint64_t Capacity, std::shared_ptr< OnDiskCASLogger > Logger, function_ref< Error(DatabaseFile &)> NewDBConstructor)
Create the DatabaseFile at Path with Capacity.
Generic handle for a table.
TableHandle(MappedFileRegion &Region, Header &H)
const Header & getHeader() const
StringRef getName() const
MappedFileRegion & getRegion() const
TableHandle(MappedFileRegion &Region, intptr_t HeaderOffset)
An efficient, type-erasing, non-owning reference to a callable.
Error createTableConfigError(std::errc ErrC, StringRef Path, StringRef TableName, const Twine &Msg)
MappedFileRegionArena::RegionT MappedFileRegion
Error checkTable(StringRef Label, size_t Expected, size_t Observed, StringRef Path, StringRef TrieName)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
int32_t NameRelOffset
Relative to Header.