#include <kchashdb.h>
Classes | |
class | Cursor |
Cursor to indicate a record. More... | |
struct | FreeBlock |
Free block data. | |
struct | FreeBlockComparator |
Comparator for free blocks. | |
struct | Record |
Record data. | |
class | Repeater |
Repeating visitor. | |
Public Types | |
enum | Option { TSMALL = 1 << 0, TLINEAR = 1 << 1, TCOMPRESS = 1 << 2 } |
Tuning Options. More... | |
enum | Flag { FOPEN = 1 << 0, FFATAL = 1 << 1 } |
Status flags. More... | |
Public Member Functions | |
HashDB () | |
Default constructor. | |
virtual | ~HashDB () |
Destructor. | |
virtual bool | accept (const char *kbuf, size_t ksiz, Visitor *visitor, bool writable=true) |
Accept a visitor to a record. | |
virtual bool | iterate (Visitor *visitor, bool writable=true) |
Iterate to accept a visitor for each record. | |
virtual Error | error () const |
Get the last happened error. | |
virtual void | set_error (Error::Code code, const char *message) |
Set the error information. | |
virtual bool | open (const std::string &path, uint32_t mode=OWRITER|OCREATE) |
Open a database file. | |
virtual bool | close () |
Close the database file. | |
virtual bool | synchronize (bool hard=false, FileProcessor *proc=NULL) |
Synchronize updated contents with the file and the device. | |
virtual bool | begin_transaction (bool hard=false) |
Begin transaction. | |
virtual bool | begin_transaction_try (bool hard=false) |
Try to begin transaction. | |
virtual bool | end_transaction (bool commit=true) |
End transaction. | |
virtual bool | clear () |
Remove all records. | |
virtual int64_t | count () |
Get the number of records. | |
virtual int64_t | size () |
Get the size of the database file. | |
virtual std::string | path () |
Get the path of the database file. | |
virtual bool | status (std::map< std::string, std::string > *strmap) |
Get the miscellaneous status information. | |
virtual Cursor * | cursor () |
Create a cursor object. | |
virtual bool | tune_error_reporter (std::ostream *erstrm, bool ervbs) |
Set the internal error reporter. | |
virtual bool | tune_alignment (int8_t apow) |
Set the power of the alignment of record size. | |
virtual bool | tune_fbp (int8_t fpow) |
Set the power of the capacity of the free block pool. | |
virtual bool | tune_options (int8_t opts) |
Set the optional features. | |
virtual bool | tune_buckets (int64_t bnum) |
Set the number of buckets of the hash table. | |
virtual bool | tune_map (int64_t msiz) |
Set the size of the internal memory-mapped region. | |
virtual bool | tune_defrag (int64_t dfunit) |
Set the unit step number of auto defragmentation. | |
virtual bool | tune_compressor (Compressor *comp) |
Set the data compressor. | |
virtual char * | opaque () |
Get the opaque data. | |
virtual bool | synchronize_opaque () |
Synchronize the opaque data. | |
virtual bool | defrag (int64_t step) |
Perform defragmentation of the file. | |
virtual uint8_t | flags () |
Get the status flags. | |
Protected Member Functions | |
virtual void | set_error (const char *file, int32_t line, Error::Code code, const char *message) |
Set the error information. | |
virtual void | report (const char *file, int32_t line, const char *type, const char *format,...) |
Report a message for debugging. | |
virtual void | report_binary (const char *file, int32_t line, const char *type, const char *name, const char *buf, size_t size) |
Report the content of a binary buffer for debugging. | |
virtual bool | tune_type (int8_t type) |
Set the database type. | |
virtual uint8_t | libver () |
Get the library version. | |
virtual uint8_t | librev () |
Get the library revision. | |
virtual uint8_t | fmtver () |
Get the format version. | |
virtual uint8_t | chksum () |
Get the module checksum. | |
virtual uint8_t | type () |
Get the database type. | |
virtual uint8_t | apow () |
Get the alignment power. | |
virtual uint8_t | fpow () |
Get the free block pool power. | |
virtual uint8_t | opts () |
Get the options. | |
virtual int64_t | bnum () |
Get the bucket number. | |
virtual int64_t | msiz () |
Get the size of the internal memory-mapped region. | |
virtual int64_t | dfunit () |
Get the unit step number of auto defragmentation. | |
virtual Compressor * | comp () |
Get the data compressor. | |
virtual bool | recovered () |
Check whether the database was recovered or not. | |
virtual bool | reorganized () |
Check whether the database was reorganized or not. | |
Friends | |
class | TreeDB |
File hash database.
kyotocabinet::HashDB::HashDB | ( | ) | [explicit] |
Default constructor.
virtual kyotocabinet::HashDB::~HashDB | ( | ) | [virtual] |
Destructor.
virtual bool kyotocabinet::HashDB::accept | ( | const char * | kbuf, | |
size_t | ksiz, | |||
Visitor * | visitor, | |||
bool | writable = true | |||
) | [virtual] |
Accept a visitor to a record.
kbuf | the pointer to the key region. | |
ksiz | the size of the key region. | |
visitor | a visitor object. | |
writable | true for writable operation, or false for read-only operation. |
Implements kyotocabinet::DB.
virtual bool kyotocabinet::HashDB::iterate | ( | Visitor * | visitor, | |
bool | writable = true | |||
) | [virtual] |
Iterate to accept a visitor for each record.
visitor | a visitor object. | |
writable | true for writable operation, or false for read-only operation. |
Implements kyotocabinet::DB.
virtual Error kyotocabinet::HashDB::error | ( | ) | const [virtual] |
virtual void kyotocabinet::HashDB::set_error | ( | Error::Code | code, | |
const char * | message | |||
) | [virtual] |
Set the error information.
code | an error code. | |
message | a supplement message. |
virtual bool kyotocabinet::HashDB::open | ( | const std::string & | path, | |
uint32_t | mode = OWRITER | OCREATE | |||
) | [virtual] |
Open a database file.
path | the path of a database file. | |
mode | the connection mode. HashDB::OWRITER as a writer, HashDB::OREADER as a reader. The following may be added to the writer mode by bitwise-or: HashDB::OCREATE, which means it creates a new database if the file does not exist, HashDB::OTRUNCATE, which means it creates a new database regardless if the file exists, HashDB::OAUTOTRAN, which means each updating operation is performed in implicit transaction, HashDB::OAUTOSYNC, which means each updating operation is followed by implicit synchronization with the file system. The following may be added to both of the reader mode and the writer mode by bitwise-or: HashDB::ONOLOCK, which means it opens the database file without file locking, HashDB::OTRYLOCK, which means locking is performed without blocking, HashDB::ONOREPAIR, which means the database file is not repaired implicitly even if file destruction is detected. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::close | ( | ) | [virtual] |
Close the database file.
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::synchronize | ( | bool | hard = false , |
|
FileProcessor * | proc = NULL | |||
) | [virtual] |
Synchronize updated contents with the file and the device.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. | |
proc | a postprocessor object. If it is NULL, no postprocessing is performed. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::begin_transaction | ( | bool | hard = false |
) | [virtual] |
Begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::begin_transaction_try | ( | bool | hard = false |
) | [virtual] |
Try to begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::end_transaction | ( | bool | commit = true |
) | [virtual] |
End transaction.
commit | true to commit the transaction, or false to abort the transaction. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::clear | ( | ) | [virtual] |
virtual int64_t kyotocabinet::HashDB::count | ( | ) | [virtual] |
Get the number of records.
Implements kyotocabinet::DB.
virtual int64_t kyotocabinet::HashDB::size | ( | ) | [virtual] |
Get the size of the database file.
Implements kyotocabinet::FileDB.
virtual std::string kyotocabinet::HashDB::path | ( | ) | [virtual] |
Get the path of the database file.
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::status | ( | std::map< std::string, std::string > * | strmap | ) | [virtual] |
Get the miscellaneous status information.
strmap | a string map to contain the result. |
Implements kyotocabinet::FileDB.
virtual Cursor* kyotocabinet::HashDB::cursor | ( | ) | [virtual] |
Create a cursor object.
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::HashDB::tune_error_reporter | ( | std::ostream * | erstrm, | |
bool | ervbs | |||
) | [virtual] |
Set the internal error reporter.
erstrm | a stream object into which internal error messages are stored. | |
ervbs | true to report all errors, or false to report fatal errors only. |
virtual bool kyotocabinet::HashDB::tune_alignment | ( | int8_t | apow | ) | [virtual] |
Set the power of the alignment of record size.
apow | the power of the alignment of record size. |
virtual bool kyotocabinet::HashDB::tune_fbp | ( | int8_t | fpow | ) | [virtual] |
Set the power of the capacity of the free block pool.
fpow | the power of the capacity of the free block pool. |
virtual bool kyotocabinet::HashDB::tune_options | ( | int8_t | opts | ) | [virtual] |
Set the optional features.
opts | the optional features by bitwise-or: HashDB::TSMALL to use 32-bit addressing, HashDB::TLINEAR to use linear collision chaining, HashDB::TCOMPRESS to compress each record. |
virtual bool kyotocabinet::HashDB::tune_buckets | ( | int64_t | bnum | ) | [virtual] |
Set the number of buckets of the hash table.
bnum | the number of buckets of the hash table. |
virtual bool kyotocabinet::HashDB::tune_map | ( | int64_t | msiz | ) | [virtual] |
Set the size of the internal memory-mapped region.
msiz | the size of the internal memory-mapped region. |
virtual bool kyotocabinet::HashDB::tune_defrag | ( | int64_t | dfunit | ) | [virtual] |
Set the unit step number of auto defragmentation.
dfunit | the unit step number of auto defragmentation. |
virtual bool kyotocabinet::HashDB::tune_compressor | ( | Compressor * | comp | ) | [virtual] |
Set the data compressor.
comp | the data compressor object. |
virtual char* kyotocabinet::HashDB::opaque | ( | ) | [virtual] |
Get the opaque data.
virtual bool kyotocabinet::HashDB::synchronize_opaque | ( | ) | [virtual] |
Synchronize the opaque data.
virtual bool kyotocabinet::HashDB::defrag | ( | int64_t | step | ) | [virtual] |
Perform defragmentation of the file.
step | the number of steps. If it is not more than 0, the whole region is defraged. |
virtual uint8_t kyotocabinet::HashDB::flags | ( | ) | [virtual] |
Get the status flags.
virtual void kyotocabinet::HashDB::set_error | ( | const char * | file, | |
int32_t | line, | |||
Error::Code | code, | |||
const char * | message | |||
) | [protected, virtual] |
Set the error information.
file | the file name of the epicenter. | |
line | the line number of the epicenter. | |
code | an error code. | |
message | a supplement message. |
virtual void kyotocabinet::HashDB::report | ( | const char * | file, | |
int32_t | line, | |||
const char * | type, | |||
const char * | format, | |||
... | ||||
) | [protected, virtual] |
Report a message for debugging.
file | the file name of the epicenter. | |
line | the line number of the epicenter. | |
type | the type string. | |
format | the printf-like format string. | |
... | used according to the format string. |
virtual void kyotocabinet::HashDB::report_binary | ( | const char * | file, | |
int32_t | line, | |||
const char * | type, | |||
const char * | name, | |||
const char * | buf, | |||
size_t | size | |||
) | [protected, virtual] |
Report the content of a binary buffer for debugging.
file | the file name of the epicenter. | |
line | the line number of the epicenter. | |
type | the type string. | |
name | the name of the information. | |
buf | the binary buffer. | |
size | the size of the binary buffer |
virtual bool kyotocabinet::HashDB::tune_type | ( | int8_t | type | ) | [protected, virtual] |
Set the database type.
type | the database type. |
virtual uint8_t kyotocabinet::HashDB::libver | ( | ) | [protected, virtual] |
Get the library version.
virtual uint8_t kyotocabinet::HashDB::librev | ( | ) | [protected, virtual] |
Get the library revision.
virtual uint8_t kyotocabinet::HashDB::fmtver | ( | ) | [protected, virtual] |
Get the format version.
virtual uint8_t kyotocabinet::HashDB::chksum | ( | ) | [protected, virtual] |
Get the module checksum.
virtual uint8_t kyotocabinet::HashDB::type | ( | ) | [protected, virtual] |
Get the database type.
virtual uint8_t kyotocabinet::HashDB::apow | ( | ) | [protected, virtual] |
Get the alignment power.
virtual uint8_t kyotocabinet::HashDB::fpow | ( | ) | [protected, virtual] |
Get the free block pool power.
virtual uint8_t kyotocabinet::HashDB::opts | ( | ) | [protected, virtual] |
Get the options.
virtual int64_t kyotocabinet::HashDB::bnum | ( | ) | [protected, virtual] |
Get the bucket number.
virtual int64_t kyotocabinet::HashDB::msiz | ( | ) | [protected, virtual] |
Get the size of the internal memory-mapped region.
virtual int64_t kyotocabinet::HashDB::dfunit | ( | ) | [protected, virtual] |
Get the unit step number of auto defragmentation.
virtual Compressor* kyotocabinet::HashDB::comp | ( | ) | [protected, virtual] |
Get the data compressor.
virtual bool kyotocabinet::HashDB::recovered | ( | ) | [protected, virtual] |
Check whether the database was recovered or not.
virtual bool kyotocabinet::HashDB::reorganized | ( | ) | [protected, virtual] |
Check whether the database was reorganized or not.