KitaroDB 2.0 API for C++
High Performance NoSQL for Win32
Using KitaroDB for C++ development

KitaroDB includes a library of classes and enumerations (in the KitaroDB namespace) that enable you to create and manage KitaroDB databases and to create, access, and modify key-value pairs or records in a KitaroDB database. Once you've installed KitaroDB and added a reference to db.h in your Visual Studio C++ project, you can use the KitaroDB API for C++ to do the following. For more information, see KitaroDB basics.

▶  Create a KitaroDB database

You can create a key-value pair database or an intrusive-keyed database (a database that has structure-based records and that can have multiple indexes). To create a key-value pair database, simply use one of the DB.Create factory methods. To create an intrusive-keyed database, use the DBKey constructor to define the second and subsequent keys; then use the DB.Create factory method that accepts an array of keys. Note that you can create segmented keys, which enable you to sort on non-contiguous sections of a record and on different types. (The DBKeySegment constructor enables you to define segments.) See Creating a KitaroDB database for details.

▶  Open a KitaroDB database

To open an existing KitaroDB database, use DB.Open. Note that you can open a KitaroDB database from a previous version of KitaroDB, but access will be read only.

▶  Insert a key-value pair or record

To insert a key-value pair or a record, use DB.Insert. See Inserting a record or key-value pair for details.

▶  Use a cursor to filter, traverse, and lock records or key-value pairs

Cursors enable you to filter, traverse over, and lock key-value pairs and records. There are two types of cursor: discriminated and unfiltered. Use DB.Select to create a discriminated cursor, which limits subsequent cursor operations to key-value pairs or records that match the key passed to DB.Select. Use DB.Seek to create an unfiltered cursor. With an unfiltered cursor, subsequent cursor operations apply to all key-value pairs or records in the database. When you open a cursor, you can set read/lock modes (which include modes for automatic unlocking and manual unlocking using DBCursor.UnlockGRFA). And once a cursor has been opened, you can reposition it using DBCursor.MoveFirst, DBCursor.MoveLast, DBCursor.MoveNext, DBCursor.MovePrevious, or DBCursor.Seek. See Using cursors for details.

▶  Read a key-value pair or record

There are two ways to read data. Either pass a key directly to DB.Get, or use DBCursor.Get or DBCursor.GetString to get the value for the key-value pair or record at the current cursor position. See Reading, updating, deleting for more information.

▶  Update a key-value pair or record

There are two ways to update data. Either pass a key directly to DB.Update, or use DBCursor.Update to update the key-value pair or record at the current cursor position. See Reading, updating, deleting for more information.

▶  Delete a key-value pair or record

There are two ways to delete a key-value pair or record. Either pass a key directly to DB.Delete, or use DBCursor.Delete to delete the key-value pair or record at the current cursor position. See Reading, updating, deleting for more information.

▶  Handle errors

Errors are derived from the std::exception class. See Handling errors.

▶  Get information about keys, segments, GRFAs, and record length

To get all keys defined for an intrusive-keyed database, use DB.GetKeys.

To get the key for the current cursor location, use DBCursor.GetKey or DBCursor.GetKeyString.

To get information about a key, use DBKey methods (KeySize, KeyPosition, etc.).

To get information about a segment, use DBKeySegment methods (SegmentSize, SegmentPosition, etc.).

To get the global record file address (GRFA) for a record, use DBCursor.GetGRFA. (See KitaroDB basics for more information.)

To retrieve the maximum record length for a database, use the DB.MaxRecordLength method.

▶  Rename or delete a KitaroDB database

To rename a KitaroDB database, including both the index and data files for the database, use the DB.Rename method.

To delete a KitaroDB database, use the DB.Purge method. This deletes the index file and data file for the database.