|
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 | validateObject (const CASID &ID) final |
| Validate the underlying object referred by CASID. | |
| Public Member Functions inherited from llvm::cas::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 (bool CheckHash) const =0 |
| Validate the entire ObjectStore. | |
| 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. | |
| virtual Error | setSizeLimit (std::optional< uint64_t > SizeLimit) |
| Set the size for limiting growth of on-disk storage. | |
| virtual Expected< std::optional< uint64_t > > | getStorageSize () const |
| virtual Error | pruneStorageData () |
| Prune local storage to reduce its size according to the desired size limit. | |
| Error | validateTree (ObjectRef Ref) |
| Validate the whole node tree. | |
| Expected< ObjectRef > | importObject (ObjectStore &Upstream, ObjectRef Other) |
| Import object from another CAS. | |
| virtual void | print (raw_ostream &) const |
| Print the ObjectStore internals for debugging purpose. | |
| void | dump () const |
| const CASContext & | getContext () 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< ObjectHandle > | load (ObjectRef Ref) |
Like loadIfExists but returns an error if the object is missing. | |
| 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 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 24 of file BuiltinCAS.h.
|
inline |
Definition at line 26 of file BuiltinCAS.h.
References llvm::cas::ObjectStore::ObjectStore().
Definition at line 61 of file BuiltinCAS.h.
References llvm::createStringError().
Referenced by validateObject().
|
inline |
Definition at line 66 of file BuiltinCAS.h.
References llvm::createStringError().
Definition at line 56 of file BuiltinCAS.h.
References llvm::createStringError().
Referenced by validateObject().
|
inlinefinalvirtual |
Implements llvm::cas::ObjectStore.
Definition at line 47 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 52 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 43 of file BuiltinCAS.cpp.
References llvm::cas::CASID::create(), llvm::cas::ObjectStore::getContext(), llvm::cas::builtin::BuiltinCASContext::parseID(), llvm::Expected< T >::takeError(), and llvm::toStringRef().
|
finalvirtual |
Store object into ObjectStore.
Implements llvm::cas::ObjectStore.
Definition at line 66 of file BuiltinCAS.cpp.
References llvm::Data, llvm::cas::BuiltinObjectHasher< HasherT >::hashObject(), and storeImpl().
|
inlinevirtual |
Definition at line 37 of file BuiltinCAS.h.
References llvm::ArrayRef(), and storeImpl().
|
pure virtual |
References llvm::Data.
Referenced by store(), and storeFromNullTerminatedRegion().
Validate the underlying object referred by CASID.
Implements llvm::cas::ObjectStore.
Definition at line 72 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().