LLVM 22.0.0git
|
Common base class for builtin CAS implementations using the same CASContext. More...
#include "CAS/BuiltinCAS.h"
Public Member Functions | |
BuiltinCAS () | |
Expected< CASID > | parseID (StringRef Reference) final |
Get a CASID from a ID , which should have been generated by CASID::print(). | |
Expected< ObjectRef > | store (ArrayRef< ObjectRef > Refs, ArrayRef< char > Data) final |
Store object into ObjectStore. | |
virtual Expected< ObjectRef > | storeImpl (ArrayRef< uint8_t > ComputedHash, ArrayRef< ObjectRef > Refs, ArrayRef< char > Data)=0 |
virtual Expected< ObjectRef > | storeFromNullTerminatedRegion (ArrayRef< uint8_t > ComputedHash, sys::fs::mapped_file_region Map) |
virtual ArrayRef< char > | getDataConst (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< char > | getData (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. | |
![]() | |
virtual Expected< CASID > | parseID (StringRef ID)=0 |
Get a CASID from a ID , which should have been generated by CASID::print(). | |
virtual Expected< ObjectRef > | store (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< ObjectRef > | getReference (const CASID &ID) const =0 |
Get an existing reference to the object called ID . | |
virtual Expected< bool > | isMaterialized (ObjectRef Ref) const =0 |
virtual Error | validate (const CASID &ID)=0 |
Validate the underlying object referred by CASID. | |
Expected< ObjectProxy > | createProxy (ArrayRef< ObjectRef > Refs, StringRef Data) |
Helper functions to store object and returns a ObjectProxy. | |
Expected< ObjectRef > | storeFromString (ArrayRef< ObjectRef > Refs, StringRef String) |
Store object from StringRef. | |
Expected< ObjectRef > | storeFromOpenFile (sys::fs::file_t FD, std::optional< sys::fs::file_status > Status=std::nullopt) |
Default implementation reads FD and calls storeNode(). | |
Expected< ObjectProxy > | getProxy (const CASID &ID) |
Create ObjectProxy from CASID. If the object doesn't exist, get an error. | |
Expected< ObjectProxy > | getProxy (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 CASContext & | getContext () const |
Get CASContext. | |
virtual | ~ObjectStore ()=default |
Additional Inherited Members | |
![]() | |
static Error | createUnknownObjectError (const CASID &ID) |
![]() | |
virtual Expected< std::optional< ObjectHandle > > | loadIfExists (ObjectRef Ref)=0 |
Load the object referenced by Ref . | |
Expected< ObjectHandle > | load (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< char > | getData (ObjectHandle Node, bool RequiresNullTerminator=false) const =0 |
virtual Expected< ObjectRef > | storeFromOpenFileImpl (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< MemoryBuffer > | getMemoryBuffer (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) | |
Common base class for builtin CAS implementations using the same CASContext.
Definition at line 21 of file BuiltinCAS.h.
|
inline |
Definition at line 23 of file BuiltinCAS.h.
Definition at line 58 of file BuiltinCAS.h.
References llvm::createStringError().
Referenced by validate().
|
inline |
Definition at line 63 of file BuiltinCAS.h.
References llvm::createStringError().
Definition at line 53 of file BuiltinCAS.h.
References llvm::createStringError().
Referenced by validate().
|
inlinefinalvirtual |
Implements llvm::cas::ObjectStore.
Definition at line 44 of file BuiltinCAS.h.
References getDataConst().
|
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().
|
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().
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().
|
finalvirtual |
Store object into ObjectStore.
Implements llvm::cas::ObjectStore.
Definition at line 65 of file BuiltinCAS.cpp.
References llvm::Data, and storeImpl().
|
inlinevirtual |
Definition at line 34 of file BuiltinCAS.h.
References storeImpl().
|
pure virtual |
Referenced by store(), and storeFromNullTerminatedRegion().
Validate the underlying object referred by CASID.
Implements llvm::cas::ObjectStore.
Definition at line 71 of file BuiltinCAS.cpp.
References createCorruptObjectError(), createUnknownObjectError(), llvm::Data, llvm::cas::ObjectStore::getReference(), llvm::cas::BuiltinObjectHasher< HasherT >::hashObject(), llvm::cas::ObjectProxy::load(), load, llvm::Ref, and llvm::Error::success().