SplinterDB is an embedded key-value store. It is currently Linux-only.
To use SplinterDB, you must link your program to the library and call
the C functions declared in the include/splinterdb
headers. More details on our build process are here.
This document is a high-level overview, but the code comments in the header files are the definitive API reference. We're actively evolving our public API surface right now, and will do our best to keep this document up to date as details change. If something looks out-of-date, please open an issue or pull request.
-
Choose values for configuration options defined in the
splinterdb_config{}structure. For thedata_cfgfield, simple applications may opt to use thedefault_data_config_init()initializer method which provides a basic key / value interface with lexicographical sorting of keys. -
Call
splinterdb_create()to create a new database in a file or block device,splinterdb_open()to open an existing database, andsplinterdb_close()to flush any pending writes and close the database.All access to a SplinterDB database file or device must go through the single
splinterdb*object returned. It is not safe for more than one process to open the same SplinterDB database file or device. -
Basic key/value operations like
insert,delete, pointlookupand range scan using aniteratorare available. See the code comments insplinterdb.h. -
If an application frequently makes small modifications to existing values, better performance may be possible by using a custom
data_configobject and thesplinterdb_insert_raw_message()function. A raw message may encode a "blind update" to a value, for example an "append" or "increment" operation that may be persisted without doing a read. Some applications may be able to avoid a read-modify-write sequence this way. To use the message-oriented API, the application implements thedata_configinterface defined indata.h) and sets it onsplinterdb_configwhen creating/opening a database. -
SplinterDB is designed to deliver high-performance for multi-threaded applications, but follow these guidelines:
-
The thread which called
splinterdb_create()orsplinterdb_open()is called the "initial thread". -
The initial thread should be the one to call
splinterdb_close()when thesplinterdbinstance is no longer needed. -
Threads are registered automatically the first time they call a SplinterDB public API, and are deregistered automatically when they exit. Internally, SplinterDB allocates per-thread scratch space at registration time.
-
The low-level thread registration APIs remain available for tests and callers that want to reserve or release a thread ID explicitly.
-
Note these rules apply to system threads, not runtime-managed threading available in higher-level languages.
-
-
Internally SplinterDB supports asynchronous IO, but this capability is not yet documented. Some example code for this may be found in the unit and functional tests.
tests/unit/splinterdb_quick_test.ccovers various basic operations on a single thread. The setup step shows how to specify a default configuration and then create a new instance.tests/unit/splinterdb_stress_test.cuses multiple threadstests/unit/splinter_test.ccovers slightly advanced steps to create a SplinterDB instance. It covers configuration of a SplinterDB instance, creating heap memory, allocating memory for various sub-system configurations, and initialization of individual sub-systems.