Please download the BangDB for linux native file and un-compress it. Run the install.sh file to install the BangDB.
The download files are (once un-compressed):
To run the test files, simply download the tar file, untar it and then cd to the directory and run following command;
g++ -D_FILE_OFFSET_BITS=64 -O3 bench.cpp -obench -lpthread -lbangdb
Then run the exe with command line arg as suggested by the exe. For example to put and get 100,000 items with 4 threads run
./bench 4 100000 all
/* Create db, table and connection */
database *db = new database((char*)"mydb");
table *tbl = db->gettable((char*)"mytbl", 0);
if(tbl == NULL)
{
printf("Table is NULL, quitting");
return -1;
}
connection *conn = tbl->getconnection();
if(conn == NULL)
{
printf("Connection is NULL, quitting");
return -1;
}
/* do some operations */
char *key = "key_1";
char *val = "This is the test value for key_1";
/* put */
if(conn->put(key, val, INSERT_UNIQUE) < 0)
printf("Put error");
/* get */
char *out = conn->get(key);
if(out == NULL)
printf("Get error");
/* update */
val = "Update value for the test key";
if(conn->put(key, val, UPDATE_EXISTING) < 0)
printf("Update error");
/* del */
if(conn->del(key) < 0)
printf("Del error");
/* try to get the del key */
if(conn->get(key) != NULL)
printf("Got the deleted value, error");
I have just used char string for keys and values, however, you can use any arbitrary bytes for these using FDT data type. Also look at the general getting started for example using FDT Check out more in the available test/bench files which can be downloaded for further experiments.