/* -*- mode: C; c-basic-offset: 4 -*- */ #ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." #include "brt.h" #include "key.h" #include "pma.h" #include "brt-internal.h" #include "memory.h" #include #include #include #include #include #include #include #include #include "test.h" static TOKUTXN const null_txn = 0; static DB * const null_db = 0; static void test0 (void) { BRT t; int r; CACHETABLE ct; char fname[]="testbrt.brt"; if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__); toku_memory_check=1; toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__); unlink(fname); 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 = 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); toku_memory_check_all_free(); } static void test1 (void) { BRT t; int r; CACHETABLE ct; char fname[]="testbrt.brt"; DBT k,v; toku_memory_check=1; toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0); toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn); { r = toku_brt_lookup(t, toku_fill_dbt(&k, "hello", 6), toku_init_dbt(&v)); assert(r==0); assert(strcmp(v.data, "there")==0); assert(v.size==6); } r = toku_close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); if (verbose) printf("test1 ok\n"); } static void test2 (int memcheck) { BRT t; int r; int i; CACHETABLE ct; char fname[]="testbrt.brt"; toku_memory_check=memcheck; if (verbose) printf("%s:%d checking\n", __FILE__, __LINE__); toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db); if (verbose) printf("%s:%d did setup\n", __FILE__, __LINE__); assert(r==0); for (i=0; i<2048; i++) { DBT k,v; char key[100],val[100]; snprintf(key,100,"hello%d",i); snprintf(val,100,"there%d",i); toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn); //printf("%s:%d did insert %d\n", __FILE__, __LINE__, i); if (0) { brt_flush(t); { int n = toku_get_n_items_malloced(); if (verbose) printf("%s:%d i=%d n_items_malloced=%d\n", __FILE__, __LINE__, i, n); if (n!=3) toku_print_malloced_items(); assert(n==3); } } } if (verbose) printf("%s:%d inserted\n", __FILE__, __LINE__); r = toku_close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); if (verbose) printf("test2 ok\n"); } static void test3 (int nodesize, int count, int memcheck) { BRT t; int r; struct timeval t0,t1; int i; CACHETABLE ct; char fname[]="testbrt.brt"; toku_memory_check=memcheck; toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); gettimeofday(&t0, 0); unlink(fname); 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=0) { char key[100], valexpected[100]; DBT k,v; if (i%1000==0 && verbose) { printf("r"); fflush(stdout); } snprintf(key, 100, "key%d", rk); snprintf(valexpected, 100, "val%d", values[rk]); r = toku_brt_lookup(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_init_dbt(&v)); assert(r==0); assert(v.size==(1+strlen(valexpected))); assert(memcmp(v.data,valexpected,v.size)==0); } } if (verbose) printf("\n"); toku_free(values); r = toku_close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); } static void test_dump_empty_db (void) { BRT t; CACHETABLE ct; int r; char fname[]="testbrt.brt"; toku_memory_check=1; r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0); if (verbose) toku_dump_brt(t); r = toku_close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); } /* Test running multiple trees in different files */ static void test_multiple_files_of_size (int size) { const char *n0 = "test0.brt"; const char *n1 = "test1.brt"; CACHETABLE ct; BRT t0,t1; int r,i; if (verbose) printf("test_multiple_files_of_size(%d)\n", size); unlink(n0); unlink(n1); toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); 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); toku_brt_insert(t0, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn); snprintf(val, 100, "Val%d", i); toku_brt_insert(t1, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn); } //toku_verify_brt(t0); //dump_brt(t0); //dump_brt(t1); toku_verify_brt(t0); toku_verify_brt(t1); r = toku_close_brt(t0); assert(r==0); r = toku_close_brt(t1); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_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 = toku_open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); if (verbose) printf("%s:%d r=%d\n", __FILE__, __LINE__,r); 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=toku_brt_lookup(t0, toku_fill_dbt(&k, key, 1+strlen(key)), toku_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=toku_brt_lookup(t1, toku_fill_dbt(&k, key, 1+strlen(key)), toku_init_dbt(&actual)); assert(r==0); assert(strcmp(val,actual.data)==0); assert(actual.size==1+strlen(val)); } r = toku_close_brt(t0); assert(r==0); r = toku_close_brt(t1); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); } static void test_multiple_files (void) { test_multiple_files_of_size (1<<12); test_multiple_files_of_size (1<<20); } static void test_named_db (void) { const char *n0 = "test0.brt"; const char *n1 = "test1.brt"; CACHETABLE ct; BRT t0; int r; DBT k,v; if (verbose) printf("test_named_db\n"); unlink(n0); unlink(n1); toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); 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); toku_brt_insert(t0, toku_fill_dbt(&k, "good", 5), toku_fill_dbt(&v, "day", 4), null_txn); assert(r==0); r = toku_close_brt(t0); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); 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_brt_lookup(t0, toku_fill_dbt(&k, "good", 5), toku_init_dbt(&v)); assert(r==0); assert(v.size==4); assert(strcmp(v.data,"day")==0); } r = toku_close_brt(t0); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); toku_memory_check_all_free(); } static void test_multiple_dbs (void) { const char *n0 = "test0.brt"; const char *n1 = "test1.brt"; CACHETABLE ct; BRT t0,t1; int r; DBT k,v; if (verbose) printf("test_multiple_dbs: "); unlink(n0); unlink(n1); toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); 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); toku_brt_insert(t0, toku_fill_dbt(&k, "good", 5), toku_fill_dbt(&v, "grief", 6), null_txn); assert(r==0); toku_brt_insert(t1, toku_fill_dbt(&k, "bad", 4), toku_fill_dbt(&v, "night", 6), null_txn); 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); toku_memory_check_all_free(); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); 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 = toku_brt_lookup(t0, toku_fill_dbt(&k, "good", 5), toku_init_dbt(&v)); assert(r==0); assert(v.size==6); assert(strcmp(v.data,"grief")==0); r = toku_brt_lookup(t1, toku_fill_dbt(&k, "good", 5), toku_init_dbt(&v)); assert(r!=0); r = toku_brt_lookup(t0, toku_fill_dbt(&k, "bad", 4), toku_init_dbt(&v)); assert(r!=0); r = toku_brt_lookup(t1, toku_fill_dbt(&k, "bad", 4), toku_init_dbt(&v)); assert(r==0); assert(v.size==6); assert(strcmp(v.data,"night")==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); toku_memory_check_all_free(); if (verbose) printf("ok\n"); } /* Test to see a single file can contain many databases. */ static void test_multiple_dbs_many (void) { enum { MANYN = 16 }; int i, r; const char *name = "test.brt"; CACHETABLE ct; BRT trees[MANYN]; if (verbose) printf("test_multiple_dbs_many:\n"); toku_memory_check_all_free(); unlink(name); r = toku_brt_create_cachetable(&ct, MANYN+4, ZERO_LSN, NULL_LOGGER); assert(r==0); for (i=0; idata; unsigned char *bd=b->data; unsigned int siz=a->size; assert(a->size==b->size); assert(db==&nonce_db); // make sure the db was passed down correctly for (i=0; ibd[siz-1-i]) return +1; } return 0; } static void test_wrongendian_compare (int wrong_p, unsigned int N) { const char *n="testbrt.brt"; CACHETABLE ct; BRT brt; BRT_CURSOR cursor; int r; DBT kbt, vbt; unsigned int i; unlink(n); toku_memory_check_all_free(); { char a[4]={0,1,0,0}; char b[4]={1,0,0,0}; DBT at, bt; assert(wrong_compare_fun(&nonce_db, toku_fill_dbt(&at, a, 4), toku_fill_dbt(&bt, b, 4))>0); assert(wrong_compare_fun(&nonce_db, toku_fill_dbt(&at, b, 4), toku_fill_dbt(&bt, a, 4))<0); } r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); //printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p); if (0) { // ???? Why is this commented out? 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; b[2] = a[1] = (i>>8)&255; b[1] = a[2] = (i>>16)&255; b[0] = a[3] = (i>>24)&255; toku_fill_dbt(&kbt, a, sizeof(a)); toku_fill_dbt(&vbt, b, sizeof(b)); if (verbose) 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 = toku_brt_insert(brt, &kbt, &vbt, null_txn); assert(r==0); } r = toku_brt_cursor(brt, &cursor); assert(r==0); for (i=0; i<2; i++) { toku_init_dbt(&kbt); toku_init_dbt(&vbt); r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn); assert(r==0); assert(kbt.size==4 && vbt.size==4); if (verbose) printf("%s:%d %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 = toku_close_brt(brt); } { toku_cachetable_verify(ct); 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>8)&255; b[1] = a[2] = (i>>16)&255; b[0] = a[3] = (i>>24)&255; toku_fill_dbt(&kbt, a, sizeof(a)); toku_fill_dbt(&vbt, b, sizeof(b)); 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 = toku_brt_insert(brt, &kbt, &vbt, null_txn); assert(r==0); toku_cachetable_verify(ct); } r = toku_brt_cursor(brt, &cursor); assert(r==0); int prev=-1; for (i=0; i %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]); this= ( (((unsigned char*)kbt.data)[3] << 24) + (((unsigned char*)kbt.data)[2] << 16) + (((unsigned char*)kbt.data)[1] << 8) + (((unsigned char*)kbt.data)[0] << 0)); assert(prevdata, a->size, b->data, b->size); } static void assert_cursor_notfound(BRT brt, int position) { BRT_CURSOR cursor; int r; DBT kbt, vbt; r = toku_brt_cursor(brt, &cursor); assert(r==0); toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = toku_brt_cursor_get(cursor, &kbt, &vbt, position, null_txn); assert(r == DB_NOTFOUND); r = toku_brt_cursor_close(cursor); assert(r==0); } static void assert_cursor_value(BRT brt, int position, long long value) { BRT_CURSOR cursor; int r; DBT kbt, vbt; long long v; r = toku_brt_cursor(brt, &cursor); assert(r==0); if (test_cursor_debug && verbose) printf("key: "); toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = toku_brt_cursor_get(cursor, &kbt, &vbt, position, null_txn); assert(r == 0); if (test_cursor_debug && verbose) printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == value); toku_free(kbt.data); toku_free(vbt.data); if (test_cursor_debug && verbose) printf("\n"); r = toku_brt_cursor_close(cursor); assert(r==0); } static void assert_cursor_first_last(BRT brt, long long firstv, long long lastv) { BRT_CURSOR cursor; int r; DBT kbt, vbt; long long v; r = toku_brt_cursor(brt, &cursor); assert(r==0); if (test_cursor_debug && verbose) printf("first key: "); toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_FIRST, null_txn); assert(r == 0); if (test_cursor_debug && verbose) printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == firstv); toku_free(kbt.data); toku_free(vbt.data); if (test_cursor_debug && verbose) printf("\n"); if (test_cursor_debug && verbose) printf("last key:"); toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, null_txn); assert(r == 0); if (test_cursor_debug)printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == lastv); toku_free(kbt.data); toku_free(vbt.data); if (test_cursor_debug) printf("\n"); r = toku_brt_cursor_close(cursor); assert(r==0); } static void test_brt_cursor_first(int n, DB *db) { const char *fname="testbrt.brt"; CACHETABLE ct; BRT brt; int r; int i; if (verbose) printf("test_brt_cursor_first:%d %p\n", n, db); unlink(fname); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); 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 */ for (i=0; i=0; i--) { char key[8]; long long v; DBT kbt, vbt; snprintf(key, sizeof key, "%4.4d", i); toku_fill_dbt(&kbt, key, strlen(key)+1); v = i; toku_fill_dbt(&vbt, &v, sizeof v); r = toku_brt_insert(brt, &kbt, &vbt, 0); assert(r==0); } if (n == 0) assert_cursor_notfound(brt, DB_FIRST); else assert_cursor_value(brt, DB_FIRST, 0); r = toku_close_brt(brt); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } static void assert_cursor_walk(BRT brt, int n) { BRT_CURSOR cursor; int i; int r; r = toku_brt_cursor(brt, &cursor); assert(r==0); if (test_cursor_debug && verbose) printf("key: "); for (i=0; ; i++) { DBT kbt, vbt; long long v; toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn); if (r != 0) break; if (test_cursor_debug && verbose) printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == i); toku_free(kbt.data); toku_free(vbt.data); } if (test_cursor_debug && verbose) printf("\n"); assert(i == n); r = toku_brt_cursor_close(cursor); assert(r==0); } static void test_brt_cursor_walk(int n, DB *db) { const char *fname="testbrt.brt"; CACHETABLE ct; BRT brt; int r; int i; if (verbose) printf("test_brt_cursor_walk:%d %p\n", n, db); unlink(fname); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); 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 */ for (i=0; i= v */ for (i=0; i max_key) /* there is no smallest key if v > the max key */ assert(r == DB_NOTFOUND); else { assert(r == 0); assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == (((v+9)/10)*10)); toku_free(val.data); } } r = toku_brt_cursor_close(cursor); assert(r==0); r = toku_close_brt(brt); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } static void test_brt_cursor_delete(int n, DB *db) { if (verbose) printf("test_brt_cursor_delete:%d %p\n", n, db); int error; char fname[]="testbrt.brt"; CACHETABLE ct; BRT brt; BRT_CURSOR cursor; unlink(fname); error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(error == 0); 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); assert(error == 0); DBT key, val; int k, v; int i; /* insert keys 0, 1, 2, .. (n-1) */ for (i=0; i 0) { k = htonl(n-1); toku_fill_dbt(&key, &k, sizeof k); r = toku_brt_delete(t, &key); assert(r == 0); k = htonl(n-1); toku_fill_dbt(&key, &k, sizeof k); toku_init_dbt(&val); val.flags = DB_DBT_MALLOC; r = toku_brt_lookup(t, &key, &val); assert(r == DB_NOTFOUND); } r = toku_close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } /* insert <0,0>, <0,1>, .. <0,n> delete_both <0,i> for all even i verify <0,i> exists for all odd i */ void test_brt_delete_both(int n) { if (verbose) printf("test_brt_delete_both:%d\n", n); BRT t; int r; CACHETABLE ct; char fname[]="testbrt.brt"; int i; r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = toku_brt_create(&t); assert(r == 0); r = toku_brt_set_flags(t, TOKU_DB_DUP + TOKU_DB_DUPSORT); assert(r == 0); r = toku_brt_set_nodesize(t, 4096); assert(r == 0); r = toku_brt_open(t, fname, fname, 0, 1, 1, 0, ct, null_txn); assert(r==0); DBT key, val; int k, v; for (i=0; i