Commit 67cedd5b authored by Yoni Fogel's avatar Yoni Fogel

Added Db.set_bt_compare and Db.remove

test1 modified to test the new features.

git-svn-id: file:///svn/tokudb@1289 c7de825b-a66e-492c-adef-691d508d4ae1
parent e669f589
......@@ -60,8 +60,18 @@ int Db::cursor(DbTxn *txn, Dbc **cursorp, u_int32_t flags) {
int ret = the_db->cursor(the_db, txn->get_DB_TXN(), (DBC**)cursorp, flags);
return ret;
}
int Db::set_pagesize(u_int32_t size) {
int ret = the_db->set_pagesize(the_db, size);
return ret;
}
int Db::remove(const char *file, const char *database, u_int32_t flags) {
int ret = the_db->remove(the_db, file, database, flags);
return ret;
}
int Db::set_bt_compare(bt_compare_fcn_type bt_compare_fcn) {
int ret = the_db->set_bt_compare(the_db, bt_compare_fcn);
return ret;
}
#include <db_cxx.h>
#include <errno.h>
#include <iostream>
using namespace std;
int main()
{
void test_dbt(void) {
u_int32_t size = 3;
u_int32_t flags = 5;
u_int32_t ulen = 7;
......@@ -19,6 +20,24 @@ int main()
assert(dbt.get_flags() == flags);
assert(dbt.get_data() == data);
assert(dbt.get_ulen() == ulen);
}
int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) {
return 0;
}
void test_db(void) {
Db db(NULL, 0);
int r;
r = db.set_bt_compare(cmp); assert(r == 0);
r = db.remove("DoesNotExist.db", NULL, 0); assert(r == ENOENT);
}
int main()
{
test_dbt();
test_db();
cout << "Hello World!" << endl; cout << "Welcome to C++ Programming" << endl;
return 0;
}
......@@ -35,6 +35,10 @@ class Dbt : private DBT
// Nothing here.
};
extern "C" {
typedef int (*bt_compare_fcn_type)(DB *db, const DBT *dbt1, const DBT *dbt2);
};
class Db {
public:
/* Functions to make C++ work, defined in the BDB C++ API documents */
......@@ -64,6 +68,8 @@ class Db {
int get_flags(u_int32_t *);
int set_flags(u_int32_t);
int set_pagesize(u_int32_t);
int remove(const char *file, const char *database, u_int32_t flags);
int set_bt_compare(bt_compare_fcn_type bt_compare_fcn);
private:
DB *the_db;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment