Skip to content

Instantly share code, notes, and snippets.

@mschoch
Created October 31, 2014 01:47
Show Gist options
  • Save mschoch/7a5fb25d8ce2b485ffde to your computer and use it in GitHub Desktop.
Save mschoch/7a5fb25d8ce2b485ffde to your computer and use it in GitHub Desktop.
ForestDB test program with no fdb_commit()
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "libforestdb/forestdb.h"
int main(int argc, char**argv) {
fdb_handle *db;
fdb_status status;
fdb_config config;
config = fdb_get_default_config();
status = fdb_open(&db, "/tmp/db", &config);
assert(status == FDB_RESULT_SUCCESS);
printf("opened database\n");
int i;
for (i = 0; i < 100000000; i++) {
char key[10];
snprintf(key, 9, "%d", i);
int keylen = strlen(key);
status = fdb_set_kv(db, key, keylen, "BOGUSDATA", 9);
assert(status == FDB_RESULT_SUCCESS);
if((i+1)%1000000 == 0) {
printf("written %d keys\n", i+1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment