Commit e976e235 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:3646] merging changes from tokudb.3646b. fixes #3646

git-svn-id: file:///svn/toku/tokudb@32975 c7de825b-a66e-492c-adef-691d508d4ae1
parent f398fd55
...@@ -421,12 +421,14 @@ struct __toku_db { ...@@ -421,12 +421,14 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags); int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags);
int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags); int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags);
void* __toku_dummy0[13]; void* __toku_dummy0[11];
char __toku_dummy1[96]; char __toku_dummy1[96];
void *api_internal; /* 32-bit offset=236 size=4, 64=bit offset=376 size=8 */ void *api_internal; /* 32-bit offset=236 size=4, 64=bit offset=376 size=8 */
void* __toku_dummy2[5]; void* __toku_dummy2[5];
......
...@@ -431,12 +431,14 @@ struct __toku_db { ...@@ -431,12 +431,14 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags); int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags);
int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags); int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags);
void* __toku_dummy0[16]; void* __toku_dummy0[14];
char __toku_dummy1[96]; char __toku_dummy1[96];
void *api_internal; /* 32-bit offset=248 size=4, 64=bit offset=400 size=8 */ void *api_internal; /* 32-bit offset=248 size=4, 64=bit offset=400 size=8 */
void* __toku_dummy2[5]; void* __toku_dummy2[5];
......
...@@ -433,12 +433,14 @@ struct __toku_db { ...@@ -433,12 +433,14 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags); int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags);
int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags); int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags);
void* __toku_dummy0[18]; void* __toku_dummy0[16];
char __toku_dummy1[96]; char __toku_dummy1[96];
void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */ void *api_internal; /* 32-bit offset=256 size=4, 64=bit offset=416 size=8 */
void* __toku_dummy2[5]; void* __toku_dummy2[5];
......
...@@ -433,12 +433,14 @@ struct __toku_db { ...@@ -433,12 +433,14 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags); int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags);
int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags); int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags);
void* __toku_dummy0[21]; void* __toku_dummy0[19];
char __toku_dummy1[96]; char __toku_dummy1[96];
void *api_internal; /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */ void *api_internal; /* 32-bit offset=268 size=4, 64=bit offset=440 size=8 */
void* __toku_dummy2[5]; void* __toku_dummy2[5];
......
...@@ -436,12 +436,14 @@ struct __toku_db { ...@@ -436,12 +436,14 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags); int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags);
int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags); int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags);
void* __toku_dummy1[25]; void* __toku_dummy1[23];
char __toku_dummy2[80]; char __toku_dummy2[80];
void *api_internal; /* 32-bit offset=276 size=4, 64=bit offset=464 size=8 */ void *api_internal; /* 32-bit offset=276 size=4, 64=bit offset=464 size=8 */
void* __toku_dummy3[5]; void* __toku_dummy3[5];
......
...@@ -684,6 +684,8 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ ...@@ -684,6 +684,8 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
"int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */", "int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */",
"int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */", "int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */",
"int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)", "int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)",
"int (*get_readpagesize)(DB*,u_int32_t*)",
"int (*set_readpagesize)(DB*,u_int32_t)",
"int (*set_indexer)(DB*, DB_INDEXER*)", "int (*set_indexer)(DB*, DB_INDEXER*)",
"void (*get_indexer)(DB*, DB_INDEXER**)", "void (*get_indexer)(DB*, DB_INDEXER**)",
"int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going)", "int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going)",
......
...@@ -405,6 +405,8 @@ struct __toku_db { ...@@ -405,6 +405,8 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
......
...@@ -405,6 +405,8 @@ struct __toku_db { ...@@ -405,6 +405,8 @@ struct __toku_db {
int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */; int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */;
int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */; int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */;
int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION); int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION);
int (*get_readpagesize)(DB*,u_int32_t*);
int (*set_readpagesize)(DB*,u_int32_t);
int (*set_indexer)(DB*, DB_INDEXER*); int (*set_indexer)(DB*, DB_INDEXER*);
void (*get_indexer)(DB*, DB_INDEXER**); void (*get_indexer)(DB*, DB_INDEXER**);
int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going); int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going);
......
...@@ -41,6 +41,7 @@ enum { BRT_CMD_OVERHEAD = (1 + sizeof(MSN)) // the type plus MSN ...@@ -41,6 +41,7 @@ enum { BRT_CMD_OVERHEAD = (1 + sizeof(MSN)) // the type plus MSN
}; };
enum { BRT_DEFAULT_NODE_SIZE = 1 << 22 }; enum { BRT_DEFAULT_NODE_SIZE = 1 << 22 };
enum { BRT_DEFAULT_BASEMENT_NODE_SIZE = 128 * 1024 };
struct nodeheader_in_file { struct nodeheader_in_file {
int n_in_buffer; int n_in_buffer;
...@@ -389,6 +390,7 @@ struct brt_header { ...@@ -389,6 +390,7 @@ struct brt_header {
BOOL upgrade_brt_performed; // initially FALSE, set TRUE when brt has been fully updated (even though nodes may not have been) BOOL upgrade_brt_performed; // initially FALSE, set TRUE when brt has been fully updated (even though nodes may not have been)
int64_t num_blocks_to_upgrade; // Number of v13 blocks still not newest version. When we release layout 15 we may need to turn this to an array or add more variables. int64_t num_blocks_to_upgrade; // Number of v13 blocks still not newest version. When we release layout 15 we may need to turn this to an array or add more variables.
unsigned int nodesize; unsigned int nodesize;
unsigned int basementnodesize;
BLOCKNUM root; // roots of the dictionary BLOCKNUM root; // roots of the dictionary
struct remembered_hash root_hash; // hash of the root offset. struct remembered_hash root_hash; // hash of the root offset.
unsigned int flags; unsigned int flags;
...@@ -419,6 +421,7 @@ struct brt { ...@@ -419,6 +421,7 @@ struct brt {
struct toku_list cursors; struct toku_list cursors;
unsigned int nodesize; unsigned int nodesize;
unsigned int basementnodesize;
unsigned int flags; unsigned int flags;
BOOL did_set_flags; BOOL did_set_flags;
int (*compare_fun)(DB*,const DBT*,const DBT*); int (*compare_fun)(DB*,const DBT*,const DBT*);
...@@ -442,6 +445,7 @@ struct brt { ...@@ -442,6 +445,7 @@ struct brt {
/* serialization code */ /* serialization code */
int toku_serialize_brtnode_to_memory (BRTNODE node, int toku_serialize_brtnode_to_memory (BRTNODE node,
unsigned int basementnodesize,
/*out*/ size_t *n_bytes_to_write, /*out*/ size_t *n_bytes_to_write,
/*out*/ char **bytes_to_write); /*out*/ char **bytes_to_write);
int toku_serialize_brtnode_to(int fd, BLOCKNUM, BRTNODE node, struct brt_header *h, int n_workitems, int n_threads, BOOL for_checkpoint); int toku_serialize_brtnode_to(int fd, BLOCKNUM, BRTNODE node, struct brt_header *h, int n_workitems, int n_threads, BOOL for_checkpoint);
......
...@@ -455,8 +455,6 @@ array_item (OMTVALUE lev, u_int32_t idx, void *vsi) { ...@@ -455,8 +455,6 @@ array_item (OMTVALUE lev, u_int32_t idx, void *vsi) {
return 0; return 0;
} }
#define BN_MAX_SIZE 128*1024
struct sum_info { struct sum_info {
unsigned int dsum; unsigned int dsum;
unsigned int msum; unsigned int msum;
...@@ -475,7 +473,7 @@ sum_item (OMTVALUE lev, u_int32_t UU(idx), void *vsi) { ...@@ -475,7 +473,7 @@ sum_item (OMTVALUE lev, u_int32_t UU(idx), void *vsi) {
// There must still be at least one child // There must still be at least one child
static void static void
rebalance_brtnode_leaf(BRTNODE node) rebalance_brtnode_leaf(BRTNODE node, unsigned int basementnodesize)
{ {
assert(node->height == 0); assert(node->height == 0);
assert(node->dirty); assert(node->dirty);
...@@ -506,7 +504,7 @@ rebalance_brtnode_leaf(BRTNODE node) ...@@ -506,7 +504,7 @@ rebalance_brtnode_leaf(BRTNODE node)
u_int32_t bn_size_so_far = 0; u_int32_t bn_size_so_far = 0;
for (u_int32_t i = 0; i < num_le; i++) { for (u_int32_t i = 0; i < num_le; i++) {
u_int32_t curr_size = leafentry_disksize(array[i]); u_int32_t curr_size = leafentry_disksize(array[i]);
if ((bn_size_so_far + curr_size > BN_MAX_SIZE) && (num_le_in_curr_bn != 0)) { if ((bn_size_so_far + curr_size > basementnodesize) && (num_le_in_curr_bn != 0)) {
// cap off the current basement node to end with the element before i // cap off the current basement node to end with the element before i
new_pivots[curr_pivot] = i-1; new_pivots[curr_pivot] = i-1;
curr_pivot++; curr_pivot++;
...@@ -535,7 +533,6 @@ rebalance_brtnode_leaf(BRTNODE node) ...@@ -535,7 +533,6 @@ rebalance_brtnode_leaf(BRTNODE node)
max_msn = (curr_msn.msn > max_msn.msn) ? curr_msn : max_msn; max_msn = (curr_msn.msn > max_msn.msn) ? curr_msn : max_msn;
} }
// Now destroy the old stuff; // Now destroy the old stuff;
toku_destroy_brtnode_internals(node); toku_destroy_brtnode_internals(node);
...@@ -611,13 +608,14 @@ rebalance_brtnode_leaf(BRTNODE node) ...@@ -611,13 +608,14 @@ rebalance_brtnode_leaf(BRTNODE node)
// //
int int
toku_serialize_brtnode_to_memory (BRTNODE node, toku_serialize_brtnode_to_memory (BRTNODE node,
unsigned int basementnodesize,
/*out*/ size_t *n_bytes_to_write, /*out*/ size_t *n_bytes_to_write,
/*out*/ char **bytes_to_write) /*out*/ char **bytes_to_write)
{ {
toku_assert_entire_node_in_memory(node); toku_assert_entire_node_in_memory(node);
if (node->height == 0) { if (node->height == 0) {
rebalance_brtnode_leaf(node); rebalance_brtnode_leaf(node, basementnodesize);
} }
const int npartitions = node->n_children; const int npartitions = node->n_children;
...@@ -714,7 +712,8 @@ toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct brt_h ...@@ -714,7 +712,8 @@ toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct brt_h
size_t n_to_write; size_t n_to_write;
char *compressed_buf = NULL; char *compressed_buf = NULL;
{ {
int r = toku_serialize_brtnode_to_memory (node, &n_to_write, &compressed_buf); int r = toku_serialize_brtnode_to_memory(node, h->basementnodesize,
&n_to_write, &compressed_buf);
if (r!=0) return r; if (r!=0) return r;
} }
...@@ -1413,6 +1412,7 @@ serialize_brt_header_min_size (u_int32_t version) { ...@@ -1413,6 +1412,7 @@ serialize_brt_header_min_size (u_int32_t version) {
switch(version) { switch(version) {
case BRT_LAYOUT_VERSION_15: case BRT_LAYOUT_VERSION_15:
size += 4; // basement node size
case BRT_LAYOUT_VERSION_14: case BRT_LAYOUT_VERSION_14:
size += 8; //TXNID that created size += 8; //TXNID that created
case BRT_LAYOUT_VERSION_13: case BRT_LAYOUT_VERSION_13:
...@@ -1479,6 +1479,7 @@ int toku_serialize_brt_header_to_wbuf (struct wbuf *wbuf, struct brt_header *h, ...@@ -1479,6 +1479,7 @@ int toku_serialize_brt_header_to_wbuf (struct wbuf *wbuf, struct brt_header *h,
} }
wbuf_ulonglong(wbuf, h->num_blocks_to_upgrade); wbuf_ulonglong(wbuf, h->num_blocks_to_upgrade);
wbuf_TXNID(wbuf, h->root_xid_that_created); wbuf_TXNID(wbuf, h->root_xid_that_created);
wbuf_int(wbuf, h->basementnodesize);
u_int32_t checksum = x1764_finish(&wbuf->checksum); u_int32_t checksum = x1764_finish(&wbuf->checksum);
wbuf_int(wbuf, checksum); wbuf_int(wbuf, checksum);
lazy_assert(wbuf->ndone == wbuf->size); lazy_assert(wbuf->ndone == wbuf->size);
...@@ -1745,6 +1746,9 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) { ...@@ -1745,6 +1746,9 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) {
// at this layer, this new field is the only difference between versions 13 and 14 // at this layer, this new field is the only difference between versions 13 and 14
rbuf_TXNID(&rc, &h->root_xid_that_created); rbuf_TXNID(&rc, &h->root_xid_that_created);
} }
if (h->layout_version >= BRT_LAYOUT_VERSION_15) {
h->basementnodesize = rbuf_int(&rc);
}
(void)rbuf_int(&rc); //Read in checksum and ignore (already verified). (void)rbuf_int(&rc); //Read in checksum and ignore (already verified).
if (rc.ndone!=rc.size) {ret = EINVAL; goto died1;} if (rc.ndone!=rc.size) {ret = EINVAL; goto died1;}
toku_free(rc.buf); toku_free(rc.buf);
...@@ -1795,6 +1799,8 @@ deserialize_brtheader_versioned (int fd, struct rbuf *rb, struct brt_header **br ...@@ -1795,6 +1799,8 @@ deserialize_brtheader_versioned (int fd, struct rbuf *rb, struct brt_header **br
upgrade++; upgrade++;
//Fall through on purpose //Fall through on purpose
case BRT_LAYOUT_VERSION_14: case BRT_LAYOUT_VERSION_14:
h->basementnodesize = 128*1024; // basement nodes added in v15
//fall through on purpose
case BRT_LAYOUT_VERSION_15: case BRT_LAYOUT_VERSION_15:
invariant(h->layout_version == BRT_LAYOUT_VERSION); invariant(h->layout_version == BRT_LAYOUT_VERSION);
h->upgrade_brt_performed = FALSE; h->upgrade_brt_performed = FALSE;
......
...@@ -1024,6 +1024,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r ...@@ -1024,6 +1024,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r
void void
toku_create_new_brtnode (BRT t, BRTNODE *result, int height, int n_children) { toku_create_new_brtnode (BRT t, BRTNODE *result, int height, int n_children) {
assert(t->h->nodesize > 0); assert(t->h->nodesize > 0);
assert(t->h->basementnodesize > 0);
if (height == 0) if (height == 0)
assert(n_children > 0); assert(n_children > 0);
...@@ -3514,7 +3515,7 @@ toku_brt_send_delete(BRT brt, DBT *key, XIDS xids) { ...@@ -3514,7 +3515,7 @@ toku_brt_send_delete(BRT brt, DBT *key, XIDS xids) {
/* ******************** open,close and create ********************** */ /* ******************** open,close and create ********************** */
// Test only function (not used in running system). This one has no env // Test only function (not used in running system). This one has no env
int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize, CACHETABLE cachetable, TOKUTXN txn, int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize, int basementnodesize, CACHETABLE cachetable, TOKUTXN txn,
int (*compare_fun)(DB*,const DBT*,const DBT*), DB *db) { int (*compare_fun)(DB*,const DBT*,const DBT*), DB *db) {
BRT brt; BRT brt;
int r; int r;
...@@ -3524,6 +3525,7 @@ int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize, ...@@ -3524,6 +3525,7 @@ int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize,
if (r != 0) if (r != 0)
return r; return r;
r = toku_brt_set_nodesize(brt, nodesize); assert_zero(r); r = toku_brt_set_nodesize(brt, nodesize); assert_zero(r);
r = toku_brt_set_basementnodesize(brt, basementnodesize); assert_zero(r);
r = toku_brt_set_bt_compare(brt, compare_fun); assert_zero(r); r = toku_brt_set_bt_compare(brt, compare_fun); assert_zero(r);
r = toku_brt_open(brt, fname, is_create, only_create, cachetable, txn, db); r = toku_brt_open(brt, fname, is_create, only_create, cachetable, txn, db);
...@@ -3631,6 +3633,7 @@ brt_init_header_partial (BRT t, TOKUTXN txn) { ...@@ -3631,6 +3633,7 @@ brt_init_header_partial (BRT t, TOKUTXN txn) {
if (t->h->cf!=NULL) assert(t->h->cf == t->cf); if (t->h->cf!=NULL) assert(t->h->cf == t->cf);
t->h->cf = t->cf; t->h->cf = t->cf;
t->h->nodesize=t->nodesize; t->h->nodesize=t->nodesize;
t->h->basementnodesize=t->basementnodesize;
t->h->num_blocks_to_upgrade = 0; t->h->num_blocks_to_upgrade = 0;
t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE; t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE;
...@@ -3904,7 +3907,7 @@ brt_open(BRT t, const char *fname_in_env, int is_create, int only_create, CACHET ...@@ -3904,7 +3907,7 @@ brt_open(BRT t, const char *fname_in_env, int is_create, int only_create, CACHET
if (r != 0) goto died1; if (r != 0) goto died1;
} }
txn_created = (BOOL)(txn!=NULL); txn_created = (BOOL)(txn!=NULL);
r = toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, t->flags, t->nodesize); r = toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, t->flags, t->nodesize, t->basementnodesize);
if (r!=0) goto died1; if (r!=0) goto died1;
r = brt_create_file(t, fname_in_cwd, &fd); r = brt_create_file(t, fname_in_cwd, &fd);
} }
...@@ -3948,6 +3951,7 @@ brt_open(BRT t, const char *fname_in_env, int is_create, int only_create, CACHET ...@@ -3948,6 +3951,7 @@ brt_open(BRT t, const char *fname_in_env, int is_create, int only_create, CACHET
if ((r = toku_read_brt_header_and_store_in_cachefile(t->cf, max_acceptable_lsn, &t->h, &was_already_open))!=0) goto died_after_open; if ((r = toku_read_brt_header_and_store_in_cachefile(t->cf, max_acceptable_lsn, &t->h, &was_already_open))!=0) goto died_after_open;
found_it: found_it:
t->nodesize = t->h->nodesize; /* inherit the pagesize from the file */ t->nodesize = t->h->nodesize; /* inherit the pagesize from the file */
t->basementnodesize = t->h->basementnodesize;
if (!t->did_set_flags) { if (!t->did_set_flags) {
r = verify_builtin_comparisons_consistent(t, t->flags); r = verify_builtin_comparisons_consistent(t, t->flags);
if (r!=0) goto died_after_read_and_pin; if (r!=0) goto died_after_read_and_pin;
...@@ -4044,6 +4048,8 @@ brt_open_for_redirect(BRT *new_brtp, const char *fname_in_env, TOKUTXN txn, BRT ...@@ -4044,6 +4048,8 @@ brt_open_for_redirect(BRT *new_brtp, const char *fname_in_env, TOKUTXN txn, BRT
assert_zero(r); assert_zero(r);
r = toku_brt_set_nodesize(t, old_brt->nodesize); r = toku_brt_set_nodesize(t, old_brt->nodesize);
assert_zero(r); assert_zero(r);
r = toku_brt_set_basementnodesize(t, old_brt->basementnodesize);
assert_zero(r);
CACHETABLE ct = toku_cachefile_get_cachetable(old_brt->cf); CACHETABLE ct = toku_cachefile_get_cachetable(old_brt->cf);
r = brt_open(t, fname_in_env, 0, 0, ct, txn, old_brt->db, FILENUM_NONE, old_h->dict_id, MAX_LSN); r = brt_open(t, fname_in_env, 0, 0, ct, txn, old_brt->db, FILENUM_NONE, old_h->dict_id, MAX_LSN);
assert_zero(r); assert_zero(r);
...@@ -4339,6 +4345,16 @@ int toku_brt_get_nodesize(BRT brt, unsigned int *nodesize) { ...@@ -4339,6 +4345,16 @@ int toku_brt_get_nodesize(BRT brt, unsigned int *nodesize) {
return 0; return 0;
} }
int toku_brt_set_basementnodesize(BRT brt, unsigned int basementnodesize) {
brt->basementnodesize = basementnodesize;
return 0;
}
int toku_brt_get_basementnodesize(BRT brt, unsigned int *basementnodesize) {
*basementnodesize = brt->basementnodesize;
return 0;
}
int toku_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; brt->compare_fun = bt_compare;
return 0; return 0;
...@@ -4683,6 +4699,7 @@ int toku_brt_create(BRT *brt_ptr) { ...@@ -4683,6 +4699,7 @@ int toku_brt_create(BRT *brt_ptr) {
brt->flags = 0; brt->flags = 0;
brt->did_set_flags = FALSE; brt->did_set_flags = FALSE;
brt->nodesize = BRT_DEFAULT_NODE_SIZE; brt->nodesize = BRT_DEFAULT_NODE_SIZE;
brt->basementnodesize = BRT_DEFAULT_BASEMENT_NODE_SIZE;
brt->compare_fun = toku_builtin_compare_fun; brt->compare_fun = toku_builtin_compare_fun;
brt->update_fun = NULL; brt->update_fun = NULL;
int r = toku_omt_create(&brt->txns); int r = toku_omt_create(&brt->txns);
......
...@@ -28,7 +28,7 @@ C_BEGIN ...@@ -28,7 +28,7 @@ C_BEGIN
//-infinity depending on direction) //-infinity depending on direction)
typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void*); typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void*);
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result)); int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result));
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn); int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn);
int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd); int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
...@@ -44,6 +44,8 @@ int toku_brt_set_flags(BRT, unsigned int flags) __attribute__ ((warn_unused_res ...@@ -44,6 +44,8 @@ int toku_brt_set_flags(BRT, unsigned int flags) __attribute__ ((warn_unused_res
int toku_brt_get_flags(BRT, unsigned int *flags) __attribute__ ((warn_unused_result)); int toku_brt_get_flags(BRT, unsigned int *flags) __attribute__ ((warn_unused_result));
int toku_brt_set_nodesize(BRT, unsigned int nodesize) __attribute__ ((warn_unused_result)); int toku_brt_set_nodesize(BRT, unsigned int nodesize) __attribute__ ((warn_unused_result));
int toku_brt_get_nodesize(BRT, unsigned int *nodesize) __attribute__ ((warn_unused_result)); int toku_brt_get_nodesize(BRT, unsigned int *nodesize) __attribute__ ((warn_unused_result));
int toku_brt_set_basementnodesize(BRT, unsigned int basementnodesize) __attribute__ ((warn_unused_result));
int toku_brt_get_basementnodesize(BRT, unsigned int *basementnodesize) __attribute__ ((warn_unused_result));
int toku_brt_set_bt_compare(BRT, brt_compare_func) __attribute__ ((warn_unused_result)); int toku_brt_set_bt_compare(BRT, brt_compare_func) __attribute__ ((warn_unused_result));
brt_compare_func toku_brt_get_bt_compare (BRT brt); brt_compare_func toku_brt_get_bt_compare (BRT brt);
......
...@@ -18,7 +18,7 @@ enum brt_layout_version_e { ...@@ -18,7 +18,7 @@ enum brt_layout_version_e {
BRT_LAYOUT_VERSION_12 = 12, // Diff from 11 to 12: Added BRT_CMD 'BRT_INSERT_NO_OVERWRITE', compressed block format, num old blocks BRT_LAYOUT_VERSION_12 = 12, // Diff from 11 to 12: Added BRT_CMD 'BRT_INSERT_NO_OVERWRITE', compressed block format, num old blocks
BRT_LAYOUT_VERSION_13 = 13, // Diff from 12 to 13: Fixed loader pivot bug, added build_id to every node, timestamps to brtheader BRT_LAYOUT_VERSION_13 = 13, // Diff from 12 to 13: Fixed loader pivot bug, added build_id to every node, timestamps to brtheader
BRT_LAYOUT_VERSION_14 = 14, // Diff from 13 to 14: Added MVCC; deprecated TOKU_DB_VALCMP_BUILTIN(_13); Remove fingerprints; Support QUICKLZ; add end-to-end checksum on uncompressed data. BRT_LAYOUT_VERSION_14 = 14, // Diff from 13 to 14: Added MVCC; deprecated TOKU_DB_VALCMP_BUILTIN(_13); Remove fingerprints; Support QUICKLZ; add end-to-end checksum on uncompressed data.
BRT_LAYOUT_VERSION_15 = 15, // Diff from 14 to 15: TODO BRT_LAYOUT_VERSION_15 = 15, // Diff from 14 to 15: basement nodes, TODO
BRT_NEXT_VERSION, // the version after the current version BRT_NEXT_VERSION, // the version after the current version
BRT_LAYOUT_VERSION = BRT_NEXT_VERSION-1, // A hack so I don't have to change this line. BRT_LAYOUT_VERSION = BRT_NEXT_VERSION-1, // A hack so I don't have to change this line.
BRT_LAYOUT_MIN_SUPPORTED_VERSION = BRT_LAYOUT_VERSION_13, // Minimum version supported BRT_LAYOUT_MIN_SUPPORTED_VERSION = BRT_LAYOUT_VERSION_13, // Minimum version supported
......
...@@ -101,6 +101,7 @@ dump_header (int f, struct brt_header **header, CACHEFILE cf) { ...@@ -101,6 +101,7 @@ dump_header (int f, struct brt_header **header, CACHEFILE cf) {
printf(" dirty=%d\n", h->dirty); printf(" dirty=%d\n", h->dirty);
printf(" nodesize=%u\n", h->nodesize); printf(" nodesize=%u\n", h->nodesize);
printf(" basementnodesize=%u\n", h->basementnodesize);
printf(" unnamed_root=%" PRId64 "\n", h->root.b); printf(" unnamed_root=%" PRId64 "\n", h->root.b);
printf(" flags=%u\n", h->flags); printf(" flags=%u\n", h->flags);
dump_descriptor(&h->descriptor); dump_descriptor(&h->descriptor);
......
...@@ -188,6 +188,7 @@ struct fractal_thread_args { ...@@ -188,6 +188,7 @@ struct fractal_thread_args {
int errno_result; // the final result. int errno_result; // the final result.
int which_db; int which_db;
uint32_t target_nodesize; uint32_t target_nodesize;
uint32_t target_basementnodesize;
}; };
void toku_brt_loader_set_n_rows(BRTLOADER bl, u_int64_t n_rows); void toku_brt_loader_set_n_rows(BRTLOADER bl, u_int64_t n_rows);
...@@ -220,7 +221,8 @@ int toku_loader_write_brt_from_q_in_C (BRTLOADER bl, ...@@ -220,7 +221,8 @@ int toku_loader_write_brt_from_q_in_C (BRTLOADER bl,
QUEUE q, QUEUE q,
uint64_t total_disksize_estimate, uint64_t total_disksize_estimate,
int which_db, int which_db,
uint32_t target_nodesize); uint32_t target_nodesize,
uint32_t target_basementnodesize);
int brt_loader_mergesort_row_array (struct row rows[/*n*/], int n, int which_db, DB *dest_db, brt_compare_func, BRTLOADER, struct rowset *); int brt_loader_mergesort_row_array (struct row rows[/*n*/], int n, int which_db, DB *dest_db, brt_compare_func, BRTLOADER, struct rowset *);
......
This diff is collapsed.
...@@ -129,6 +129,7 @@ const struct logtype logtypes[] = { ...@@ -129,6 +129,7 @@ const struct logtype logtypes[] = {
{"u_int32_t", "mode", "0%o"}, {"u_int32_t", "mode", "0%o"},
{"u_int32_t", "treeflags", 0}, {"u_int32_t", "treeflags", 0},
{"u_int32_t", "nodesize", 0}, {"u_int32_t", "nodesize", 0},
{"u_int32_t", "basementnodesize", 0},
NULLFIELD}}, NULLFIELD}},
//TODO: #2037 Add dname //TODO: #2037 Add dname
{"fopen", 'O', FA{{"BYTESTRING", "iname", 0}, {"fopen", 'O', FA{{"BYTESTRING", "iname", 0},
......
...@@ -846,12 +846,12 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn) ...@@ -846,12 +846,12 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn)
} }
// fname is the iname // fname is the iname
int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_int32_t mode, u_int32_t treeflags, u_int32_t nodesize) { int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_int32_t mode, u_int32_t treeflags, u_int32_t nodesize, u_int32_t basementnodesize) {
if (txn==0) return 0; if (txn==0) return 0;
if (txn->logger->is_panicked) return EINVAL; if (txn->logger->is_panicked) return EINVAL;
BYTESTRING bs_fname = { .len=strlen(fname), .data = (char *) fname }; BYTESTRING bs_fname = { .len=strlen(fname), .data = (char *) fname };
// fsync log on fcreate // fsync log on fcreate
int r = toku_log_fcreate (txn->logger, (LSN*)0, 1, toku_txn_get_txnid(txn), filenum, bs_fname, mode, treeflags, nodesize); int r = toku_log_fcreate (txn->logger, (LSN*)0, 1, toku_txn_get_txnid(txn), filenum, bs_fname, mode, treeflags, nodesize, basementnodesize);
return r; return r;
} }
......
...@@ -57,7 +57,7 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn); ...@@ -57,7 +57,7 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn);
// Returns: 0 if success // Returns: 0 if success
int toku_logger_maybe_trim_log(TOKULOGGER logger, LSN oldest_open_lsn); int toku_logger_maybe_trim_log(TOKULOGGER logger, LSN oldest_open_lsn);
int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_int32_t mode, u_int32_t flags, u_int32_t nodesize); int toku_logger_log_fcreate (TOKUTXN txn, const char *fname, FILENUM filenum, u_int32_t mode, u_int32_t flags, u_int32_t nodesize, u_int32_t basementnodesize);
int toku_logger_log_fdelete (TOKUTXN txn, const char *fname); int toku_logger_log_fdelete (TOKUTXN txn, const char *fname);
int toku_logger_log_fopen (TOKUTXN txn, const char * fname, FILENUM filenum, uint32_t treeflags); int toku_logger_log_fopen (TOKUTXN txn, const char * fname, FILENUM filenum, uint32_t treeflags);
......
...@@ -241,7 +241,7 @@ static void recover_yield(voidfp f, void *fpthunk, void *UU(yieldthunk)) { ...@@ -241,7 +241,7 @@ static void recover_yield(voidfp f, void *fpthunk, void *UU(yieldthunk)) {
// Open the file if it is not already open. If it is already open, then do nothing. // Open the file if it is not already open. If it is already open, then do nothing.
static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create, int mode, BYTESTRING *bs_iname, FILENUM filenum, u_int32_t treeflags, static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create, int mode, BYTESTRING *bs_iname, FILENUM filenum, u_int32_t treeflags,
TOKUTXN txn, uint32_t nodesize, LSN max_acceptable_lsn) { TOKUTXN txn, uint32_t nodesize, uint32_t basementnodesize, LSN max_acceptable_lsn) {
int r; int r;
char *iname = fixup_fname(bs_iname); char *iname = fixup_fname(bs_iname);
...@@ -257,6 +257,11 @@ static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create ...@@ -257,6 +257,11 @@ static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create
assert(r == 0); assert(r == 0);
} }
if (basementnodesize != 0) {
r = toku_brt_set_basementnodesize(brt, basementnodesize);
assert(r == 0);
}
// set the key compare functions // set the key compare functions
if (!(treeflags & TOKU_DB_KEYCMP_BUILTIN) && renv->bt_compare) { if (!(treeflags & TOKU_DB_KEYCMP_BUILTIN) && renv->bt_compare) {
r = toku_brt_set_bt_compare(brt, renv->bt_compare); r = toku_brt_set_bt_compare(brt, renv->bt_compare);
...@@ -417,7 +422,7 @@ static int toku_recover_fassociate (struct logtype_fassociate *l, RECOVER_ENV re ...@@ -417,7 +422,7 @@ static int toku_recover_fassociate (struct logtype_fassociate *l, RECOVER_ENV re
LSN max_acceptable_lsn = MAX_LSN; LSN max_acceptable_lsn = MAX_LSN;
if (rollback_file) if (rollback_file)
max_acceptable_lsn = renv->ss.checkpoint_begin_lsn; max_acceptable_lsn = renv->ss.checkpoint_begin_lsn;
r = internal_recover_fopen_or_fcreate(renv, FALSE, 0, &l->iname, l->filenum, l->treeflags, NULL, 0, max_acceptable_lsn); r = internal_recover_fopen_or_fcreate(renv, FALSE, 0, &l->iname, l->filenum, l->treeflags, NULL, 0, 0, max_acceptable_lsn);
if (r==0 && rollback_file) { if (r==0 && rollback_file) {
//Load rollback cachefile //Load rollback cachefile
r = file_map_find(&renv->fmap, l->filenum, &tuple); r = file_map_find(&renv->fmap, l->filenum, &tuple);
...@@ -646,7 +651,7 @@ static int toku_recover_fcreate (struct logtype_fcreate *l, RECOVER_ENV renv) { ...@@ -646,7 +651,7 @@ static int toku_recover_fcreate (struct logtype_fcreate *l, RECOVER_ENV renv) {
toku_free(iname); toku_free(iname);
BOOL must_create = TRUE; BOOL must_create = TRUE;
r = internal_recover_fopen_or_fcreate(renv, must_create, l->mode, &l->iname, l->filenum, l->treeflags, txn, l->nodesize, MAX_LSN); r = internal_recover_fopen_or_fcreate(renv, must_create, l->mode, &l->iname, l->filenum, l->treeflags, txn, l->nodesize, l->basementnodesize, MAX_LSN);
return r; return r;
} }
...@@ -671,7 +676,7 @@ static int toku_recover_fopen (struct logtype_fopen *l, RECOVER_ENV renv) { ...@@ -671,7 +676,7 @@ static int toku_recover_fopen (struct logtype_fopen *l, RECOVER_ENV renv) {
if (strcmp(fname, ROLLBACK_CACHEFILE_NAME)) { if (strcmp(fname, ROLLBACK_CACHEFILE_NAME)) {
//Rollback cachefile can only be opened via fassociate. //Rollback cachefile can only be opened via fassociate.
r = internal_recover_fopen_or_fcreate(renv, must_create, 0, &l->iname, l->filenum, l->treeflags, txn, 0, MAX_LSN); r = internal_recover_fopen_or_fcreate(renv, must_create, 0, &l->iname, l->filenum, l->treeflags, txn, 0, 0, MAX_LSN);
} }
toku_free(fname); toku_free(fname);
return r; return r;
......
...@@ -16,8 +16,10 @@ enum { ITEMS_TO_INSERT_PER_ITERATION = 1<<20 }; ...@@ -16,8 +16,10 @@ enum { ITEMS_TO_INSERT_PER_ITERATION = 1<<20 };
enum { BOUND_INCREASE_PER_ITERATION = SERIAL_SPACING*ITEMS_TO_INSERT_PER_ITERATION }; enum { BOUND_INCREASE_PER_ITERATION = SERIAL_SPACING*ITEMS_TO_INSERT_PER_ITERATION };
enum { NODE_SIZE = 1<<20 }; enum { NODE_SIZE = 1<<20 };
enum { BASEMENT_NODE_SIZE = 128 * 1024 };
static int nodesize = NODE_SIZE; static int nodesize = NODE_SIZE;
static int basementnodesize = BASEMENT_NODE_SIZE;
static int keysize = sizeof (long long); static int keysize = sizeof (long long);
static int valsize = sizeof (long long); static int valsize = sizeof (long long);
static int do_verify =0; /* Do a slow verify after every insert. */ static int do_verify =0; /* Do a slow verify after every insert. */
...@@ -32,7 +34,7 @@ static void setup (void) { ...@@ -32,7 +34,7 @@ static void setup (void) {
int r; int r;
unlink(fname); unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, ct, NULL_TXN, toku_builtin_compare_fun, (DB*)0); assert(r==0); r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, NULL_TXN, toku_builtin_compare_fun, (DB*)0); assert(r==0);
} }
static void toku_shutdown (void) { static void toku_shutdown (void) {
......
...@@ -14,6 +14,7 @@ static void test_sub_block(int n) { ...@@ -14,6 +14,7 @@ static void test_sub_block(int n) {
const char fname[]= __FILE__ ".brt"; const char fname[]= __FILE__ ".brt";
const int nodesize = 4*1024*1024; const int nodesize = 4*1024*1024;
const int basementnodesize = 128*1024;
TOKUTXN const null_txn = 0; TOKUTXN const null_txn = 0;
DB * const null_db = 0; DB * const null_db = 0;
...@@ -28,7 +29,7 @@ static void test_sub_block(int n) { ...@@ -28,7 +29,7 @@ static void test_sub_block(int n) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0); assert(error == 0);
error = toku_open_brt(fname, TRUE, &brt, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); error = toku_open_brt(fname, TRUE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(error == 0); assert(error == 0);
// insert keys 0, 1, 2, .. (n-1) // insert keys 0, 1, 2, .. (n-1)
...@@ -47,7 +48,7 @@ static void test_sub_block(int n) { ...@@ -47,7 +48,7 @@ static void test_sub_block(int n) {
assert(error == 0); assert(error == 0);
// verify the brt by walking a cursor through the rows // verify the brt by walking a cursor through the rows
error = toku_open_brt(fname, FALSE, &brt, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); error = toku_open_brt(fname, FALSE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(error == 0); assert(error == 0);
BRT_CURSOR cursor; BRT_CURSOR cursor;
......
...@@ -193,6 +193,7 @@ test_serialize_leaf_with_large_pivots(enum brtnode_verify_type bft) { ...@@ -193,6 +193,7 @@ test_serialize_leaf_with_large_pivots(enum brtnode_verify_type bft) {
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
...@@ -307,6 +308,7 @@ test_serialize_leaf_with_many_rows(enum brtnode_verify_type bft) { ...@@ -307,6 +308,7 @@ test_serialize_leaf_with_many_rows(enum brtnode_verify_type bft) {
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
...@@ -427,6 +429,7 @@ test_serialize_leaf_with_large_rows(enum brtnode_verify_type bft) { ...@@ -427,6 +429,7 @@ test_serialize_leaf_with_large_rows(enum brtnode_verify_type bft) {
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
...@@ -551,6 +554,7 @@ test_serialize_leaf_with_empty_basement_nodes(enum brtnode_verify_type bft) { ...@@ -551,6 +554,7 @@ test_serialize_leaf_with_empty_basement_nodes(enum brtnode_verify_type bft) {
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
...@@ -662,6 +666,7 @@ test_serialize_leaf_with_multiple_empty_basement_nodes(enum brtnode_verify_type ...@@ -662,6 +666,7 @@ test_serialize_leaf_with_multiple_empty_basement_nodes(enum brtnode_verify_type
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
...@@ -780,6 +785,7 @@ test_serialize_leaf(enum brtnode_verify_type bft) { ...@@ -780,6 +785,7 @@ test_serialize_leaf(enum brtnode_verify_type bft) {
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
...@@ -917,6 +923,7 @@ test_serialize_nonleaf(enum brtnode_verify_type bft) { ...@@ -917,6 +923,7 @@ test_serialize_nonleaf(enum brtnode_verify_type bft) {
brt->h = brt_h; brt->h = brt_h;
brt_h->type = BRTHEADER_CURRENT; brt_h->type = BRTHEADER_CURRENT;
brt_h->panic = 0; brt_h->panic_string = 0; brt_h->panic = 0; brt_h->panic_string = 0;
brt_h->basementnodesize = 128*1024;
toku_blocktable_create_new(&brt_h->blocktable); toku_blocktable_create_new(&brt_h->blocktable);
//Want to use block #20 //Want to use block #20
BLOCKNUM b = make_blocknum(0); BLOCKNUM b = make_blocknum(0);
......
...@@ -35,7 +35,7 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) { ...@@ -35,7 +35,7 @@ static void test_multiple_brt_cursor_dbts(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, db);
assert(r==0); assert(r==0);
int i; int i;
......
...@@ -90,7 +90,7 @@ static void test_brt_cursor_first(int n, DB *db) { ...@@ -90,7 +90,7 @@ static void test_brt_cursor_first(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -131,7 +131,7 @@ static void test_brt_cursor_last(int n, DB *db) { ...@@ -131,7 +131,7 @@ static void test_brt_cursor_last(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert keys 0, 1, .. (n-1) */ /* insert keys 0, 1, .. (n-1) */
...@@ -172,7 +172,7 @@ static void test_brt_cursor_first_last(int n, DB *db) { ...@@ -172,7 +172,7 @@ static void test_brt_cursor_first_last(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -217,7 +217,7 @@ static void test_brt_cursor_rfirst(int n, DB *db) { ...@@ -217,7 +217,7 @@ static void test_brt_cursor_rfirst(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert keys n-1, n-2, ... , 0 */ /* insert keys n-1, n-2, ... , 0 */
...@@ -285,7 +285,7 @@ static void test_brt_cursor_walk(int n, DB *db) { ...@@ -285,7 +285,7 @@ static void test_brt_cursor_walk(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -351,7 +351,7 @@ static void test_brt_cursor_rwalk(int n, DB *db) { ...@@ -351,7 +351,7 @@ static void test_brt_cursor_rwalk(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -435,7 +435,7 @@ static void test_brt_cursor_rand(int n, DB *db) { ...@@ -435,7 +435,7 @@ static void test_brt_cursor_rand(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -489,7 +489,7 @@ static void test_brt_cursor_split(int n, DB *db) { ...@@ -489,7 +489,7 @@ static void test_brt_cursor_split(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
/* insert a bunch of kv pairs */ /* insert a bunch of kv pairs */
...@@ -565,7 +565,7 @@ static void test_multiple_brt_cursors(int n, DB *db) { ...@@ -565,7 +565,7 @@ static void test_multiple_brt_cursors(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
int i; int i;
...@@ -614,7 +614,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) { ...@@ -614,7 +614,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
int c; int c;
...@@ -691,7 +691,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -691,7 +691,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
int i; int i;
...@@ -763,7 +763,7 @@ static void test_brt_cursor_set_range(int n, DB *db) { ...@@ -763,7 +763,7 @@ static void test_brt_cursor_set_range(int n, DB *db) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(r==0); assert(r==0);
int i; int i;
...@@ -827,7 +827,7 @@ static void test_brt_cursor_delete(int n, DB *db) { ...@@ -827,7 +827,7 @@ static void test_brt_cursor_delete(int n, DB *db) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0); assert(error == 0);
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db);
assert(error == 0); assert(error == 0);
error = toku_brt_cursor(brt, &cursor, NULL, FALSE); error = toku_brt_cursor(brt, &cursor, NULL, FALSE);
......
...@@ -18,7 +18,7 @@ static void test_dump_empty_db (void) { ...@@ -18,7 +18,7 @@ static void test_dump_empty_db (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
if (verbose) { r=toku_dump_brt(stdout, t); assert(r==0); } if (verbose) { r=toku_dump_brt(stdout, t); assert(r==0); }
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
...@@ -38,8 +38,8 @@ static void test_multiple_files_of_size (int size) { ...@@ -38,8 +38,8 @@ static void test_multiple_files_of_size (int size) {
unlink(n1); unlink(n1);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, 1, &t0, size, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(n0, 1, &t0, size, size / 4, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
r = toku_open_brt(n1, 1, &t1, size, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(n1, 1, &t1, size, size / 4, ct, null_txn, toku_builtin_compare_fun, null_db); 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;
...@@ -62,10 +62,10 @@ static void test_multiple_files_of_size (int size) { ...@@ -62,10 +62,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 = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n0, 0, &t0, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(n0, 0, &t0, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db);
if (verbose) printf("%s:%d r=%d\n", __FILE__, __LINE__,r); if (verbose) printf("%s:%d r=%d\n", __FILE__, __LINE__,r);
assert(r==0); assert(r==0);
r = toku_open_brt(n1, 0, &t1, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(n1, 0, &t1, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); 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];
...@@ -98,7 +98,7 @@ static void test_multiple_brts_one_db_one_file (void) { ...@@ -98,7 +98,7 @@ static void test_multiple_brts_one_db_one_file (void) {
unlink(fname); unlink(fname);
r = toku_brt_create_cachetable(&ct, 32, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_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 = toku_open_brt(fname, (i==0), &trees[i], 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, (i==0), &trees[i], 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
} }
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
...@@ -137,7 +137,7 @@ static void test_read_what_was_written (void) { ...@@ -137,7 +137,7 @@ static void test_read_what_was_written (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
r = toku_close_brt(brt, 0); assert(r==0); r = toku_close_brt(brt, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
...@@ -145,7 +145,7 @@ static void test_read_what_was_written (void) { ...@@ -145,7 +145,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 = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 0, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
/* See if we can put something in it. */ /* See if we can put something in it. */
{ {
...@@ -161,7 +161,7 @@ static void test_read_what_was_written (void) { ...@@ -161,7 +161,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 = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 0, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
brt_lookup_and_check_nodup(brt, "hello", "there"); brt_lookup_and_check_nodup(brt, "hello", "there");
...@@ -225,7 +225,7 @@ static void test_read_what_was_written (void) { ...@@ -225,7 +225,7 @@ static void test_read_what_was_written (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 0, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 0, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
brt_lookup_and_check_nodup(brt, "hello", "there"); brt_lookup_and_check_nodup(brt, "hello", "there");
{ {
...@@ -259,7 +259,7 @@ static void test_cursor_last_empty(void) { ...@@ -259,7 +259,7 @@ static void test_cursor_last_empty(void) {
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_cursor(brt, &cursor, NULL, FALSE); assert(r==0); r = toku_brt_cursor(brt, &cursor, NULL, FALSE); assert(r==0);
{ {
...@@ -292,7 +292,7 @@ static void test_cursor_next (void) { ...@@ -292,7 +292,7 @@ static void test_cursor_next (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, toku_get_n_items_malloced()); toku_print_malloced_items();
r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "hello", 6), toku_fill_dbt(&vbt, "there", 6), null_txn); r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "hello", 6), toku_fill_dbt(&vbt, "there", 6), null_txn);
r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "byebye", 7), toku_fill_dbt(&vbt, "byenow", 7), null_txn); r = toku_brt_insert(brt, toku_fill_dbt(&kbt, "byebye", 7), toku_fill_dbt(&vbt, "byenow", 7), null_txn);
...@@ -371,7 +371,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -371,7 +371,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 = toku_open_brt(fname, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun, &nonce_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<20, 1<<17, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun, &nonce_db); 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] = (unsigned char)(i&255); b[3] = a[0] = (unsigned char)(i&255);
...@@ -410,7 +410,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -410,7 +410,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
{ {
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_open_brt(fname, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun, &nonce_db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<20, 1<<17, ct, null_txn, wrong_p ? wrong_compare_fun : toku_builtin_compare_fun, &nonce_db); assert(r==0);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
...@@ -465,7 +465,7 @@ static void test_large_kv(int bsize, int ksize, int vsize) { ...@@ -465,7 +465,7 @@ static void test_large_kv(int bsize, int ksize, int vsize) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, bsize, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, bsize, bsize / 4, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -511,7 +511,7 @@ static void test_brt_delete_empty(void) { ...@@ -511,7 +511,7 @@ static void test_brt_delete_empty(void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 4096, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
DBT key; DBT key;
...@@ -539,7 +539,7 @@ static void test_brt_delete_present(int n) { ...@@ -539,7 +539,7 @@ static void test_brt_delete_present(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 4096, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
/* insert 0 .. n-1 */ /* insert 0 .. n-1 */
...@@ -601,7 +601,7 @@ static void test_brt_delete_not_present(int n) { ...@@ -601,7 +601,7 @@ static void test_brt_delete_not_present(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 4096, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
DBT key, val; DBT key, val;
...@@ -647,7 +647,7 @@ static void test_brt_delete_cursor_first(int n) { ...@@ -647,7 +647,7 @@ static void test_brt_delete_cursor_first(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 4096, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
/* insert 0 .. n-1 */ /* insert 0 .. n-1 */
...@@ -740,7 +740,7 @@ static void test_insert_delete_lookup(int n) { ...@@ -740,7 +740,7 @@ static void test_insert_delete_lookup(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 4096, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 4096, 1024, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
/* insert 0 .. n-1 */ /* insert 0 .. n-1 */
...@@ -1158,7 +1158,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -1158,7 +1158,7 @@ static void test_new_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 = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db); assert(r==0);
int i; int i;
......
...@@ -20,7 +20,7 @@ static void test0 (void) { ...@@ -20,7 +20,7 @@ static void test0 (void) {
assert(r==0); assert(r==0);
if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__); if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
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);
......
...@@ -19,7 +19,7 @@ static void test1 (void) { ...@@ -19,7 +19,7 @@ static void test1 (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
r = toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn); r = toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn);
assert(r==0); assert(r==0);
......
...@@ -19,7 +19,7 @@ static void test2 (int memcheck, int limit) { ...@@ -19,7 +19,7 @@ static void test2 (int memcheck, int limit) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
if (verbose) printf("%s:%d did setup\n", __FILE__, __LINE__); if (verbose) printf("%s:%d did setup\n", __FILE__, __LINE__);
assert(r==0); assert(r==0);
for (i=0; i<limit; i++) { // 4096 for (i=0; i<limit; i++) { // 4096
......
...@@ -11,7 +11,7 @@ static const char fname[]= __FILE__ ".brt"; ...@@ -11,7 +11,7 @@ static const char fname[]= __FILE__ ".brt";
static TOKUTXN const null_txn = 0; static TOKUTXN const null_txn = 0;
static DB * const null_db = 0; static DB * const null_db = 0;
static void test3 (int nodesize, int count, int memcheck) { static void test3 (int nodesize, int basementnodesize, int count, int memcheck) {
BRT t; BRT t;
int r; int r;
struct timeval t0,t1; struct timeval t0,t1;
...@@ -22,7 +22,7 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -22,7 +22,7 @@ static void test3 (int nodesize, int count, int memcheck) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0); gettimeofday(&t0, 0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun, null_db);
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];
...@@ -46,25 +46,25 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -46,25 +46,25 @@ static void test3 (int nodesize, int count, int memcheck) {
static void brt_blackbox_test (void) { static void brt_blackbox_test (void) {
if (verbose) printf("test3 slow\n"); if (verbose) printf("test3 slow\n");
toku_memory_check=0; toku_memory_check=0;
test3(2048, 1<<15, 1); test3(2048, 512, 1<<15, 1);
if (verbose) printf("test3 fast\n"); if (verbose) printf("test3 fast\n");
//if (verbose) toku_pma_show_stats(); //if (verbose) toku_pma_show_stats();
test3(1<<15, 1024, 1); test3(1<<15, 1<<12, 1024, 1);
if (verbose) printf("test3 fast\n"); if (verbose) printf("test3 fast\n");
test3(1<<18, 1<<20, 0); test3(1<<18, 1<<15, 1<<20, 0);
toku_memory_check = 1; toku_memory_check = 1;
// test3(1<<19, 1<<20, 0); // test3(1<<19, 1<<16, 1<<20, 0);
// test3(1<<20, 1<<20, 0); // test3(1<<20, 1<<17, 1<<20, 0);
// test3(1<<20, 1<<21, 0); // test3(1<<20, 1<<17, 1<<21, 0);
// test3(1<<20, 1<<22, 0); // test3(1<<20, 1<<17, 1<<22, 0);
} }
......
...@@ -22,7 +22,7 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -22,7 +22,7 @@ static void test4 (int nodesize, int count, int memcheck) {
toku_memory_check=memcheck; toku_memory_check=memcheck;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, ct, null_txn, toku_builtin_compare_fun, null_db); 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();
......
...@@ -21,7 +21,7 @@ static void test5 (void) { ...@@ -21,7 +21,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 = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); 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;
......
...@@ -132,7 +132,7 @@ static void write_dbfile (char *template, int n, char *output_name, BOOL expect_ ...@@ -132,7 +132,7 @@ static void write_dbfile (char *template, int n, char *output_name, BOOL expect_
brt_loader_set_error_function(&bl.error_callback, NULL, NULL); brt_loader_set_error_function(&bl.error_callback, NULL, NULL);
brt_loader_set_poll_function(&bl.poll_callback, loader_poll_callback, NULL); brt_loader_set_poll_function(&bl.poll_callback, loader_poll_callback, NULL);
r = toku_loader_write_brt_from_q_in_C(&bl, &desc, fd, 1000, q2, size_est, 0, 0); r = toku_loader_write_brt_from_q_in_C(&bl, &desc, fd, 1000, q2, size_est, 0, 0, 0);
// if (!(expect_error ? r != 0 : r == 0)) printf("WARNING%%d expect_error=%d r=%d\n", __LINE__, expect_error, r); // if (!(expect_error ? r != 0 : r == 0)) printf("WARNING%%d expect_error=%d r=%d\n", __LINE__, expect_error, r);
assert(expect_error ? r != 0 : r == 0); assert(expect_error ? r != 0 : r == 0);
......
...@@ -169,7 +169,7 @@ static void test_write_dbfile (char *template, int n, char *output_name, TXNID x ...@@ -169,7 +169,7 @@ static void test_write_dbfile (char *template, int n, char *output_name, TXNID x
assert(fd>=0); assert(fd>=0);
if (verbose) traceit("write to file"); if (verbose) traceit("write to file");
r = toku_loader_write_brt_from_q_in_C(&bl, &desc, fd, 1000, q2, size_est, 0, 0); r = toku_loader_write_brt_from_q_in_C(&bl, &desc, fd, 1000, q2, size_est, 0, 0, 0);
assert(r==0); assert(r==0);
r = queue_destroy(q2); r = queue_destroy(q2);
......
...@@ -323,7 +323,7 @@ static void verify_dbfile(int n, int sorted_keys[], const char *sorted_vals[], c ...@@ -323,7 +323,7 @@ static void verify_dbfile(int n, int sorted_keys[], const char *sorted_vals[], c
int fd = open(output_name, O_RDWR | O_CREAT | O_BINARY, S_IRWXU|S_IRWXG|S_IRWXO); int fd = open(output_name, O_RDWR | O_CREAT | O_BINARY, S_IRWXU|S_IRWXG|S_IRWXO);
assert(fd>=0); assert(fd>=0);
r = toku_loader_write_brt_from_q_in_C(&bl, &desc, fd, 1000, q, size_est, 0, 0); r = toku_loader_write_brt_from_q_in_C(&bl, &desc, fd, 1000, q, size_est, 0, 0, 0);
assert(r==0); assert(r==0);
destroy_merge_fileset(&fs); destroy_merge_fileset(&fs);
......
...@@ -39,7 +39,7 @@ static void test_it (int N) { ...@@ -39,7 +39,7 @@ static void test_it (int N) {
TOKUTXN txn; TOKUTXN txn;
r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r); r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r);
r = toku_open_brt(FILENAME, 1, &brt, 1024, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r); r = toku_open_brt(FILENAME, 1, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r); r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r);
toku_txn_close_txn(txn); toku_txn_close_txn(txn);
...@@ -50,7 +50,7 @@ static void test_it (int N) { ...@@ -50,7 +50,7 @@ static void test_it (int N) {
unsigned int rands[N]; unsigned int rands[N];
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r); r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r);
r = toku_open_brt(FILENAME, 0, &brt, 1024, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r); r = toku_open_brt(FILENAME, 0, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r); r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r);
toku_txn_close_txn(txn); toku_txn_close_txn(txn);
...@@ -73,7 +73,7 @@ static void test_it (int N) { ...@@ -73,7 +73,7 @@ static void test_it (int N) {
} }
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r); r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r);
r = toku_open_brt(FILENAME, 0, &brt, 1024, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r); r = toku_open_brt(FILENAME, 0, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r); r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r);
toku_txn_close_txn(txn); toku_txn_close_txn(txn);
...@@ -99,7 +99,7 @@ static void test_it (int N) { ...@@ -99,7 +99,7 @@ static void test_it (int N) {
if (verbose) printf("d=%d\n", i); if (verbose) printf("d=%d\n", i);
} }
r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r); r = toku_txn_begin_txn((DB_TXN*)NULL, (TOKUTXN)0, &txn, logger, TXN_SNAPSHOT_ROOT); CKERR(r);
r = toku_open_brt(FILENAME, 0, &brt, 1024, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r); r = toku_open_brt(FILENAME, 0, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun, NULL); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r); r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL); CKERR(r);
toku_txn_close_txn(txn); toku_txn_close_txn(txn);
......
...@@ -100,7 +100,7 @@ test_make_tree(int height, int fanout, int nperleaf, uint64_t subtree_size) { ...@@ -100,7 +100,7 @@ test_make_tree(int height, int fanout, int nperleaf, uint64_t subtree_size) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
...@@ -18,7 +18,7 @@ static void test_flat (u_int64_t limit) { ...@@ -18,7 +18,7 @@ static void test_flat (u_int64_t limit) {
// set the cachetable to size 1 so that things won't fit. // set the cachetable to size 1 so that things won't fit.
int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
BRT t; BRT t;
r = toku_open_brt(fname, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
u_int64_t i; u_int64_t i;
// permute the numbers from 0 (inclusive) to limit (exclusive) // permute the numbers from 0 (inclusive) to limit (exclusive)
time_t now; time_t now;
......
...@@ -17,7 +17,7 @@ static void test_flat (void) { ...@@ -17,7 +17,7 @@ static void test_flat (void) {
CACHETABLE ct; CACHETABLE ct;
int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
BRT t; BRT t;
r = toku_open_brt(fname, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
u_int64_t i; u_int64_t i;
for (i=0; i<limit; i++) { for (i=0; i<limit; i++) {
char key[100],val[100]; char key[100],val[100];
......
...@@ -46,7 +46,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) { ...@@ -46,7 +46,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, txn, test_brt_cursor_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_brt_cursor_keycompare, null_db);
assert(error == 0); assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL); error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL);
...@@ -112,7 +112,7 @@ test_provdel(const char *logdir, const char *fname, int n) { ...@@ -112,7 +112,7 @@ test_provdel(const char *logdir, const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, txn, test_brt_cursor_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_brt_cursor_keycompare, null_db);
assert(error == 0); assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL); error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL);
......
...@@ -49,7 +49,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) { ...@@ -49,7 +49,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, txn, test_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_keycompare, null_db);
assert(error == 0); assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL); error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL);
...@@ -101,7 +101,7 @@ test_neg_infinity(const char *fname, int n) { ...@@ -101,7 +101,7 @@ test_neg_infinity(const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_keycompare, null_db);
assert(error == 0); assert(error == 0);
// position the cursor at -infinity // position the cursor at -infinity
...@@ -138,7 +138,7 @@ test_pos_infinity(const char *fname, int n) { ...@@ -138,7 +138,7 @@ test_pos_infinity(const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_keycompare, null_db);
assert(error == 0); assert(error == 0);
// position the LE_CURSOR at +infinity // position the LE_CURSOR at +infinity
...@@ -199,7 +199,7 @@ test_between(const char *fname, int n) { ...@@ -199,7 +199,7 @@ test_between(const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_keycompare, null_db);
assert(error == 0); assert(error == 0);
// position the LE_CURSOR at +infinity // position the LE_CURSOR at +infinity
......
...@@ -46,7 +46,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) { ...@@ -46,7 +46,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, txn, test_brt_cursor_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_brt_cursor_keycompare, null_db);
assert(error == 0); assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL); error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL);
...@@ -99,7 +99,7 @@ walk_tree(const char *fname, int n) { ...@@ -99,7 +99,7 @@ walk_tree(const char *fname, int n) {
assert(error == 0); assert(error == 0);
BRT brt = NULL; BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, null_db); error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, null_db);
assert(error == 0); assert(error == 0);
LE_CURSOR cursor = NULL; LE_CURSOR cursor = NULL;
......
...@@ -125,7 +125,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -125,7 +125,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
...@@ -120,7 +120,7 @@ test_msnfilter(int do_verify) { ...@@ -120,7 +120,7 @@ test_msnfilter(int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// discard the old root block // discard the old root block
......
...@@ -22,7 +22,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute ...@@ -22,7 +22,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute
unlink(fname); unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare, db); assert(r==0); r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare, db); assert(r==0);
r = toku_brt_cursor(brt, &cursor, NULL, FALSE); assert(r==0); r = toku_brt_cursor(brt, &cursor, NULL, FALSE); assert(r==0);
int i; int i;
......
...@@ -20,7 +20,7 @@ test_overflow (void) { ...@@ -20,7 +20,7 @@ test_overflow (void) {
int r; int r;
unlink(fname); unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
DBT k,v; DBT k,v;
u_int32_t vsize = nodesize/8; u_int32_t vsize = nodesize/8;
......
...@@ -28,7 +28,7 @@ doit (void) { ...@@ -28,7 +28,7 @@ doit (void) {
snprintf(fname, fnamelen, "%s.brt", __FILE__); snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 16*1024, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 16*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, NODESIZE, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
toku_free(fname); toku_free(fname);
......
...@@ -18,7 +18,7 @@ test_main(int argc, const char *argv[]) { ...@@ -18,7 +18,7 @@ test_main(int argc, const char *argv[]) {
unlink(n); unlink(n);
assert(f); assert(f);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(n, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
int i; int i;
for (i=0; i<10000; i++) { for (i=0; i<10000; i++) {
char key[100],val[100]; char key[100],val[100];
......
...@@ -58,7 +58,7 @@ doit (int ksize __attribute__((__unused__))) { ...@@ -58,7 +58,7 @@ doit (int ksize __attribute__((__unused__))) {
snprintf(fname, fnamelen, "%s.brt", __FILE__); snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 16*1024, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_brt_create_cachetable(&ct, 16*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 1, &t, NODESIZE, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r==0); assert(r==0);
toku_free(fname); toku_free(fname);
......
...@@ -24,7 +24,7 @@ static void setup (void) { ...@@ -24,7 +24,7 @@ static void setup (void) {
{ int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); } { int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); }
char fname[] = __FILE__ "test1.dat"; char fname[] = __FILE__ "test1.dat";
unlink(fname); unlink(fname);
{ int r = toku_open_brt(fname, 1, &t, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); } { int r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); }
} }
......
...@@ -178,13 +178,13 @@ int create_logfiles() { ...@@ -178,13 +178,13 @@ int create_logfiles() {
//xbegin 'b': lsn=1 parenttxnid=0 crc=00005f1f len=29 //xbegin 'b': lsn=1 parenttxnid=0 crc=00005f1f len=29
r = toku_log_xbegin(logger, &lsn, NO_FSYNC, 0); assert(r==0); txnid = lsn.lsn; r = toku_log_xbegin(logger, &lsn, NO_FSYNC, 0); assert(r==0); txnid = lsn.lsn;
//fcreate 'F': lsn=2 txnid=1 filenum=0 fname={len=4 data="a.db"} mode=0777 treeflags=0 crc=18a3d525 len=49 //fcreate 'F': lsn=2 txnid=1 filenum=0 fname={len=4 data="a.db"} mode=0777 treeflags=0 crc=18a3d525 len=49
r = toku_log_fcreate(logger, &lsn, NO_FSYNC, txnid, fn_aname, bs_aname, 0x0777, 0, 0); assert(r==0); r = toku_log_fcreate(logger, &lsn, NO_FSYNC, txnid, fn_aname, bs_aname, 0x0777, 0, 0, 0); assert(r==0);
//commit 'C': lsn=3 txnid=1 crc=00001f1e len=29 //commit 'C': lsn=3 txnid=1 crc=00001f1e len=29
r = toku_log_xcommit(logger, &lsn, FSYNC, txnid); assert(r==0); r = toku_log_xcommit(logger, &lsn, FSYNC, txnid); assert(r==0);
//xbegin 'b': lsn=4 parenttxnid=0 crc=00000a1f len=29 //xbegin 'b': lsn=4 parenttxnid=0 crc=00000a1f len=29
r = toku_log_xbegin(logger, &lsn, NO_FSYNC, 0); assert(r==0); txnid = lsn.lsn; r = toku_log_xbegin(logger, &lsn, NO_FSYNC, 0); assert(r==0); txnid = lsn.lsn;
//fcreate 'F': lsn=5 txnid=4 filenum=1 fname={len=4 data="b.db"} mode=0777 treeflags=0 crc=14a47925 len=49 //fcreate 'F': lsn=5 txnid=4 filenum=1 fname={len=4 data="b.db"} mode=0777 treeflags=0 crc=14a47925 len=49
r = toku_log_fcreate(logger, &lsn, NO_FSYNC, txnid, fn_bname, bs_bname, 0x0777, 0, 0); assert(r==0); r = toku_log_fcreate(logger, &lsn, NO_FSYNC, txnid, fn_bname, bs_bname, 0x0777, 0, 0, 0); assert(r==0);
//commit 'C': lsn=6 txnid=4 crc=0000c11e len=29 //commit 'C': lsn=6 txnid=4 crc=0000c11e len=29
r = toku_log_xcommit(logger, &lsn, FSYNC, txnid); assert(r==0); r = toku_log_xcommit(logger, &lsn, FSYNC, txnid); assert(r==0);
//xbegin 'b': lsn=7 parenttxnid=0 crc=0000f91f len=29 //xbegin 'b': lsn=7 parenttxnid=0 crc=0000f91f len=29
......
...@@ -131,7 +131,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -131,7 +131,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
...@@ -112,7 +112,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -112,7 +112,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
...@@ -59,7 +59,7 @@ test_dup_in_leaf(int do_verify) { ...@@ -59,7 +59,7 @@ test_dup_in_leaf(int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// discard the old root block // discard the old root block
......
...@@ -112,7 +112,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -112,7 +112,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
...@@ -116,7 +116,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -116,7 +116,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
...@@ -59,7 +59,7 @@ test_dup_in_leaf(int do_verify) { ...@@ -59,7 +59,7 @@ test_dup_in_leaf(int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// discard the old root block // discard the old root block
......
...@@ -112,7 +112,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -112,7 +112,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
TOKUTXN null_txn = NULL; TOKUTXN null_txn = NULL;
DB *null_db = NULL; DB *null_db = NULL;
BRT brt = NULL; BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, ct, null_txn, toku_builtin_compare_fun, null_db); r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun, null_db);
assert(r == 0); assert(r == 0);
// make a tree // make a tree
......
// verify thtat we can create the correct tree type after the db is removed
#ident "$Id$"
#ident "Copyright (c) 2011 Tokutek Inc. All rights reserved."
#include <sys/stat.h>
#include "test.h"
static const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE;
static char *namea="a.db"; uint32_t nodesizea = 0;
static char *nameb="b.db"; uint32_t nodesizeb = 32*1024;
static void do_remove(DB_ENV *env, const char *filename) {
int r;
#if TOKUDB
DBT dname;
DBT iname;
dbt_init(&dname, filename, strlen(filename)+1);
dbt_init(&iname, NULL, 0);
iname.flags |= DB_DBT_MALLOC;
r = env->get_iname(env, &dname, &iname); CKERR(r);
if (verbose) printf("%s -> %s\n", filename, (char *) iname.data);
char rmcmd[32 + strlen(ENVDIR) + strlen(iname.data)];
sprintf(rmcmd, "rm %s/%s", ENVDIR, (char *) iname.data);
r = system(rmcmd); CKERR(r);
toku_free(iname.data);
#else
env = env;
char rmcmd[32 + strlen(ENVDIR) + strlen(filename)];
sprintf(rmcmd, "rm %s/%s", ENVDIR, filename);
r = system(rmcmd); CKERR(r);
#endif
}
static void run_test (void) {
int r;
r = system("rm -rf " ENVDIR);
CKERR(r);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
DB_ENV *env;
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r);
DB_TXN *txn;
r = env->txn_begin(env, NULL, &txn, 0); CKERR(r);
// create a db with the default nodesize
DB *dba;
r = db_create(&dba, env, 0); CKERR(r);
r = dba->get_readpagesize(dba, &nodesizea); CKERR(r);
if (verbose) printf("nodesizea=%u", nodesizea);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
r = dba->close(dba, 0); CKERR(r);
// create a db with a small nodesize
DB *dbb;
r = db_create(&dbb, env, 0); CKERR(r);
r = dbb->set_readpagesize(dbb, nodesizeb); CKERR(r);
r = dbb->open(dbb, NULL, nameb, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
r = dbb->close(dbb, 0); CKERR(r);
r = txn->commit(txn, 0); CKERR(r);
// remove the inames to force recovery to recreate them
do_remove(env, namea);
do_remove(env, nameb);
toku_hard_crash_on_purpose();
}
static void run_recover (void) {
int r;
// run recovery
DB_ENV *env;
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags + DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
// verify that the trees have the correct nodesizes
uint32_t pagesize;
DB *dba;
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r);
r = dba->get_readpagesize(dba, &pagesize); CKERR(r);
if (verbose) printf("%u\n", pagesize);
// assert(pagesize == nodesizea);
r = dba->close(dba, 0); CKERR(r);
DB *dbb;
r = db_create(&dbb, env, 0); CKERR(r);
r = dbb->open(dbb, NULL, nameb, NULL, DB_UNKNOWN, DB_AUTO_COMMIT, 0666); CKERR(r);
r = dbb->get_readpagesize(dbb, &pagesize); CKERR(r);
if (verbose) printf("%u\n", pagesize);
assert(pagesize == nodesizeb);
r = dbb->close(dbb, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
exit(0);
}
static void run_no_recover (void) {
int r;
DB_ENV *env;
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags & ~DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = env->close(env, 0); CKERR(r);
exit(0);
}
static const char *cmd;
static BOOL do_test=FALSE, do_recover=FALSE, do_recover_only=FALSE, do_no_recover = FALSE;
static void test_parse_args (int argc, char * const argv[]) {
int resultcode;
cmd = argv[0];
argc--; argv++;
while (argc>0) {
if (strcmp(argv[0], "-v") == 0) {
verbose++;
} else if (strcmp(argv[0],"-q")==0) {
verbose--;
if (verbose<0) verbose=0;
} else if (strcmp(argv[0], "--test")==0) {
do_test=TRUE;
} else if (strcmp(argv[0], "--recover") == 0) {
do_recover=TRUE;
} else if (strcmp(argv[0], "--recover-only") == 0) {
do_recover_only=TRUE;
} else if (strcmp(argv[0], "--no-recover") == 0) {
do_no_recover=TRUE;
} else if (strcmp(argv[0], "-h")==0) {
resultcode=0;
do_usage:
fprintf(stderr, "Usage:\n%s [-v|-q]* [-h] {--test | --recover } \n", cmd);
exit(resultcode);
} else {
fprintf(stderr, "Unknown arg: %s\n", argv[0]);
resultcode=1;
goto do_usage;
}
argc--;
argv++;
}
}
int test_main (int argc, char * const argv[]) {
test_parse_args(argc, argv);
if (do_test) {
run_test();
} else if (do_recover) {
run_recover();
} else if (do_recover_only) {
run_recover();
} else if (do_no_recover) {
run_no_recover();
}
return 0;
}
...@@ -5429,6 +5429,20 @@ toku_db_get_pagesize(DB *db, u_int32_t *pagesize_ptr) { ...@@ -5429,6 +5429,20 @@ toku_db_get_pagesize(DB *db, u_int32_t *pagesize_ptr) {
return r; return r;
} }
static int
toku_db_set_readpagesize(DB *db, u_int32_t readpagesize) {
HANDLE_PANICKED_DB(db);
int r = toku_brt_set_basementnodesize(db->i->brt, readpagesize);
return r;
}
static int
toku_db_get_readpagesize(DB *db, u_int32_t *readpagesize_ptr) {
HANDLE_PANICKED_DB(db);
int r = toku_brt_get_basementnodesize(db->i->brt, readpagesize_ptr);
return r;
}
static int static int
toku_db_stat64(DB * db, DB_TXN *txn, DB_BTREE_STAT64 *s) { toku_db_stat64(DB * db, DB_TXN *txn, DB_BTREE_STAT64 *s) {
HANDLE_PANICKED_DB(db); HANDLE_PANICKED_DB(db);
...@@ -5860,6 +5874,16 @@ locked_db_get_pagesize(DB *db, u_int32_t *pagesize_ptr) { ...@@ -5860,6 +5874,16 @@ locked_db_get_pagesize(DB *db, u_int32_t *pagesize_ptr) {
toku_ydb_lock(); int r = toku_db_get_pagesize(db, pagesize_ptr); toku_ydb_unlock(); return r; toku_ydb_lock(); int r = toku_db_get_pagesize(db, pagesize_ptr); toku_ydb_unlock(); return r;
} }
static int
locked_db_set_readpagesize(DB *db, u_int32_t readpagesize) {
toku_ydb_lock(); int r = toku_db_set_readpagesize(db, readpagesize); toku_ydb_unlock(); return r;
}
static int
locked_db_get_readpagesize(DB *db, u_int32_t *readpagesize_ptr) {
toku_ydb_lock(); int r = toku_db_get_readpagesize(db, readpagesize_ptr); toku_ydb_unlock(); return r;
}
// TODO 2216 delete this // TODO 2216 delete this
static int static int
locked_db_fd(DB * UU(db), int * UU(fdp)) { locked_db_fd(DB * UU(db), int * UU(fdp)) {
...@@ -6040,6 +6064,8 @@ toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) { ...@@ -6040,6 +6064,8 @@ toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
SDB(set_errfile); SDB(set_errfile);
SDB(set_pagesize); SDB(set_pagesize);
SDB(get_pagesize); SDB(get_pagesize);
SDB(set_readpagesize);
SDB(get_readpagesize);
SDB(set_flags); SDB(set_flags);
SDB(get_flags); SDB(get_flags);
SDB(stat64); SDB(stat64);
......
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