|
LLVM 23.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 LLVM_ABI_FOR_TEST Expected< std::unique_ptr< OnDiskGraphDB > > | open (StringRef Path, StringRef HashName, unsigned HashByteSize, OnDiskGraphDB *UpstreamDB=nullptr, std::shared_ptr< OnDiskCASLogger > Logger=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 258 of file OnDiskGraphDB.h.
Hashing function type for validation.
Definition at line 332 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 348 of file OnDiskGraphDB.h.
| OnDiskGraphDB::~OnDiskGraphDB | ( | ) |
Definition at line 1676 of file OnDiskGraphDB.cpp.
|
inline |
Check whether the object associated with Ref is stored in the CAS.
Note that this function does not fault-in.
Definition at line 292 of file OnDiskGraphDB.h.
References llvm::consumeError(), llvm_unreachable, and llvm::Ref.
Definition at line 271 of file OnDiskGraphDB.h.
References llvm::cantFail(), getDigest(), and llvm::Ref.
Referenced by getDigest(), load(), store(), and validateObjectID().
| std::optional< ObjectID > OnDiskGraphDB::getExistingReference | ( | ArrayRef< uint8_t > | Digest, |
| bool | CheckUpstream = true ) |
Get an existing reference to the object Digest.
Returns nullopt if the object is not stored in this CAS.
Definition at line 1157 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 1589 of file OnDiskGraphDB.cpp.
| ArrayRef< char > OnDiskGraphDB::getObjectData | ( | ObjectHandle | Node | ) | const |
Definition at line 1220 of file OnDiskGraphDB.cpp.
References assert(), and getContentFromHandle().
|
inline |
Definition at line 313 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 1145 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 1585 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 1297 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 1236 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::sys::fs::openNativeFileForRead(), llvm::sys::fs::mapped_file_region::readonly, llvm::Ref, llvm::sys::sandbox::scopedDisable(), 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. User need to make sure UpstreamDB outlives current instance of OnDiskGraphDB and the common usage is to have an UnifiedOnDiskCache to manage both. |
| 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 1596 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().
Referenced by llvm::cas::ondisk::UnifiedOnDiskCache::open().
| void OnDiskGraphDB::print | ( | raw_ostream & | OS | ) | const |
Definition at line 1062 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 1450 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 899 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().
Checks that ID exists in the index.
It is allowed to not have data associated with it.
Definition at line 1032 of file OnDiskGraphDB.cpp.
References llvm::createStringError(), getDigest(), llvm::cas::ondisk::ObjectID::getOpaqueData(), I, llvm::illegal_byte_sequence, llvm::cas::ondisk::OnDiskGraphDB::IndexProxy::Offset, P, llvm::Error::success(), llvm::toHex(), llvm::toString(), and llvm::utohexstr().