LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::OnDiskChainedHashTable< Info > Class Template Reference

Provides lookup on an on disk hash table. More...

#include "llvm/Support/OnDiskHashTable.h"

Inheritance diagram for llvm::OnDiskChainedHashTable< Info >:
Inheritance graph
[legend]

Classes

class  iterator
 

Public Types

typedef Info InfoType
 
typedef Info::internal_key_type internal_key_type
 
typedef Info::external_key_type external_key_type
 
typedef Info::data_type data_type
 
typedef Info::hash_value_type hash_value_type
 
typedef Info::offset_type offset_type
 

Public Member Functions

 OnDiskChainedHashTable (offset_type NumBuckets, offset_type NumEntries, const unsigned char *Buckets, const unsigned char *Base, const Info &InfoObj=Info())
 
offset_type getNumBuckets () const
 
offset_type getNumEntries () const
 
const unsigned chargetBase () const
 
const unsigned chargetBuckets () const
 
bool isEmpty () const
 
iterator find (const external_key_type &EKey, Info *InfoPtr=nullptr)
 Look up the stored data for a particular key.
 
iterator find_hashed (const internal_key_type &IKey, hash_value_type KeyHash, Info *InfoPtr=nullptr)
 Look up the stored data for a particular key with a known hash.
 
iterator end () const
 
InfogetInfoObj ()
 

Static Public Member Functions

static std::pair< offset_type, offset_typereadNumBucketsAndEntries (const unsigned char *&Buckets)
 Read the number of buckets and the number of entries from a hash table produced by OnDiskHashTableGenerator::Emit, and advance the Buckets pointer past them.
 
static OnDiskChainedHashTableCreate (const unsigned char *Buckets, const unsigned char *const Base, const Info &InfoObj=Info())
 Create the hash table.
 

Detailed Description

template<typename Info>
class llvm::OnDiskChainedHashTable< Info >

Provides lookup on an on disk hash table.

This needs an Info that handles reading values from the hash table's payload and computes the hash for a given key. This should provide the following interface:

class ExampleLookupInfo {
public:
typedef ExampleData data_type;
typedef ExampleInternalKey internal_key_type; // The stored key type.
typedef ExampleKey external_key_type; // The type to pass to find().
typedef uint32_t hash_value_type; // The type the hash function returns.
typedef uint32_t offset_type; // The type for offsets into the table.
/// Compare two keys for equality.
static bool EqualKey(internal_key_type &Key1, internal_key_type &Key2);
/// Calculate the hash for the given key.
static hash_value_type ComputeHash(internal_key_type &IKey);
/// Translate from the semantic type of a key in the hash table to the
/// type that is actually stored and used for hashing and comparisons.
/// The internal and external types are often the same, in which case this
/// can simply return the passed in value.
static const internal_key_type &GetInternalKey(external_key_type &EKey);
/// Read the key and data length from Buffer, leaving it pointing at the
/// following byte.
static std::pair<offset_type, offset_type>
ReadKeyDataLength(const unsigned char *&Buffer);
/// Read the key from Buffer, given the KeyLen as reported from
/// ReadKeyDataLength.
const internal_key_type &ReadKey(const unsigned char *Buffer,
offset_type KeyLen);
/// Read the data for Key from Buffer, given the DataLen as reported from
/// ReadKeyDataLength.
data_type ReadData(StringRef Key, const unsigned char *Buffer,
offset_type DataLen);
};
InstrProfLookupTrait::offset_type offset_type
InstrProfLookupTrait::data_type data_type
Info::hash_value_type hash_value_type
Info::external_key_type external_key_type
Info::internal_key_type internal_key_type
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51

Definition at line 273 of file OnDiskHashTable.h.

Member Typedef Documentation

◆ data_type

template<typename Info >
typedef Info::data_type llvm::OnDiskChainedHashTable< Info >::data_type

Definition at line 284 of file OnDiskHashTable.h.

◆ external_key_type

template<typename Info >
typedef Info::external_key_type llvm::OnDiskChainedHashTable< Info >::external_key_type

Definition at line 283 of file OnDiskHashTable.h.

◆ hash_value_type

template<typename Info >
typedef Info::hash_value_type llvm::OnDiskChainedHashTable< Info >::hash_value_type

Definition at line 285 of file OnDiskHashTable.h.

◆ InfoType

template<typename Info >
typedef Info llvm::OnDiskChainedHashTable< Info >::InfoType

Definition at line 281 of file OnDiskHashTable.h.

◆ internal_key_type

template<typename Info >
typedef Info::internal_key_type llvm::OnDiskChainedHashTable< Info >::internal_key_type

Definition at line 282 of file OnDiskHashTable.h.

◆ offset_type

template<typename Info >
typedef Info::offset_type llvm::OnDiskChainedHashTable< Info >::offset_type

Definition at line 286 of file OnDiskHashTable.h.

Constructor & Destructor Documentation

◆ OnDiskChainedHashTable()

template<typename Info >
llvm::OnDiskChainedHashTable< Info >::OnDiskChainedHashTable ( offset_type  NumBuckets,
offset_type  NumEntries,
const unsigned char Buckets,
const unsigned char Base,
const Info InfoObj = Info() 
)
inline

Definition at line 288 of file OnDiskHashTable.h.

References assert(), and llvm::sampleprof::Base.

Member Function Documentation

◆ Create()

template<typename Info >
static OnDiskChainedHashTable * llvm::OnDiskChainedHashTable< Info >::Create ( const unsigned char Buckets,
const unsigned char *const  Base,
const Info InfoObj = Info() 
)
inlinestatic

Create the hash table.

Parameters
Bucketsis the beginning of the hash table itself, which follows the payload of entire structure. This is the value returned by OnDiskHashTableGenerator::Emit.
Baseis the point from which all offsets into the structure are based. This is offset 0 in the stream that was used when Emitting the table.

Definition at line 419 of file OnDiskHashTable.h.

References assert(), llvm::sampleprof::Base, and llvm::OnDiskChainedHashTable< Info >::readNumBucketsAndEntries().

◆ end()

template<typename Info >
iterator llvm::OnDiskChainedHashTable< Info >::end ( ) const
inline

Definition at line 406 of file OnDiskHashTable.h.

◆ find()

template<typename Info >
iterator llvm::OnDiskChainedHashTable< Info >::find ( const external_key_type EKey,
Info InfoPtr = nullptr 
)
inline

Look up the stored data for a particular key.

Definition at line 344 of file OnDiskHashTable.h.

References llvm::OnDiskChainedHashTable< Info >::find_hashed().

◆ find_hashed()

template<typename Info >
iterator llvm::OnDiskChainedHashTable< Info >::find_hashed ( const internal_key_type IKey,
hash_value_type  KeyHash,
Info InfoPtr = nullptr 
)
inline

Look up the stored data for a particular key with a known hash.

Definition at line 351 of file OnDiskHashTable.h.

References llvm::sampleprof::Base, Idx, llvm::Offset, and X.

Referenced by llvm::OnDiskChainedHashTable< Info >::find().

◆ getBase()

template<typename Info >
const unsigned char * llvm::OnDiskChainedHashTable< Info >::getBase ( ) const
inline

Definition at line 317 of file OnDiskHashTable.h.

References llvm::sampleprof::Base.

◆ getBuckets()

template<typename Info >
const unsigned char * llvm::OnDiskChainedHashTable< Info >::getBuckets ( ) const
inline

Definition at line 318 of file OnDiskHashTable.h.

◆ getInfoObj()

template<typename Info >
Info & llvm::OnDiskChainedHashTable< Info >::getInfoObj ( )
inline

◆ getNumBuckets()

template<typename Info >
offset_type llvm::OnDiskChainedHashTable< Info >::getNumBuckets ( ) const
inline

Definition at line 315 of file OnDiskHashTable.h.

◆ getNumEntries()

template<typename Info >
offset_type llvm::OnDiskChainedHashTable< Info >::getNumEntries ( ) const
inline

◆ isEmpty()

template<typename Info >
bool llvm::OnDiskChainedHashTable< Info >::isEmpty ( ) const
inline

Definition at line 320 of file OnDiskHashTable.h.

◆ readNumBucketsAndEntries()

template<typename Info >
static std::pair< offset_type, offset_type > llvm::OnDiskChainedHashTable< Info >::readNumBucketsAndEntries ( const unsigned char *&  Buckets)
inlinestatic

Read the number of buckets and the number of entries from a hash table produced by OnDiskHashTableGenerator::Emit, and advance the Buckets pointer past them.

Definition at line 302 of file OnDiskHashTable.h.

References assert().

Referenced by llvm::OnDiskChainedHashTable< Info >::Create(), and llvm::OnDiskIterableChainedHashTable< Info >::Create().


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