LLVM 22.0.0git
llvm::cas::ondisk::DatabaseFile Class Reference

Encapsulate a database file, which: More...

#include "CAS/DatabaseFile.h"

Classes

struct  Header

Public Member Functions

const HeadergetHeader ()
MappedFileRegionArenagetAlloc ()
MappedFileRegiongetRegion ()
Error addTable (TableHandle Table)
 Add a table.
std::optional< TableHandlefindTable (StringRef Name)
 Find a table. May return null.
size_t size () const

Static Public Member Functions

static constexpr uint32_t getMagic ()
static constexpr uint32_t getVersion ()
static Expected< DatabaseFilecreate (const Twine &Path, uint64_t Capacity, function_ref< Error(DatabaseFile &)> NewDBConstructor)
 Create the DatabaseFile at Path with Capacity.

Detailed Description

Encapsulate a database file, which:

  • Sets/checks magic.
  • Sets/checks version.
  • Points at an arbitrary root table.
  • Sets up a MappedFileRegionArena for allocation.

Top-level layout:

  • 4-bytes: Magic
  • 4-bytes: Version
  • 8-bytes: RootTableOffset (16-bits: Kind; 48-bits: Offset)
  • 8-bytes: BumpPtr from MappedFileRegionArena

Definition at line 95 of file DatabaseFile.h.

Member Function Documentation

◆ addTable()

◆ create()

Expected< DatabaseFile > DatabaseFile::create ( const Twine & Path,
uint64_t Capacity,
function_ref< Error(DatabaseFile &)> NewDBConstructor )
static

◆ findTable()

std::optional< TableHandle > DatabaseFile::findTable ( StringRef Name)

Find a table. May return null.

Definition at line 89 of file DatabaseFile.cpp.

References llvm::cas::ondisk::TableHandle::getName(), and getRegion().

◆ getAlloc()

MappedFileRegionArena & llvm::cas::ondisk::DatabaseFile::getAlloc ( )
inline

Definition at line 106 of file DatabaseFile.h.

◆ getHeader()

const Header & llvm::cas::ondisk::DatabaseFile::getHeader ( )
inline

Definition at line 105 of file DatabaseFile.h.

◆ getMagic()

constexpr uint32_t llvm::cas::ondisk::DatabaseFile::getMagic ( )
inlinestaticconstexpr

Definition at line 97 of file DatabaseFile.h.

Referenced by create().

◆ getRegion()

MappedFileRegion & llvm::cas::ondisk::DatabaseFile::getRegion ( )
inline

Definition at line 107 of file DatabaseFile.h.

Referenced by addTable(), and findTable().

◆ getVersion()

constexpr uint32_t llvm::cas::ondisk::DatabaseFile::getVersion ( )
inlinestaticconstexpr

Definition at line 98 of file DatabaseFile.h.

Referenced by create().

◆ size()

size_t llvm::cas::ondisk::DatabaseFile::size ( ) const
inline

Definition at line 121 of file DatabaseFile.h.


The documentation for this class was generated from the following files: