kyotocabinet::TreeDB Class Reference

File tree database. More...

#include <kctreedb.h>

List of all members.

Classes

class  Cursor
 Cursor to indicate a record. More...
struct  InnerNode
 Inner node of B+ tree.
struct  InnerSlot
 Slot cache of inner nodes.
struct  LeafNode
 Leaf node of B+ tree.
struct  LeafSlot
 Slot cache of inner nodes.
struct  Link
 Link to a node.
struct  LinkComparator
 Comparator for links.
struct  Record
 Record data.
struct  RecordComparator
 Comparator for records.

Public Types

enum  Option { TSMALL = HashDB::TSMALL, TLINEAR = HashDB::TLINEAR, TCOMPRESS = HashDB::TCOMPRESS }
 

Tuning Options.

More...
enum  Flag { FOPEN = HashDB::FOPEN, FFATAL = HashDB::FFATAL }
 

Status flags.

More...

Public Member Functions

 TreeDB ()
 Default constructor.
virtual ~TreeDB ()
 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 Cursorcursor ()
 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_page (int32_t psiz)
 Set the size of each page.
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_page_cache (int64_t pccap)
 Set the capacity of the total size of the page cache.
virtual bool tune_compressor (Compressor *comp)
 Set the data compressor.
virtual bool tune_comparator (Comparator *rcomp)
 Set the record comparator.
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.

Detailed Description

File tree database.


Member Enumeration Documentation

Tuning Options.

Enumerator:
TSMALL 

use 32-bit addressing

TLINEAR 

use linear collision chaining

TCOMPRESS 

compress each record

Status flags.

Enumerator:
FOPEN 

whether opened

FFATAL 

whether with fatal error


Constructor & Destructor Documentation

kyotocabinet::TreeDB::TreeDB (  )  [explicit]

Default constructor.

virtual kyotocabinet::TreeDB::~TreeDB (  )  [virtual]

Destructor.

Note:
If the database is not closed, it is closed implicitly.

Member Function Documentation

virtual bool kyotocabinet::TreeDB::accept ( const char *  kbuf,
size_t  ksiz,
Visitor visitor,
bool  writable = true 
) [virtual]

Accept a visitor to a record.

Parameters:
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.
Returns:
true on success, or false on failure.
Note:
the operation for each record is performed atomically and other threads accessing the same record are blocked.

Implements kyotocabinet::DB.

virtual bool kyotocabinet::TreeDB::iterate ( Visitor visitor,
bool  writable = true 
) [virtual]

Iterate to accept a visitor for each record.

Parameters:
visitor a visitor object.
writable true for writable operation, or false for read-only operation.
Returns:
true on success, or false on failure.
Note:
the whole iteration is performed atomically and other threads are blocked.

Implements kyotocabinet::DB.

virtual Error kyotocabinet::TreeDB::error (  )  const [virtual]

Get the last happened error.

Returns:
the last happened error.

Implements kyotocabinet::FileDB.

virtual void kyotocabinet::TreeDB::set_error ( Error::Code  code,
const char *  message 
) [virtual]

Set the error information.

Parameters:
code an error code.
message a supplement message.
virtual bool kyotocabinet::TreeDB::open ( const std::string &  path,
uint32_t  mode = OWRITER | OCREATE 
) [virtual]

Open a database file.

Parameters:
path the path of a database file.
mode the connection mode. TreeDB::OWRITER as a writer, TreeDB::OREADER as a reader. The following may be added to the writer mode by bitwise-or: TreeDB::OCREATE, which means it creates a new database if the file does not exist, TreeDB::OTRUNCATE, which means it creates a new database regardless if the file exists, TreeDB::OAUTOTRAN, which means each updating operation is performed in implicit transaction, TreeDB::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: TreeDB::ONOLOCK, which means it opens the database file without file locking, TreeDB::OTRYLOCK, which means locking is performed without blocking, TreeDB::ONOREPAIR, which means the database file is not repaired implicitly even if file destruction is detected.
Returns:
true on success, or false on failure.
Note:
Every opened database must be closed by the TreeDB::close method when it is no longer in use.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::close (  )  [virtual]

Close the database file.

Returns:
true on success, or false on failure.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::synchronize ( bool  hard = false,
FileProcessor proc = NULL 
) [virtual]

Synchronize updated contents with the file and the device.

Parameters:
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.
Returns:
true on success, or false on failure.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::begin_transaction ( bool  hard = false  )  [virtual]

Begin transaction.

Parameters:
hard true for physical synchronization with the device, or false for logical synchronization with the file system.
Returns:
true on success, or false on failure.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::begin_transaction_try ( bool  hard = false  )  [virtual]

Try to begin transaction.

Parameters:
hard true for physical synchronization with the device, or false for logical synchronization with the file system.
Returns:
true on success, or false on failure.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::end_transaction ( bool  commit = true  )  [virtual]

End transaction.

Parameters:
commit true to commit the transaction, or false to abort the transaction.
Returns:
true on success, or false on failure.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::clear (  )  [virtual]

Remove all records.

Returns:
true on success, or false on failure.

Implements kyotocabinet::DB.

virtual int64_t kyotocabinet::TreeDB::count (  )  [virtual]

Get the number of records.

Returns:
the number of records, or -1 on failure.

Implements kyotocabinet::DB.

virtual int64_t kyotocabinet::TreeDB::size (  )  [virtual]

Get the size of the database file.

Returns:
the size of the database file in bytes, or -1 on failure.

Implements kyotocabinet::FileDB.

virtual std::string kyotocabinet::TreeDB::path (  )  [virtual]

Get the path of the database file.

Returns:
the path of the database file in bytes, or an empty string on failure.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::status ( std::map< std::string, std::string > *  strmap  )  [virtual]

Get the miscellaneous status information.

Parameters:
strmap a string map to contain the result.
Returns:
true on success, or false on failure.

Implements kyotocabinet::FileDB.

virtual Cursor* kyotocabinet::TreeDB::cursor (  )  [virtual]

Create a cursor object.

Returns:
the return value is the created cursor object.
Note:
Because the object of the return value is allocated by the constructor, it should be released with the delete operator when it is no longer in use.

Implements kyotocabinet::FileDB.

virtual bool kyotocabinet::TreeDB::tune_error_reporter ( std::ostream *  erstrm,
bool  ervbs 
) [virtual]

Set the internal error reporter.

Parameters:
erstrm a stream object into which internal error messages are stored.
ervbs true to report all errors, or false to report fatal errors only.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_alignment ( int8_t  apow  )  [virtual]

Set the power of the alignment of record size.

Parameters:
apow the power of the alignment of record size.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_fbp ( int8_t  fpow  )  [virtual]

Set the power of the capacity of the free block pool.

Parameters:
fpow the power of the capacity of the free block pool.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_options ( int8_t  opts  )  [virtual]

Set the optional features.

Parameters:
opts the optional features by bitwise-or: TreeDB::TSMALL to use 32-bit addressing, TreeDB::TLINEAR to use linear collision chaining, TreeDB::TCOMPRESS to compress each record.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_buckets ( int64_t  bnum  )  [virtual]

Set the number of buckets of the hash table.

Parameters:
bnum the number of buckets of the hash table.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_page ( int32_t  psiz  )  [virtual]

Set the size of each page.

Parameters:
psiz the size of each page.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_map ( int64_t  msiz  )  [virtual]

Set the size of the internal memory-mapped region.

Parameters:
msiz the size of the internal memory-mapped region.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_defrag ( int64_t  dfunit  )  [virtual]

Set the unit step number of auto defragmentation.

Parameters:
dfunit the unit step number of auto defragmentation.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_page_cache ( int64_t  pccap  )  [virtual]

Set the capacity of the total size of the page cache.

Parameters:
pccap the capacity of the total size of the page cache.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_compressor ( Compressor comp  )  [virtual]

Set the data compressor.

Parameters:
comp the data compressor object.
Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::tune_comparator ( Comparator rcomp  )  [virtual]

Set the record comparator.

Parameters:
rcomp the record comparator object.
Returns:
true on success, or false on failure.
virtual char* kyotocabinet::TreeDB::opaque (  )  [virtual]

Get the opaque data.

Returns:
the pointer to the opaque data region, whose size is 16 bytes.
virtual bool kyotocabinet::TreeDB::synchronize_opaque (  )  [virtual]

Synchronize the opaque data.

Returns:
true on success, or false on failure.
virtual bool kyotocabinet::TreeDB::defrag ( int64_t  step  )  [virtual]

Perform defragmentation of the file.

Parameters:
step the number of steps. If it is not more than 0, the whole region is defraged.
Returns:
true on success, or false on failure.
virtual uint8_t kyotocabinet::TreeDB::flags (  )  [virtual]

Get the status flags.

Returns:
the status flags, or 0 on failure.
virtual void kyotocabinet::TreeDB::set_error ( const char *  file,
int32_t  line,
Error::Code  code,
const char *  message 
) [protected, virtual]

Set the error information.

Parameters:
file the file name of the epicenter.
line the line number of the epicenter.
code an error code.
message a supplement message.

Generated by  doxygen 1.6.2