LLVM 23.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 Member Functions

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

Static Public Member Functions

static LLVM_ABI_FOR_TEST Expected< std::unique_ptr< OnDiskKeyValueDB > > open (StringRef Path, StringRef HashName, unsigned KeySize, StringRef ValueName, size_t ValueSize, UnifiedOnDiskCache *UnifiedCache=nullptr, std::shared_ptr< OnDiskCASLogger > Logger=nullptr)
 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 29 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 55 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 53 of file OnDiskKeyValueDB.h.

◆ getStorageSize()

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

Definition at line 48 of file OnDiskKeyValueDB.h.

◆ open()

Expected< std::unique_ptr< OnDiskKeyValueDB > > OnDiskKeyValueDB::open ( StringRef Path,
StringRef HashName,
unsigned KeySize,
StringRef ValueName,
size_t ValueSize,
UnifiedOnDiskCache * UnifiedCache = nullptr,
std::shared_ptr< OnDiskCASLogger > Logger = nullptr )
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.
UnifiedCacheAn optional UnifiedOnDiskCache that manages the size and lifetime of the CAS instance and it must owns current initializing KeyValueDB after initialized.

Definition at line 70 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().

Referenced by llvm::cas::ondisk::UnifiedOnDiskCache::open().

◆ 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 36 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 ( ) const

Validate the storage.

Definition at line 130 of file OnDiskKeyValueDB.cpp.

References assert(), and validateOnDiskKeyValueDB().

Referenced by llvm::cas::ondisk::UnifiedOnDiskCache::validateActionCache().


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