LLVM 22.0.0git
Public Member Functions | List of all members
llvm::cas::builtin::BuiltinCAS Class Referenceabstract

Common base class for builtin CAS implementations using the same CASContext. More...

#include "CAS/BuiltinCAS.h"

Inheritance diagram for llvm::cas::builtin::BuiltinCAS:
[legend]

Public Member Functions

 BuiltinCAS ()
 
Expected< CASIDparseID (StringRef Reference) final
 Get a CASID from a ID, which should have been generated by CASID::print().
 
Expected< ObjectRefstore (ArrayRef< ObjectRef > Refs, ArrayRef< char > Data) final
 Store object into ObjectStore.
 
virtual Expected< ObjectRefstoreImpl (ArrayRef< uint8_t > ComputedHash, ArrayRef< ObjectRef > Refs, ArrayRef< char > Data)=0
 
virtual Expected< ObjectRefstoreFromNullTerminatedRegion (ArrayRef< uint8_t > ComputedHash, sys::fs::mapped_file_region Map)
 
virtual ArrayRef< chargetDataConst (ObjectHandle Node) const =0
 Both builtin CAS implementations provide lifetime for free, so this can be const, and readData() and getDataSize() can be implemented on top of it.
 
ArrayRef< chargetData (ObjectHandle Node, bool RequiresNullTerminator) const final
 
uint64_t getDataSize (ObjectHandle Node) const final
 Get the size of some data.
 
Error createUnknownObjectError (const CASID &ID) const
 
Error createCorruptObjectError (const CASID &ID) const
 
Error createCorruptStorageError () const
 
Error validate (const CASID &ID) final
 Validate the underlying object referred by CASID.
 
- Public Member Functions inherited from llvm::cas::ObjectStore
virtual Expected< CASIDparseID (StringRef ID)=0
 Get a CASID from a ID, which should have been generated by CASID::print().
 
virtual Expected< ObjectRefstore (ArrayRef< ObjectRef > Refs, ArrayRef< char > Data)=0
 Store object into ObjectStore.
 
virtual CASID getID (ObjectRef Ref) const =0
 Get an ID for Ref.
 
virtual std::optional< ObjectRefgetReference (const CASID &ID) const =0
 Get an existing reference to the object called ID.
 
virtual Expected< boolisMaterialized (ObjectRef Ref) const =0
 
virtual Error validate (const CASID &ID)=0
 Validate the underlying object referred by CASID.
 
Expected< ObjectProxycreateProxy (ArrayRef< ObjectRef > Refs, StringRef Data)
 Helper functions to store object and returns a ObjectProxy.
 
Expected< ObjectRefstoreFromString (ArrayRef< ObjectRef > Refs, StringRef String)
 Store object from StringRef.
 
Expected< ObjectRefstoreFromOpenFile (sys::fs::file_t FD, std::optional< sys::fs::file_status > Status=std::nullopt)
 Default implementation reads FD and calls storeNode().
 
Expected< ObjectProxygetProxy (const CASID &ID)
 Create ObjectProxy from CASID. If the object doesn't exist, get an error.
 
Expected< ObjectProxygetProxy (ObjectRef Ref)
 Create ObjectProxy from ObjectRef.
 
Expected< std::optional< ObjectProxy > > getProxyIfExists (ObjectRef Ref)
 
uint64_t readData (ObjectHandle Node, raw_ostream &OS, uint64_t Offset=0, uint64_t MaxBytes=-1ULL) const
 Read the data from Data into OS.
 
Error validateTree (ObjectRef Ref)
 Validate the whole node tree.
 
const CASContextgetContext () const
 Get CASContext.
 
virtual ~ObjectStore ()=default
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::cas::ObjectStore
static Error createUnknownObjectError (const CASID &ID)
 
- Protected Member Functions inherited from llvm::cas::ObjectStore
virtual Expected< std::optional< ObjectHandle > > loadIfExists (ObjectRef Ref)=0
 Load the object referenced by Ref.
 
Expected< ObjectHandleload (ObjectRef Ref)
 Like loadIfExists but returns an error if the object is missing.
 
virtual uint64_t getDataSize (ObjectHandle Node) const =0
 Get the size of some data.
 
virtual Error forEachRef (ObjectHandle Node, function_ref< Error(ObjectRef)> Callback) const =0
 Methods for handling objects.
 
virtual ObjectRef readRef (ObjectHandle Node, size_t I) const =0
 
virtual size_t getNumRefs (ObjectHandle Node) const =0
 
virtual ArrayRef< chargetData (ObjectHandle Node, bool RequiresNullTerminator=false) const =0
 
virtual Expected< ObjectRefstoreFromOpenFileImpl (sys::fs::file_t FD, std::optional< sys::fs::file_status > Status)
 Get ObjectRef from open file.
 
StringRef getDataString (ObjectHandle Node)
 Get a lifetime-extended StringRef pointing at Data.
 
std::unique_ptr< MemoryBuffergetMemoryBuffer (ObjectHandle Node, StringRef Name="", bool RequiresNullTerminator=true)
 Get a lifetime-extended MemoryBuffer pointing at Data.
 
virtual void readRefs (ObjectHandle Node, SmallVectorImpl< ObjectRef > &Refs) const
 Read all the refs from object in a SmallVector.
 
 ObjectStore (const CASContext &Context)
 

Detailed Description

Common base class for builtin CAS implementations using the same CASContext.

Definition at line 21 of file BuiltinCAS.h.

Constructor & Destructor Documentation

◆ BuiltinCAS()

llvm::cas::builtin::BuiltinCAS::BuiltinCAS ( )
inline

Definition at line 23 of file BuiltinCAS.h.

Member Function Documentation

◆ createCorruptObjectError()

Error llvm::cas::builtin::BuiltinCAS::createCorruptObjectError ( const CASID ID) const
inline

Definition at line 58 of file BuiltinCAS.h.

References llvm::createStringError().

Referenced by validate().

◆ createCorruptStorageError()

Error llvm::cas::builtin::BuiltinCAS::createCorruptStorageError ( ) const
inline

Definition at line 63 of file BuiltinCAS.h.

References llvm::createStringError().

◆ createUnknownObjectError()

Error llvm::cas::builtin::BuiltinCAS::createUnknownObjectError ( const CASID ID) const
inline

Definition at line 53 of file BuiltinCAS.h.

References llvm::createStringError().

Referenced by validate().

◆ getData()

ArrayRef< char > llvm::cas::builtin::BuiltinCAS::getData ( ObjectHandle  Node,
bool  RequiresNullTerminator 
) const
inlinefinalvirtual

Implements llvm::cas::ObjectStore.

Definition at line 44 of file BuiltinCAS.h.

References getDataConst().

◆ getDataConst()

virtual ArrayRef< char > llvm::cas::builtin::BuiltinCAS::getDataConst ( ObjectHandle  Node) const
pure virtual

Both builtin CAS implementations provide lifetime for free, so this can be const, and readData() and getDataSize() can be implemented on top of it.

Referenced by getData(), and getDataSize().

◆ getDataSize()

uint64_t llvm::cas::builtin::BuiltinCAS::getDataSize ( ObjectHandle  Node) const
inlinefinalvirtual

Get the size of some data.

Implements llvm::cas::ObjectStore.

Definition at line 49 of file BuiltinCAS.h.

References getDataConst(), and llvm::ArrayRef< T >::size().

◆ parseID()

Expected< CASID > BuiltinCAS::parseID ( StringRef  ID)
finalvirtual

Get a CASID from a ID, which should have been generated by CASID::print().

This succeeds as long as validateID() would pass. The object may be unknown to this CAS instance.

TODO: Remove, and update callers to use validateID() or extractHashFromID().

Implements llvm::cas::ObjectStore.

Definition at line 42 of file BuiltinCAS.cpp.

References llvm::cas::CASID::create(), llvm::cas::ObjectStore::getContext(), llvm::cas::builtin::BuiltinCASContext::parseID(), and llvm::Expected< T >::takeError().

◆ store()

Expected< ObjectRef > BuiltinCAS::store ( ArrayRef< ObjectRef Refs,
ArrayRef< char Data 
)
finalvirtual

Store object into ObjectStore.

Implements llvm::cas::ObjectStore.

Definition at line 65 of file BuiltinCAS.cpp.

References llvm::Data, and storeImpl().

◆ storeFromNullTerminatedRegion()

virtual Expected< ObjectRef > llvm::cas::builtin::BuiltinCAS::storeFromNullTerminatedRegion ( ArrayRef< uint8_t ComputedHash,
sys::fs::mapped_file_region  Map 
)
inlinevirtual

Definition at line 34 of file BuiltinCAS.h.

References storeImpl().

◆ storeImpl()

virtual Expected< ObjectRef > llvm::cas::builtin::BuiltinCAS::storeImpl ( ArrayRef< uint8_t ComputedHash,
ArrayRef< ObjectRef Refs,
ArrayRef< char Data 
)
pure virtual

◆ validate()

Error BuiltinCAS::validate ( const CASID ID)
finalvirtual

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