LLVM 22.0.0git
|
On-disk CAS nodes database, independent of a particular hashing algorithm. More...
#include "llvm/CAS/OnDiskGraphDB.h"
Classes | |
struct | IndexProxy |
Proxy for an on-disk index record. More... |
Public Types | |
enum class | FaultInPolicy { SingleNode , FullTree } |
How to fault-in nodes if an upstream database is used. More... | |
using | HashingFuncT |
Hashing function type for validation. |
Static Public Member Functions | |
static Expected< std::unique_ptr< OnDiskGraphDB > > | open (StringRef Path, StringRef HashName, unsigned HashByteSize, std::unique_ptr< OnDiskGraphDB > UpstreamDB=nullptr, FaultInPolicy Policy=FaultInPolicy::FullTree) |
Open the on-disk store from a directory. |
On-disk CAS nodes database, independent of a particular hashing algorithm.
Definition at line 256 of file OnDiskGraphDB.h.
Hashing function type for validation.
Definition at line 315 of file OnDiskGraphDB.h.
|
strong |
How to fault-in nodes if an upstream database is used.
Enumerator | |
---|---|
SingleNode | Copy only the requested node. |
FullTree | Copy the the entire graph of a node. |
Definition at line 327 of file OnDiskGraphDB.h.
OnDiskGraphDB::~OnDiskGraphDB | ( | ) |
Definition at line 1631 of file OnDiskGraphDB.cpp.
Check whether the object associated with Ref
is stored in the CAS.
Note that this function does not fault-in.
Definition at line 288 of file OnDiskGraphDB.h.
References containsObject(), and llvm::Ref.
Referenced by containsObject().
Definition at line 268 of file OnDiskGraphDB.h.
References llvm::cantFail(), getDigest(), and llvm::Ref.
Referenced by getDigest(), load(), and store().
Get an existing reference to the object Digest
.
Returns nullopt
if the object is not stored in this CAS.
Definition at line 1120 of file OnDiskGraphDB.cpp.
References llvm::expectedToOptional(), I, LLVM_UNLIKELY, P, and llvm::Ref.
unsigned OnDiskGraphDB::getHardStorageLimitUtilization | ( | ) | const |
Return value is an integer between 0 and 100 for percentage.
Definition at line 1546 of file OnDiskGraphDB.cpp.
ArrayRef< char > OnDiskGraphDB::getObjectData | ( | ObjectHandle | Node | ) | const |
Definition at line 1182 of file OnDiskGraphDB.cpp.
References assert(), and getContentFromHandle().
|
inline |
Definition at line 296 of file OnDiskGraphDB.h.
References llvm::cas::ondisk::InternalRefArrayRef::begin(), llvm::cas::ondisk::InternalRefArrayRef::end(), and llvm::make_range().
Form a reference for the provided hash.
The reference can be used as part of a CAS object even if it's not associated with an object yet.
Definition at line 1108 of file OnDiskGraphDB.cpp.
References I, and LLVM_UNLIKELY.
size_t OnDiskGraphDB::getStorageSize | ( | ) | const |
NOTE: There's a possibility that the returned size is not including a large object if the process crashed right at the point of inserting it.
Definition at line 1542 of file OnDiskGraphDB.cpp.
Check whether the object associated with Ref
is stored in the CAS.
Note that this function will fault-in according to the policy.
Definition at line 1260 of file OnDiskGraphDB.cpp.
References llvm_unreachable, and llvm::Ref.
Expected< std::optional< ObjectHandle > > OnDiskGraphDB::load | ( | ObjectID | Ref | ) |
nullopt
if the object associated with Ref
does not exist. Definition at line 1198 of file OnDiskGraphDB.cpp.
References llvm::sys::fs::closeFile(), createCorruptObjectError(), llvm::createFileError(), llvm::cas::ondisk::ObjectHandle::fromFileOffset(), llvm::cas::ondisk::ObjectHandle::fromMemory(), getDigest(), I, llvm_unreachable, llvm::make_scope_exit(), llvm::sys::fs::openNativeFileForRead(), llvm::sys::fs::mapped_file_region::readonly, llvm::Ref, and llvm::sys::fs::status().
|
static |
Open the on-disk store from a directory.
Path | directory for the on-disk store. The directory will be created if it doesn't exist. |
HashName | Identifier name for the hashing algorithm that is going to be used. |
HashByteSize | Size for the object digest hash bytes. |
UpstreamDB | Optional on-disk store to be used for faulting-in nodes if they don't exist in the primary store. The upstream store is only used for reading nodes, new nodes are only written to the primary store. |
Policy | If UpstreamDB is provided, controls how nodes are copied to primary store. This is recorded at creation time and subsequent opens need to pass the same policy otherwise the open will fail. |
Definition at line 1552 of file OnDiskGraphDB.cpp.
References llvm::sys::path::append(), llvm::argument_out_of_domain, llvm::cas::ondisk::CASFormatVersion, llvm::cas::OnDiskDataAllocator::create(), llvm::cas::OnDiskTrieRawHashMap::create(), llvm::sys::fs::create_directories(), llvm::createFileError(), llvm::createStringError(), DataPoolFilePrefix, DataPoolTableName, llvm::cas::ondisk::getOverriddenMaxMappingSize(), IndexFilePrefix, IndexTableName, SingleNode, and llvm::cas::ondisk::useSmallMappingSize().
void OnDiskGraphDB::print | ( | raw_ostream & | OS | ) | const |
Definition at line 1025 of file OnDiskGraphDB.cpp.
References assert(), D(), llvm::Data, llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::isAligned(), llvm::Align::Of(), llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::sort(), and llvm::toString().
Associate data & references with a particular object ID.
If there is already a record for this object the operation is a no-op.
Definition at line 1407 of file OnDiskGraphDB.cpp.
References llvm::Alloc, assert(), createCorruptObjectError(), createTempFile(), llvm::Data, llvm::dbgs(), llvm::ArrayRef< T >::empty(), llvm::cas::FileOffset::get(), getDigest(), llvm::handleErrors(), I, LLVM_DEBUG, LLVM_UNLIKELY, P, llvm::Ref, Size, and llvm::Error::success().
Error OnDiskGraphDB::validate | ( | bool | Deep, |
HashingFuncT | Hasher ) const |
Validate the OnDiskGraphDB.
Deep | if true, rehash all the objects to ensure no data corruption in stored objects, otherwise just validate the structure of CAS database. |
Hasher | is the hashing function used for objects inside CAS. |
Definition at line 895 of file OnDiskGraphDB.cpp.
References llvm::arrayRefFromStringRef(), llvm::createStringError(), D(), llvm::ArrayRef< T >::drop_back(), llvm::sys::fs::exists(), llvm::MemoryBuffer::getFile(), llvm::cas::ondisk::InternalRef::getFromOffset(), I, llvm::illegal_byte_sequence, llvm::isAligned(), llvm_unreachable, llvm::Align::Of(), llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Ref, llvm::Error::success(), llvm::toHex(), llvm::toString(), and llvm::utohexstr().