Commit 252ec018 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make all external symbols in key.o start with toku_. Addresses #8

git-svn-id: file:///svn/tokudb@676 c7de825b-a66e-492c-adef-691d508d4ae1
parent ff277a4b
...@@ -31,7 +31,7 @@ void setup (void) { ...@@ -31,7 +31,7 @@ void setup (void) {
int r; int r;
unlink(fname); unlink(fname);
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, nodesize, ct, NULL_TXN, default_compare_fun); assert(r==0); r = open_brt(fname, 0, 1, &t, nodesize, ct, NULL_TXN, toku_default_compare_fun); assert(r==0);
} }
void shutdown (void) { void shutdown (void) {
......
...@@ -99,7 +99,7 @@ struct brt { ...@@ -99,7 +99,7 @@ struct brt {
void toku_seralize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node); void toku_seralize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node);
int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int flags, int nodesize, int (*bt_compare)(DB *, const DBT*, const DBT*), int (*dup_compare)(DB *, const DBT *, const DBT *)); int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int flags, int nodesize, int (*bt_compare)(DB *, const DBT*, const DBT*), int (*dup_compare)(DB *, const DBT *, const DBT *));
unsigned int toku_serialize_brtnode_size(BRTNODE node); /* How much space will it take? */ unsigned int toku_serialize_brtnode_size(BRTNODE node); /* How much space will it take? */
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len); int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
void toku_verify_counts(BRTNODE); void toku_verify_counts(BRTNODE);
......
...@@ -28,7 +28,7 @@ static void test0 (void) { ...@@ -28,7 +28,7 @@ static void test0 (void) {
assert(r==0); assert(r==0);
printf("%s:%d test0\n", __FILE__, __LINE__); printf("%s:%d test0\n", __FILE__, __LINE__);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
//printf("%s:%d test0\n", __FILE__, __LINE__); //printf("%s:%d test0\n", __FILE__, __LINE__);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
...@@ -50,7 +50,7 @@ static void test1 (void) { ...@@ -50,7 +50,7 @@ static void test1 (void) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_db, null_txn); brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_db, null_txn);
{ {
...@@ -76,7 +76,7 @@ static void test2 (int memcheck) { ...@@ -76,7 +76,7 @@ static void test2 (int memcheck) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun);
printf("%s:%d did setup\n", __FILE__, __LINE__); printf("%s:%d did setup\n", __FILE__, __LINE__);
assert(r==0); assert(r==0);
for (i=0; i<2048; i++) { for (i=0; i<2048; i++) {
...@@ -115,7 +115,7 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -115,7 +115,7 @@ static void test3 (int nodesize, int count, int memcheck) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0); gettimeofday(&t0, 0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
char key[100],val[100]; char key[100],val[100];
...@@ -146,7 +146,7 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -146,7 +146,7 @@ static void test4 (int nodesize, int count, int memcheck) {
memory_check=memcheck; memory_check=memcheck;
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun); assert(r==0);
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
char key[100],val[100]; char key[100],val[100];
int rv = random(); int rv = random();
...@@ -178,7 +178,7 @@ static void test5 (void) { ...@@ -178,7 +178,7 @@ static void test5 (void) {
for (i=0; i<limit; i++) values[i]=-1; for (i=0; i<limit; i++) values[i]=-1;
unlink(fname); unlink(fname);
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(fname, 0, 1, &t, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(fname, 0, 1, &t, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
for (i=0; i<limit/2; i++) { for (i=0; i<limit/2; i++) {
char key[100],val[100]; char key[100],val[100];
int rk = random()%limit; int rk = random()%limit;
...@@ -221,7 +221,7 @@ static void test_dump_empty_db (void) { ...@@ -221,7 +221,7 @@ static void test_dump_empty_db (void) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
dump_brt(t); dump_brt(t);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
...@@ -241,8 +241,8 @@ static void test_multiple_files_of_size (int size) { ...@@ -241,8 +241,8 @@ static void test_multiple_files_of_size (int size) {
unlink(n1); unlink(n1);
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, 0, 1, &t0, size, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n0, 0, 1, &t0, size, ct, null_txn, toku_default_compare_fun); assert(r==0);
r = open_brt(n1, 0, 1, &t1, size, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n1, 0, 1, &t1, size, ct, null_txn, toku_default_compare_fun); assert(r==0);
for (i=0; i<10000; i++) { for (i=0; i<10000; i++) {
char key[100],val[100]; char key[100],val[100];
DBT k,v; DBT k,v;
...@@ -265,10 +265,10 @@ static void test_multiple_files_of_size (int size) { ...@@ -265,10 +265,10 @@ static void test_multiple_files_of_size (int size) {
/* Now see if the data is all there. */ /* Now see if the data is all there. */
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, default_compare_fun); r = open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun);
printf("%s:%d r=%d\n", __FILE__, __LINE__,r); printf("%s:%d r=%d\n", __FILE__, __LINE__,r);
assert(r==0); assert(r==0);
r = open_brt(n1, 0, 0, &t1, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n1, 0, 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
for (i=0; i<10000; i++) { for (i=0; i<10000; i++) {
char key[100],val[100]; char key[100],val[100];
...@@ -310,7 +310,7 @@ static void test_named_db (void) { ...@@ -310,7 +310,7 @@ static void test_named_db (void) {
unlink(n1); unlink(n1);
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0);
...@@ -321,7 +321,7 @@ static void test_named_db (void) { ...@@ -321,7 +321,7 @@ static void test_named_db (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
{ {
r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0); r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0);
...@@ -347,8 +347,8 @@ static void test_multiple_dbs (void) { ...@@ -347,8 +347,8 @@ static void test_multiple_dbs (void) {
unlink(n1); unlink(n1);
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
r = open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_db, null_txn); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_db, null_txn); assert(r==0);
brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_db, null_txn); assert(r==0); brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_db, null_txn); assert(r==0);
...@@ -360,8 +360,8 @@ static void test_multiple_dbs (void) { ...@@ -360,8 +360,8 @@ static void test_multiple_dbs (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
r = open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
{ {
r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0); r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0);
...@@ -403,7 +403,7 @@ static void test_multiple_dbs_many (void) { ...@@ -403,7 +403,7 @@ static void test_multiple_dbs_many (void) {
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
char dbname[20]; char dbname[20];
snprintf(dbname, 20, "db%d", i); snprintf(dbname, 20, "db%d", i);
r = open_brt(name, dbname, 1, &trees[i], 1<<12, ct, null_txn, default_compare_fun); r = open_brt(name, dbname, 1, &trees[i], 1<<12, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
} }
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
...@@ -432,7 +432,7 @@ static void test_multiple_brts_one_db_one_file (void) { ...@@ -432,7 +432,7 @@ static void test_multiple_brts_one_db_one_file (void) {
unlink(name); unlink(name);
r = brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
r = open_brt(name, 0, (i==0), &trees[i], 1<<12, ct, null_txn, default_compare_fun); r = open_brt(name, 0, (i==0), &trees[i], 1<<12, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
} }
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
...@@ -475,7 +475,7 @@ static void test_read_what_was_written (void) { ...@@ -475,7 +475,7 @@ static void test_read_what_was_written (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
r = close_brt(brt); assert(r==0); r = close_brt(brt); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
...@@ -483,7 +483,7 @@ static void test_read_what_was_written (void) { ...@@ -483,7 +483,7 @@ static void test_read_what_was_written (void) {
/* Now see if we can read an empty tree in. */ /* Now see if we can read an empty tree in. */
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
/* See if we can put something in it. */ /* See if we can put something in it. */
{ {
...@@ -498,7 +498,7 @@ static void test_read_what_was_written (void) { ...@@ -498,7 +498,7 @@ static void test_read_what_was_written (void) {
/* Now see if we can read it in and get the value. */ /* Now see if we can read it in and get the value. */
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
{ {
DBT k,v; DBT k,v;
...@@ -574,7 +574,7 @@ static void test_read_what_was_written (void) { ...@@ -574,7 +574,7 @@ static void test_read_what_was_written (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n, 0, 0, &brt, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
{ {
DBT k,v; DBT k,v;
...@@ -622,7 +622,7 @@ void test_cursor_last_empty(void) { ...@@ -622,7 +622,7 @@ void test_cursor_last_empty(void) {
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = 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(); //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, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = brt_cursor(brt, &cursor); assert(r==0); r = brt_cursor(brt, &cursor); assert(r==0);
init_dbt(&kbt); init_dbt(&kbt);
...@@ -654,7 +654,7 @@ void test_cursor_next (void) { ...@@ -654,7 +654,7 @@ void test_cursor_next (void) {
memory_check_all_free(); memory_check_all_free();
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = 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(); //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, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //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_db, null_txn); r = brt_insert(brt, fill_dbt(&kbt, "hello", 6), fill_dbt(&vbt, "there", 6), null_db, null_txn);
r = brt_insert(brt, fill_dbt(&kbt, "byebye", 7), fill_dbt(&vbt, "byenow", 7), null_db, null_txn); r = brt_insert(brt, fill_dbt(&kbt, "byebye", 7), fill_dbt(&vbt, "byenow", 7), null_db, null_txn);
...@@ -734,7 +734,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -734,7 +734,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
//printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p); //printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p);
if (0) { // ???? Why is this commented out? if (0) { // ???? Why is this commented out?
r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun); assert(r==0);
for (i=1; i<257; i+=255) { for (i=1; i<257; i+=255) {
unsigned char a[4],b[4]; unsigned char a[4],b[4];
b[3] = a[0] = i&255; b[3] = a[0] = i&255;
...@@ -767,7 +767,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -767,7 +767,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
{ {
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun); assert(r==0);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
...@@ -816,7 +816,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -816,7 +816,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
int test_cursor_debug = 0; int test_cursor_debug = 0;
int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) { int test_brt_cursor_keycompare(DB *db __attribute__((unused)), const DBT *a, const DBT *b) {
return keycompare(a->data, a->size, b->data, b->size); return toku_keycompare(a->data, a->size, b->data, b->size);
} }
void assert_cursor_notfound(BRT brt, int position, DB *db) { void assert_cursor_notfound(BRT brt, int position, DB *db) {
...@@ -1887,7 +1887,7 @@ void test_large_kv(int bsize, int ksize, int vsize) { ...@@ -1887,7 +1887,7 @@ void test_large_kv(int bsize, int ksize, int vsize) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, bsize, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, bsize, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -1934,7 +1934,7 @@ void test_brt_delete_empty() { ...@@ -1934,7 +1934,7 @@ void test_brt_delete_empty() {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
DBT key; DBT key;
...@@ -1963,7 +1963,7 @@ void test_brt_delete_present(int n) { ...@@ -1963,7 +1963,7 @@ void test_brt_delete_present(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -2025,7 +2025,7 @@ void test_brt_delete_not_present(int n) { ...@@ -2025,7 +2025,7 @@ void test_brt_delete_not_present(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -2072,7 +2072,7 @@ void test_brt_delete_cursor_first(int n) { ...@@ -2072,7 +2072,7 @@ void test_brt_delete_cursor_first(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -2164,7 +2164,7 @@ void test_insert_delete_lookup(int n) { ...@@ -2164,7 +2164,7 @@ void test_insert_delete_lookup(int n) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, default_compare_fun); r = open_brt(fname, 0, 1, &t, 4096, ct, null_txn, toku_default_compare_fun);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
......
...@@ -91,8 +91,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve ...@@ -91,8 +91,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve
unsigned int datalen __attribute__((__unused__)), unsigned int datalen __attribute__((__unused__)),
int type __attribute__((__unused__)), int type __attribute__((__unused__)),
void *ignore __attribute__((__unused__))) { void *ignore __attribute__((__unused__))) {
if (thislorange) assert(keycompare(thislorange,thislolen,key,keylen)<0); if (thislorange) assert(toku_keycompare(thislorange,thislolen,key,keylen)<0);
if (thishirange && keycompare(key,keylen,thishirange,thishilen)>0) { if (thishirange && toku_keycompare(key,keylen,thishirange,thishilen)>0) {
printf("%s:%d in buffer %d key %s is bigger than %s\n", __FILE__, __LINE__, i, (char*)key, (char*)thishirange); printf("%s:%d in buffer %d key %s is bigger than %s\n", __FILE__, __LINE__, i, (char*)key, (char*)thishirange);
result=1; result=1;
} }
...@@ -102,8 +102,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve ...@@ -102,8 +102,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve
} }
for (i=0; i<node->u.n.n_children; i++) { for (i=0; i<node->u.n.n_children; i++) {
if (i>0) { if (i>0) {
if (lorange) assert(keycompare(lorange,lolen, node->u.n.childkeys[i-1], node->u.n.childkeylens[i-1])<0); if (lorange) assert(toku_keycompare(lorange,lolen, node->u.n.childkeys[i-1], node->u.n.childkeylens[i-1])<0);
if (hirange) assert(keycompare(node->u.n.childkeys[i-1], node->u.n.childkeylens[i-1], hirange, hilen)<=0); if (hirange) assert(toku_keycompare(node->u.n.childkeys[i-1], node->u.n.childkeylens[i-1], hirange, hilen)<=0);
} }
if (recurse) { if (recurse) {
result|=verify_brtnode(brt, node->u.n.children[i], result|=verify_brtnode(brt, node->u.n.children[i],
......
...@@ -259,13 +259,15 @@ typedef struct kvpair { ...@@ -259,13 +259,15 @@ typedef struct kvpair {
unsigned int vallen; unsigned int vallen;
} *KVPAIR; } *KVPAIR;
#if 0
int kvpair_compare (const void *av, const void *bv) { int kvpair_compare (const void *av, const void *bv) {
const KVPAIR a = (const KVPAIR)av; const KVPAIR a = (const KVPAIR)av;
const KVPAIR b = (const KVPAIR)bv; const KVPAIR b = (const KVPAIR)bv;
int r = keycompare(a->key, a->keylen, b->key, b->keylen); int r = toku_keycompare(a->key, a->keylen, b->key, b->keylen);
//printf("keycompare(%s,\n %s)-->%d\n", a->key, b->key, r); //printf("keycompare(%s,\n %s)-->%d\n", a->key, b->key, r);
return r; return r;
} }
#endif
/* Forgot to handle the case where there is something in the freelist. */ /* Forgot to handle the case where there is something in the freelist. */
static DISKOFF malloc_diskblock_header_is_in_memory (BRT brt, int size) { static DISKOFF malloc_diskblock_header_is_in_memory (BRT brt, int size) {
...@@ -1471,8 +1473,8 @@ int brt_create(BRT *brt_ptr) { ...@@ -1471,8 +1473,8 @@ int brt_create(BRT *brt_ptr) {
memset(brt, 0, sizeof *brt); memset(brt, 0, sizeof *brt);
brt->flags = 0; brt->flags = 0;
brt->nodesize = BRT_DEFAULT_NODE_SIZE; brt->nodesize = BRT_DEFAULT_NODE_SIZE;
brt->compare_fun = default_compare_fun; brt->compare_fun = toku_default_compare_fun;
brt->dup_compare = default_compare_fun; brt->dup_compare = toku_default_compare_fun;
*brt_ptr = brt; *brt_ptr = brt;
return 0; return 0;
} }
......
...@@ -267,7 +267,7 @@ int hashtable_find_last(HASHTABLE h, bytevec *key, ITEMLEN *keylen, bytevec *dat ...@@ -267,7 +267,7 @@ int hashtable_find_last(HASHTABLE h, bytevec *key, ITEMLEN *keylen, bytevec *dat
ITEMLEN best_kl, best_dl; ITEMLEN best_kl, best_dl;
HASHTABLE_ITERATE(h, this_k, this_kl, this_d, this_dl, HASHTABLE_ITERATE(h, this_k, this_kl, this_d, this_dl,
({ ({
if (best_k==0 || keycompare(best_k, best_kl, this_k, this_kl)<0) { if (best_k==0 || toku_keycompare(best_k, best_kl, this_k, this_kl)<0) {
best_k = this_k; best_k = this_k;
best_kl = this_kl; best_kl = this_kl;
best_d = this_d; best_d = this_d;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <string.h> #include <string.h>
#if 0 #if 0
int keycompare (bytevec key1b, ITEMLEN key1len, bytevec key2b, ITEMLEN key2len) { int toku_keycompare (bytevec key1b, ITEMLEN key1len, bytevec key2b, ITEMLEN key2len) {
const unsigned char *key1 = key1b; const unsigned char *key1 = key1b;
const unsigned char *key2 = key2b; const unsigned char *key2 = key2b;
while (key1len > 0 && key2len > 0) { while (key1len > 0 && key2len > 0) {
...@@ -20,7 +20,7 @@ int keycompare (bytevec key1b, ITEMLEN key1len, bytevec key2b, ITEMLEN key2len) ...@@ -20,7 +20,7 @@ int keycompare (bytevec key1b, ITEMLEN key1len, bytevec key2b, ITEMLEN key2len)
} }
#elif 0 #elif 0
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
if (key1len==key2len) { if (key1len==key2len) {
return memcmp(key1,key2,key1len); return memcmp(key1,key2,key1len);
} else if (key1len<key2len) { } else if (key1len<key2len) {
...@@ -28,12 +28,12 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { ...@@ -28,12 +28,12 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
if (r<=0) return -1; /* If the keys are the same up to 1's length, then return -1, since key1 is shorter than key2. */ if (r<=0) return -1; /* If the keys are the same up to 1's length, then return -1, since key1 is shorter than key2. */
else return 1; else return 1;
} else { } else {
return -keycompare(key2,key2len,key1,key1len); return -toku_keycompare(key2,key2len,key1,key1len);
} }
} }
#elif 0 #elif 0
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
if (key1len==key2len) { if (key1len==key2len) {
return memcmp(key1,key2,key1len); return memcmp(key1,key2,key1len);
} else if (key1len<key2len) { } else if (key1len<key2len) {
...@@ -48,7 +48,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { ...@@ -48,7 +48,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
} }
#elif 0 #elif 0
/* This one looks tighter, but it does use memcmp... */ /* This one looks tighter, but it does use memcmp... */
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
int comparelen = key1len<key2len ? key1len : key2len; int comparelen = key1len<key2len ? key1len : key2len;
const unsigned char *k1; const unsigned char *k1;
const unsigned char *k2; const unsigned char *k2;
...@@ -63,7 +63,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { ...@@ -63,7 +63,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
} }
#else #else
/* unroll that one four times */ /* unroll that one four times */
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
int comparelen = key1len<key2len ? key1len : key2len; int comparelen = key1len<key2len ? key1len : key2len;
const unsigned char *k1; const unsigned char *k1;
const unsigned char *k2; const unsigned char *k2;
...@@ -87,18 +87,18 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) { ...@@ -87,18 +87,18 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
#endif #endif
void test_keycompare (void) { void toku_test_keycompare (void) {
assert(keycompare("a",1, "a",1)==0); assert(toku_keycompare("a",1, "a",1)==0);
assert(keycompare("aa",2, "a",1)>0); assert(toku_keycompare("aa",2, "a",1)>0);
assert(keycompare("a",1, "aa",2)<0); assert(toku_keycompare("a",1, "aa",2)<0);
assert(keycompare("b",1, "aa",2)>0); assert(toku_keycompare("b",1, "aa",2)>0);
assert(keycompare("aa",2, "b",1)<0); assert(toku_keycompare("aa",2, "b",1)<0);
assert(keycompare("aaaba",5, "aaaba",5)==0); assert(toku_keycompare("aaaba",5, "aaaba",5)==0);
assert(keycompare("aaaba",5, "aaaaa",5)>0); assert(toku_keycompare("aaaba",5, "aaaaa",5)>0);
assert(keycompare("aaaaa",5, "aaaba",5)<0); assert(toku_keycompare("aaaaa",5, "aaaba",5)<0);
assert(keycompare("aaaaa",3, "aaaba",3)==0); assert(toku_keycompare("aaaaa",3, "aaaba",3)==0);
} }
int default_compare_fun (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) { int toku_default_compare_fun (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
return keycompare(a->data, a->size, b->data, b->size); return toku_keycompare(a->data, a->size, b->data, b->size);
} }
#include "ybt.h" #include "ybt.h"
#include "brttypes.h" #include "brttypes.h"
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len); int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
void test_keycompare (void) ; void toku_test_keycompare (void) ;
int default_compare_fun (DB *, const DBT *, const DBT*); int toku_default_compare_fun (DB *, const DBT *, const DBT*);
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
//#define USEPMA //#define USEPMA
#define USEHASH #define USEHASH
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len); int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
#ifdef USEPMA #ifdef USEPMA
......
...@@ -25,7 +25,7 @@ static void test_make_space_at (void) { ...@@ -25,7 +25,7 @@ static void test_make_space_at (void) {
key = "B"; key = "B";
key_B = kv_pair_malloc(key, strlen(key)+1, 0, 0); key_B = kv_pair_malloc(key, strlen(key)+1, 0, 0);
r=pma_create(&pma, default_compare_fun, 0); r=pma_create(&pma, toku_default_compare_fun, 0);
assert(r==0); assert(r==0);
assert(pma_n_entries(pma)==0); assert(pma_n_entries(pma)==0);
r=pmainternal_make_space_at(pma, 2); r=pmainternal_make_space_at(pma, 2);
...@@ -95,7 +95,7 @@ static void test_pma_find (void) { ...@@ -95,7 +95,7 @@ static void test_pma_find (void) {
pma->N = N; pma->N = N;
for (i=0; i<N; i++) pma->pairs[i]=0; for (i=0; i<N; i++) pma->pairs[i]=0;
assert(pma_index_limit(pma)==N); assert(pma_index_limit(pma)==N);
pma->compare_fun = default_compare_fun; pma->compare_fun = toku_default_compare_fun;
r=pmainternal_find(pma, fill_dbt(&k, "hello", 5), 0); r=pmainternal_find(pma, fill_dbt(&k, "hello", 5), 0);
assert(r==0); assert(r==0);
...@@ -278,7 +278,7 @@ static void do_delete (PMA pma, const void *key, int keylen, const void *data, i ...@@ -278,7 +278,7 @@ static void do_delete (PMA pma, const void *key, int keylen, const void *data, i
static void test_pma_random_pick (void) { static void test_pma_random_pick (void) {
PMA pma; PMA pma;
int r = pma_create(&pma, default_compare_fun, 0); int r = pma_create(&pma, toku_default_compare_fun, 0);
bytevec key,val; bytevec key,val;
ITEMLEN keylen,vallen; ITEMLEN keylen,vallen;
DBT k; DBT k;
...@@ -351,7 +351,7 @@ static void test_find_insert (void) { ...@@ -351,7 +351,7 @@ static void test_find_insert (void) {
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
pma_create(&pma, default_compare_fun, 0); pma_create(&pma, toku_default_compare_fun, 0);
r=pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v, 0); r=pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v, 0);
assert(r==DB_NOTFOUND); assert(r==DB_NOTFOUND);
...@@ -361,7 +361,7 @@ static void test_find_insert (void) { ...@@ -361,7 +361,7 @@ static void test_find_insert (void) {
r=pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v, 0); r=pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v, 0);
assert(r==BRT_OK); assert(r==BRT_OK);
assert(v.size==7); assert(v.size==7);
assert(keycompare(v.data,v.size,"aaadata", 7)==0); assert(toku_keycompare(v.data,v.size,"aaadata", 7)==0);
//toku_free(v.data); v.data=0; //toku_free(v.data); v.data=0;
do_insert(pma, "bbb", 4, "bbbdata", 8, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "bbb", 4, "bbbdata", 8, rand4fingerprint, &sum, &expect_fingerprint);
...@@ -369,12 +369,12 @@ static void test_find_insert (void) { ...@@ -369,12 +369,12 @@ static void test_find_insert (void) {
init_dbt(&v); init_dbt(&v);
r=pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v, 0); r=pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v, 0);
assert(r==BRT_OK); assert(r==BRT_OK);
assert(keycompare(v.data,v.size,"aaadata", 7)==0); assert(toku_keycompare(v.data,v.size,"aaadata", 7)==0);
init_dbt(&v); init_dbt(&v);
r=pma_lookup(pma, fill_dbt(&k, "bbb", 4), &v, 0); r=pma_lookup(pma, fill_dbt(&k, "bbb", 4), &v, 0);
assert(r==BRT_OK); assert(r==BRT_OK);
assert(keycompare(v.data,v.size,"bbbdata", 8)==0); assert(toku_keycompare(v.data,v.size,"bbbdata", 8)==0);
assert((unsigned long)pma->pairs[pma_index_limit(pma)]==0xdeadbeefL); assert((unsigned long)pma->pairs[pma_index_limit(pma)]==0xdeadbeefL);
...@@ -383,7 +383,7 @@ static void test_find_insert (void) { ...@@ -383,7 +383,7 @@ static void test_find_insert (void) {
assert((unsigned long)pma->pairs[pma_index_limit(pma)]==0xdeadbeefL); assert((unsigned long)pma->pairs[pma_index_limit(pma)]==0xdeadbeefL);
r=pma_free(&pma); assert(r==0); assert(pma==0); r=pma_free(&pma); assert(r==0); assert(pma==0);
pma_create(&pma, default_compare_fun, 0); assert(pma!=0); pma_create(&pma, toku_default_compare_fun, 0); assert(pma!=0);
rand4fingerprint = random(); rand4fingerprint = random();
sum = expect_fingerprint = 0; sum = expect_fingerprint = 0;
...@@ -426,7 +426,7 @@ static void test_pma_iterate (void) { ...@@ -426,7 +426,7 @@ static void test_pma_iterate (void) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
pma_create(&pma, default_compare_fun, 0); pma_create(&pma, toku_default_compare_fun, 0);
do_insert(pma, "42", 3, "-19", 4, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "42", 3, "-19", 4, rand4fingerprint, &sum, &expect_fingerprint);
test_pma_iterate_internal(pma, 42, -19); test_pma_iterate_internal(pma, 42, -19);
...@@ -449,8 +449,8 @@ static void test_pma_iterate2 (void) { ...@@ -449,8 +449,8 @@ static void test_pma_iterate2 (void) {
u_int32_t sum1 = 0; u_int32_t sum1 = 0;
u_int32_t expect_fingerprint1 = 0; u_int32_t expect_fingerprint1 = 0;
r=pma_create(&pma0, default_compare_fun, 0); assert(r==0); r=pma_create(&pma0, toku_default_compare_fun, 0); assert(r==0);
r=pma_create(&pma1, default_compare_fun, 0); assert(r==0); r=pma_create(&pma1, toku_default_compare_fun, 0); assert(r==0);
do_insert(pma0, "a", 2, "aval", 5, rand4fingerprint0, &sum0, &expect_fingerprint0); do_insert(pma0, "a", 2, "aval", 5, rand4fingerprint0, &sum0, &expect_fingerprint0);
do_insert(pma0, "b", 2, "bval", 5, rand4fingerprint0, &sum0, &expect_fingerprint0); do_insert(pma0, "b", 2, "bval", 5, rand4fingerprint0, &sum0, &expect_fingerprint0);
do_insert(pma1, "x", 2, "xval", 5, rand4fingerprint1, &sum1, &expect_fingerprint1); do_insert(pma1, "x", 2, "xval", 5, rand4fingerprint1, &sum1, &expect_fingerprint1);
...@@ -467,7 +467,7 @@ void test_pma_cursor_0 (void) { ...@@ -467,7 +467,7 @@ void test_pma_cursor_0 (void) {
PMA pma; PMA pma;
PMA_CURSOR c=0; PMA_CURSOR c=0;
int r; int r;
r=pma_create(&pma, default_compare_fun, 0); assert(r==0); r=pma_create(&pma, toku_default_compare_fun, 0); assert(r==0);
r=pma_cursor(pma, &c); assert(r==0); assert(c!=0); r=pma_cursor(pma, &c); assert(r==0); assert(c!=0);
printf("%s:%d\n", __FILE__, __LINE__); printf("%s:%d\n", __FILE__, __LINE__);
r=pma_free(&pma); assert(r!=0); /* didn't deallocate the cursor. */ r=pma_free(&pma); assert(r!=0); /* didn't deallocate the cursor. */
...@@ -485,7 +485,7 @@ void test_pma_cursor_1 (void) { ...@@ -485,7 +485,7 @@ void test_pma_cursor_1 (void) {
int r; int r;
int order; int order;
for (order=0; order<6; order++) { for (order=0; order<6; order++) {
r=pma_create(&pma, default_compare_fun, 0); assert(r==0); r=pma_create(&pma, toku_default_compare_fun, 0); assert(r==0);
r=pma_cursor(pma, &c0); assert(r==0); assert(c0!=0); r=pma_cursor(pma, &c0); assert(r==0); assert(c0!=0);
r=pma_cursor(pma, &c1); assert(r==0); assert(c1!=0); r=pma_cursor(pma, &c1); assert(r==0); assert(c1!=0);
r=pma_cursor(pma, &c2); assert(r==0); assert(c2!=0); r=pma_cursor(pma, &c2); assert(r==0); assert(c2!=0);
...@@ -516,7 +516,7 @@ void test_pma_cursor_2 (void) { ...@@ -516,7 +516,7 @@ void test_pma_cursor_2 (void) {
DBT key,val; DBT key,val;
init_dbt(&key); key.flags=DB_DBT_REALLOC; init_dbt(&key); key.flags=DB_DBT_REALLOC;
init_dbt(&val); val.flags=DB_DBT_REALLOC; init_dbt(&val); val.flags=DB_DBT_REALLOC;
r=pma_create(&pma, default_compare_fun, 0); assert(r==0); r=pma_create(&pma, toku_default_compare_fun, 0); assert(r==0);
r=pma_cursor(pma, &c); assert(r==0); assert(c!=0); r=pma_cursor(pma, &c); assert(r==0); assert(c!=0);
r=pma_cursor_set_position_last(c); assert(r==DB_NOTFOUND); r=pma_cursor_set_position_last(c); assert(r==DB_NOTFOUND);
r=pma_cursor_free(&c); assert(r==0); r=pma_cursor_free(&c); assert(r==0);
...@@ -533,7 +533,7 @@ void test_pma_cursor_3 (void) { ...@@ -533,7 +533,7 @@ void test_pma_cursor_3 (void) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r=pma_create(&pma, default_compare_fun, 0); assert(r==0); r=pma_create(&pma, toku_default_compare_fun, 0); assert(r==0);
do_insert(pma, "x", 2, "xx", 3, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "x", 2, "xx", 3, rand4fingerprint, &sum, &expect_fingerprint);
do_insert(pma, "m", 2, "mm", 3, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "m", 2, "mm", 3, rand4fingerprint, &sum, &expect_fingerprint);
do_insert(pma, "aa", 3, "a", 2, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "aa", 3, "a", 2, rand4fingerprint, &sum, &expect_fingerprint);
...@@ -599,7 +599,7 @@ void test_pma_cursor_4 (void) { ...@@ -599,7 +599,7 @@ void test_pma_cursor_4 (void) {
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
printf("test_pma_cursor_4\n"); printf("test_pma_cursor_4\n");
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
for (i=1; i<=4; i += 1) { for (i=1; i<=4; i += 1) {
...@@ -668,7 +668,7 @@ void test_pma_cursor_delete(int n) { ...@@ -668,7 +668,7 @@ void test_pma_cursor_delete(int n) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
/* insert 1 -> 42 */ /* insert 1 -> 42 */
...@@ -776,7 +776,7 @@ void test_pma_compare_fun (int wrong_endian_p) { ...@@ -776,7 +776,7 @@ void test_pma_compare_fun (int wrong_endian_p) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, wrong_endian_p ? wrong_endian_compare_fun : default_compare_fun, 0); assert(r==0); r = pma_create(&pma, wrong_endian_p ? wrong_endian_compare_fun : toku_default_compare_fun, 0); assert(r==0);
do_insert(pma, "10", 3, "10v", 4, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "10", 3, "10v", 4, rand4fingerprint, &sum, &expect_fingerprint);
do_insert(pma, "00", 3, "00v", 4, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "00", 3, "00v", 4, rand4fingerprint, &sum, &expect_fingerprint);
do_insert(pma, "01", 3, "01v", 4, rand4fingerprint, &sum, &expect_fingerprint); do_insert(pma, "01", 3, "01v", 4, rand4fingerprint, &sum, &expect_fingerprint);
...@@ -824,11 +824,11 @@ void test_pma_split_n(int n) { ...@@ -824,11 +824,11 @@ void test_pma_split_n(int n) {
printf("test_pma_split_n:%d\n", n); printf("test_pma_split_n:%d\n", n);
error = pma_create(&pmaa, default_compare_fun, 0); error = pma_create(&pmaa, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
error = pma_create(&pmab, default_compare_fun, 0); error = pma_create(&pmab, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
error = pma_create(&pmac, default_compare_fun, 0); error = pma_create(&pmac, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
/* insert some kv pairs */ /* insert some kv pairs */
...@@ -887,13 +887,13 @@ void test_pma_dup_split_n(int n, int dup_mode) { ...@@ -887,13 +887,13 @@ void test_pma_dup_split_n(int n, int dup_mode) {
printf("test_pma_dup_split_n:%d %d\n", n, dup_mode); printf("test_pma_dup_split_n:%d %d\n", n, dup_mode);
error = pma_create(&pmaa, default_compare_fun, 0); error = pma_create(&pmaa, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
pma_set_dup_mode(pmaa, dup_mode); pma_set_dup_mode(pmaa, dup_mode);
error = pma_create(&pmab, default_compare_fun, 0); error = pma_create(&pmab, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
pma_set_dup_mode(pmab, dup_mode); pma_set_dup_mode(pmab, dup_mode);
error = pma_create(&pmac, default_compare_fun, 0); error = pma_create(&pmac, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
pma_set_dup_mode(pmac, dup_mode); pma_set_dup_mode(pmac, dup_mode);
...@@ -966,11 +966,11 @@ void test_pma_split_varkey(void) { ...@@ -966,11 +966,11 @@ void test_pma_split_varkey(void) {
printf("test_pma_split_varkey\n"); printf("test_pma_split_varkey\n");
error = pma_create(&pmaa, default_compare_fun, 0); error = pma_create(&pmaa, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
error = pma_create(&pmab, default_compare_fun, 0); error = pma_create(&pmab, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
error = pma_create(&pmac, default_compare_fun, 0); error = pma_create(&pmac, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
/* insert some kv pairs */ /* insert some kv pairs */
...@@ -1084,11 +1084,11 @@ void test_pma_split_cursor(void) { ...@@ -1084,11 +1084,11 @@ void test_pma_split_cursor(void) {
printf("test_pma_split_cursor\n"); printf("test_pma_split_cursor\n");
error = pma_create(&pmaa, default_compare_fun, 0); error = pma_create(&pmaa, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
error = pma_create(&pmab, default_compare_fun, 0); error = pma_create(&pmab, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
error = pma_create(&pmac, default_compare_fun, 0); error = pma_create(&pmac, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
/* insert some kv pairs */ /* insert some kv pairs */
...@@ -1204,7 +1204,7 @@ void test_pma_bulk_insert_n(int n) { ...@@ -1204,7 +1204,7 @@ void test_pma_bulk_insert_n(int n) {
printf("test_pma_bulk_insert_n: %d\n", n); printf("test_pma_bulk_insert_n: %d\n", n);
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
/* init n kv pairs */ /* init n kv pairs */
...@@ -1287,7 +1287,7 @@ void test_pma_insert_or_replace(void) { ...@@ -1287,7 +1287,7 @@ void test_pma_insert_or_replace(void) {
u_int32_t rand4fingerprint = random(); u_int32_t rand4fingerprint = random();
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, 0); r = pma_create(&pma, toku_default_compare_fun, 0);
assert(r==0); assert(r==0);
r = pma_insert_or_replace(pma, fill_dbt(&dbtk, "aaa", 4), fill_dbt(&dbtv, "zzz", 4), &n_diff, NULL_ARGS, rand4fingerprint, &sum); r = pma_insert_or_replace(pma, fill_dbt(&dbtk, "aaa", 4), fill_dbt(&dbtv, "zzz", 4), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
assert(r==0); assert(n_diff==-1); assert(r==0); assert(n_diff==-1);
...@@ -1336,7 +1336,7 @@ void test_pma_delete_shrink(int n) { ...@@ -1336,7 +1336,7 @@ void test_pma_delete_shrink(int n) {
printf("test_pma_delete_shrink:%d\n", n); printf("test_pma_delete_shrink:%d\n", n);
r = pma_create(&pma, default_compare_fun, n*(8 + 11 + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, n*(8 + 11 + sizeof (int)));
assert(r == 0); assert(r == 0);
/* insert */ /* insert */
...@@ -1380,7 +1380,7 @@ void test_pma_delete_random(int n) { ...@@ -1380,7 +1380,7 @@ void test_pma_delete_random(int n) {
printf("test_pma_delete_random:%d\n", n); printf("test_pma_delete_random:%d\n", n);
r = pma_create(&pma, default_compare_fun, n * (8 + 11 + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, n * (8 + 11 + sizeof (int)));
assert(r == 0); assert(r == 0);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
...@@ -1454,7 +1454,7 @@ void test_pma_delete_cursor(int n) { ...@@ -1454,7 +1454,7 @@ void test_pma_delete_cursor(int n) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, 0); r = pma_create(&pma, toku_default_compare_fun, 0);
assert(r == 0); assert(r == 0);
int i; int i;
...@@ -1517,7 +1517,7 @@ void test_pma_delete_insert() { ...@@ -1517,7 +1517,7 @@ void test_pma_delete_insert() {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
PMA_CURSOR pmacursor; PMA_CURSOR pmacursor;
...@@ -1566,7 +1566,7 @@ void test_pma_double_delete() { ...@@ -1566,7 +1566,7 @@ void test_pma_double_delete() {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
PMA_CURSOR pmacursor; PMA_CURSOR pmacursor;
...@@ -1611,7 +1611,7 @@ void test_pma_cursor_first_delete_last() { ...@@ -1611,7 +1611,7 @@ void test_pma_cursor_first_delete_last() {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
int k, v; int k, v;
...@@ -1658,7 +1658,7 @@ void test_pma_cursor_last_delete_first() { ...@@ -1658,7 +1658,7 @@ void test_pma_cursor_last_delete_first() {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
int k, v; int k, v;
...@@ -1714,7 +1714,7 @@ void test_pma_already_there() { ...@@ -1714,7 +1714,7 @@ void test_pma_already_there() {
u_int32_t rand4fingerprint = random(); u_int32_t rand4fingerprint = random();
u_int32_t sum = 0; u_int32_t sum = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
DBT key, val; DBT key, val;
...@@ -1740,7 +1740,7 @@ void test_pma_cursor_set_key() { ...@@ -1740,7 +1740,7 @@ void test_pma_cursor_set_key() {
int error; int error;
PMA pma; PMA pma;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
DBT key, val; DBT key, val;
...@@ -1800,7 +1800,7 @@ void test_pma_cursor_set_range() { ...@@ -1800,7 +1800,7 @@ void test_pma_cursor_set_range() {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
error = pma_create(&pma, default_compare_fun, 0); error = pma_create(&pma, toku_default_compare_fun, 0);
assert(error == 0); assert(error == 0);
DBT key, val; DBT key, val;
...@@ -1860,7 +1860,7 @@ void test_pma_cursor_delete_under() { ...@@ -1860,7 +1860,7 @@ void test_pma_cursor_delete_under() {
const int n = 1000; const int n = 1000;
error = pma_create(&pma, default_compare_fun, n * (8 + sizeof (int) + sizeof (int))); error = pma_create(&pma, toku_default_compare_fun, n * (8 + sizeof (int) + sizeof (int)));
assert(error == 0); assert(error == 0);
PMA_CURSOR cursor; PMA_CURSOR cursor;
...@@ -1932,7 +1932,7 @@ void test_pma_cursor_set_both() { ...@@ -1932,7 +1932,7 @@ void test_pma_cursor_set_both() {
const int n = 1000; const int n = 1000;
error = pma_create(&pma, default_compare_fun, n * (8 + sizeof (int) + sizeof (int))); error = pma_create(&pma, toku_default_compare_fun, n * (8 + sizeof (int) + sizeof (int)));
assert(error == 0); assert(error == 0);
PMA_CURSOR cursor; PMA_CURSOR cursor;
...@@ -2007,7 +2007,7 @@ void test_nodup_key_insert(int n) { ...@@ -2007,7 +2007,7 @@ void test_nodup_key_insert(int n) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, n * (8 + sizeof (int) + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, n * (8 + sizeof (int) + sizeof (int)));
assert(r == 0); assert(r == 0);
/* insert 0->0, 0->1, .. 0->n-1 */ /* insert 0->0, 0->1, .. 0->n-1 */
...@@ -2044,7 +2044,7 @@ void test_dup_key_insert(int n) { ...@@ -2044,7 +2044,7 @@ void test_dup_key_insert(int n) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int)));
assert(r == 0); assert(r == 0);
pma_verify(pma, null_db); pma_verify(pma, null_db);
...@@ -2131,7 +2131,7 @@ void test_dup_key_delete(int n, int mode) { ...@@ -2131,7 +2131,7 @@ void test_dup_key_delete(int n, int mode) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int)));
assert(r == 0); assert(r == 0);
pma_verify(pma, null_db); pma_verify(pma, null_db);
...@@ -2139,7 +2139,7 @@ void test_dup_key_delete(int n, int mode) { ...@@ -2139,7 +2139,7 @@ void test_dup_key_delete(int n, int mode) {
assert(r == 0); assert(r == 0);
if (mode & TOKU_DB_DUPSORT) { if (mode & TOKU_DB_DUPSORT) {
r = pma_set_dup_compare(pma, default_compare_fun); r = pma_set_dup_compare(pma, toku_default_compare_fun);
assert(r == 0); assert(r == 0);
} }
...@@ -2232,14 +2232,14 @@ void test_dupsort_key_insert(int n, int dup_data) { ...@@ -2232,14 +2232,14 @@ void test_dupsort_key_insert(int n, int dup_data) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int)));
assert(r == 0); assert(r == 0);
pma_verify(pma, null_db); pma_verify(pma, null_db);
r = pma_set_dup_mode(pma, TOKU_DB_DUP+TOKU_DB_DUPSORT); r = pma_set_dup_mode(pma, TOKU_DB_DUP+TOKU_DB_DUPSORT);
assert(r == 0); assert(r == 0);
r = pma_set_dup_compare(pma, default_compare_fun); r = pma_set_dup_compare(pma, toku_default_compare_fun);
assert(r == 0); assert(r == 0);
DBT key, val; DBT key, val;
...@@ -2326,7 +2326,7 @@ void test_dup_key_lookup(int n, int mode) { ...@@ -2326,7 +2326,7 @@ void test_dup_key_lookup(int n, int mode) {
u_int32_t sum = 0; u_int32_t sum = 0;
u_int32_t expect_fingerprint = 0; u_int32_t expect_fingerprint = 0;
r = pma_create(&pma, default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int))); r = pma_create(&pma, toku_default_compare_fun, (n + 2) * (8 + sizeof (int) + sizeof (int)));
assert(r == 0); assert(r == 0);
pma_verify(pma, null_db); pma_verify(pma, null_db);
...@@ -2334,7 +2334,7 @@ void test_dup_key_lookup(int n, int mode) { ...@@ -2334,7 +2334,7 @@ void test_dup_key_lookup(int n, int mode) {
assert(r == 0); assert(r == 0);
if (mode & TOKU_DB_DUPSORT) { if (mode & TOKU_DB_DUPSORT) {
r = pma_set_dup_compare(pma, default_compare_fun); r = pma_set_dup_compare(pma, toku_default_compare_fun);
assert(r == 0); assert(r == 0);
} }
...@@ -2394,7 +2394,7 @@ void test_dup() { ...@@ -2394,7 +2394,7 @@ void test_dup() {
void pma_tests (void) { void pma_tests (void) {
memory_check=1; memory_check=1;
test_keycompare(); memory_check_all_free(); toku_test_keycompare(); memory_check_all_free();
test_pma_compare_fun(0); memory_check_all_free(); test_pma_compare_fun(0); memory_check_all_free();
test_pma_compare_fun(1); memory_check_all_free(); test_pma_compare_fun(1); memory_check_all_free();
test_pma_iterate(); test_pma_iterate();
......
...@@ -136,8 +136,6 @@ void pma_iterate (PMA, void(*)(bytevec,ITEMLEN,bytevec,ITEMLEN, void*), void*); ...@@ -136,8 +136,6 @@ void pma_iterate (PMA, void(*)(bytevec,ITEMLEN,bytevec,ITEMLEN, void*), void*);
body; \ body; \
} } }) } } })
int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len);
void pma_verify_fingerprint (PMA pma, u_int32_t rand4fingerprint, u_int32_t fingerprint); void pma_verify_fingerprint (PMA pma, u_int32_t rand4fingerprint, u_int32_t fingerprint);
#endif #endif
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