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

[t:4882] change compression type to be set before create

this means you have to set the compression type before calling db->open
and you can't change it after that

we also log it now

this bumps the version layout to BRT_LAYOUT_VERSION_20


git-svn-id: file:///svn/toku/tokudb@43511 c7de825b-a66e-492c-adef-691d508d4ae1
parent b2449e6b
default:\
:skip=/windows/,/dbg/,/opt/,/build/,/gccdbg/,/gccopt/,/iccdbg/,/iccopt/,/NightlyRelease/,/NightlyCoverage/,/NightlyDebug/,/Debug/,/Release/,/Coverage/,/cov/:
:skip=/windows/,/dbg/,/opt/,/build/,/gccdbg/,/gccopt/,/iccdbg/,/iccopt/,/clangdbg/,/NightlyRelease/,/NightlyCoverage/,/NightlyDebug/,/Debug/,/Release/,/Coverage/,/cov/:
......@@ -425,6 +425,7 @@ struct brt {
unsigned int nodesize;
unsigned int basementnodesize;
enum toku_compression_method compression_method;
unsigned int flags;
BOOL did_set_flags;
brt_compare_func compare_fun;
......
......@@ -2502,52 +2502,53 @@ serialize_brt_header_min_size (u_int32_t version) {
switch(version) {
case BRT_LAYOUT_VERSION_20:
case BRT_LAYOUT_VERSION_19:
size += 1; // compression method
size += sizeof(uint64_t); // highest_unused_msn_for_upgrade
case BRT_LAYOUT_VERSION_18:
size += sizeof(uint64_t); // time_of_last_optimize_begin
size += sizeof(uint64_t); // time_of_last_optimize_end
size += sizeof(uint32_t); // count_of_optimize_in_progress
size += sizeof(MSN); // msn_at_start_of_last_completed_optimize
size -= 8; // removed num_blocks_to_upgrade_14
size -= 8; // removed num_blocks_to_upgrade_13
case BRT_LAYOUT_VERSION_17:
size += 16;
invariant(sizeof(STAT64INFO_S) == 16);
case BRT_LAYOUT_VERSION_16:
case BRT_LAYOUT_VERSION_15:
size += 4; // basement node size
size += 8; // num_blocks_to_upgrade_14 (previously num_blocks_to_upgrade, now one int each for upgrade from 13, 14
size += 8; // time of last verification
case BRT_LAYOUT_VERSION_14:
size += 8; //TXNID that created
case BRT_LAYOUT_VERSION_13:
size += ( 4 // build_id
+4 // build_id_original
+8 // time_of_creation
+8 // time_of_last_modification
);
// fall through
case BRT_LAYOUT_VERSION_12:
size += (+8 // "tokudata"
+4 // version
+4 // original_version
+4 // size
+8 // byte order verification
+8 // checkpoint_count
+8 // checkpoint_lsn
+4 // tree's nodesize
+8 // translation_size_on_disk
+8 // translation_address_on_disk
+4 // checksum
+8 // Number of blocks in old version.
+8 // diskoff
+4 // flags
);
break;
default:
lazy_assert(FALSE);
size += sizeof(uint64_t); // highest_unused_msn_for_upgrade
case BRT_LAYOUT_VERSION_18:
size += sizeof(uint64_t); // time_of_last_optimize_begin
size += sizeof(uint64_t); // time_of_last_optimize_end
size += sizeof(uint32_t); // count_of_optimize_in_progress
size += sizeof(MSN); // msn_at_start_of_last_completed_optimize
size -= 8; // removed num_blocks_to_upgrade_14
size -= 8; // removed num_blocks_to_upgrade_13
case BRT_LAYOUT_VERSION_17:
size += 16;
invariant(sizeof(STAT64INFO_S) == 16);
case BRT_LAYOUT_VERSION_16:
case BRT_LAYOUT_VERSION_15:
size += 4; // basement node size
size += 8; // num_blocks_to_upgrade_14 (previously num_blocks_to_upgrade, now one int each for upgrade from 13, 14
size += 8; // time of last verification
case BRT_LAYOUT_VERSION_14:
size += 8; //TXNID that created
case BRT_LAYOUT_VERSION_13:
size += ( 4 // build_id
+4 // build_id_original
+8 // time_of_creation
+8 // time_of_last_modification
);
// fall through
case BRT_LAYOUT_VERSION_12:
size += (+8 // "tokudata"
+4 // version
+4 // original_version
+4 // size
+8 // byte order verification
+8 // checkpoint_count
+8 // checkpoint_lsn
+4 // tree's nodesize
+8 // translation_size_on_disk
+8 // translation_address_on_disk
+4 // checksum
+8 // Number of blocks in old version.
+8 // diskoff
+4 // flags
);
break;
default:
lazy_assert(FALSE);
}
lazy_assert(size <= BLOCK_ALLOCATOR_HEADER_RESERVE);
return size;
......
......@@ -3053,8 +3053,11 @@ mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_f
/* ******************** open,close and create ********************** */
// 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, int basementnodesize, CACHETABLE cachetable, TOKUTXN txn,
int (*compare_fun)(DB *, const DBT*,const DBT*)) {
int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize,
int basementnodesize,
enum toku_compression_method compression_method,
CACHETABLE cachetable, TOKUTXN txn,
int (*compare_fun)(DB *, const DBT*,const DBT*)) {
BRT brt;
int r;
const int only_create = 0;
......@@ -3064,6 +3067,7 @@ int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize,
return 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_compression_method(brt, compression_method); 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);
......@@ -3118,14 +3122,14 @@ static int brt_open_file(const char *fname, int *fdp) {
int
toku_brt_set_compression_method(BRT t, enum toku_compression_method method)
{
t->h->compression_method = method;
t->compression_method = method;
return 0;
}
int
toku_brt_get_compression_method(BRT t, enum toku_compression_method *methodp)
{
*methodp = t->h->compression_method;
*methodp = t->compression_method;
return 0;
}
......@@ -3272,7 +3276,7 @@ brt_open(BRT t, const char *fname_in_env, int is_create, int only_create, CACHET
assert_zero(r);
}
txn_created = (BOOL)(txn!=NULL);
r = toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, t->flags, t->nodesize, t->basementnodesize);
r = toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, t->flags, t->nodesize, t->basementnodesize, t->compression_method);
assert_zero(r); // only possible failure is panic, which we check above
r = brt_create_file(t, fname_in_cwd, &fd);
assert_zero(r);
......@@ -3309,6 +3313,7 @@ brt_open(BRT t, const char *fname_in_env, int is_create, int only_create, CACHET
}
t->nodesize = t->h->nodesize; /* inherit the pagesize from the file */
t->basementnodesize = t->h->basementnodesize;
t->compression_method = t->h->compression_method;
if (!t->did_set_flags) {
r = verify_builtin_comparisons_consistent(t, t->flags);
if (r) { goto exit; }
......@@ -3566,6 +3571,7 @@ int toku_brt_create(BRT *brt_ptr) {
brt->did_set_flags = FALSE;
brt->nodesize = BRT_DEFAULT_NODE_SIZE;
brt->basementnodesize = BRT_DEFAULT_BASEMENT_NODE_SIZE;
brt->compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
brt->compare_fun = toku_builtin_compare_fun;
brt->update_fun = NULL;
*brt_ptr = brt;
......
......@@ -28,7 +28,7 @@
// When lock_only is true, the callback only does optional lock tree locking.
typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, void *extra, bool lock_only);
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, CACHETABLE, TOKUTXN, int(*)(DB *,const DBT*,const DBT*)) __attribute__ ((warn_unused_result));
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, int basementnodesize, enum toku_compression_method compression_method, CACHETABLE, TOKUTXN, int(*)(DB *,const DBT*,const DBT*)) __attribute__ ((warn_unused_result));
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn, BOOL update_cmp_descriptor);
int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
// Note: See the locking discussion in brt.c for toku_brt_change_descriptor and toku_update_descriptor.
......
......@@ -366,6 +366,7 @@ brt_init_header_partial (BRT t, CACHEFILE cf, TOKUTXN txn) {
t->h->cf = cf;
t->h->nodesize = t->nodesize;
t->h->basementnodesize = t->basementnodesize;
t->h->compression_method = t->compression_method;
t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE;
t->h->compare_fun = t->compare_fun;
t->h->update_fun = t->update_fun;
......@@ -404,7 +405,6 @@ brt_init_header (BRT t, CACHEFILE cf, TOKUTXN txn) {
//Assign blocknum for root block, also dirty the header
toku_allocate_blocknum(t->h->blocktable, &root, t->h);
t->h->root_blocknum = root;
t->h->compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
toku_list_init(&t->h->live_brts);
int r = toku_omt_create(&t->h->txns);
......@@ -639,6 +639,8 @@ brt_open_for_redirect(BRT *new_brtp, const char *fname_in_env, TOKUTXN txn, stru
assert_zero(r);
r = toku_brt_set_basementnodesize(t, old_h->basementnodesize);
assert_zero(r);
r = toku_brt_set_compression_method(t, old_h->compression_method);
assert_zero(r);
CACHETABLE ct = toku_cachefile_get_cachetable(old_h->cf);
r = toku_brt_open_with_dict_id(t, fname_in_env, 0, 0, ct, txn, old_h->dict_id);
assert_zero(r);
......
......@@ -24,6 +24,7 @@ enum brt_layout_version_e {
BRT_LAYOUT_VERSION_17 = 17, // Dr. No: Add STAT64INFO_S to brt_header
BRT_LAYOUT_VERSION_18 = 18, // Dr. No: Add HOT info to brt_header
BRT_LAYOUT_VERSION_19 = 19, // Doofenshmirtz: Add compression method, highest_unused_msn_for_upgrade
BRT_LAYOUT_VERSION_20 = 20, // Clayface: Add compression method to log_fcreate
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_MIN_SUPPORTED_VERSION = BRT_LAYOUT_VERSION_13, // Minimum version supported
......
......@@ -104,6 +104,7 @@ dump_header (int f, struct brt_header **header, CACHEFILE cf) {
printf(" checkpoint_lsn=%" PRId64 "\n", h->checkpoint_lsn.lsn);
printf(" nodesize=%u\n", h->nodesize);
printf(" basementnodesize=%u\n", h->basementnodesize);
printf(" compression_method=%u\n", (unsigned) h->compression_method);
printf(" unnamed_root=%" PRId64 "\n", h->root_blocknum.b);
printf(" flags=%u\n", h->flags);
dump_descriptor(&h->descriptor);
......
......@@ -143,6 +143,7 @@ const struct logtype logtypes[] = {
{"u_int32_t", "treeflags", 0},
{"u_int32_t", "nodesize", 0},
{"u_int32_t", "basementnodesize", 0},
{"u_int32_t", "compression_method", 0},
NULLFIELD}},
//TODO: #2037 Add dname
{"fopen", 'O', FA{{"BYTESTRING", "iname", 0},
......
......@@ -859,12 +859,12 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn)
}
// 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, u_int32_t basementnodesize) {
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, enum toku_compression_method compression_method) {
if (txn==0) return 0;
if (txn->logger->is_panicked) return EINVAL;
BYTESTRING bs_fname = { .len=strlen(fname), .data = (char *) fname };
// 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, basementnodesize);
int r = toku_log_fcreate (txn->logger, (LSN*)0, 1, toku_txn_get_txnid(txn), filenum, bs_fname, mode, treeflags, nodesize, basementnodesize, compression_method);
return r;
}
......
......@@ -58,7 +58,7 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn);
// Returns: 0 if success
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, u_int32_t basementnodesize);
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, enum toku_compression_method compression_method);
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);
......
......@@ -267,7 +267,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.
static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create, int UU(mode), BYTESTRING *bs_iname, FILENUM filenum, u_int32_t treeflags,
TOKUTXN txn, uint32_t nodesize, uint32_t basementnodesize, LSN max_acceptable_lsn) {
TOKUTXN txn, uint32_t nodesize, uint32_t basementnodesize, enum toku_compression_method compression_method, LSN max_acceptable_lsn) {
int r;
BRT brt = NULL;
char *iname = fixup_fname(bs_iname);
......@@ -288,6 +288,11 @@ static int internal_recover_fopen_or_fcreate (RECOVER_ENV renv, BOOL must_create
assert(r == 0);
}
if (compression_method != TOKU_DEFAULT_COMPRESSION_METHOD) {
r = toku_brt_set_compression_method(brt, compression_method);
assert(r == 0);
}
// set the key compare functions
if (!(treeflags & TOKU_DB_KEYCMP_BUILTIN) && renv->bt_compare) {
r = toku_brt_set_bt_compare(brt, renv->bt_compare);
......@@ -452,7 +457,7 @@ static int toku_recover_fassociate (struct logtype_fassociate *l, RECOVER_ENV re
r = toku_brt_open_recovery(t, ROLLBACK_CACHEFILE_NAME, false, false, renv->ct, (TOKUTXN)NULL, l->filenum, max_acceptable_lsn);
renv->logger->rollback_cachefile = t->h->cf;
} else {
r = internal_recover_fopen_or_fcreate(renv, FALSE, 0, &l->iname, l->filenum, l->treeflags, NULL, 0, 0, max_acceptable_lsn);
r = internal_recover_fopen_or_fcreate(renv, FALSE, 0, &l->iname, l->filenum, l->treeflags, NULL, 0, 0, TOKU_DEFAULT_COMPRESSION_METHOD, max_acceptable_lsn);
assert(r==0);
}
}
......@@ -766,7 +771,7 @@ static int toku_recover_fcreate (struct logtype_fcreate *l, RECOVER_ENV renv) {
toku_free(iname);
BOOL must_create = TRUE;
r = internal_recover_fopen_or_fcreate(renv, must_create, l->mode, &l->iname, l->filenum, l->treeflags, txn, l->nodesize, l->basementnodesize, MAX_LSN);
r = internal_recover_fopen_or_fcreate(renv, must_create, l->mode, &l->iname, l->filenum, l->treeflags, txn, l->nodesize, l->basementnodesize, (enum toku_compression_method) l->compression_method, MAX_LSN);
return r;
}
......@@ -790,7 +795,7 @@ static int toku_recover_fopen (struct logtype_fopen *l, RECOVER_ENV renv) {
char *fname = fixup_fname(&l->iname);
assert(0!=strcmp(fname, ROLLBACK_CACHEFILE_NAME)); //Rollback cachefile can be opened only via fassociate.
r = internal_recover_fopen_or_fcreate(renv, must_create, 0, &l->iname, l->filenum, l->treeflags, txn, 0, 0, MAX_LSN);
r = internal_recover_fopen_or_fcreate(renv, must_create, 0, &l->iname, l->filenum, l->treeflags, txn, 0, 0, TOKU_DEFAULT_COMPRESSION_METHOD, MAX_LSN);
toku_free(fname);
return r;
......
......@@ -20,6 +20,7 @@ enum { BASEMENT_NODE_SIZE = 128 * 1024 };
static int nodesize = NODE_SIZE;
static int basementnodesize = BASEMENT_NODE_SIZE;
static enum toku_compression_method compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
static int keysize = sizeof (long long);
static int valsize = sizeof (long long);
static int do_verify =0; /* Do a slow verify after every insert. */
......@@ -34,7 +35,7 @@ static void setup (void) {
int r;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, NULL_TXN, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, compression_method, ct, NULL_TXN, toku_builtin_compare_fun); assert(r==0);
}
static void toku_shutdown (void) {
......
......@@ -15,6 +15,7 @@ static void test_sub_block(int n) {
const char fname[]= __FILE__ ".brt";
const int nodesize = 4*1024*1024;
const int basementnodesize = 128*1024;
const enum toku_compression_method compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
TOKUTXN const null_txn = 0;
......@@ -28,7 +29,7 @@ static void test_sub_block(int n) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0);
error = toku_open_brt(fname, TRUE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun);
error = toku_open_brt(fname, TRUE, &brt, nodesize, basementnodesize, compression_method, ct, null_txn, toku_builtin_compare_fun);
assert(error == 0);
// insert keys 0, 1, 2, .. (n-1)
......@@ -47,7 +48,7 @@ static void test_sub_block(int n) {
assert(error == 0);
// verify the brt by walking a cursor through the rows
error = toku_open_brt(fname, FALSE, &brt, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun);
error = toku_open_brt(fname, FALSE, &brt, nodesize, basementnodesize, compression_method, ct, null_txn, toku_builtin_compare_fun);
assert(error == 0);
BRT_CURSOR cursor;
......
......@@ -35,7 +35,7 @@ static void test_multiple_brt_cursor_dbts(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
int i;
......
......@@ -90,7 +90,7 @@ static void test_brt_cursor_first(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -131,7 +131,7 @@ static void test_brt_cursor_last(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert keys 0, 1, .. (n-1) */
......@@ -172,7 +172,7 @@ static void test_brt_cursor_first_last(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -217,7 +217,7 @@ static void test_brt_cursor_rfirst(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert keys n-1, n-2, ... , 0 */
......@@ -285,7 +285,7 @@ static void test_brt_cursor_walk(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -351,7 +351,7 @@ static void test_brt_cursor_rwalk(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -436,7 +436,7 @@ static void test_brt_cursor_rand(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -490,7 +490,7 @@ static void test_brt_cursor_split(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
/* insert a bunch of kv pairs */
......@@ -566,7 +566,7 @@ static void test_multiple_brt_cursors(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
int i;
......@@ -615,7 +615,7 @@ static void test_multiple_brt_cursor_walk(int n) {
r = toku_brt_create_cachetable(&ct, cachesize, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
int c;
......@@ -692,7 +692,7 @@ static void test_brt_cursor_set(int n, int cursor_op) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
int i;
......@@ -764,7 +764,7 @@ static void test_brt_cursor_set_range(int n) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(r==0);
int i;
......@@ -828,7 +828,7 @@ static void test_brt_cursor_delete(int n) {
error = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(error == 0);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(error == 0);
error = toku_brt_cursor(brt, &cursor, NULL, FALSE, FALSE);
......
......@@ -21,7 +21,7 @@ static void test_header (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
// now insert some info into the header
struct brt_header *h = t->h;
......@@ -39,7 +39,7 @@ static void test_header (void) {
// Now read dictionary back into memory and examine some header fields
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
r = toku_open_brt(fname, 0, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 0, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
h = t->h;
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ static void test0 (void) {
assert(r==0);
if (verbose) printf("%s:%d test0\n", __FILE__, __LINE__);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
//printf("%s:%d test0\n", __FILE__, __LINE__);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
......
......@@ -18,7 +18,7 @@ static void test1 (void) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER);
assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
r = toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn);
assert(r==0);
......
......@@ -18,7 +18,7 @@ static void test2 (int limit) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
if (verbose) printf("%s:%d did setup\n", __FILE__, __LINE__);
assert(r==0);
for (i=0; i<limit; i++) { // 4096
......
......@@ -8,6 +8,8 @@
static const char fname[]= __FILE__ ".brt";
static const enum toku_compression_method compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
......@@ -21,7 +23,7 @@ static void test3 (int nodesize, int basementnodesize, int count) {
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
gettimeofday(&t0, 0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, compression_method, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
for (i=0; i<count; i++) {
char key[100],val[100];
......
......@@ -21,7 +21,7 @@ static void test4 (int nodesize, int count) {
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
for (i=0; i<count; i++) {
char key[100],val[100];
int rv = random();
......
......@@ -21,7 +21,7 @@ static void test5 (void) {
for (i=0; i<limit; i++) values[i]=-1;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
for (i=0; i<limit/2; i++) {
char key[100],val[100];
int rk = random()%limit;
......
......@@ -39,7 +39,7 @@ static void test_it (int N) {
TOKUTXN txn;
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, 256, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_open_brt(FILENAME, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL, false); CKERR(r);
toku_txn_close_txn(txn);
......@@ -50,7 +50,7 @@ static void test_it (int N) {
unsigned int rands[N];
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_open_brt(FILENAME, 0, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_open_brt(FILENAME, 0, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL, false); CKERR(r);
toku_txn_close_txn(txn);
......@@ -73,7 +73,7 @@ static void test_it (int N) {
}
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_open_brt(FILENAME, 0, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_open_brt(FILENAME, 0, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL, false); CKERR(r);
toku_txn_close_txn(txn);
......@@ -99,7 +99,7 @@ static void test_it (int N) {
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_open_brt(FILENAME, 0, &brt, 1024, 256, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_open_brt(FILENAME, 0, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, toku_builtin_compare_fun); CKERR(r);
r = toku_txn_commit_txn(txn, FALSE, do_yield, NULL, NULL, NULL, false); CKERR(r);
toku_txn_close_txn(txn);
......
......@@ -26,7 +26,7 @@ static void open_brt_and_ct (bool unlink_old) {
int r;
if (unlink_old) unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
}
static void close_and_reopen (void) {
......
......@@ -45,7 +45,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_brt_cursor_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, test_brt_cursor_keycompare);
assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL, false);
......@@ -111,7 +111,7 @@ test_provdel(const char *logdir, const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_brt_cursor_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, test_brt_cursor_keycompare);
assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL, false);
......
......@@ -49,7 +49,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, test_keycompare);
assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL, false);
......@@ -101,7 +101,7 @@ test_neg_infinity(const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_keycompare);
assert(error == 0);
// position the cursor at -infinity
......@@ -138,7 +138,7 @@ test_pos_infinity(const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_keycompare);
assert(error == 0);
// position the LE_CURSOR at +infinity
......@@ -199,7 +199,7 @@ test_between(const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_keycompare);
assert(error == 0);
// position the LE_CURSOR at +infinity
......
......@@ -45,7 +45,7 @@ create_populate_tree(const char *logdir, const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, txn, test_brt_cursor_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, txn, test_brt_cursor_keycompare);
assert(error == 0);
error = toku_txn_commit_txn(txn, TRUE, txn_yield, NULL, NULL, NULL, false);
......@@ -98,7 +98,7 @@ walk_tree(const char *fname, int n) {
assert(error == 0);
BRT brt = NULL;
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare);
error = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare);
assert(error == 0);
LE_CURSOR cursor = NULL;
......
......@@ -125,7 +125,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// make a tree
......
......@@ -118,7 +118,7 @@ test_msnfilter(int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
BRTNODE newroot = make_node(brt, 0);
......
......@@ -1128,7 +1128,7 @@ test_main (int argc, const char *argv[]) {
assert(r==0);
unlink(fname);
BRT t;
r = toku_open_brt(fname, 1, &t, 128*1024, 4096, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, 128*1024, 4096, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_brt_set_update(t, orthopush_flush_update_fun); assert(r==0);
for (int i = 0; i < 10; ++i) {
......
......@@ -20,7 +20,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, ct, null_txn, test_brt_cursor_keycompare); assert(r==0);
r = toku_open_brt(fname, 1, &brt, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, test_brt_cursor_keycompare); assert(r==0);
r = toku_brt_cursor(brt, &cursor, NULL, FALSE, FALSE); assert(r==0);
int i;
......
......@@ -23,7 +23,7 @@ test_overflow (void) {
int r;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, nodesize / 8, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
DBT k,v;
u_int32_t vsize = nodesize/8;
......
......@@ -96,7 +96,7 @@ doit (BOOL after_child_pin) {
r = toku_brt_create_cachetable(&ct, 500*1024*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink("foo1.brt");
r = toku_open_brt("foo1.brt", 1, &t, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("foo1.brt", 1, &t, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......@@ -189,7 +189,7 @@ doit (BOOL after_child_pin) {
assert_zero(r);
BRT c_brt;
r = toku_open_brt("bar1.brt", 0, &c_brt, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("bar1.brt", 0, &c_brt, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
//
......
......@@ -91,7 +91,7 @@ doit (int state) {
// note the basement node size is 5 times the node size
// this is done to avoid rebalancing when writing a leaf
// node to disk
r = toku_open_brt("foo2.brt", 1, &t, NODESIZE, 5*NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("foo2.brt", 1, &t, NODESIZE, 5*NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......@@ -208,7 +208,7 @@ doit (int state) {
// note the basement node size is 5 times the node size
// this is done to avoid rebalancing when writing a leaf
// node to disk
r = toku_open_brt("bar2.brt", 0, &c_brt, NODESIZE, 5*NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("bar2.brt", 0, &c_brt, NODESIZE, 5*NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
//
......
......@@ -91,7 +91,7 @@ doit (int state) {
// note the basement node size is 5 times the node size
// this is done to avoid rebalancing when writing a leaf
// node to disk
r = toku_open_brt("foo3.brt", 1, &t, NODESIZE, 5*NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("foo3.brt", 1, &t, NODESIZE, 5*NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......@@ -228,7 +228,7 @@ doit (int state) {
// note the basement node size is 5 times the node size
// this is done to avoid rebalancing when writing a leaf
// node to disk
r = toku_open_brt("bar3.brt", 0, &c_brt, NODESIZE, 5*NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("bar3.brt", 0, &c_brt, NODESIZE, 5*NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
//
......
......@@ -100,7 +100,7 @@ doit (BOOL after_split) {
// note the basement node size is 5 times the node size
// this is done to avoid rebalancing when writing a leaf
// node to disk
r = toku_open_brt("foo4.brt", 1, &t, NODESIZE, 5*NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("foo4.brt", 1, &t, NODESIZE, 5*NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_testsetup_initialize(); // must precede any other toku_testsetup calls
......@@ -204,7 +204,7 @@ doit (BOOL after_split) {
// note the basement node size is 5 times the node size
// this is done to avoid rebalancing when writing a leaf
// node to disk
r = toku_open_brt("bar4.brt", 0, &c_brt, NODESIZE, 5*NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt("bar4.brt", 0, &c_brt, NODESIZE, 5*NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
//
......
......@@ -28,7 +28,7 @@ doit (void) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 16*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -54,7 +54,7 @@ doit (void) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 500*1024*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &brt, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -18,7 +18,7 @@ test_main(int argc, const char *argv[]) {
unlink(n);
assert(f);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(n, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(n, 1, &t, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
int i;
for (i=0; i<10000; i++) {
char key[100],val[100];
......
......@@ -54,7 +54,7 @@ doit (BOOL keep_other_bn_in_memory) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 500*1024*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &brt, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -58,7 +58,7 @@ doit (int ksize __attribute__((__unused__))) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 16*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -53,7 +53,7 @@ doit (void) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 500*1024*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &brt, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -87,7 +87,7 @@ doit (void) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 500*1024*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -24,7 +24,7 @@ static void setup (void) {
{ int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); }
char fname[] = __FILE__ "test1.dat";
unlink(fname);
{ int r = toku_open_brt(fname, 1, &t, 1024, 256, ct, null_txn, toku_builtin_compare_fun); assert(r==0); }
{ int r = toku_open_brt(fname, 1, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0); }
}
......
......@@ -15,6 +15,7 @@ static const char fname[]= __FILE__ ".brt";
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
static int const nodesize = 1<<12, basementnodesize = 1<<9;
static const enum toku_compression_method compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
static int const count = 1000;
static int
......@@ -38,7 +39,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_
int r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, ct, null_txn, string_cmp); assert(r==0);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, compression_method, ct, null_txn, string_cmp); assert(r==0);
for (int i = 0; i < count; ++i) {
char key[100],val[100];
......@@ -52,7 +53,7 @@ test_main (int argc __attribute__((__unused__)), const char *argv[] __attribute_
r = toku_cachetable_close(&ct); 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, basementnodesize, ct, null_txn, string_cmp); assert(r == 0);
r = toku_open_brt(fname, 1, &t, nodesize, basementnodesize, compression_method, ct, null_txn, string_cmp); assert(r == 0);
for (int n = 0; n < count/100; ++n) {
int i = n * 100;
......
......@@ -165,7 +165,7 @@ test_split_on_boundary(void)
CACHETABLE ct;
BRT brt;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
BRTNODE nodea, nodeb;
DBT splitk;
......@@ -238,7 +238,7 @@ test_split_with_everything_on_the_left(void)
CACHETABLE ct;
BRT brt;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
BRTNODE nodea, nodeb;
DBT splitk;
......@@ -313,7 +313,7 @@ test_split_on_boundary_of_last_node(void)
CACHETABLE ct;
BRT brt;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
BRTNODE nodea, nodeb;
DBT splitk;
......@@ -381,7 +381,7 @@ test_split_at_begin(void)
CACHETABLE ct;
BRT brt;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
BRTNODE nodea, nodeb;
DBT splitk;
......@@ -445,7 +445,7 @@ test_split_at_end(void)
CACHETABLE ct;
BRT brt;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
BRTNODE nodea, nodeb;
DBT splitk;
......@@ -499,7 +499,7 @@ test_split_odd_nodes(void)
CACHETABLE ct;
BRT brt;
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &brt, nodesize, bnsize, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
BRTNODE nodea, nodeb;
DBT splitk;
......
......@@ -32,7 +32,7 @@ static void open_brt_and_ct (bool unlink_old) {
int r;
if (unlink_old) unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_open_brt(fname, 1, &t, 1<<12, 1<<9, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_brt_set_bt_compare(t, dont_allow_prefix);
}
......
......@@ -29,7 +29,7 @@ doit (void) {
snprintf(fname, fnamelen, "%s.brt", __FILE__);
r = toku_brt_create_cachetable(&ct, 500*1024*1024, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE/2, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &t, NODESIZE, NODESIZE/2, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r==0);
toku_free(fname);
......
......@@ -184,13 +184,13 @@ int create_logfiles() {
//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;
//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, 0); assert(r==0);
r = toku_log_fcreate(logger, &lsn, NO_FSYNC, txnid, fn_aname, bs_aname, 0x0777, 0, 0, TOKU_DEFAULT_COMPRESSION_METHOD, 0); assert(r==0);
//commit 'C': lsn=3 txnid=1 crc=00001f1e len=29
r = toku_log_xcommit(logger, &lsn, FSYNC, txnid); assert(r==0);
//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;
//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, 0); assert(r==0);
r = toku_log_fcreate(logger, &lsn, NO_FSYNC, txnid, fn_bname, bs_bname, 0x0777, 0, 0, TOKU_DEFAULT_COMPRESSION_METHOD, 0); assert(r==0);
//commit 'C': lsn=6 txnid=4 crc=0000c11e len=29
r = toku_log_xcommit(logger, &lsn, FSYNC, txnid); assert(r==0);
//xbegin 'b': lsn=7 parenttxnid=0 crc=0000f91f len=29
......
......@@ -97,6 +97,7 @@ with_open_tree(const char *fname, tree_cb cb, void *cb_extra)
&t,
4*(1<<20),
128*(1<<10),
TOKU_DEFAULT_COMPRESSION_METHOD,
ct,
null_txn,
toku_builtin_compare_fun
......
......@@ -131,7 +131,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// make a tree
......
......@@ -101,7 +101,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// make a tree
......
......@@ -59,7 +59,7 @@ test_dup_in_leaf(int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// discard the old root block
......
......@@ -101,7 +101,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// make a tree
......
......@@ -116,7 +116,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// make a tree
......
......@@ -59,7 +59,7 @@ test_dup_in_leaf(int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// discard the old root block
......
......@@ -101,7 +101,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// create the brt
TOKUTXN null_txn = NULL;
BRT brt = NULL;
r = toku_open_brt(fname, 1, &brt, 1024, 256, ct, null_txn, toku_builtin_compare_fun);
r = toku_open_brt(fname, 1, &brt, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
assert(r == 0);
// make a tree
......
......@@ -65,21 +65,12 @@ with_open_db(db_callback cb, void *cb_extra, bool set_method, enum toku_compress
DB_TXN *txn;
r = env->txn_begin(env, 0, &txn, 0);
CKERR(r);
{
// we should not be able to successfully do this on an unopened DB
r = db->set_compression_method(db, TOKU_NO_COMPRESSION);
assert(r != 0);
enum toku_compression_method m = (enum toku_compression_method) 999;
r = db->get_compression_method(db, &m);
assert(r != 0);
assert(m == 999);
}
r = db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR(r);
if (set_method) {
r = db->set_compression_method(db, method);
CKERR(r);
}
r = db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR(r);
r = txn->commit(txn, 0);
CKERR(r);
}
......
......@@ -575,26 +575,14 @@ toku_db_get_readpagesize(DB *db, u_int32_t *readpagesize_ptr) {
static int
toku_db_set_compression_method(DB *db, enum toku_compression_method compression_method) {
HANDLE_PANICKED_DB(db);
int r;
// compression method is tracked in the brt header, so it must be open
if (!db_opened(db)) {
r = EINVAL;
} else {
r = toku_brt_set_compression_method(db->i->brt, compression_method);
}
int r = toku_brt_set_compression_method(db->i->brt, compression_method);
return r;
}
static int
toku_db_get_compression_method(DB *db, enum toku_compression_method *compression_method_ptr) {
HANDLE_PANICKED_DB(db);
int r;
// compression method is tracked in the brt header, so it must be open
if (!db_opened(db)) {
r = EINVAL;
} else {
r = toku_brt_get_compression_method(db->i->brt, compression_method_ptr);
}
int r = toku_brt_get_compression_method(db->i->brt, compression_method_ptr);
return r;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment