Commit 9f54dcef authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Rename a bunch of symbols to toku_symbols. Addresses #8.

git-svn-id: file:///svn/tokudb@823 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6b2f1c61
......@@ -34,12 +34,12 @@ void setup (void) {
int r;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, nodesize, ct, NULL_TXN, toku_default_compare_fun, (DB*)0); assert(r==0);
r = toku_open_brt(fname, 0, 1, &t, nodesize, ct, NULL_TXN, toku_default_compare_fun, (DB*)0); assert(r==0);
}
void shutdown (void) {
int r;
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
void long_long_to_array (unsigned char *a, unsigned long long l) {
......@@ -55,7 +55,7 @@ void insert (long long v) {
long_long_to_array(kc, v);
memset(vc, 0, sizeof vc);
long_long_to_array(vc, v);
brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0);
toku_brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0);
if (do_verify) toku_cachetable_verify(ct);
}
......
......@@ -6,7 +6,7 @@ static int brt_root_put_cmd_XY (BRT brt, BRT_CMD *md, TOKUTXN txn) {
}
CACHEKEY *rootp = toku_calculate_root_offset_pointer(brt);
if ((r=cachetable_get_and_pin(brt->cf, *rootp, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, (void*)(long)brt->h->nodesize))) {
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, (void*)(long)brt->h->nodesize))) {
goto died0;
}
node=node_v;
......
......@@ -119,10 +119,7 @@ int toku_serialize_brt_header_to (int fd, struct brt_header *h);
int toku_serialize_brt_header_to_wbuf (struct wbuf *, struct brt_header *h);
int toku_deserialize_brtheader_from (int fd, DISKOFF off, struct brt_header **brth);
/* return the size of a tree node */
long brtnode_size (BRTNODE node);
void brtnode_free (BRTNODE *node);
void toku_brtnode_free (BRTNODE *node);
//static inline int brtnode_n_hashtables(BRTNODE node) { if (node->height==0) return 1; else return node->u.n.n_children; }
......@@ -175,11 +172,6 @@ void toku_brt_cursor_nonleaf_expand(BRT_CURSOR cursor, BRT t, BRTNODE oldnode, i
/* a brt internal node has split. modify this cursor if it includes the old node in its path. */
void toku_brt_cursor_nonleaf_split(BRT_CURSOR cursor, BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right);
void brt_update_cursors_new_root(BRT t, BRTNODE newroot, BRTNODE left, BRTNODE right);
void brt_update_cursors_leaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right);
void brt_update_cursors_nonleaf_expand(BRT t, BRTNODE oldnode, int childnum, BRTNODE left, BRTNODE right);
void brt_update_cursors_nonleaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right);
enum brt_cmd_type {
BRT_NONE = 0,
BRT_INSERT = 1,
......@@ -205,8 +197,8 @@ struct brtenv {
// SPINLOCK checkpointing;
};
extern cachetable_flush_func_t brtnode_flush_callback, brtheader_flush_callback;
extern cachetable_fetch_func_t brtnode_fetch_callback, brtheader_fetch_callback;
extern cachetable_flush_func_t toku_brtnode_flush_callback, toku_brtheader_flush_callback;
extern cachetable_fetch_func_t toku_brtnode_fetch_callback, toku_brtheader_fetch_callback;
extern int toku_read_and_pin_brt_header (CACHEFILE cf, struct brt_header **header);
extern int toku_unpin_brt_header (BRT brt);
extern CACHEKEY* toku_calculate_root_offset_pointer (BRT brt);
......
......@@ -91,7 +91,7 @@ void test_serialize(void) {
assert(datalen==5);
assert(type == BRT_NONE);
}
brtnode_free(&dn);
toku_brtnode_free(&dn);
kv_pair_free(sn.u.n.childkeys[0]);
toku_free(hello_string);
......
......@@ -31,11 +31,11 @@ static void test0 (void) {
assert(r==0);
printf("%s:%d test0\n", __FILE__, __LINE__);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
//printf("%s:%d test0\n", __FILE__, __LINE__);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
r = toku_cachetable_close(&ct);
assert(r==0);
......@@ -53,16 +53,16 @@ static void test1 (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_txn);
toku_brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_txn);
{
r = brt_lookup(t, fill_dbt(&k, "hello", 6), init_dbt(&v));
r = toku_brt_lookup(t, fill_dbt(&k, "hello", 6), init_dbt(&v));
assert(r==0);
assert(strcmp(v.data, "there")==0);
assert(v.size==6);
}
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
printf("test1 ok\n");
......@@ -79,7 +79,7 @@ static void test2 (int memcheck) {
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
printf("%s:%d did setup\n", __FILE__, __LINE__);
assert(r==0);
for (i=0; i<2048; i++) {
......@@ -87,7 +87,7 @@ static void test2 (int memcheck) {
char key[100],val[100];
snprintf(key,100,"hello%d",i);
snprintf(val,100,"there%d",i);
brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
//printf("%s:%d did insert %d\n", __FILE__, __LINE__, i);
if (0) {
brt_flush(t);
......@@ -100,7 +100,7 @@ static void test2 (int memcheck) {
}
}
printf("%s:%d inserted\n", __FILE__, __LINE__);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
printf("test2 ok\n");
......@@ -118,16 +118,16 @@ static void test3 (int nodesize, int count, int memcheck) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
for (i=0; i<count; i++) {
char key[100],val[100];
DBT k,v;
snprintf(key,100,"hello%d",i);
snprintf(val,100,"there%d",i);
brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
}
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
gettimeofday(&t1, 0);
......@@ -149,16 +149,16 @@ static void test4 (int nodesize, int count, int memcheck) {
memory_check=memcheck;
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
for (i=0; i<count; i++) {
char key[100],val[100];
int rv = random();
DBT k,v;
snprintf(key,100,"hello%d",rv);
snprintf(val,100,"there%d",i);
brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
}
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
gettimeofday(&t1, 0);
......@@ -181,7 +181,7 @@ static void test5 (void) {
for (i=0; i<limit; i++) values[i]=-1;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(fname, 0, 1, &t, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
for (i=0; i<limit/2; i++) {
char key[100],val[100];
int rk = random()%limit;
......@@ -191,7 +191,7 @@ static void test5 (void) {
snprintf(key, 100, "key%d", rk);
snprintf(val, 100, "val%d", rv);
DBT k,v;
brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
}
printf("\n");
for (i=0; i<limit/2; i++) {
......@@ -202,7 +202,7 @@ static void test5 (void) {
if (i%1000==0) printf("r"); fflush(stdout);
snprintf(key, 100, "key%d", rk);
snprintf(valexpected, 100, "val%d", values[rk]);
r = brt_lookup(t, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&v));
r = toku_brt_lookup(t, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&v));
assert(r==0);
assert(v.size==(1+strlen(valexpected)));
assert(memcmp(v.data,valexpected,v.size)==0);
......@@ -210,7 +210,7 @@ static void test5 (void) {
}
printf("\n");
toku_free(values);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
}
......@@ -224,10 +224,10 @@ static void test_dump_empty_db (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
dump_brt(t);
r = close_brt(t); assert(r==0);
toku_dump_brt(t);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
}
......@@ -244,16 +244,16 @@ static void test_multiple_files_of_size (int size) {
unlink(n1);
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, 0, 1, &t0, size, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = open_brt(n1, 0, 1, &t1, size, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n0, 0, 1, &t0, size, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, 0, 1, &t1, size, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
for (i=0; i<10000; i++) {
char key[100],val[100];
DBT k,v;
snprintf(key, 100, "key%d", i);
snprintf(val, 100, "val%d", i);
brt_insert(t0, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
toku_brt_insert(t0, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
snprintf(val, 100, "Val%d", i);
brt_insert(t1, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
toku_brt_insert(t1, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
}
//toku_verify_brt(t0);
//dump_brt(t0);
......@@ -261,36 +261,36 @@ static void test_multiple_files_of_size (int size) {
toku_verify_brt(t0);
toku_verify_brt(t1);
r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0);
r = toku_close_brt(t0); assert(r==0);
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
/* Now see if the data is all there. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db);
printf("%s:%d r=%d\n", __FILE__, __LINE__,r);
assert(r==0);
r = open_brt(n1, 0, 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, 0, 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
for (i=0; i<10000; i++) {
char key[100],val[100];
DBT k,actual;
snprintf(key, 100, "key%d", i);
snprintf(val, 100, "val%d", i);
r=brt_lookup(t0, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual));
r=toku_brt_lookup(t0, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual));
assert(r==0);
assert(strcmp(val,actual.data)==0);
assert(actual.size==1+strlen(val));
snprintf(val, 100, "Val%d", i);
r=brt_lookup(t1, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual));
r=toku_brt_lookup(t1, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual));
assert(r==0);
assert(strcmp(val,actual.data)==0);
assert(actual.size==1+strlen(val));
}
r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0);
r = toku_close_brt(t0); assert(r==0);
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
}
......@@ -313,27 +313,27 @@ static void test_named_db (void) {
unlink(n1);
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_txn); assert(r==0);
toku_brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_txn); assert(r==0);
r = close_brt(t0); assert(r==0);
r = toku_close_brt(t0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
{
r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v));
r = toku_brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v));
assert(r==0);
assert(v.size==4);
assert(strcmp(v.data,"day")==0);
}
r = close_brt(t0); assert(r==0);
r = toku_close_brt(t0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
}
......@@ -350,42 +350,42 @@ static void test_multiple_dbs (void) {
unlink(n1);
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_txn); assert(r==0);
brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_txn); assert(r==0);
toku_brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_txn); assert(r==0);
toku_brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_txn); assert(r==0);
r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0);
r = toku_close_brt(t0); assert(r==0);
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
{
r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v));
r = toku_brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v));
assert(r==0);
assert(v.size==6);
assert(strcmp(v.data,"grief")==0);
r = brt_lookup(t1, fill_dbt(&k, "good", 5), init_dbt(&v));
r = toku_brt_lookup(t1, fill_dbt(&k, "good", 5), init_dbt(&v));
assert(r!=0);
r = brt_lookup(t0, fill_dbt(&k, "bad", 4), init_dbt(&v));
r = toku_brt_lookup(t0, fill_dbt(&k, "bad", 4), init_dbt(&v));
assert(r!=0);
r = brt_lookup(t1, fill_dbt(&k, "bad", 4), init_dbt(&v));
r = toku_brt_lookup(t1, fill_dbt(&k, "bad", 4), init_dbt(&v));
assert(r==0);
assert(v.size==6);
assert(strcmp(v.data,"night")==0);
}
r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0);
r = toku_close_brt(t0); assert(r==0);
r = toku_close_brt(t1); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
......@@ -406,7 +406,7 @@ static void test_multiple_dbs_many (void) {
for (i=0; i<MANYN; i++) {
char dbname[20];
snprintf(dbname, 20, "db%d", i);
r = open_brt(name, dbname, 1, &trees[i], 1<<12, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(name, dbname, 1, &trees[i], 1<<12, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
}
for (i=0; i<MANYN; i++) {
......@@ -414,10 +414,10 @@ static void test_multiple_dbs_many (void) {
DBT kdbt,vdbt;
snprintf(k, 20, "key%d", i);
snprintf(v, 20, "val%d", i);
brt_insert(trees[i], fill_dbt(&kdbt, k, strlen(k)+1), fill_dbt(&vdbt, v, strlen(v)+1), null_txn);
toku_brt_insert(trees[i], fill_dbt(&kdbt, k, strlen(k)+1), fill_dbt(&vdbt, v, strlen(v)+1), null_txn);
}
for (i=0; i<MANYN; i++) {
r = close_brt(trees[i]); assert(r==0);
r = toku_close_brt(trees[i]); assert(r==0);
}
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
......@@ -435,7 +435,7 @@ static void test_multiple_brts_one_db_one_file (void) {
unlink(name);
r = toku_brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) {
r = open_brt(name, 0, (i==0), &trees[i], 1<<12, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(name, 0, (i==0), &trees[i], 1<<12, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
}
for (i=0; i<MANYN; i++) {
......@@ -443,20 +443,20 @@ static void test_multiple_brts_one_db_one_file (void) {
DBT kb, vb;
snprintf(k, 20, "key%d", i);
snprintf(v, 20, "val%d", i);
brt_insert(trees[i], fill_dbt(&kb, k, strlen(k)+1), fill_dbt(&vb, v, strlen(v)+1), null_txn);
toku_brt_insert(trees[i], fill_dbt(&kb, k, strlen(k)+1), fill_dbt(&vb, v, strlen(v)+1), null_txn);
}
for (i=0; i<MANYN; i++) {
char k[20],vexpect[20];
DBT kb, vb;
snprintf(k, 20, "key%d", i);
snprintf(vexpect, 20, "val%d", i);
r=brt_lookup(trees[0], fill_dbt(&kb, k, strlen(k)+1), init_dbt(&vb));
r=toku_brt_lookup(trees[0], fill_dbt(&kb, k, strlen(k)+1), init_dbt(&vb));
assert(r==0);
assert(vb.size==1+strlen(vexpect));
assert(strcmp(vb.data, vexpect)==0);
}
for (i=0; i<MANYN; i++) {
r=close_brt(trees[i]); assert(r==0);
r=toku_close_brt(trees[i]); assert(r==0);
}
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
......@@ -478,34 +478,34 @@ static void test_read_what_was_written (void) {
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = close_brt(brt); assert(r==0);
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
/* Now see if we can read an empty tree in. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
/* See if we can put something in it. */
{
DBT k,v;
brt_insert(brt, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_txn);
toku_brt_insert(brt, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_txn);
}
r = close_brt(brt); assert(r==0);
r = toku_close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
/* Now see if we can read it in and get the value. */
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
{
DBT k,v;
r = brt_lookup(brt, fill_dbt(&k, "hello", 6), init_dbt(&v));
r = toku_brt_lookup(brt, fill_dbt(&k, "hello", 6), init_dbt(&v));
assert(r==0);
assert(v.size==6);
assert(strcmp(v.data,"there")==0);
......@@ -525,11 +525,11 @@ static void test_read_what_was_written (void) {
int verify_result=toku_verify_brt(brt);;
assert(verify_result==0);
}
brt_insert(brt, fill_dbt(&k, key, strlen(key)+1), fill_dbt(&v, val, strlen(val)+1), null_txn);
toku_brt_insert(brt, fill_dbt(&k, key, strlen(key)+1), fill_dbt(&v, val, strlen(val)+1), null_txn);
if (i<600) {
int verify_result=toku_verify_brt(brt);
if (verify_result) {
dump_brt(brt);
toku_dump_brt(brt);
assert(0);
}
{
......@@ -538,10 +538,10 @@ static void test_read_what_was_written (void) {
char expectedval[100];
snprintf(key, 100, "key%d", j);
snprintf(expectedval, 100, "val%d", j);
r=brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
r=toku_brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
if (r!=0) {
printf("%s:%d r=%d on lookup(key=%s) after i=%d\n", __FILE__, __LINE__, r, key, i);
dump_brt(brt);
toku_dump_brt(brt);
}
assert(r==0);
}
......@@ -563,25 +563,25 @@ static void test_read_what_was_written (void) {
DBT k,v;
snprintf(key, 100, "key%d", i);
snprintf(expectedval, 100, "val%d", i);
r=brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
r=toku_brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
if (r!=0) printf("%s:%d r=%d on key=%s\n", __FILE__, __LINE__, r, key);
assert(r==0);
}
}
r = close_brt(brt); assert(r==0);
r = toku_close_brt(brt); assert(r==0);
printf("%s:%d About to close %p\n", __FILE__, __LINE__, ct);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
{
DBT k,v;
r = brt_lookup(brt, fill_dbt(&k, "hello", 6), init_dbt(&v));
r = toku_brt_lookup(brt, fill_dbt(&k, "hello", 6), init_dbt(&v));
assert(r==0);
assert(v.size==6);
assert(strcmp(v.data,"there")==0);
......@@ -593,14 +593,14 @@ static void test_read_what_was_written (void) {
DBT k,v;
snprintf(key, 100, "key%d", i);
snprintf(expectedval, 100, "val%d", i);
r=brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
r=toku_brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
if (r!=0) printf("%s:%d r=%d on key=%s\n", __FILE__, __LINE__, r, key);
assert(r==0);
}
}
r = close_brt(brt); assert(r==0);
r = toku_close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
......@@ -625,7 +625,7 @@ void test_cursor_last_empty(void) {
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = toku_brt_cursor(brt, &cursor); assert(r==0);
init_dbt(&kbt);
......@@ -638,7 +638,7 @@ void test_cursor_last_empty(void) {
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_FIRST, null_txn);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
assert(r==DB_NOTFOUND);
r = close_brt(brt);
r = toku_close_brt(brt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
......@@ -657,10 +657,10 @@ void test_cursor_next (void) {
memory_check_all_free();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = brt_insert(brt, fill_dbt(&kbt, "hello", 6), fill_dbt(&vbt, "there", 6), null_txn);
r = brt_insert(brt, fill_dbt(&kbt, "byebye", 7), fill_dbt(&vbt, "byenow", 7), null_txn);
r = toku_brt_insert(brt, fill_dbt(&kbt, "hello", 6), fill_dbt(&vbt, "there", 6), null_txn);
r = toku_brt_insert(brt, fill_dbt(&kbt, "byebye", 7), fill_dbt(&vbt, "byenow", 7), null_txn);
printf("%s:%d calling toku_brt_cursor(...)\n", __FILE__, __LINE__);
r = toku_brt_cursor(brt, &cursor); assert(r==0);
init_dbt(&kbt);
......@@ -688,7 +688,7 @@ void test_cursor_next (void) {
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
assert(r==DB_NOTFOUND);
r = close_brt(brt);
r = toku_close_brt(brt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
......@@ -737,7 +737,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
//printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p);
if (0) { // ???? Why is this commented out?
r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun, &nonce_db); assert(r==0);
r = toku_open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun, &nonce_db); assert(r==0);
for (i=1; i<257; i+=255) {
unsigned char a[4],b[4];
b[3] = a[0] = i&255;
......@@ -749,7 +749,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__,
((char*)kbt.data)[0], ((char*)kbt.data)[1], ((char*)kbt.data)[2], ((char*)kbt.data)[3],
((char*)vbt.data)[0], ((char*)vbt.data)[1], ((char*)vbt.data)[2], ((char*)vbt.data)[3]);
r = brt_insert(brt, &kbt, &vbt, null_txn);
r = toku_brt_insert(brt, &kbt, &vbt, null_txn);
assert(r==0);
}
r = toku_brt_cursor(brt, &cursor); assert(r==0);
......@@ -765,12 +765,12 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
}
r = close_brt(brt);
r = toku_close_brt(brt);
}
{
toku_cachetable_verify(ct);
r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun, &nonce_db); assert(r==0);
r = toku_open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun, &nonce_db); assert(r==0);
toku_cachetable_verify(ct);
for (i=0; i<N; i++) {
......@@ -784,7 +784,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
if (0) printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__,
((unsigned char*)kbt.data)[0], ((unsigned char*)kbt.data)[1], ((unsigned char*)kbt.data)[2], ((unsigned char*)kbt.data)[3],
((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]);
r = brt_insert(brt, &kbt, &vbt, null_txn);
r = toku_brt_insert(brt, &kbt, &vbt, null_txn);
assert(r==0);
toku_cachetable_verify(ct);
}
......@@ -810,7 +810,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
toku_cachetable_verify(ct);
}
r = close_brt(brt);
r = toku_close_brt(brt);
}
r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free();
......@@ -918,7 +918,7 @@ void test_brt_cursor_first(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -930,7 +930,7 @@ void test_brt_cursor_first(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
......@@ -939,7 +939,7 @@ void test_brt_cursor_first(int n, DB *db) {
else
assert_cursor_value(brt, DB_FIRST, 0);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -960,7 +960,7 @@ void test_brt_cursor_last(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert keys 0, 1, .. (n-1) */
......@@ -972,7 +972,7 @@ void test_brt_cursor_last(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
......@@ -981,7 +981,7 @@ void test_brt_cursor_last(int n, DB *db) {
else
assert_cursor_value(brt, DB_LAST, n-1);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1002,7 +1002,7 @@ void test_brt_cursor_first_last(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -1015,7 +1015,7 @@ void test_brt_cursor_first_last(int n, DB *db) {
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
......@@ -1025,7 +1025,7 @@ void test_brt_cursor_first_last(int n, DB *db) {
} else
assert_cursor_first_last(brt, 0, n-1);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1048,7 +1048,7 @@ void test_brt_cursor_rfirst(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert keys n-1, n-2, ... , 0 */
......@@ -1061,7 +1061,7 @@ void test_brt_cursor_rfirst(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
......@@ -1070,7 +1070,7 @@ void test_brt_cursor_rfirst(int n, DB *db) {
else
assert_cursor_value(brt, DB_FIRST, 0);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1123,7 +1123,7 @@ void test_brt_cursor_walk(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -1135,14 +1135,14 @@ void test_brt_cursor_walk(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
/* walk the tree */
assert_cursor_walk(brt, n);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1196,7 +1196,7 @@ void test_brt_cursor_rwalk(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -1208,14 +1208,14 @@ void test_brt_cursor_rwalk(int n, DB *db) {
fill_dbt(&kbt, &k, sizeof k);
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
/* walk the tree */
assert_cursor_rwalk(brt, n);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1275,7 +1275,7 @@ void test_brt_cursor_rand(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -1289,12 +1289,12 @@ void test_brt_cursor_rand(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = i;
fill_dbt(&vbt, &v, sizeof v);
r = brt_lookup(brt, &kbt, &vbt);
r = toku_brt_lookup(brt, &kbt, &vbt);
if (r == 0) {
printf("dup");
continue;
}
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
break;
}
......@@ -1303,7 +1303,7 @@ void test_brt_cursor_rand(int n, DB *db) {
/* walk the tree */
assert_cursor_walk_inorder(brt, n);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1328,7 +1328,7 @@ void test_brt_cursor_split(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -1339,7 +1339,7 @@ void test_brt_cursor_split(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = keyseqnum;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
......@@ -1365,7 +1365,7 @@ void test_brt_cursor_split(int n, DB *db) {
fill_dbt(&kbt, key, strlen(key)+1);
v = keyseqnum;
fill_dbt(&vbt, &v, sizeof v);
r = brt_insert(brt, &kbt, &vbt, 0);
r = toku_brt_insert(brt, &kbt, &vbt, 0);
assert(r==0);
}
......@@ -1385,7 +1385,7 @@ void test_brt_cursor_split(int n, DB *db) {
r = toku_brt_cursor_close(cursor);
assert(r==0);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1406,7 +1406,7 @@ void test_multiple_brt_cursors(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
int i;
......@@ -1420,7 +1420,7 @@ void test_multiple_brt_cursors(int n, DB *db) {
assert(r == 0);
}
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1456,7 +1456,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
int c;
......@@ -1476,7 +1476,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(brt, &key, &val, 0);
r = toku_brt_insert(brt, &key, &val, 0);
assert(r == 0);
/* point cursor i / cursor_gap to the current last key i */
......@@ -1517,7 +1517,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
assert(r == 0);
}
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1538,7 +1538,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
int i;
......@@ -1551,7 +1551,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
v = 10*i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(brt, &key, &val, 0);
r = toku_brt_insert(brt, &key, &val, 0);
assert(r == 0);
}
......@@ -1590,7 +1590,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
r = toku_brt_cursor_close(cursor);
assert(r==0);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1611,7 +1611,7 @@ void test_brt_cursor_set_range(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
r = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0);
int i;
......@@ -1625,7 +1625,7 @@ void test_brt_cursor_set_range(int n, DB *db) {
v = 10*i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(brt, &key, &val, 0);
r = toku_brt_insert(brt, &key, &val, 0);
assert(r == 0);
}
......@@ -1657,7 +1657,7 @@ void test_brt_cursor_set_range(int n, DB *db) {
r = toku_brt_cursor_close(cursor);
assert(r==0);
r = close_brt(brt);
r = toku_close_brt(brt);
assert(r==0);
r = toku_cachetable_close(&ct);
......@@ -1678,7 +1678,7 @@ void test_brt_cursor_delete(int n, DB *db) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0);
error = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
error = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(error == 0);
error = toku_brt_cursor(brt, &cursor);
......@@ -1694,7 +1694,7 @@ void test_brt_cursor_delete(int n, DB *db) {
v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
error = brt_insert(brt, &key, &val, 0);
error = toku_brt_insert(brt, &key, &val, 0);
assert(error == 0);
}
......@@ -1719,7 +1719,7 @@ void test_brt_cursor_delete(int n, DB *db) {
error = toku_brt_cursor_close(cursor);
assert(error == 0);
error = close_brt(brt);
error = toku_close_brt(brt);
assert(error == 0);
error = toku_cachetable_close(&ct);
......@@ -1740,7 +1740,7 @@ void test_brt_cursor_get_both(int n, DB *db) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0);
error = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
error = toku_open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db);
assert(error == 0);
error = toku_brt_cursor(brt, &cursor);
......@@ -1764,7 +1764,7 @@ void test_brt_cursor_get_both(int n, DB *db) {
v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
error = brt_insert(brt, &key, &val, 0);
error = toku_brt_insert(brt, &key, &val, 0);
assert(error == 0);
}
......@@ -1823,7 +1823,7 @@ void test_brt_cursor_get_both(int n, DB *db) {
error = toku_brt_cursor_close(cursor);
assert(error == 0);
error = close_brt(brt);
error = toku_close_brt(brt);
assert(error == 0);
error = toku_cachetable_close(&ct);
......@@ -1890,7 +1890,7 @@ void test_large_kv(int bsize, int ksize, int vsize) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, bsize, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, bsize, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
DBT key, val;
......@@ -1900,13 +1900,13 @@ void test_large_kv(int bsize, int ksize, int vsize) {
fill_dbt(&key, k, ksize);
fill_dbt(&val, v, vsize);
r = brt_insert(t, &key, &val, 0);
r = toku_brt_insert(t, &key, &val, 0);
assert(r == 0);
toku_free(k);
toku_free(v);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
......@@ -1937,16 +1937,16 @@ void test_brt_delete_empty() {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
DBT key;
int k = htonl(1);
fill_dbt(&key, &k, sizeof k);
r = brt_delete(t, &key);
r = toku_brt_delete(t, &key);
assert(r == 0);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
......@@ -1966,7 +1966,7 @@ void test_brt_delete_present(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
DBT key, val;
......@@ -1977,7 +1977,7 @@ void test_brt_delete_present(int n) {
k = htonl(i); v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(t, &key, &val, 0);
r = toku_brt_insert(t, &key, &val, 0);
assert(r == 0);
}
......@@ -1985,7 +1985,7 @@ void test_brt_delete_present(int n) {
for (i=0; i<n; i++) {
k = htonl(i);
fill_dbt(&key, &k, sizeof k);
r = brt_delete(t, &key);
r = toku_brt_delete(t, &key);
assert(r == 0);
}
......@@ -1994,7 +1994,7 @@ void test_brt_delete_present(int n) {
k = htonl(i);
fill_dbt(&key, &k, sizeof k);
init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = brt_lookup(t, &key, &val);
r = toku_brt_lookup(t, &key, &val);
assert(r == DB_NOTFOUND);
}
......@@ -2012,7 +2012,7 @@ void test_brt_delete_present(int n) {
r = toku_brt_cursor_close(cursor);
assert(r == 0);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
......@@ -2028,7 +2028,7 @@ void test_brt_delete_not_present(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
DBT key, val;
......@@ -2039,7 +2039,7 @@ void test_brt_delete_not_present(int n) {
k = htonl(i); v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(t, &key, &val, 0);
r = toku_brt_insert(t, &key, &val, 0);
assert(r == 0);
}
......@@ -2047,19 +2047,19 @@ void test_brt_delete_not_present(int n) {
for (i=0; i<n; i++) {
k = htonl(i);
fill_dbt(&key, &k, sizeof k);
r = brt_delete(t, &key);
r = toku_brt_delete(t, &key);
assert(r == 0);
}
/* try to delete key n+1 not in the tree */
k = htonl(n+1);
fill_dbt(&key, &k, sizeof k);
r = brt_delete(t, &key);
r = toku_brt_delete(t, &key);
/* the delete may be buffered or may be executed on a leaf node, so the
return value depends */
printf("brt_delete k=%d %d\n", k, r);
printf("toku_brt_delete k=%d %d\n", k, r);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
......@@ -2075,7 +2075,7 @@ void test_brt_delete_cursor_first(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
DBT key, val;
......@@ -2086,7 +2086,7 @@ void test_brt_delete_cursor_first(int n) {
k = htonl(i); v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(t, &key, &val, 0);
r = toku_brt_insert(t, &key, &val, 0);
assert(r == 0);
}
......@@ -2095,7 +2095,7 @@ void test_brt_delete_cursor_first(int n) {
k = htonl(i);
fill_dbt(&key, &k, sizeof k);
init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = brt_lookup(t, &key, &val);
r = toku_brt_lookup(t, &key, &val);
assert(r == 0);
assert(val.size == sizeof (int));
int vv;
......@@ -2108,11 +2108,11 @@ void test_brt_delete_cursor_first(int n) {
for (i=0; i<n-1; i++) {
k = htonl(i);
fill_dbt(&key, &k, sizeof k);
r = brt_delete(t, &key);
r = toku_brt_delete(t, &key);
assert(r == 0);
init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = brt_lookup(t, &key, &val);
r = toku_brt_lookup(t, &key, &val);
assert(r == DB_NOTFOUND);
}
......@@ -2121,7 +2121,7 @@ void test_brt_delete_cursor_first(int n) {
k = htonl(i);
fill_dbt(&key, &k, sizeof k);
init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = brt_lookup(t, &key, &val);
r = toku_brt_lookup(t, &key, &val);
assert(r == DB_NOTFOUND);
}
......@@ -2145,7 +2145,7 @@ void test_brt_delete_cursor_first(int n) {
r = toku_brt_cursor_close(cursor);
assert(r == 0);
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
......@@ -2167,7 +2167,7 @@ void test_insert_delete_lookup(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
r = toku_open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
DBT key, val;
......@@ -2178,24 +2178,24 @@ void test_insert_delete_lookup(int n) {
k = htonl(i); v = i;
fill_dbt(&key, &k, sizeof k);
fill_dbt(&val, &v, sizeof v);
r = brt_insert(t, &key, &val, 0);
r = toku_brt_insert(t, &key, &val, 0);
assert(r == 0);
}
if (n > 0) {
k = htonl(n-1);
fill_dbt(&key, &k, sizeof k);
r = brt_delete(t, &key);
r = toku_brt_delete(t, &key);
assert(r == 0);
k = htonl(n-1);
fill_dbt(&key, &k, sizeof k);
init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = brt_lookup(t, &key, &val);
r = toku_brt_lookup(t, &key, &val);
assert(r == DB_NOTFOUND);
}
r = close_brt(t); assert(r==0);
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
......
......@@ -62,7 +62,7 @@ int toku_verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, b
void *node_v;
int r;
if ((r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, (void*)(long)brt->h->nodesize)))
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, (void*)(long)brt->h->nodesize)))
return r;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
node=node_v;
......
......@@ -42,7 +42,7 @@ static DISKOFF malloc_diskblock (BRT brt, int size);
//static void verify_local_fingerprint_nonleaf (BRTNODE node);
/* Frees a node, including all the stuff in the hash table. */
void brtnode_free (BRTNODE *nodep) {
void toku_brtnode_free (BRTNODE *nodep) {
BRTNODE node=*nodep;
int i;
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, node, node->mdicts[0]);
......@@ -64,7 +64,7 @@ void brtnode_free (BRTNODE *nodep) {
*nodep=0;
}
long brtnode_size(BRTNODE node) {
static long brtnode_size(BRTNODE node) {
long size;
assert(node->tag == TYP_BRTNODE);
if (node->height > 0)
......@@ -74,6 +74,11 @@ long brtnode_size(BRTNODE node) {
return size;
}
static void brt_update_cursors_new_root(BRT t, BRTNODE newroot, BRTNODE left, BRTNODE right);
static void brt_update_cursors_leaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right);
static void brt_update_cursors_nonleaf_expand(BRT t, BRTNODE oldnode, int childnum, BRTNODE left, BRTNODE right);
static void brt_update_cursors_nonleaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right);
static void fix_up_parent_pointers_of_children (BRT t, BRTNODE node) {
int i;
assert(node->height>0);
......@@ -135,13 +140,13 @@ static int brt_compare_pivot(BRT brt, DBT *key, DBT *data, bytevec ck, unsigned
}
void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnode_v, long size __attribute((unused)), BOOL write_me, BOOL keep_me, LSN modified_lsn __attribute__((__unused__)) , BOOL rename_p __attribute__((__unused__))) {
void toku_brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnode_v, long size __attribute((unused)), BOOL write_me, BOOL keep_me, LSN modified_lsn __attribute__((__unused__)) , BOOL rename_p __attribute__((__unused__))) {
BRTNODE brtnode = brtnode_v;
// if ((write_me || keep_me) && (brtnode->height==0)) {
// toku_pma_verify_fingerprint(brtnode->u.l.buffer, brtnode->rand4fingerprint, brtnode->subtree_fingerprint);
// }
if (0) {
printf("%s:%d brtnode_flush_callback %p keep_me=%d height=%d", __FILE__, __LINE__, brtnode, keep_me, brtnode->height);
printf("%s:%d toku_brtnode_flush_callback %p keep_me=%d height=%d", __FILE__, __LINE__, brtnode, keep_me, brtnode->height);
if (brtnode->height==0) printf(" pma=%p", brtnode->u.l.buffer);
printf("\n");
}
......@@ -188,12 +193,12 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod
}
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]);
if (!keep_me) {
brtnode_free(&brtnode);
toku_brtnode_free(&brtnode);
}
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
}
int brtnode_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **brtnode_pv, long *sizep, void*extraargs, LSN *written_lsn) {
int toku_brtnode_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **brtnode_pv, long *sizep, void*extraargs, LSN *written_lsn) {
BRT t =(BRT)extraargs;
BRTNODE *result=(BRTNODE*)brtnode_pv;
int r = toku_deserialize_brtnode_from(toku_cachefile_fd(cachefile), nodename, result, t->flags, t->nodesize,
......@@ -206,7 +211,7 @@ int brtnode_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **brtnod
return r;
}
void brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *header_v, long size __attribute((unused)), BOOL write_me, BOOL keep_me, LSN lsn __attribute__((__unused__)), BOOL rename_p __attribute__((__unused__))) {
void toku_brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *header_v, long size __attribute((unused)), BOOL write_me, BOOL keep_me, LSN lsn __attribute__((__unused__)), BOOL rename_p __attribute__((__unused__))) {
struct brt_header *h = header_v;
assert(nodename==0);
assert(!h->dirty); // shouldn't be dirty once it is unpinned.
......@@ -226,7 +231,7 @@ void brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *head
}
}
int brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **headerp_v, long *sizep __attribute__((unused)), void*extraargs __attribute__((__unused__)), LSN *written_lsn) {
int toku_brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **headerp_v, long *sizep __attribute__((unused)), void*extraargs __attribute__((__unused__)), LSN *written_lsn) {
struct brt_header **h = (struct brt_header **)headerp_v;
assert(nodename==0);
int r = toku_deserialize_brtheader_from(toku_cachefile_fd(cachefile), nodename, h);
......@@ -238,7 +243,7 @@ int toku_read_and_pin_brt_header (CACHEFILE cf, struct brt_header **header) {
void *header_p;
//fprintf(stderr, "%s:%d read_and_pin_brt_header(...)\n", __FILE__, __LINE__);
int r = toku_cachetable_get_and_pin(cf, 0, &header_p, NULL,
brtheader_flush_callback, brtheader_fetch_callback, 0);
toku_brtheader_flush_callback, toku_brtheader_fetch_callback, 0);
if (r!=0) return r;
*header = header_p;
return 0;
......@@ -347,11 +352,11 @@ static void create_new_brtnode (BRT t, BRTNODE *result, int height, BRTNODE pare
// n->brt = t;
//printf("%s:%d putting %p (%lld) parent=%p\n", __FILE__, __LINE__, n, n->thisnodename, parent_brtnode);
r=toku_cachetable_put(t->cf, n->thisnodename, n, brtnode_size(n),
brtnode_flush_callback, brtnode_fetch_callback, t);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, t);
assert(r==0);
}
void delete_node (BRT t, BRTNODE node) {
static void delete_node (BRT t, BRTNODE node) {
int i;
assert(node->height>=0);
if (node->height==0) {
......@@ -388,7 +393,7 @@ static int insert_to_hash_in_nonleaf (BRTNODE node, int childnum, DBT *k, DBT *v
}
int brtleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk) {
static int brtleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk) {
BRTNODE A,B;
assert(node->height==0);
assert(t->h->nodesize>=node->nodesize); /* otherwise we might be in trouble because the nodesize shrank. */
......@@ -429,7 +434,7 @@ static void brt_update_fingerprint_when_moving_hashtable (BRTNODE oldnode, BRTNO
}
/* Side effect: sets splitk->data pointer to a malloc'd value */
void brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk) {
static void brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nodeb, DBT *splitk) {
int n_children_in_a = node->u.n.n_children/2;
BRTNODE A,B;
assert(node->height>0);
......@@ -783,7 +788,7 @@ static int push_some_brt_cmds_down (BRT t, BRTNODE node, int childnum,
DISKOFF targetchild = node->u.n.children[childnum];
assert(targetchild>=0 && targetchild<t->h->unused_memory); // This assertion could fail in a concurrent setting since another process might have bumped unused memory.
r = toku_cachetable_get_and_pin(t->cf, targetchild, &childnode_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, t);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, t);
if (r!=0) return r;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, childnode_v);
child=childnode_v;
......@@ -1039,7 +1044,7 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd,
r = toku_cachetable_maybe_get_and_pin(t->cf, node->u.n.children[childnum], &child_v);
else
r = toku_cachetable_get_and_pin(t->cf, node->u.n.children[childnum], &child_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, t);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, t);
if (r != 0)
return r;
......@@ -1437,7 +1442,7 @@ static int setup_brt_root_node (BRT t, DISKOFF offset, TOKUTXN txn) {
}
//printf("%s:%d putting %p (%lld)\n", __FILE__, __LINE__, node, node->thisnodename);
r=toku_cachetable_put(t->cf, offset, node, brtnode_size(node),
brtnode_flush_callback, brtnode_fetch_callback, t);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, t);
if (r!=0) {
toku_free(node);
return r;
......@@ -1478,38 +1483,38 @@ int toku_brt_create(BRT *brt_ptr) {
return 0;
}
int brt_set_flags(BRT brt, int flags) {
int toku_brt_set_flags(BRT brt, int flags) {
brt->flags = flags;
return 0;
}
int brt_get_flags(BRT brt, int *flags) {
int toku_brt_get_flags(BRT brt, int *flags) {
*flags = brt->flags;
return 0;
}
int brt_set_nodesize(BRT brt, int nodesize) {
int toku_brt_set_nodesize(BRT brt, int nodesize) {
brt->nodesize = nodesize;
return 0;
}
int brt_set_bt_compare(BRT brt, int (*bt_compare)(DB *, const DBT*, const DBT*)) {
int toku_brt_set_bt_compare(BRT brt, int (*bt_compare)(DB *, const DBT*, const DBT*)) {
brt->compare_fun = bt_compare;
return 0;
}
int brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT*)) {
int toku_brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT*)) {
brt->dup_compare = dup_compare;
return 0;
}
int brt_open(BRT t, const char *fname, const char *fname_in_env, const char *dbname, int is_create, int only_create, CACHETABLE cachetable, TOKUTXN txn) {
int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, const char *dbname, int is_create, int only_create, CACHETABLE cachetable, TOKUTXN txn) {
/* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */
int r;
char *malloced_name=0;
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
WHEN_BRTTRACE(fprintf(stderr, "BRTTRACE: %s:%d open_brt(%s, \"%s\", %d, %p, %d, %p)\n",
WHEN_BRTTRACE(fprintf(stderr, "BRTTRACE: %s:%d toku_open_brt(%s, \"%s\", %d, %p, %d, %p)\n",
__FILE__, __LINE__, fname, dbname, is_create, newbrt, nodesize, cachetable));
if (0) { died0: assert(r); return r; }
......@@ -1579,7 +1584,7 @@ int brt_open(BRT t, const char *fname, const char *fname_in_env, const char *dbn
}
if ((r=tokulogger_log_header(txn, toku_cachefile_filenum(t->cf), t->h))) { goto died6; }
if ((r=setup_brt_root_node(t, t->nodesize, txn))!=0) { died6: if (dbname) goto died5; else goto died2; }
if ((r=toku_cachetable_put(t->cf, 0, t->h, 0, brtheader_flush_callback, brtheader_fetch_callback, 0))) { goto died6; }
if ((r=toku_cachetable_put(t->cf, 0, t->h, 0, toku_brtheader_flush_callback, toku_brtheader_fetch_callback, 0))) { goto died6; }
} else {
int i;
assert(r==0);
......@@ -1633,7 +1638,7 @@ int brt_open(BRT t, const char *fname, const char *fname_in_env, const char *dbn
return 0;
}
int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
int r;
int r2 = 0;
int i;
......@@ -1642,7 +1647,7 @@ int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
assert(flags == 0);
r = toku_read_and_pin_brt_header(brt->cf, &brt->h);
//TODO: What if r != 0? Is this possible?
// We just called brt_open, so it should exist...
// We just called toku_brt_open, so it should exist...
assert(r==0);
assert(brt->h->unnamed_root==-1);
......@@ -1680,7 +1685,7 @@ int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags) {
}
// This one has no env
int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt, int nodesize, CACHETABLE cachetable, TOKUTXN txn,
int toku_open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt, int nodesize, CACHETABLE cachetable, TOKUTXN txn,
int (*compare_fun)(DB*,const DBT*,const DBT*), DB *db) {
BRT brt;
int r;
......@@ -1689,11 +1694,11 @@ int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt,
r = toku_brt_create(&brt);
if (r != 0)
return r;
brt_set_nodesize(brt, nodesize);
brt_set_bt_compare(brt, compare_fun);
toku_brt_set_nodesize(brt, nodesize);
toku_brt_set_bt_compare(brt, compare_fun);
brt->db = db;
r = brt_open(brt, fname, fname, dbname, is_create, only_create, cachetable, txn);
r = toku_brt_open(brt, fname, fname, dbname, is_create, only_create, cachetable, txn);
if (r != 0) {
return r;
}
......@@ -1702,7 +1707,7 @@ int open_brt (const char *fname, const char *dbname, int is_create, BRT *newbrt,
return r;
}
int close_brt (BRT brt) {
int toku_close_brt (BRT brt) {
int r;
while (brt->cursors_head) {
BRT_CURSOR c = brt->cursors_head;
......@@ -1737,7 +1742,7 @@ CACHEKEY* toku_calculate_root_offset_pointer (BRT brt) {
abort();
}
int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *rootp) {
static int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *rootp) {
TAGMALLOC(BRTNODE, newroot);
int r;
DISKOFF newroot_diskoff=malloc_diskblock(brt, brt->h->nodesize);
......@@ -1770,7 +1775,7 @@ int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKE
if (r!=0) return r;
//printf("%s:%d put %lld\n", __FILE__, __LINE__, brt->root);
toku_cachetable_put(brt->cf, newroot_diskoff, newroot, brtnode_size(newroot),
brtnode_flush_callback, brtnode_fetch_callback, brt);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt);
brt_update_cursors_new_root(brt, newroot, nodea, nodeb);
return 0;
}
......@@ -1792,7 +1797,7 @@ static int brt_root_put_cmd(BRT brt, BRT_CMD *cmd, TOKUTXN txn) {
rootp = toku_calculate_root_offset_pointer(brt);
if (debug) printf("%s:%d Getting %lld\n", __FILE__, __LINE__, *rootp);
if ((r=toku_cachetable_get_and_pin(brt->cf, *rootp, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt))) {
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt))) {
goto died0;
}
//printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
......@@ -1831,7 +1836,7 @@ static int brt_root_put_cmd(BRT brt, BRT_CMD *cmd, TOKUTXN txn) {
return result;
}
int brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
int toku_brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
int r;
BRT_CMD brtcmd;
......@@ -1842,11 +1847,11 @@ int brt_insert (BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
return r;
}
int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, BRTNODE parent_brtnode) {
static int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, BRTNODE parent_brtnode) {
int result;
void *node_v;
int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt);
if (r!=0)
return r;
......@@ -1911,7 +1916,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, BRTNODE parent_brtnod
}
int brt_lookup (BRT brt, DBT *k, DBT *v) {
int toku_brt_lookup (BRT brt, DBT *k, DBT *v) {
int r;
CACHEKEY *rootp;
assert(0==toku_cachefile_count_pinned(brt->cf, 1));
......@@ -1933,7 +1938,7 @@ int brt_lookup (BRT brt, DBT *k, DBT *v) {
return 0;
}
int brt_delete(BRT brt, DBT *key) {
int toku_brt_delete(BRT brt, DBT *key) {
int r;
BRT_CMD brtcmd;
DBT val;
......@@ -1954,7 +1959,7 @@ int toku_dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN
BRTNODE node;
void *node_v;
int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt);
assert(r==0);
printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
node=node_v;
......@@ -2002,7 +2007,7 @@ int toku_dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN
return result;
}
int dump_brt (BRT brt) {
int toku_dump_brt (BRT brt) {
int r;
CACHEKEY *rootp;
if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) {
......@@ -2022,7 +2027,7 @@ static int show_brtnode_blocknumbers (BRT brt, DISKOFF off, BRTNODE parent_brtno
int i,r;
assert(off%brt->h->nodesize==0);
if ((r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt))) {
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt))) {
if (0) { died0: toku_cachetable_unpin(brt->cf, off, 0, 0); }
return r;
}
......@@ -2056,7 +2061,7 @@ int show_brt_blocknumbers (BRT brt) {
}
#endif
int brt_flush_debug = 0;
static int brt_flush_debug = 0;
/*
* Flush the buffer for a child of a node.
......@@ -2064,7 +2069,7 @@ int brt_flush_debug = 0;
* then reflect the node split up the cursor path towards the tree root.
* If the root is reached then create a new root
*/
void brt_flush_child(BRT t, BRTNODE node, int childnum, BRT_CURSOR cursor, TOKUTXN txn) {
static void brt_flush_child(BRT t, BRTNODE node, int childnum, BRT_CURSOR cursor, TOKUTXN txn) {
int r;
int child_did_split;
BRTNODE childa, childb;
......@@ -2121,7 +2126,7 @@ void brt_flush_child(BRT t, BRTNODE node, int childnum, BRT_CURSOR cursor, TOKUT
/*
* Add a cursor to child of a node. Increment the cursor count on the child. Flush the buffer associated with the child.
*/
void brt_node_add_cursor(BRTNODE node, int childnum, BRT_CURSOR cursor) {
static void brt_node_add_cursor(BRTNODE node, int childnum, BRT_CURSOR cursor) {
if (node->height > 0) {
if (0) printf("brt_node_add_cursor %lld %d %p\n", node->thisnodename, childnum, cursor);
node->u.n.n_cursors[childnum] += 1;
......@@ -2131,7 +2136,7 @@ void brt_node_add_cursor(BRTNODE node, int childnum, BRT_CURSOR cursor) {
/*
* Remove a cursor from the child of a node. Decrement the cursor count on the child.
*/
void brt_node_remove_cursor(BRTNODE node, int childnum, BRT_CURSOR cursor __attribute__((unused))) {
static void brt_node_remove_cursor(BRTNODE node, int childnum, BRT_CURSOR cursor __attribute__((unused))) {
if (node->height > 0) {
if (0) printf("brt_node_remove_cursor %lld %d %p\n", node->thisnodename, childnum, cursor);
assert(node->u.n.n_cursors[childnum] > 0);
......@@ -2153,7 +2158,7 @@ void brt_update_cursors_new_root(BRT t, BRTNODE newroot, BRTNODE left, BRTNODE r
}
}
void brt_update_cursors_leaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right) {
static void brt_update_cursors_leaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right) {
BRT_CURSOR cursor;
if (brt_update_debug) printf("brt_update_cursors_leaf_split %lld %lld %lld\n", oldnode->thisnodename,
......@@ -2165,7 +2170,7 @@ void brt_update_cursors_leaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE
}
}
void brt_update_cursors_nonleaf_expand(BRT t, BRTNODE node, int childnum, BRTNODE left, BRTNODE right) {
static void brt_update_cursors_nonleaf_expand(BRT t, BRTNODE node, int childnum, BRTNODE left, BRTNODE right) {
BRT_CURSOR cursor;
if (brt_update_debug) printf("brt_update_cursors_nonleaf_expand %lld h=%d c=%d nc=%d %lld %lld\n", node->thisnodename, node->height, childnum,
......@@ -2177,7 +2182,7 @@ void brt_update_cursors_nonleaf_expand(BRT t, BRTNODE node, int childnum, BRTNOD
}
}
void brt_update_cursors_nonleaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right) {
static void brt_update_cursors_nonleaf_split(BRT t, BRTNODE oldnode, BRTNODE left, BRTNODE right) {
BRT_CURSOR cursor;
if (brt_update_debug) printf("brt_update_cursors_nonleaf_split %lld %lld %lld\n", oldnode->thisnodename,
......@@ -2389,12 +2394,12 @@ void toku_brt_cursor_print(BRT_CURSOR cursor) {
printf("\n");
}
int brtcurs_set_position_last (BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN txn, BRTNODE parent_brtnode) {
static int brtcurs_set_position_last (BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN txn, BRTNODE parent_brtnode) {
BRT brt=cursor->brt;
void *node_v;
int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt);
if (r!=0) {
if (0) { died0: toku_cachetable_unpin(brt->cf, off, 1, 0); }
return r;
......@@ -2451,12 +2456,12 @@ int brtcurs_set_position_last (BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN
}
}
int brtcurs_set_position_first (BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN txn, BRTNODE parent_brtnode) {
static int brtcurs_set_position_first (BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN txn, BRTNODE parent_brtnode) {
BRT brt=cursor->brt;
void *node_v;
int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt);
toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt);
if (r!=0) {
if (0) { died0: toku_cachetable_unpin(brt->cf, off, 1, 0); }
return r;
......@@ -2514,7 +2519,7 @@ int brtcurs_set_position_first (BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTX
}
}
int brtcurs_set_position_next2(BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
static int brtcurs_set_position_next2(BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
BRTNODE node;
int childnum;
int r;
......@@ -2562,7 +2567,7 @@ int brtcurs_set_position_next2(BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
}
/* requires that the cursor is initialized. */
int brtcurs_set_position_next (BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
static int brtcurs_set_position_next (BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
int r = toku_pma_cursor_set_position_next(cursor->pmacurs);
if (r==DB_NOTFOUND) {
/* We fell off the end of the pma. */
......@@ -2575,7 +2580,7 @@ int brtcurs_set_position_next (BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
return 0;
}
int brtcurs_set_position_prev2(BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
static int brtcurs_set_position_prev2(BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
BRTNODE node;
int childnum;
int r;
......@@ -2622,7 +2627,7 @@ int brtcurs_set_position_prev2(BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
return brtcurs_set_position_prev2(cursor, key, txn);
}
int brtcurs_set_position_prev (BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
static int brtcurs_set_position_prev (BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
int r = toku_pma_cursor_set_position_prev(cursor->pmacurs);
if (r==DB_NOTFOUND) {
if (cursor->path_len==1)
......@@ -2634,12 +2639,12 @@ int brtcurs_set_position_prev (BRT_CURSOR cursor, DBT *key, TOKUTXN txn) {
return 0;
}
int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag, TOKUTXN txn, BRTNODE parent_brtnode) {
static int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag, TOKUTXN txn, BRTNODE parent_brtnode) {
BRT brt = cursor->brt;
void *node_v;
int r;
r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL, brtnode_flush_callback,
brtnode_fetch_callback, brt);
r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL, toku_brtnode_flush_callback,
toku_brtnode_fetch_callback, brt);
if (r != 0)
return r;
......@@ -2696,12 +2701,12 @@ int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag
return r;
}
int brtcurs_set_range(BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN txn, BRTNODE parent_brtnode) {
static int brtcurs_set_range(BRT_CURSOR cursor, DISKOFF off, DBT *key, TOKUTXN txn, BRTNODE parent_brtnode) {
BRT brt = cursor->brt;
void *node_v;
int r;
r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL, brtnode_flush_callback,
brtnode_fetch_callback, brt);
r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL, toku_brtnode_flush_callback,
toku_brtnode_fetch_callback, brt);
if (r != 0)
return r;
......
......@@ -11,23 +11,23 @@
#include "cachetable.h"
#include "log.h"
int open_brt (const char *fname, const char *dbname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*);
int toku_open_brt (const char *fname, const char *dbname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*);
int toku_brt_create(BRT *);
int brt_set_flags(BRT, int flags);
int brt_get_flags(BRT, int *flags);
int brt_set_nodesize(BRT, int nodesize);
int brt_set_bt_compare(BRT, int (*bt_compare)(DB *, const DBT*, const DBT*));
int brt_set_dup_compare(BRT, int (*dup_compare)(DB *, const DBT*, const DBT*));
int toku_brt_set_flags(BRT, int flags);
int toku_brt_get_flags(BRT, int *flags);
int toku_brt_set_nodesize(BRT, int nodesize);
int toku_brt_set_bt_compare(BRT, int (*bt_compare)(DB *, const DBT*, const DBT*));
int toku_brt_set_dup_compare(BRT, int (*dup_compare)(DB *, const DBT*, const DBT*));
int brt_set_cachetable(BRT, CACHETABLE);
int brt_open(BRT, const char *fname, const char *fname_in_env, const char *dbname, int is_create, int only_create, CACHETABLE ct, TOKUTXN txn);
int brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags);
int brt_insert (BRT, DBT *, DBT *, TOKUTXN);
int brt_lookup (BRT brt, DBT *k, DBT *v);
int brt_delete (BRT brt, DBT *k);
int close_brt (BRT);
int dump_brt (BRT brt);
int toku_brt_open(BRT, const char *fname, const char *fname_in_env, const char *dbname, int is_create, int only_create, CACHETABLE ct, TOKUTXN txn);
int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags);
int toku_brt_insert (BRT, DBT *, DBT *, TOKUTXN);
int toku_brt_lookup (BRT brt, DBT *k, DBT *v);
int toku_brt_delete (BRT brt, DBT *k);
int toku_close_brt (BRT);
int toku_dump_brt (BRT brt);
void brt_fsync (BRT); /* fsync, but don't clear the caches. */
void brt_flush (BRT); /* fsync and clear the caches. */
......
......@@ -77,7 +77,7 @@ static void toku_recover_fheader (struct logtype_fheader *c) {
} else {
assert(0);
}
toku_cachetable_put(cf, 0, h, 0, brtheader_flush_callback, brtheader_fetch_callback, 0);
toku_cachetable_put(cf, 0, h, 0, toku_brtheader_flush_callback, toku_brtheader_fetch_callback, 0);
}
static void toku_recover_newbrtnode (struct logtype_newbrtnode *c) {
......@@ -106,7 +106,7 @@ static void toku_recover_newbrtnode (struct logtype_newbrtnode *c) {
abort();
}
// Now put it in the cachetable
toku_cachetable_put(cf, c->diskoff, n, toku_serialize_brtnode_size(n), brtnode_flush_callback, brtnode_fetch_callback, 0);
toku_cachetable_put(cf, c->diskoff, n, toku_serialize_brtnode_size(n), toku_brtnode_flush_callback, toku_brtnode_fetch_callback, 0);
r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(n));
assert(r==0);
}
......@@ -139,7 +139,7 @@ static void toku_recover_insertinleaf (struct logtype_insertinleaf *c) {
int r = find_cachefile(c->filenum, &cf, &brt);
assert(r==0);
void *node_v;
r = toku_cachetable_get_and_pin(cf, c->diskoff, &node_v, NULL, brtnode_flush_callback, brtnode_fetch_callback, brt);
r = toku_cachetable_get_and_pin(cf, c->diskoff, &node_v, NULL, toku_brtnode_flush_callback, toku_brtnode_fetch_callback, brt);
assert(r==0);
BRTNODE node = node_v;
assert(node->height==0);
......
......@@ -447,7 +447,7 @@ int db_env_create(DB_ENV ** envp, u_int32_t flags) {
return 0;
}
int toku_db_txn_commit(DB_TXN * txn, u_int32_t flags) {
static int toku_db_txn_commit(DB_TXN * txn, u_int32_t flags) {
//notef("flags=%d\n", flags);
if (!txn)
return -1;
......@@ -503,7 +503,7 @@ int log_compare(const DB_LSN * a, const DB_LSN * b) {
}
static int toku_db_close(DB * db, u_int32_t flags) {
int r = close_brt(db->i->brt);
int r = toku_close_brt(db->i->brt);
if (r != 0)
return r;
// printf("%s:%d %d=__toku_db_close(%p)\n", __FILE__, __LINE__, r, db);
......@@ -567,7 +567,7 @@ static int toku_db_del(DB * db, DB_TXN * txn, DBT * key, u_int32_t flags) {
return r;
free(search_val.data);
}
r = brt_delete(db->i->brt, key);
r = toku_brt_delete(db->i->brt, key);
return r;
}
......@@ -575,7 +575,7 @@ static int toku_db_get(DB * db, DB_TXN * txn __attribute__ ((unused)), DBT * key
assert(flags == 0);
int r;
int brtflags;
brt_get_flags(db->i->brt, &brtflags);
toku_brt_get_flags(db->i->brt, &brtflags);
if (brtflags & TOKU_DB_DUPSORT) {
DBC *dbc;
r = db->cursor(db, txn, &dbc, 0);
......@@ -584,7 +584,7 @@ static int toku_db_get(DB * db, DB_TXN * txn __attribute__ ((unused)), DBT * key
dbc->c_close(dbc);
}
} else
r = brt_lookup(db->i->brt, key, data);
r = toku_brt_lookup(db->i->brt, key, data);
return r;
}
......@@ -635,7 +635,7 @@ static char *construct_full_name(const char *dir, const char *fname) {
// have to inherit mode bits and so forth from the first file that was created.
// Other problems may ensue (who is responsible for deleting the file? That's not so bad actually.)
// This suggests that we really need to put the multiple databases into one file.
int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode) {
static int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode) {
// Warning. Should check arguments. Should check return codes on malloc and open and so forth.
int openflags = 0;
......@@ -684,7 +684,7 @@ int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, D
db->i->open_flags = flags;
db->i->open_mode = mode;
r = brt_open(db->i->brt, db->i->full_fname, fname, dbname,
r = toku_brt_open(db->i->brt, db->i->full_fname, fname, dbname,
flags & DB_CREATE, flags & DB_EXCL,
db->dbenv->i->cachetable,
txn ? txn->i->tokutxn : NULL_TXN);
......@@ -705,13 +705,13 @@ int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, D
return r;
}
int toku_db_put(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
int r = brt_insert(db->i->brt, key, data, txn ? txn->i->tokutxn : 0);
static int toku_db_put(DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_t flags) {
int r = toku_brt_insert(db->i->brt, key, data, txn ? txn->i->tokutxn : 0);
//printf("%s:%d %d=__toku_db_put(...)\n", __FILE__, __LINE__, r);
return r;
}
int toku_db_remove(DB * db, const char *fname, const char *dbname, u_int32_t flags) {
static int toku_db_remove(DB * db, const char *fname, const char *dbname, u_int32_t flags) {
int r;
int r2;
char ffull[PATH_MAX];
......@@ -724,7 +724,7 @@ int toku_db_remove(DB * db, const char *fname, const char *dbname, u_int32_t fla
//TODO: Use master database (instead of manual edit) when implemented.
if ((r = db->open(db, NULL, fname, dbname, DB_BTREE, 0, 0777)) != 0) goto cleanup;
r = brt_remove_subdb(db->i->brt, dbname, flags);
r = toku_brt_remove_subdb(db->i->brt, dbname, flags);
cleanup:
r2 = db->close(db, 0);
return r ? r : r2;
......@@ -740,7 +740,7 @@ int toku_db_remove(DB * db, const char *fname, const char *dbname, u_int32_t fla
return r ? r : r2;
}
int toku_db_rename(DB * db, const char *namea, const char *nameb, const char *namec, u_int32_t flags) {
static int toku_db_rename(DB * db, const char *namea, const char *nameb, const char *namec, u_int32_t flags) {
char afull[PATH_MAX], cfull[PATH_MAX];
int r;
assert(nameb == 0);
......@@ -751,38 +751,36 @@ int toku_db_rename(DB * db, const char *namea, const char *nameb, const char *na
return rename(afull, cfull);
}
int toku_db_set_bt_compare(DB * db, int (*bt_compare) (DB *, const DBT *, const DBT *)) {
int r = brt_set_bt_compare(db->i->brt, bt_compare);
static int toku_db_set_bt_compare(DB * db, int (*bt_compare) (DB *, const DBT *, const DBT *)) {
int r = toku_brt_set_bt_compare(db->i->brt, bt_compare);
return r;
}
int toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *, const DBT *)) {
int r = brt_set_dup_compare(db->i->brt, dup_compare);
static int toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *, const DBT *)) {
int r = toku_brt_set_dup_compare(db->i->brt, dup_compare);
return r;
}
int toku_db_set_flags(DB * db, u_int32_t flags) {
static int toku_db_set_flags(DB * db, u_int32_t flags) {
u_int32_t tflags = 0;
if (flags & DB_DUP)
tflags += TOKU_DB_DUP;
if (flags & DB_DUPSORT)
tflags += TOKU_DB_DUPSORT;
int r= brt_set_flags(db->i->brt, tflags);
int r= toku_brt_set_flags(db->i->brt, tflags);
return r;
}
int toku_db_set_pagesize(DB *db, u_int32_t pagesize) {
int r = brt_set_nodesize(db->i->brt, pagesize);
static int toku_db_set_pagesize(DB *db, u_int32_t pagesize) {
int r = toku_brt_set_nodesize(db->i->brt, pagesize);
return r;
}
int toku_db_stat(DB * db, void *v, u_int32_t flags) {
static int toku_db_stat(DB * db, void *v, u_int32_t flags) {
barf();
abort();
}
extern int toku_default_compare_fun(DB * db, const DBT * a, const DBT * b);
int db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
int r;
......
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