Commit 646aea71 authored by Yoni Fogel's avatar Yoni Fogel

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

This reverts commit 86f5bc832a3ebe5dc8ecb2105491a903e7dc4700.
This reverts commit r19651

git-svn-id: file:///svn/toku/tokudb@19681 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4f6a025c
......@@ -162,19 +162,22 @@ int toku_loader_create_loader(DB_ENV *env,
loader->close = toku_loader_close;
loader->abort = toku_loader_abort;
int r;
int r = 0;
// lock tables and check empty
for(int i=0;i<N;i++) {
r = toku_db_pre_acquire_table_lock(dbs[i], txn, TRUE);
if ( r!=0 ) {
free_loader(loader);
return -1;
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 = verify_empty(dbs[i], txn);
if ( r!=0 ) {
free_loader(loader);
return -1;
}
if (r!=0) break;
}
if ( r!=0 ) {
free_loader(loader);
return -1;
}
brt_compare_func compare_functions[N];
......
......@@ -11,7 +11,6 @@ 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;
......@@ -48,7 +47,7 @@ static void test_loader(DB **dbs)
db_flags[i] = DB_NOOVERWRITE;
dbt_flags[i] = 0;
}
uint32_t loader_flags = USE_PUTS; // set with -p option
uint32_t loader_flags = 0;
// create and initialize loader
r = env->txn_begin(env, NULL, &txn, 0);
......@@ -171,8 +170,6 @@ 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,16 +197,8 @@ 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;
......@@ -245,15 +237,12 @@ static void test_loader(DB **dbs)
poll_count=0;
// close the loader
printf("%9.6fs closing", elapsed_time()); fflush(stdout);
printf("closing"); 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);
}
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