LLVM 22.0.0git
llvm::cas::ondisk::OnDiskKeyValueDB Class Reference

An on-disk key-value data store with the following properties: More...

#include "llvm/CAS/OnDiskKeyValueDB.h"

Public Types

using CheckValueT

Public Member Functions

Expected< ArrayRef< char > > put (ArrayRef< uint8_t > Key, ArrayRef< char > Value)
 Associate a value with a key.
Expected< std::optional< ArrayRef< char > > > get (ArrayRef< uint8_t > Key)
size_t getStorageSize () const
unsigned getHardStorageLimitUtilization () const
Error validate (CheckValueT CheckValue) const
 Validate the storage with a callback CheckValue to check the stored value.

Static Public Member Functions

static Expected< std::unique_ptr< OnDiskKeyValueDB > > open (StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize)
 Open the on-disk store from a directory.

Detailed Description

An on-disk key-value data store with the following properties:

  • Keys are fixed length binary hashes with expected normal distribution.
  • Values are buffers of the same size, specified at creation time.
  • The value of a key cannot be changed once it is set.
  • The value buffers returned from a key lookup have 8-byte alignment.

Definition at line 27 of file OnDiskKeyValueDB.h.

Member Typedef Documentation

◆ CheckValueT

Initial value:
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
FileOffset is a wrapper around uint64_t to represent the offset of data from the beginning of the fil...
Definition FileOffset.h:24
An efficient, type-erasing, non-owning reference to a callable.
@ Offset
Definition DWP.cpp:477
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189

Definition at line 66 of file OnDiskKeyValueDB.h.

Member Function Documentation

◆ get()

Expected< std::optional< ArrayRef< char > > > OnDiskKeyValueDB::get ( ArrayRef< uint8_t > Key)
Returns
the value associated with the Key, or std::nullopt if the key does not exist.

Definition at line 53 of file OnDiskKeyValueDB.cpp.

References assert(), llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, and llvm::isAddrAligned().

◆ getHardStorageLimitUtilization()

unsigned llvm::cas::ondisk::OnDiskKeyValueDB::getHardStorageLimitUtilization ( ) const
inline
Returns
The precentage of space utilization of hard space limits.

Return value is an integer between 0 and 100 for percentage.

Definition at line 49 of file OnDiskKeyValueDB.h.

◆ getStorageSize()

size_t llvm::cas::ondisk::OnDiskKeyValueDB::getStorageSize ( ) const
inline
Returns
Total size of stored data.

Definition at line 44 of file OnDiskKeyValueDB.h.

◆ open()

Expected< std::unique_ptr< OnDiskKeyValueDB > > OnDiskKeyValueDB::open ( StringRef Path,
StringRef HashName,
unsigned KeySize,
StringRef ValueName,
size_t ValueSize )
static

Open the on-disk store from a directory.

Parameters
Pathdirectory for the on-disk store. The directory will be created if it doesn't exist.
HashNameIdentifier name for the hashing algorithm that is going to be used.
KeySizeSize for the key hash bytes.
ValueNameIdentifier name for the values.
ValueSizeSize for the value bytes.

Definition at line 63 of file OnDiskKeyValueDB.cpp.

References ActionCacheFile, llvm::sys::path::append(), llvm::cas::ondisk::CASFormatVersion, llvm::cas::OnDiskTrieRawHashMap::create(), llvm::sys::fs::create_directories(), llvm::createFileError(), and llvm::cas::ondisk::getOverriddenMaxMappingSize().

◆ put()

Expected< ArrayRef< char > > OnDiskKeyValueDB::put ( ArrayRef< uint8_t > Key,
ArrayRef< char > Value )

Associate a value with a key.

Parameters
Keythe hash bytes for the key
Valuethe value bytes, same size as ValueSize parameter of open call.
Returns
the value associated with the Key. It may be different than Value if another value is already associated with this key.

Definition at line 34 of file OnDiskKeyValueDB.cpp.

References assert(), llvm::copy(), llvm::createStringError(), llvm::cas::OnDiskTrieRawHashMap::ValueProxy::Data, llvm::MutableArrayRef< T >::data(), llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::invalid_argument, llvm::itostr(), LLVM_UNLIKELY, and llvm::ArrayRef< T >::size().

◆ validate()

Error OnDiskKeyValueDB::validate ( CheckValueT CheckValue) const

Validate the storage with a callback CheckValue to check the stored value.

Definition at line 93 of file OnDiskKeyValueDB.cpp.

References llvm::createStringError(), llvm::illegal_byte_sequence, llvm::isAddrAligned(), llvm::Offset, llvm::Error::success(), and llvm::utohexstr().


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