Commit 45919319 authored by Dave Wells's avatar Dave Wells Committed by Yoni Fogel

move changes to loader.c and its tests to main re:DB_DBT_REALLOC

git-svn-id: file:///svn/toku/tokudb@19651 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9542e886
......@@ -162,23 +162,20 @@ int toku_loader_create_loader(DB_ENV *env,
loader->close = toku_loader_close;
loader->abort = toku_loader_abort;
int r = 0;
int r;
// lock tables and check empty
for(int i=0;i<N;i++) {
if (!(loader_flags&DB_PRELOCKED_WRITE)) {
toku_ydb_lock(); //Must hold ydb lock for acquiring locks
BOOL using_puts = (loader->i->loader_flags & LOADER_USE_PUTS) != 0;
r = toku_db_pre_acquire_table_lock(dbs[i], txn, !using_puts);
toku_ydb_unlock();
if (r!=0) break;
r = toku_db_pre_acquire_table_lock(dbs[i], txn, TRUE);
if ( r!=0 ) {
free_loader(loader);
return -1;
}
r = verify_empty(dbs[i], txn);
if (r!=0) break;
}
if ( r!=0 ) {
free_loader(loader);
return -1;
}
}
brt_compare_func compare_functions[N];
for (int i=0; i<N; i++) {
......
......@@ -11,6 +11,7 @@ DB_ENV *env;
enum {MAX_NAME=128};
enum {NUM_DBS=1};
enum {NUM_KV_PAIRS=3};
int USE_PUTS=0;
struct kv_pair {
int64_t key;
int64_t val;
......@@ -47,7 +48,7 @@ static void test_loader(DB **dbs)
db_flags[i] = DB_NOOVERWRITE;
dbt_flags[i] = 0;
}
uint32_t loader_flags = 0;
uint32_t loader_flags = USE_PUTS; // set with -p option
// create and initialize loader
r = env->txn_begin(env, NULL, &txn, 0);
......@@ -170,6 +171,8 @@ static void do_args(int argc, char * const argv[]) {
} else if (strcmp(argv[0],"-q")==0) {
verbose--;
if (verbose<0) verbose=0;
} else if (strcmp(argv[0], "-p")==0) {
USE_PUTS = 1;
} else {
fprintf(stderr, "Unknown arg: %s\n", argv[0]);
resultcode=1;
......
......@@ -197,8 +197,16 @@ static int poll_function (void *extra, float progress) {
return 0;
}
static struct timeval starttime;
static double elapsed_time (void) {
struct timeval now;
gettimeofday(&now, NULL);
return now.tv_sec - starttime.tv_sec + 1e-6*(now.tv_usec - starttime.tv_usec);
}
static void test_loader(DB **dbs)
{
gettimeofday(&starttime, NULL);
int r;
DB_TXN *txn;
DB_LOADER *loader;
......@@ -237,12 +245,15 @@ static void test_loader(DB **dbs)
poll_count=0;
// close the loader
printf("closing"); fflush(stdout);
printf("%9.6fs closing", elapsed_time()); fflush(stdout);
r = loader->close(loader);
printf(" done\n");
CKERR(r);
if ( USE_PUTS == 0 ) {
if (poll_count == 0) printf("%s:%d\n", __FILE__, __LINE__);
assert(poll_count>0);
}
r = txn->commit(txn, 0);
CKERR(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