22 Path +
"[" + TableName +
"]: " + Msg);
30 "mismatched " + Label +
32 ", observed: " +
Twine(Observed) +
")");
40 if (Alloc.capacity() <
43 Path.str(),
"datafile",
44 "Allocator too small for header");
46 DatabaseFile DB(Alloc);
47 return NewDBConstructor(DB);
57 return DatabaseFile::get(
58 std::make_unique<MappedFileRegionArena>(std::move(Alloc)));
64 int64_t ExistingRootOffset = 0;
65 const int64_t NewOffset =
67 if (H->RootTableOffset.compare_exchange_strong(ExistingRootOffset, NewOffset))
71 if (ExistingRootOffset == NewOffset)
79 "collision with existing table of the same name '" + Table.
getName() +
83 "cannot add new table '" + Table.
getName() +
85 " to existing root '" +
90 int64_t RootTableOffset = H->RootTableOffset.load();
102 if (
Region.size() <
sizeof(Header))
104 "database: missing header");
107 auto *
H =
reinterpret_cast<Header *
>(
Region.data());
110 "database: bad magic");
113 "database: wrong version");
118 if (MFH->BumpPtr.load() < (int64_t)
sizeof(Header))
120 "database: corrupt bump-ptr");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares the common interface for a DatabaseFile that is used to implement OnDiskCAS.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
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...
static Expected< MappedFileRegionArena > create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref< Error(MappedFileRegionArena &)> NewFileConstructor)
Create a MappedFileRegionArena.
static Expected< DatabaseFile > create(const Twine &Path, uint64_t Capacity, function_ref< Error(DatabaseFile &)> NewDBConstructor)
Create the DatabaseFile at Path with Capacity.
std::optional< TableHandle > findTable(StringRef Name)
Find a table. May return null.
static constexpr uint32_t getVersion()
static constexpr uint32_t getMagic()
MappedFileRegion & getRegion()
Error addTable(TableHandle Table)
Add a table.
Generic handle for a table.
const Header & getHeader() const
StringRef getName() const
MappedFileRegion & getRegion() const
An efficient, type-erasing, non-owning reference to a callable.
LLVM_ABI char * data() const
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)
This is an optimization pass for GlobalISel generic memory operations.
std::error_code make_error_code(BitcodeError E)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.