EPICS ARCHIVER V4
|
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
| |||
bool | insert (const stdString &name, const stdString &ID_txt, FileOffset ID) | ||
Insert name w/ ID. More... | |||
Entry * | find (const stdString &name) | ||
Locate name and obtain its ID. More... | |||
Iterator * | iterator () | ||
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 |
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:
ID_txt might be "", but the name can never be empty.
NameHash::NameHash | ( | FileAllocator & | fa, |
FileOffset | anchor | ||
) |
Constructor.
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. |
Entry* NameHash::find | ( | const stdString & | name | ) |
Locate name and obtain its ID.
GenericException | on internal error. |
void NameHash::init | ( | uint32_t | ht_size = 1009 | ) |
Create a new hash table of given size.
ht_size | determines the hash table size and should be prime. |
GenericException | on error. |
bool NameHash::insert | ( | const stdString & | name, |
const stdString & | ID_txt, | ||
FileOffset | ID | ||
) |
Insert name w/ ID.
GenericException | on error. |
Iterator* NameHash::iterator | ( | ) |
Start iterating over all entries (in table's order).
GenericException | on error. |
void NameHash::reattach | ( | ) |
Attach to existing hash table
GenericException | on error. |