Specifications of QDBM for C++

Table of Contents

QDBM provides API for C++. This encapsulates the basic API, the extended API and the advanced API of QDBM, and make them thread-safe.

The basic API for C++ realizes a hash database with a file. Constructors of the class `Depot' open a database file. The member function `close' is used in order to close the database. If the instance is destroyed without closing the database explicitly, the destructor closes the database. The member function `put' is used in order to store a record. The member function `out' is used in order to delete a record. The member function `get' is used in order to retrieve a record. Besides, most operations like ones of the basic API for C are available. Each member functions throws an instance of the class `Depot_error' if an error occurs.

The extended API for C++ realizes a hash database with a directory and multiple files. Constructors of the class `Curia' open a database directory. The member function `close' is used in order to close the database. If the instance is destroyed without closing the database explicitly, the destructor closes the database. The member function `put' is used in order to store a record. The member function `out' is used in order to delete a record. The member function `get' is used in order to retrieve a record. Operations for managing large objects are also provided. Besides, most operations like ones of the extended API for C are available. Each member functions throws an instance of the class `Curia_error' if an error occurs.

The advanced API for C++ realizes a B+ tree database with a file. Constructors of the class `Villa' open a database file. The member function `close' is used in order to close the database. If the instance is destroyed without closing the database explicitly, the destructor closes the database. The member function `put' is used in order to store a record. The member function `out' is used in order to delete a record. The member function `get' is used in order to retrieve a record. Besides, most operations like ones of the advanced API for C are available. Each member functions throws an instance of the class `Villa_error' if an error occurs.

`Depot', `Curia', and `Villa' are derived classes of the class `ADBM'. This class is an interface for abstraction of database managers compatible with DBM of UNIX standard. This class does only declare pure virtual functions. Each member functions throws an instance of the class `DBM_error'. In this framework, a key and a value of each record are expressed by the class `Datum'. An instance of `Datum' has the pointer to the region of data and its size. When you choose the one of four APIs, `Depot' is suggested if performance is weighted, `Curia' is suggested if scalability is weighted, `Villa' is suggested if ordering access is required, `ADBM' is suggested if elegance and maintenance are weighted. Besides, a database file is not compatible with each API.

You should include the following header files in source files of applications: `xdepot.h' for `Depot', `xcuria.h' for `Curia', `xvilla.h' for `Villa', and `xadbm.h' for `ADBM'. Besides, each class is packaged in the name space `qdbm'.

While APIs for C are thread-safe unless plural threads do not share a database handle, APIs for C++ are thread-safe even if plural threads share a handle. This API is implemented depending on the POSIX thread package. If you use another thread package, you should write your own C++ wrapper.

When `put' overwriting an existing record is cancelled or `get' retrieving a missing record, failure of the operation is noticed by exception. If you dislike such behavior, set the `silent' flag to be true. Then, failure of the operation is noticed by the return value.

For more information about the APIs, read documents in the sub directory `xapidoc' and each header file.

Preparation

Make sure that GCC 3.3 or later version is installed. And make sure that QDBM is installed under `/usr/local'.

Change the current working directory to the sub directory named `plus'.

cd plus

Usual Steps

Run the configuration script.

./configure

Build programs.

make

Perform self-diagnostic test.

make check

Install programs. This operation must be carried out by the root user.

make install

When a series of work finishes, header files, `xdepot.h', `xcuria.h', `xvilla.h', and `xadbm.h' will be installed in `/usr/local/include', a library `libxqdbm.so' and so on will be installed in `/usr/local/lib', executable commands `xdptest', `xcrtest', and `xvltest' will be installed in `/usr/local/bin'.

To uninstall them, execute the following command after `./configure'. This operation must be carried out by the root user.

make uninstall

For Windows

On Windows (Cygwin), you should follow the procedures below for installation.

QDBM has restrictions that two or more handles of the same database file should not be used by a process at the same time. So, when a database is used by two or more threads, open the database in the main thread and pass the handle to each thread.

Because QDBM does not provide mechanism that serialize generic objects and store them into a database, if you want it, you should extend the class `ADBM'. Besides, if the comparing function of `Villa' compares deserialized objects, the database can be used as an object-oriented database.