EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Classes | Public Member Functions | Static Public Attributes | Friends | List of all members
NameHash Class Reference

A file-based Hash table for strings. More...

#include <NameHash.h>

Classes

class  Entry
 One entry in the NameHash. More...
 
class  Iterator
 Iterator over names in the hash. More...
 

Public Member Functions

 NameHash (FileAllocator &fa, FileOffset anchor)
 Constructor. More...
 
void init (uint32_t ht_size=1009)
 Create a new hash table of given size. More...
 
void reattach ()
 Attach to existing hash table

Exceptions
GenericExceptionon error.
More...
 
bool insert (const stdString &name, const stdString &ID_txt, FileOffset ID)
 Insert name w/ ID. More...
 
Entryfind (const stdString &name)
 Locate name and obtain its ID. More...
 
Iteratoriterator ()
 Start iterating over all entries (in table's order). More...
 
void showStats (FILE *f)
 Generate info on table fill ratio and list length.
 

Static Public Attributes

static const uint32_t anchor_size = 8
 anchor size
 

Friends

class PrivateIterator
 

Detailed Description

A file-based Hash table for strings.

Beginning at the 'anchor' position in the file, NameHash deposits the start offset of the hash table and the number of table entries.

Each hash table entry is a file offset that points to the beginnig of the NameHash::Entry list for that hash value.

One NameHash entry on the disk is stored like this:

* long next
* long ID
* short length of name
* short length of ID_txt
* char name[] // Stored without the delimiting'\0' !!
* char ID_txt[] // Stored without the '\0' !!
*

ID_txt might be "", but the name can never be empty.

Constructor & Destructor Documentation

NameHash::NameHash ( FileAllocator fa,
FileOffset  anchor 
)

Constructor.

Parameters
fa,:The File allocator
anchor,:The NameHash will deposit its root pointer there. Caller needs to assert that there are anchor_size bytes available at that location in the file.

Member Function Documentation

Entry* NameHash::find ( const stdString &  name)

Locate name and obtain its ID.

Returns
Returns NameInfo or 0 if nothing found. Receiver must delete.
Exceptions
GenericExceptionon internal error.
void NameHash::init ( uint32_t  ht_size = 1009)

Create a new hash table of given size.

Parameters
ht_sizedetermines the hash table size and should be prime.
Exceptions
GenericExceptionon error.
bool NameHash::insert ( const stdString &  name,
const stdString &  ID_txt,
FileOffset  ID 
)

Insert name w/ ID.

Returns
True if a new entry was generated, false if an existing entry for that name was updated with possibly new information.
Exceptions
GenericExceptionon error.
Iterator* NameHash::iterator ( )

Start iterating over all entries (in table's order).

Returns
Returns iterator. Might not be 'valid'. Caller must delete.
Exceptions
GenericExceptionon error.
void NameHash::reattach ( )

Attach to existing hash table

Exceptions
GenericExceptionon error.


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