mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
Rename a bunch of symbols to toku_symbols. Addresses #8.
git-svn-id: file:///svn/tokudb@824 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
9f54dcef61
commit
77ab644ef6
12 changed files with 321 additions and 321 deletions
|
@ -104,7 +104,7 @@ void long_long_to_array (unsigned char *a, unsigned long long l) {
|
||||||
a[i] = (l>>(56-8*i))&0xff;
|
a[i] = (l>>(56-8*i))&0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBT *fill_dbt(DBT *dbt, void *data, int size) {
|
DBT *toku_fill_dbt(DBT *dbt, void *data, int size) {
|
||||||
memset(dbt, 0, sizeof *dbt);
|
memset(dbt, 0, sizeof *dbt);
|
||||||
dbt->size = size;
|
dbt->size = size;
|
||||||
dbt->data = data;
|
dbt->data = data;
|
||||||
|
@ -118,7 +118,7 @@ void insert (long long v) {
|
||||||
long_long_to_array(kc, v);
|
long_long_to_array(kc, v);
|
||||||
memset(vc, 0, sizeof vc);
|
memset(vc, 0, sizeof vc);
|
||||||
long_long_to_array(vc, v);
|
long_long_to_array(vc, v);
|
||||||
int r = db->put(db, tid, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0);
|
int r = db->put(db, tid, toku_fill_dbt(&kt, kc, keysize), toku_fill_dbt(&vt, vc, valsize), 0);
|
||||||
CKERR(r);
|
CKERR(r);
|
||||||
if (do_transactions) {
|
if (do_transactions) {
|
||||||
if (n_insertions_since_txn_began>=ITEMS_PER_TRANSACTION) {
|
if (n_insertions_since_txn_began>=ITEMS_PER_TRANSACTION) {
|
||||||
|
@ -137,7 +137,7 @@ void serial_insert_from (long long from) {
|
||||||
int r = dbenv->txn_begin(dbenv, 0, &tid, 0); assert(r==0);
|
int r = dbenv->txn_begin(dbenv, 0, &tid, 0); assert(r==0);
|
||||||
{
|
{
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
r=db->put(db, tid, fill_dbt(&k, "a", 1), fill_dbt(&v, "b", 1), 0);
|
r=db->put(db, tid, toku_fill_dbt(&k, "a", 1), toku_fill_dbt(&v, "b", 1), 0);
|
||||||
CKERR(r);
|
CKERR(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ void insert (long long v) {
|
||||||
long_long_to_array(kc, v);
|
long_long_to_array(kc, v);
|
||||||
memset(vc, 0, sizeof vc);
|
memset(vc, 0, sizeof vc);
|
||||||
long_long_to_array(vc, v);
|
long_long_to_array(vc, v);
|
||||||
toku_brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0);
|
toku_brt_insert(t, toku_fill_dbt(&kt, kc, keysize), toku_fill_dbt(&vt, vc, valsize), 0);
|
||||||
if (do_verify) toku_cachetable_verify(ct);
|
if (do_verify) toku_cachetable_verify(ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,9 +383,9 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl
|
||||||
bytevec val; ITEMLEN vallen;
|
bytevec val; ITEMLEN vallen;
|
||||||
toku_verify_counts(result);
|
toku_verify_counts(result);
|
||||||
rbuf_bytes(&rc, &key, &keylen); /* Returns a pointer into the rbuf. */
|
rbuf_bytes(&rc, &key, &keylen); /* Returns a pointer into the rbuf. */
|
||||||
fill_dbt(&keys[i], key, keylen);
|
toku_fill_dbt(&keys[i], key, keylen);
|
||||||
rbuf_bytes(&rc, &val, &vallen);
|
rbuf_bytes(&rc, &val, &vallen);
|
||||||
fill_dbt(&vals[i], val, vallen);
|
toku_fill_dbt(&vals[i], val, vallen);
|
||||||
result->u.l.n_bytes_in_buffer += keylen + vallen + KEY_VALUE_OVERHEAD;
|
result->u.l.n_bytes_in_buffer += keylen + vallen + KEY_VALUE_OVERHEAD;
|
||||||
}
|
}
|
||||||
if (n_in_buf > 0) {
|
if (n_in_buf > 0) {
|
||||||
|
@ -410,7 +410,7 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl
|
||||||
rbuf_bytes(&rc, &val, &vallen);
|
rbuf_bytes(&rc, &val, &vallen);
|
||||||
{
|
{
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
r = toku_pma_insert(result->u.l.buffer, fill_dbt(&k, key, keylen), fill_dbt(&v, val, vallen), 0);
|
r = toku_pma_insert(result->u.l.buffer, toku_fill_dbt(&k, key, keylen), toku_fill_dbt(&v, val, vallen), 0);
|
||||||
if (r!=0) goto died_21;
|
if (r!=0) goto died_21;
|
||||||
}
|
}
|
||||||
result->u.l.n_bytes_in_buffer += keylen + vallen + KEY_VALUE_OVERHEAD;
|
result->u.l.n_bytes_in_buffer += keylen + vallen + KEY_VALUE_OVERHEAD;
|
||||||
|
|
|
@ -55,9 +55,9 @@ static void test1 (void) {
|
||||||
unlink(fname);
|
unlink(fname);
|
||||||
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
|
r = toku_open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun, null_db);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
toku_brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_txn);
|
toku_brt_insert(t, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn);
|
||||||
{
|
{
|
||||||
r = toku_brt_lookup(t, fill_dbt(&k, "hello", 6), init_dbt(&v));
|
r = toku_brt_lookup(t, toku_fill_dbt(&k, "hello", 6), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(strcmp(v.data, "there")==0);
|
assert(strcmp(v.data, "there")==0);
|
||||||
assert(v.size==6);
|
assert(v.size==6);
|
||||||
|
@ -87,7 +87,7 @@ static void test2 (int memcheck) {
|
||||||
char key[100],val[100];
|
char key[100],val[100];
|
||||||
snprintf(key,100,"hello%d",i);
|
snprintf(key,100,"hello%d",i);
|
||||||
snprintf(val,100,"there%d",i);
|
snprintf(val,100,"there%d",i);
|
||||||
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
||||||
//printf("%s:%d did insert %d\n", __FILE__, __LINE__, i);
|
//printf("%s:%d did insert %d\n", __FILE__, __LINE__, i);
|
||||||
if (0) {
|
if (0) {
|
||||||
brt_flush(t);
|
brt_flush(t);
|
||||||
|
@ -125,7 +125,7 @@ static void test3 (int nodesize, int count, int memcheck) {
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
snprintf(key,100,"hello%d",i);
|
snprintf(key,100,"hello%d",i);
|
||||||
snprintf(val,100,"there%d",i);
|
snprintf(val,100,"there%d",i);
|
||||||
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
||||||
}
|
}
|
||||||
r = toku_close_brt(t); assert(r==0);
|
r = toku_close_brt(t); assert(r==0);
|
||||||
r = toku_cachetable_close(&ct); assert(r==0);
|
r = toku_cachetable_close(&ct); assert(r==0);
|
||||||
|
@ -156,7 +156,7 @@ static void test4 (int nodesize, int count, int memcheck) {
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
snprintf(key,100,"hello%d",rv);
|
snprintf(key,100,"hello%d",rv);
|
||||||
snprintf(val,100,"there%d",i);
|
snprintf(val,100,"there%d",i);
|
||||||
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
||||||
}
|
}
|
||||||
r = toku_close_brt(t); assert(r==0);
|
r = toku_close_brt(t); assert(r==0);
|
||||||
r = toku_cachetable_close(&ct); assert(r==0);
|
r = toku_cachetable_close(&ct); assert(r==0);
|
||||||
|
@ -191,7 +191,7 @@ static void test5 (void) {
|
||||||
snprintf(key, 100, "key%d", rk);
|
snprintf(key, 100, "key%d", rk);
|
||||||
snprintf(val, 100, "val%d", rv);
|
snprintf(val, 100, "val%d", rv);
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
toku_brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
toku_brt_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (i=0; i<limit/2; i++) {
|
for (i=0; i<limit/2; i++) {
|
||||||
|
@ -202,7 +202,7 @@ static void test5 (void) {
|
||||||
if (i%1000==0) printf("r"); fflush(stdout);
|
if (i%1000==0) printf("r"); fflush(stdout);
|
||||||
snprintf(key, 100, "key%d", rk);
|
snprintf(key, 100, "key%d", rk);
|
||||||
snprintf(valexpected, 100, "val%d", values[rk]);
|
snprintf(valexpected, 100, "val%d", values[rk]);
|
||||||
r = toku_brt_lookup(t, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&v));
|
r = toku_brt_lookup(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(v.size==(1+strlen(valexpected)));
|
assert(v.size==(1+strlen(valexpected)));
|
||||||
assert(memcmp(v.data,valexpected,v.size)==0);
|
assert(memcmp(v.data,valexpected,v.size)==0);
|
||||||
|
@ -251,9 +251,9 @@ static void test_multiple_files_of_size (int size) {
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
snprintf(key, 100, "key%d", i);
|
snprintf(key, 100, "key%d", i);
|
||||||
snprintf(val, 100, "val%d", i);
|
snprintf(val, 100, "val%d", i);
|
||||||
toku_brt_insert(t0, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
toku_brt_insert(t0, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
||||||
snprintf(val, 100, "Val%d", i);
|
snprintf(val, 100, "Val%d", i);
|
||||||
toku_brt_insert(t1, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
toku_brt_insert(t1, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
|
||||||
}
|
}
|
||||||
//toku_verify_brt(t0);
|
//toku_verify_brt(t0);
|
||||||
//dump_brt(t0);
|
//dump_brt(t0);
|
||||||
|
@ -278,12 +278,12 @@ static void test_multiple_files_of_size (int size) {
|
||||||
DBT k,actual;
|
DBT k,actual;
|
||||||
snprintf(key, 100, "key%d", i);
|
snprintf(key, 100, "key%d", i);
|
||||||
snprintf(val, 100, "val%d", i);
|
snprintf(val, 100, "val%d", i);
|
||||||
r=toku_brt_lookup(t0, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual));
|
r=toku_brt_lookup(t0, toku_fill_dbt(&k, key, 1+strlen(key)), toku_init_dbt(&actual));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(strcmp(val,actual.data)==0);
|
assert(strcmp(val,actual.data)==0);
|
||||||
assert(actual.size==1+strlen(val));
|
assert(actual.size==1+strlen(val));
|
||||||
snprintf(val, 100, "Val%d", i);
|
snprintf(val, 100, "Val%d", i);
|
||||||
r=toku_brt_lookup(t1, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual));
|
r=toku_brt_lookup(t1, toku_fill_dbt(&k, key, 1+strlen(key)), toku_init_dbt(&actual));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(strcmp(val,actual.data)==0);
|
assert(strcmp(val,actual.data)==0);
|
||||||
assert(actual.size==1+strlen(val));
|
assert(actual.size==1+strlen(val));
|
||||||
|
@ -316,7 +316,7 @@ static void test_named_db (void) {
|
||||||
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
|
|
||||||
|
|
||||||
toku_brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_txn); assert(r==0);
|
toku_brt_insert(t0, toku_fill_dbt(&k, "good", 5), toku_fill_dbt(&v, "day", 4), null_txn); assert(r==0);
|
||||||
|
|
||||||
r = toku_close_brt(t0); assert(r==0);
|
r = toku_close_brt(t0); assert(r==0);
|
||||||
r = toku_cachetable_close(&ct); assert(r==0);
|
r = toku_cachetable_close(&ct); assert(r==0);
|
||||||
|
@ -327,7 +327,7 @@ static void test_named_db (void) {
|
||||||
r = toku_open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
|
|
||||||
{
|
{
|
||||||
r = toku_brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v));
|
r = toku_brt_lookup(t0, toku_fill_dbt(&k, "good", 5), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(v.size==4);
|
assert(v.size==4);
|
||||||
assert(strcmp(v.data,"day")==0);
|
assert(strcmp(v.data,"day")==0);
|
||||||
|
@ -353,8 +353,8 @@ static void test_multiple_dbs (void) {
|
||||||
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
r = toku_open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
|
|
||||||
toku_brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_txn); assert(r==0);
|
toku_brt_insert(t0, toku_fill_dbt(&k, "good", 5), toku_fill_dbt(&v, "grief", 6), null_txn); assert(r==0);
|
||||||
toku_brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_txn); assert(r==0);
|
toku_brt_insert(t1, toku_fill_dbt(&k, "bad", 4), toku_fill_dbt(&v, "night", 6), null_txn); assert(r==0);
|
||||||
|
|
||||||
r = toku_close_brt(t0); assert(r==0);
|
r = toku_close_brt(t0); assert(r==0);
|
||||||
r = toku_close_brt(t1); assert(r==0);
|
r = toku_close_brt(t1); assert(r==0);
|
||||||
|
@ -367,18 +367,18 @@ static void test_multiple_dbs (void) {
|
||||||
r = toku_open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
|
|
||||||
{
|
{
|
||||||
r = toku_brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v));
|
r = toku_brt_lookup(t0, toku_fill_dbt(&k, "good", 5), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(v.size==6);
|
assert(v.size==6);
|
||||||
assert(strcmp(v.data,"grief")==0);
|
assert(strcmp(v.data,"grief")==0);
|
||||||
|
|
||||||
r = toku_brt_lookup(t1, fill_dbt(&k, "good", 5), init_dbt(&v));
|
r = toku_brt_lookup(t1, toku_fill_dbt(&k, "good", 5), toku_init_dbt(&v));
|
||||||
assert(r!=0);
|
assert(r!=0);
|
||||||
|
|
||||||
r = toku_brt_lookup(t0, fill_dbt(&k, "bad", 4), init_dbt(&v));
|
r = toku_brt_lookup(t0, toku_fill_dbt(&k, "bad", 4), toku_init_dbt(&v));
|
||||||
assert(r!=0);
|
assert(r!=0);
|
||||||
|
|
||||||
r = toku_brt_lookup(t1, fill_dbt(&k, "bad", 4), init_dbt(&v));
|
r = toku_brt_lookup(t1, toku_fill_dbt(&k, "bad", 4), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(v.size==6);
|
assert(v.size==6);
|
||||||
assert(strcmp(v.data,"night")==0);
|
assert(strcmp(v.data,"night")==0);
|
||||||
|
@ -414,7 +414,7 @@ static void test_multiple_dbs_many (void) {
|
||||||
DBT kdbt,vdbt;
|
DBT kdbt,vdbt;
|
||||||
snprintf(k, 20, "key%d", i);
|
snprintf(k, 20, "key%d", i);
|
||||||
snprintf(v, 20, "val%d", i);
|
snprintf(v, 20, "val%d", i);
|
||||||
toku_brt_insert(trees[i], fill_dbt(&kdbt, k, strlen(k)+1), fill_dbt(&vdbt, v, strlen(v)+1), null_txn);
|
toku_brt_insert(trees[i], toku_fill_dbt(&kdbt, k, strlen(k)+1), toku_fill_dbt(&vdbt, v, strlen(v)+1), null_txn);
|
||||||
}
|
}
|
||||||
for (i=0; i<MANYN; i++) {
|
for (i=0; i<MANYN; i++) {
|
||||||
r = toku_close_brt(trees[i]); assert(r==0);
|
r = toku_close_brt(trees[i]); assert(r==0);
|
||||||
|
@ -443,14 +443,14 @@ static void test_multiple_brts_one_db_one_file (void) {
|
||||||
DBT kb, vb;
|
DBT kb, vb;
|
||||||
snprintf(k, 20, "key%d", i);
|
snprintf(k, 20, "key%d", i);
|
||||||
snprintf(v, 20, "val%d", i);
|
snprintf(v, 20, "val%d", i);
|
||||||
toku_brt_insert(trees[i], fill_dbt(&kb, k, strlen(k)+1), fill_dbt(&vb, v, strlen(v)+1), null_txn);
|
toku_brt_insert(trees[i], toku_fill_dbt(&kb, k, strlen(k)+1), toku_fill_dbt(&vb, v, strlen(v)+1), null_txn);
|
||||||
}
|
}
|
||||||
for (i=0; i<MANYN; i++) {
|
for (i=0; i<MANYN; i++) {
|
||||||
char k[20],vexpect[20];
|
char k[20],vexpect[20];
|
||||||
DBT kb, vb;
|
DBT kb, vb;
|
||||||
snprintf(k, 20, "key%d", i);
|
snprintf(k, 20, "key%d", i);
|
||||||
snprintf(vexpect, 20, "val%d", i);
|
snprintf(vexpect, 20, "val%d", i);
|
||||||
r=toku_brt_lookup(trees[0], fill_dbt(&kb, k, strlen(k)+1), init_dbt(&vb));
|
r=toku_brt_lookup(trees[0], toku_fill_dbt(&kb, k, strlen(k)+1), toku_init_dbt(&vb));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(vb.size==1+strlen(vexpect));
|
assert(vb.size==1+strlen(vexpect));
|
||||||
assert(strcmp(vb.data, vexpect)==0);
|
assert(strcmp(vb.data, vexpect)==0);
|
||||||
|
@ -491,7 +491,7 @@ static void test_read_what_was_written (void) {
|
||||||
/* See if we can put something in it. */
|
/* See if we can put something in it. */
|
||||||
{
|
{
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
toku_brt_insert(brt, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_txn);
|
toku_brt_insert(brt, toku_fill_dbt(&k, "hello", 6), toku_fill_dbt(&v, "there", 6), null_txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = toku_close_brt(brt); assert(r==0);
|
r = toku_close_brt(brt); assert(r==0);
|
||||||
|
@ -505,7 +505,7 @@ static void test_read_what_was_written (void) {
|
||||||
|
|
||||||
{
|
{
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
r = toku_brt_lookup(brt, fill_dbt(&k, "hello", 6), init_dbt(&v));
|
r = toku_brt_lookup(brt, toku_fill_dbt(&k, "hello", 6), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(v.size==6);
|
assert(v.size==6);
|
||||||
assert(strcmp(v.data,"there")==0);
|
assert(strcmp(v.data,"there")==0);
|
||||||
|
@ -525,7 +525,7 @@ static void test_read_what_was_written (void) {
|
||||||
int verify_result=toku_verify_brt(brt);;
|
int verify_result=toku_verify_brt(brt);;
|
||||||
assert(verify_result==0);
|
assert(verify_result==0);
|
||||||
}
|
}
|
||||||
toku_brt_insert(brt, fill_dbt(&k, key, strlen(key)+1), fill_dbt(&v, val, strlen(val)+1), null_txn);
|
toku_brt_insert(brt, toku_fill_dbt(&k, key, strlen(key)+1), toku_fill_dbt(&v, val, strlen(val)+1), null_txn);
|
||||||
if (i<600) {
|
if (i<600) {
|
||||||
int verify_result=toku_verify_brt(brt);
|
int verify_result=toku_verify_brt(brt);
|
||||||
if (verify_result) {
|
if (verify_result) {
|
||||||
|
@ -538,7 +538,7 @@ static void test_read_what_was_written (void) {
|
||||||
char expectedval[100];
|
char expectedval[100];
|
||||||
snprintf(key, 100, "key%d", j);
|
snprintf(key, 100, "key%d", j);
|
||||||
snprintf(expectedval, 100, "val%d", j);
|
snprintf(expectedval, 100, "val%d", j);
|
||||||
r=toku_brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
|
r=toku_brt_lookup(brt, toku_fill_dbt(&k, key, strlen(key)+1), toku_init_dbt(&v));
|
||||||
if (r!=0) {
|
if (r!=0) {
|
||||||
printf("%s:%d r=%d on lookup(key=%s) after i=%d\n", __FILE__, __LINE__, r, key, i);
|
printf("%s:%d r=%d on lookup(key=%s) after i=%d\n", __FILE__, __LINE__, r, key, i);
|
||||||
toku_dump_brt(brt);
|
toku_dump_brt(brt);
|
||||||
|
@ -563,7 +563,7 @@ static void test_read_what_was_written (void) {
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
snprintf(key, 100, "key%d", i);
|
snprintf(key, 100, "key%d", i);
|
||||||
snprintf(expectedval, 100, "val%d", i);
|
snprintf(expectedval, 100, "val%d", i);
|
||||||
r=toku_brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
|
r=toku_brt_lookup(brt, toku_fill_dbt(&k, key, strlen(key)+1), toku_init_dbt(&v));
|
||||||
if (r!=0) printf("%s:%d r=%d on key=%s\n", __FILE__, __LINE__, r, key);
|
if (r!=0) printf("%s:%d r=%d on key=%s\n", __FILE__, __LINE__, r, key);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ static void test_read_what_was_written (void) {
|
||||||
|
|
||||||
{
|
{
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
r = toku_brt_lookup(brt, fill_dbt(&k, "hello", 6), init_dbt(&v));
|
r = toku_brt_lookup(brt, toku_fill_dbt(&k, "hello", 6), toku_init_dbt(&v));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(v.size==6);
|
assert(v.size==6);
|
||||||
assert(strcmp(v.data,"there")==0);
|
assert(strcmp(v.data,"there")==0);
|
||||||
|
@ -593,7 +593,7 @@ static void test_read_what_was_written (void) {
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
snprintf(key, 100, "key%d", i);
|
snprintf(key, 100, "key%d", i);
|
||||||
snprintf(expectedval, 100, "val%d", i);
|
snprintf(expectedval, 100, "val%d", i);
|
||||||
r=toku_brt_lookup(brt, fill_dbt(&k, key, strlen(key)+1), init_dbt(&v));
|
r=toku_brt_lookup(brt, toku_fill_dbt(&k, key, strlen(key)+1), toku_init_dbt(&v));
|
||||||
if (r!=0) printf("%s:%d r=%d on key=%s\n", __FILE__, __LINE__, r, key);
|
if (r!=0) printf("%s:%d r=%d on key=%s\n", __FILE__, __LINE__, r, key);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
|
@ -628,9 +628,9 @@ void test_cursor_last_empty(void) {
|
||||||
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
r = toku_brt_cursor(brt, &cursor); assert(r==0);
|
r = toku_brt_cursor(brt, &cursor); assert(r==0);
|
||||||
init_dbt(&kbt);
|
toku_init_dbt(&kbt);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
init_dbt(&vbt);
|
toku_init_dbt(&vbt);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, null_txn);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
|
@ -659,13 +659,13 @@ void test_cursor_next (void) {
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
r = toku_open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
r = toku_brt_insert(brt, fill_dbt(&kbt, "hello", 6), 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, fill_dbt(&kbt, "byebye", 7), 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);
|
||||||
printf("%s:%d calling toku_brt_cursor(...)\n", __FILE__, __LINE__);
|
printf("%s:%d calling toku_brt_cursor(...)\n", __FILE__, __LINE__);
|
||||||
r = toku_brt_cursor(brt, &cursor); assert(r==0);
|
r = toku_brt_cursor(brt, &cursor); assert(r==0);
|
||||||
init_dbt(&kbt);
|
toku_init_dbt(&kbt);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
init_dbt(&vbt);
|
toku_init_dbt(&vbt);
|
||||||
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
|
||||||
|
|
||||||
printf("%s:%d calling toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
|
printf("%s:%d calling toku_brt_cursor_get(...)\n", __FILE__, __LINE__);
|
||||||
|
@ -729,8 +729,8 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
||||||
char a[4]={0,1,0,0};
|
char a[4]={0,1,0,0};
|
||||||
char b[4]={1,0,0,0};
|
char b[4]={1,0,0,0};
|
||||||
DBT at, bt;
|
DBT at, bt;
|
||||||
assert(wrong_compare_fun(&nonce_db, fill_dbt(&at, a, 4), fill_dbt(&bt, b, 4))>0);
|
assert(wrong_compare_fun(&nonce_db, toku_fill_dbt(&at, a, 4), toku_fill_dbt(&bt, b, 4))>0);
|
||||||
assert(wrong_compare_fun(&nonce_db, fill_dbt(&at, b, 4), fill_dbt(&bt, a, 4))<0);
|
assert(wrong_compare_fun(&nonce_db, toku_fill_dbt(&at, b, 4), toku_fill_dbt(&bt, a, 4))<0);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
|
||||||
|
@ -744,8 +744,8 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
||||||
b[2] = a[1] = (i>>8)&255;
|
b[2] = a[1] = (i>>8)&255;
|
||||||
b[1] = a[2] = (i>>16)&255;
|
b[1] = a[2] = (i>>16)&255;
|
||||||
b[0] = a[3] = (i>>24)&255;
|
b[0] = a[3] = (i>>24)&255;
|
||||||
fill_dbt(&kbt, a, sizeof(a));
|
toku_fill_dbt(&kbt, a, sizeof(a));
|
||||||
fill_dbt(&vbt, b, sizeof(b));
|
toku_fill_dbt(&vbt, b, sizeof(b));
|
||||||
printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__,
|
printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__,
|
||||||
((char*)kbt.data)[0], ((char*)kbt.data)[1], ((char*)kbt.data)[2], ((char*)kbt.data)[3],
|
((char*)kbt.data)[0], ((char*)kbt.data)[1], ((char*)kbt.data)[2], ((char*)kbt.data)[3],
|
||||||
((char*)vbt.data)[0], ((char*)vbt.data)[1], ((char*)vbt.data)[2], ((char*)vbt.data)[3]);
|
((char*)vbt.data)[0], ((char*)vbt.data)[1], ((char*)vbt.data)[2], ((char*)vbt.data)[3]);
|
||||||
|
@ -755,7 +755,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
||||||
r = toku_brt_cursor(brt, &cursor); assert(r==0);
|
r = toku_brt_cursor(brt, &cursor); assert(r==0);
|
||||||
|
|
||||||
for (i=0; i<2; i++) {
|
for (i=0; i<2; i++) {
|
||||||
init_dbt(&kbt); init_dbt(&vbt);
|
toku_init_dbt(&kbt); toku_init_dbt(&vbt);
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(kbt.size==4 && vbt.size==4);
|
assert(kbt.size==4 && vbt.size==4);
|
||||||
|
@ -779,8 +779,8 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
||||||
b[2] = a[1] = (i>>8)&255;
|
b[2] = a[1] = (i>>8)&255;
|
||||||
b[1] = a[2] = (i>>16)&255;
|
b[1] = a[2] = (i>>16)&255;
|
||||||
b[0] = a[3] = (i>>24)&255;
|
b[0] = a[3] = (i>>24)&255;
|
||||||
fill_dbt(&kbt, a, sizeof(a));
|
toku_fill_dbt(&kbt, a, sizeof(a));
|
||||||
fill_dbt(&vbt, b, sizeof(b));
|
toku_fill_dbt(&vbt, b, sizeof(b));
|
||||||
if (0) printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__,
|
if (0) printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__,
|
||||||
((unsigned char*)kbt.data)[0], ((unsigned char*)kbt.data)[1], ((unsigned char*)kbt.data)[2], ((unsigned char*)kbt.data)[3],
|
((unsigned char*)kbt.data)[0], ((unsigned char*)kbt.data)[1], ((unsigned char*)kbt.data)[2], ((unsigned char*)kbt.data)[3],
|
||||||
((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]);
|
((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]);
|
||||||
|
@ -793,7 +793,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
|
||||||
int prev=-1;
|
int prev=-1;
|
||||||
for (i=0; i<N; i++) {
|
for (i=0; i<N; i++) {
|
||||||
int this;
|
int this;
|
||||||
init_dbt(&kbt); init_dbt(&vbt);
|
toku_init_dbt(&kbt); toku_init_dbt(&vbt);
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(kbt.size==4 && vbt.size==4);
|
assert(kbt.size==4 && vbt.size==4);
|
||||||
|
@ -830,8 +830,8 @@ void assert_cursor_notfound(BRT brt, int position) {
|
||||||
r = toku_brt_cursor(brt, &cursor);
|
r = toku_brt_cursor(brt, &cursor);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, position, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, position, null_txn);
|
||||||
assert(r == DB_NOTFOUND);
|
assert(r == DB_NOTFOUND);
|
||||||
|
|
||||||
|
@ -849,8 +849,8 @@ void assert_cursor_value(BRT brt, int position, long long value) {
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
if (test_cursor_debug) printf("key: ");
|
if (test_cursor_debug) printf("key: ");
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, position, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, position, null_txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
if (test_cursor_debug) printf("%s ", (char*)kbt.data);
|
if (test_cursor_debug) printf("%s ", (char*)kbt.data);
|
||||||
|
@ -875,8 +875,8 @@ void assert_cursor_first_last(BRT brt, long long firstv, long long lastv) {
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
if (test_cursor_debug) printf("first key: ");
|
if (test_cursor_debug) printf("first key: ");
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_FIRST, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_FIRST, null_txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
if (test_cursor_debug) printf("%s ", (char*)kbt.data);
|
if (test_cursor_debug) printf("%s ", (char*)kbt.data);
|
||||||
|
@ -888,8 +888,8 @@ void assert_cursor_first_last(BRT brt, long long firstv, long long lastv) {
|
||||||
if (test_cursor_debug) printf("\n");
|
if (test_cursor_debug) printf("\n");
|
||||||
|
|
||||||
if (test_cursor_debug) printf("last key:");
|
if (test_cursor_debug) printf("last key:");
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, null_txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
if (test_cursor_debug)printf("%s ", (char*)kbt.data);
|
if (test_cursor_debug)printf("%s ", (char*)kbt.data);
|
||||||
|
@ -927,9 +927,9 @@ void test_brt_cursor_first(int n, DB *db) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", i);
|
snprintf(key, sizeof key, "%4.4d", i);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
@ -969,9 +969,9 @@ void test_brt_cursor_last(int n, DB *db) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", i);
|
snprintf(key, sizeof key, "%4.4d", i);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
@ -1011,9 +1011,9 @@ void test_brt_cursor_first_last(int n, DB *db) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", i);
|
snprintf(key, sizeof key, "%4.4d", i);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
|
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
@ -1058,9 +1058,9 @@ void test_brt_cursor_rfirst(int n, DB *db) {
|
||||||
|
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", i);
|
snprintf(key, sizeof key, "%4.4d", i);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
@ -1090,8 +1090,8 @@ void assert_cursor_walk(BRT brt, int n) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
long long v;
|
long long v;
|
||||||
|
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
break;
|
break;
|
||||||
|
@ -1132,9 +1132,9 @@ void test_brt_cursor_walk(int n, DB *db) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", i);
|
snprintf(key, sizeof key, "%4.4d", i);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
@ -1163,8 +1163,8 @@ void assert_cursor_rwalk(BRT brt, int n) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
long long v;
|
long long v;
|
||||||
|
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_PREV, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_PREV, null_txn);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
break;
|
break;
|
||||||
|
@ -1205,9 +1205,9 @@ void test_brt_cursor_rwalk(int n, DB *db) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
|
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&kbt, &k, sizeof k);
|
toku_fill_dbt(&kbt, &k, sizeof k);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
@ -1238,8 +1238,8 @@ void assert_cursor_walk_inorder(BRT brt, int n) {
|
||||||
DBT kbt, vbt;
|
DBT kbt, vbt;
|
||||||
long long v;
|
long long v;
|
||||||
|
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
break;
|
break;
|
||||||
|
@ -1286,9 +1286,9 @@ void test_brt_cursor_rand(int n, DB *db) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
v = ((long long) random() << 32) + random();
|
v = ((long long) random() << 32) + random();
|
||||||
snprintf(key, sizeof key, "%lld", v);
|
snprintf(key, sizeof key, "%lld", v);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_lookup(brt, &kbt, &vbt);
|
r = toku_brt_lookup(brt, &kbt, &vbt);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
printf("dup");
|
printf("dup");
|
||||||
|
@ -1336,9 +1336,9 @@ void test_brt_cursor_split(int n, DB *db) {
|
||||||
char key[8]; long long v;
|
char key[8]; long long v;
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", keyseqnum);
|
snprintf(key, sizeof key, "%4.4d", keyseqnum);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = keyseqnum;
|
v = keyseqnum;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
@ -1348,8 +1348,8 @@ void test_brt_cursor_split(int n, DB *db) {
|
||||||
|
|
||||||
if (test_cursor_debug) printf("key: ");
|
if (test_cursor_debug) printf("key: ");
|
||||||
for (i=0; i<n/2; i++) {
|
for (i=0; i<n/2; i++) {
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
if (test_cursor_debug) printf("%s ", (char*)kbt.data);
|
if (test_cursor_debug) printf("%s ", (char*)kbt.data);
|
||||||
|
@ -1362,17 +1362,17 @@ void test_brt_cursor_split(int n, DB *db) {
|
||||||
char key[8]; long long v;
|
char key[8]; long long v;
|
||||||
|
|
||||||
snprintf(key, sizeof key, "%4.4d", keyseqnum);
|
snprintf(key, sizeof key, "%4.4d", keyseqnum);
|
||||||
fill_dbt(&kbt, key, strlen(key)+1);
|
toku_fill_dbt(&kbt, key, strlen(key)+1);
|
||||||
v = keyseqnum;
|
v = keyseqnum;
|
||||||
fill_dbt(&vbt, &v, sizeof v);
|
toku_fill_dbt(&vbt, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
r = toku_brt_insert(brt, &kbt, &vbt, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_cursor_debug) printf("key: ");
|
if (test_cursor_debug) printf("key: ");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_txn);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
break;
|
break;
|
||||||
|
@ -1474,16 +1474,16 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &key, &val, 0);
|
r = toku_brt_insert(brt, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
/* point cursor i / cursor_gap to the current last key i */
|
/* point cursor i / cursor_gap to the current last key i */
|
||||||
if ((i % cursor_gap) == 0) {
|
if ((i % cursor_gap) == 0) {
|
||||||
c = i / cursor_gap;
|
c = i / cursor_gap;
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursors[c], &key, &val, DB_LAST, null_txn);
|
r = toku_brt_cursor_get(cursors[c], &key, &val, DB_LAST, null_txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
toku_free(key.data);
|
toku_free(key.data);
|
||||||
|
@ -1494,8 +1494,8 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
|
||||||
/* walk the cursors by cursor_gap */
|
/* walk the cursors by cursor_gap */
|
||||||
for (i=0; i<cursor_gap; i++) {
|
for (i=0; i<cursor_gap; i++) {
|
||||||
for (c=0; c<ncursors; c++) {
|
for (c=0; c<ncursors; c++) {
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursors[c], &key, &val, DB_NEXT, null_txn);
|
r = toku_brt_cursor_get(cursors[c], &key, &val, DB_NEXT, null_txn);
|
||||||
if (r == DB_NOTFOUND) {
|
if (r == DB_NOTFOUND) {
|
||||||
/* we already consumed 1 previously */
|
/* we already consumed 1 previously */
|
||||||
|
@ -1549,8 +1549,8 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(10*i);
|
k = htonl(10*i);
|
||||||
v = 10*i;
|
v = 10*i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &key, &val, 0);
|
r = toku_brt_insert(brt, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
@ -1564,8 +1564,8 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
|
||||||
|
|
||||||
v = 10*(random() % n);
|
v = 10*(random() % n);
|
||||||
k = htonl(v);
|
k = htonl(v);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &key, &val, cursor_op, null_txn);
|
r = toku_brt_cursor_get(cursor, &key, &val, cursor_op, null_txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
assert(val.size == sizeof vv);
|
assert(val.size == sizeof vv);
|
||||||
|
@ -1580,8 +1580,8 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
continue;
|
continue;
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET, null_txn);
|
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET, null_txn);
|
||||||
assert(r == DB_NOTFOUND);
|
assert(r == DB_NOTFOUND);
|
||||||
assert(key.data == &k);
|
assert(key.data == &k);
|
||||||
|
@ -1623,8 +1623,8 @@ void test_brt_cursor_set_range(int n, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(10*i);
|
k = htonl(10*i);
|
||||||
v = 10*i;
|
v = 10*i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(brt, &key, &val, 0);
|
r = toku_brt_insert(brt, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
@ -1639,8 +1639,8 @@ void test_brt_cursor_set_range(int n, DB *db) {
|
||||||
|
|
||||||
v = random() % (10*n);
|
v = random() % (10*n);
|
||||||
k = htonl(v);
|
k = htonl(v);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET_RANGE, null_txn);
|
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET_RANGE, null_txn);
|
||||||
if (v > max_key)
|
if (v > max_key)
|
||||||
/* there is no smallest key if v > the max key */
|
/* there is no smallest key if v > the max key */
|
||||||
|
@ -1692,16 +1692,16 @@ void test_brt_cursor_delete(int n, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_insert(brt, &key, &val, 0);
|
error = toku_brt_insert(brt, &key, &val, 0);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* walk the tree and delete under the cursor */
|
/* walk the tree and delete under the cursor */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_NEXT, null_txn);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_NEXT, null_txn);
|
||||||
if (error == DB_NOTFOUND)
|
if (error == DB_NOTFOUND)
|
||||||
break;
|
break;
|
||||||
|
@ -1752,8 +1752,8 @@ void test_brt_cursor_get_both(int n, DB *db) {
|
||||||
/* verify get_both on an empty tree fails */
|
/* verify get_both on an empty tree fails */
|
||||||
k = htonl(n+1);
|
k = htonl(n+1);
|
||||||
v = n+1;
|
v = n+1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
|
|
||||||
|
@ -1762,8 +1762,8 @@ void test_brt_cursor_get_both(int n, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_insert(brt, &key, &val, 0);
|
error = toku_brt_insert(brt, &key, &val, 0);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
}
|
}
|
||||||
|
@ -1771,8 +1771,8 @@ void test_brt_cursor_get_both(int n, DB *db) {
|
||||||
/* verify that keys not in the tree fail */
|
/* verify that keys not in the tree fail */
|
||||||
k = htonl(n+1);
|
k = htonl(n+1);
|
||||||
v = n-1;
|
v = n-1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
|
|
||||||
|
@ -1780,8 +1780,8 @@ void test_brt_cursor_get_both(int n, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i+1;
|
v = i+1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
@ -1790,13 +1790,13 @@ void test_brt_cursor_get_both(int n, DB *db) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
#ifdef DB_CURRENT
|
#ifdef DB_CURRENT
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, 0);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, 0);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
int vv;
|
int vv;
|
||||||
|
@ -1811,8 +1811,8 @@ void test_brt_cursor_get_both(int n, DB *db) {
|
||||||
|
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
error = toku_brt_cursor_get(cursor, &key, &val, DB_GET_BOTH, null_txn);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
@ -1897,8 +1897,8 @@ void test_large_kv(int bsize, int ksize, int vsize) {
|
||||||
char *k, *v;
|
char *k, *v;
|
||||||
k = toku_malloc(ksize); assert(k); memset(k, 0, ksize);
|
k = toku_malloc(ksize); assert(k); memset(k, 0, ksize);
|
||||||
v = toku_malloc(vsize); assert(v); memset(v, 0, vsize);
|
v = toku_malloc(vsize); assert(v); memset(v, 0, vsize);
|
||||||
fill_dbt(&key, k, ksize);
|
toku_fill_dbt(&key, k, ksize);
|
||||||
fill_dbt(&val, v, vsize);
|
toku_fill_dbt(&val, v, vsize);
|
||||||
|
|
||||||
r = toku_brt_insert(t, &key, &val, 0);
|
r = toku_brt_insert(t, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
@ -1942,7 +1942,7 @@ void test_brt_delete_empty() {
|
||||||
|
|
||||||
DBT key;
|
DBT key;
|
||||||
int k = htonl(1);
|
int k = htonl(1);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_brt_delete(t, &key);
|
r = toku_brt_delete(t, &key);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
|
@ -1975,8 +1975,8 @@ void test_brt_delete_present(int n) {
|
||||||
/* insert 0 .. n-1 */
|
/* insert 0 .. n-1 */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i); v = i;
|
k = htonl(i); v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(t, &key, &val, 0);
|
r = toku_brt_insert(t, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
@ -1984,7 +1984,7 @@ void test_brt_delete_present(int n) {
|
||||||
/* delete 0 .. n-1 */
|
/* delete 0 .. n-1 */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_brt_delete(t, &key);
|
r = toku_brt_delete(t, &key);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
@ -1992,8 +1992,8 @@ void test_brt_delete_present(int n) {
|
||||||
/* lookups should all fail */
|
/* lookups should all fail */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_lookup(t, &key, &val);
|
r = toku_brt_lookup(t, &key, &val);
|
||||||
assert(r == DB_NOTFOUND);
|
assert(r == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
@ -2004,8 +2004,8 @@ void test_brt_delete_present(int n) {
|
||||||
r = toku_brt_cursor(t, &cursor);
|
r = toku_brt_cursor(t, &cursor);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &key, &val, DB_FIRST, null_txn);
|
r = toku_brt_cursor_get(cursor, &key, &val, DB_FIRST, null_txn);
|
||||||
assert(r != 0);
|
assert(r != 0);
|
||||||
|
|
||||||
|
@ -2037,8 +2037,8 @@ void test_brt_delete_not_present(int n) {
|
||||||
/* insert 0 .. n-1 */
|
/* insert 0 .. n-1 */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i); v = i;
|
k = htonl(i); v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(t, &key, &val, 0);
|
r = toku_brt_insert(t, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
@ -2046,14 +2046,14 @@ void test_brt_delete_not_present(int n) {
|
||||||
/* delete 0 .. n-1 */
|
/* delete 0 .. n-1 */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_brt_delete(t, &key);
|
r = toku_brt_delete(t, &key);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to delete key n+1 not in the tree */
|
/* try to delete key n+1 not in the tree */
|
||||||
k = htonl(n+1);
|
k = htonl(n+1);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_brt_delete(t, &key);
|
r = toku_brt_delete(t, &key);
|
||||||
/* the delete may be buffered or may be executed on a leaf node, so the
|
/* the delete may be buffered or may be executed on a leaf node, so the
|
||||||
return value depends */
|
return value depends */
|
||||||
|
@ -2084,8 +2084,8 @@ void test_brt_delete_cursor_first(int n) {
|
||||||
/* insert 0 .. n-1 */
|
/* insert 0 .. n-1 */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i); v = i;
|
k = htonl(i); v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(t, &key, &val, 0);
|
r = toku_brt_insert(t, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
@ -2093,8 +2093,8 @@ void test_brt_delete_cursor_first(int n) {
|
||||||
/* lookups 0 .. n-1 should succeed */
|
/* lookups 0 .. n-1 should succeed */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_lookup(t, &key, &val);
|
r = toku_brt_lookup(t, &key, &val);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
assert(val.size == sizeof (int));
|
assert(val.size == sizeof (int));
|
||||||
|
@ -2107,11 +2107,11 @@ void test_brt_delete_cursor_first(int n) {
|
||||||
/* delete 0 .. n-2 */
|
/* delete 0 .. n-2 */
|
||||||
for (i=0; i<n-1; i++) {
|
for (i=0; i<n-1; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_brt_delete(t, &key);
|
r = toku_brt_delete(t, &key);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_lookup(t, &key, &val);
|
r = toku_brt_lookup(t, &key, &val);
|
||||||
assert(r == DB_NOTFOUND);
|
assert(r == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
@ -2119,8 +2119,8 @@ void test_brt_delete_cursor_first(int n) {
|
||||||
/* lookup of 0 .. n-2 should all fail */
|
/* lookup of 0 .. n-2 should all fail */
|
||||||
for (i=0; i<n-1; i++) {
|
for (i=0; i<n-1; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_lookup(t, &key, &val);
|
r = toku_brt_lookup(t, &key, &val);
|
||||||
assert(r == DB_NOTFOUND);
|
assert(r == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
@ -2131,8 +2131,8 @@ void test_brt_delete_cursor_first(int n) {
|
||||||
r = toku_brt_cursor(t, &cursor);
|
r = toku_brt_cursor(t, &cursor);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_cursor_get(cursor, &key, &val, DB_FIRST, null_txn);
|
r = toku_brt_cursor_get(cursor, &key, &val, DB_FIRST, null_txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
int vv;
|
int vv;
|
||||||
|
@ -2176,21 +2176,21 @@ void test_insert_delete_lookup(int n) {
|
||||||
/* insert 0 .. n-1 */
|
/* insert 0 .. n-1 */
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i); v = i;
|
k = htonl(i); v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_brt_insert(t, &key, &val, 0);
|
r = toku_brt_insert(t, &key, &val, 0);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
k = htonl(n-1);
|
k = htonl(n-1);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_brt_delete(t, &key);
|
r = toku_brt_delete(t, &key);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
k = htonl(n-1);
|
k = htonl(n-1);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_brt_lookup(t, &key, &val);
|
r = toku_brt_lookup(t, &key, &val);
|
||||||
assert(r == DB_NOTFOUND);
|
assert(r == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
|
30
newbrt/brt.c
30
newbrt/brt.c
|
@ -129,12 +129,12 @@ static int brt_compare_pivot(BRT brt, DBT *key, DBT *data, bytevec ck, unsigned
|
||||||
struct kv_pair *kv = (struct kv_pair *) ck;
|
struct kv_pair *kv = (struct kv_pair *) ck;
|
||||||
if (brt->flags & TOKU_DB_DUPSORT) {
|
if (brt->flags & TOKU_DB_DUPSORT) {
|
||||||
assert(kv_pair_keylen(kv) + kv_pair_vallen(kv) == cl);
|
assert(kv_pair_keylen(kv) + kv_pair_vallen(kv) == cl);
|
||||||
cmp = brt->compare_fun(brt->db, key, fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv)));
|
cmp = brt->compare_fun(brt->db, key, toku_fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv)));
|
||||||
if (cmp == 0 && data != 0)
|
if (cmp == 0 && data != 0)
|
||||||
cmp = brt->dup_compare(brt->db, data, fill_dbt(&mydbt, kv_pair_val(kv), kv_pair_vallen(kv)));
|
cmp = brt->dup_compare(brt->db, data, toku_fill_dbt(&mydbt, kv_pair_val(kv), kv_pair_vallen(kv)));
|
||||||
} else {
|
} else {
|
||||||
assert(kv_pair_keylen(kv) == cl);
|
assert(kv_pair_keylen(kv) == cl);
|
||||||
cmp = brt->compare_fun(brt->db, key, fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv)));
|
cmp = brt->compare_fun(brt->db, key, toku_fill_dbt(&mydbt, kv_pair_key(kv), kv_pair_keylen(kv)));
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ static int push_brt_cmd_down_only_if_it_wont_push_more_else_put_here (BRT t, BRT
|
||||||
if (childnum_of_node+1<node->u.n.n_children) {
|
if (childnum_of_node+1<node->u.n.n_children) {
|
||||||
DBT k2;
|
DBT k2;
|
||||||
printf(" nextsplitkey=%s\n", (char*)node->u.n.childkeys[childnum_of_node]);
|
printf(" nextsplitkey=%s\n", (char*)node->u.n.childkeys[childnum_of_node]);
|
||||||
assert(t->compare_fun(t->db, k, fill_dbt(&k2, node->u.n.childkeys[childnum_of_node], node->u.n.childkeylens[childnum_of_node]))<=0);
|
assert(t->compare_fun(t->db, k, toku_fill_dbt(&k2, node->u.n.childkeys[childnum_of_node], node->u.n.childkeylens[childnum_of_node]))<=0);
|
||||||
} else {
|
} else {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ static int push_brt_cmd_down_only_if_it_wont_push_more_else_put_here (BRT t, BRT
|
||||||
if (to_child) {
|
if (to_child) {
|
||||||
int again_split=-1; BRTNODE againa,againb;
|
int again_split=-1; BRTNODE againa,againb;
|
||||||
DBT againk;
|
DBT againk;
|
||||||
init_dbt(&againk);
|
toku_init_dbt(&againk);
|
||||||
//printf("%s:%d hello!\n", __FILE__, __LINE__);
|
//printf("%s:%d hello!\n", __FILE__, __LINE__);
|
||||||
r = brtnode_put_cmd(t, child, cmd,
|
r = brtnode_put_cmd(t, child, cmd,
|
||||||
&again_split, &againa, &againb, &againk,
|
&again_split, &againa, &againb, &againk,
|
||||||
|
@ -716,8 +716,8 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum,
|
||||||
/* Keep pushing to the children, but not if the children would require a pushdown */
|
/* Keep pushing to the children, but not if the children would require a pushdown */
|
||||||
HASHTABLE_ITERATE(old_h, skey, skeylen, sval, svallen, type, ({
|
HASHTABLE_ITERATE(old_h, skey, skeylen, sval, svallen, type, ({
|
||||||
DBT skd, svd;
|
DBT skd, svd;
|
||||||
fill_dbt(&skd, skey, skeylen);
|
toku_fill_dbt(&skd, skey, skeylen);
|
||||||
fill_dbt(&svd, sval, svallen);
|
toku_fill_dbt(&svd, sval, svallen);
|
||||||
BRT_CMD brtcmd;
|
BRT_CMD brtcmd;
|
||||||
brtcmd.type = type; brtcmd.u.id.key = &skd; brtcmd.u.id.val = &svd;
|
brtcmd.type = type; brtcmd.u.id.key = &skd; brtcmd.u.id.val = &svd;
|
||||||
//verify_local_fingerprint_nonleaf(childa); verify_local_fingerprint_nonleaf(childb);
|
//verify_local_fingerprint_nonleaf(childa); verify_local_fingerprint_nonleaf(childb);
|
||||||
|
@ -820,14 +820,14 @@ static int push_some_brt_cmds_down (BRT t, BRTNODE node, int childnum,
|
||||||
DBT childsplitk;
|
DBT childsplitk;
|
||||||
BRT_CMD brtcmd;
|
BRT_CMD brtcmd;
|
||||||
|
|
||||||
fill_dbt(&hk, key, keylen);
|
toku_fill_dbt(&hk, key, keylen);
|
||||||
fill_dbt(&hv, val, vallen);
|
toku_fill_dbt(&hv, val, vallen);
|
||||||
brtcmd.type = type;
|
brtcmd.type = type;
|
||||||
brtcmd.u.id.key = &hk;
|
brtcmd.u.id.key = &hk;
|
||||||
brtcmd.u.id.val = &hv;
|
brtcmd.u.id.val = &hv;
|
||||||
|
|
||||||
//printf("%s:%d random_picked\n", __FILE__, __LINE__);
|
//printf("%s:%d random_picked\n", __FILE__, __LINE__);
|
||||||
init_dbt(&childsplitk);
|
toku_init_dbt(&childsplitk);
|
||||||
if (debug) printf("%s:%d %*spush down %s\n", __FILE__, __LINE__, debug, "", (char*)key);
|
if (debug) printf("%s:%d %*spush down %s\n", __FILE__, __LINE__, debug, "", (char*)key);
|
||||||
r = push_a_brt_cmd_down (t, node, child, childnum,
|
r = push_a_brt_cmd_down (t, node, child, childnum,
|
||||||
&brtcmd,
|
&brtcmd,
|
||||||
|
@ -1882,19 +1882,19 @@ static int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, BRTNODE parent
|
||||||
if ((brt->flags & TOKU_DB_DUP)) {
|
if ((brt->flags & TOKU_DB_DUP)) {
|
||||||
result = brt_lookup_node(brt, node->u.n.children[childnum], k, v, node);
|
result = brt_lookup_node(brt, node->u.n.children[childnum], k, v, node);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
ybt_set_value(v, hanswer, hanswerlen, &brt->sval);
|
toku_dbt_set_value(v, hanswer, hanswerlen, &brt->sval);
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//printf("Found %d bytes\n", *vallen);
|
//printf("Found %d bytes\n", *vallen);
|
||||||
ybt_set_value(v, hanswer, hanswerlen, &brt->sval);
|
toku_dbt_set_value(v, hanswer, hanswerlen, &brt->sval);
|
||||||
//printf("%s:%d Returning %p\n", __FILE__, __LINE__, v->data);
|
//printf("%s:%d Returning %p\n", __FILE__, __LINE__, v->data);
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
} else if (type == BRT_DELETE) {
|
} else if (type == BRT_DELETE) {
|
||||||
if ((brt->flags & TOKU_DB_DUP) && toku_hash_find_idx (node->u.n.htables[childnum], k->data, k->size, 1, &hanswer, &hanswerlen, &type) == 0) {
|
if ((brt->flags & TOKU_DB_DUP) && toku_hash_find_idx (node->u.n.htables[childnum], k->data, k->size, 1, &hanswer, &hanswerlen, &type) == 0) {
|
||||||
assert(type == BRT_INSERT);
|
assert(type == BRT_INSERT);
|
||||||
ybt_set_value(v, hanswer, hanswerlen, &brt->sval);
|
toku_dbt_set_value(v, hanswer, hanswerlen, &brt->sval);
|
||||||
result = 0;
|
result = 0;
|
||||||
} else
|
} else
|
||||||
result = DB_NOTFOUND;
|
result = DB_NOTFOUND;
|
||||||
|
@ -1943,7 +1943,7 @@ int toku_brt_delete(BRT brt, DBT *key) {
|
||||||
BRT_CMD brtcmd;
|
BRT_CMD brtcmd;
|
||||||
DBT val;
|
DBT val;
|
||||||
|
|
||||||
init_dbt(&val);
|
toku_init_dbt(&val);
|
||||||
val.size = 0;
|
val.size = 0;
|
||||||
brtcmd.type = BRT_DELETE;
|
brtcmd.type = BRT_DELETE;
|
||||||
brtcmd.u.id.key = key;
|
brtcmd.u.id.key = key;
|
||||||
|
@ -2080,7 +2080,7 @@ static void brt_flush_child(BRT t, BRTNODE node, int childnum, BRT_CURSOR cursor
|
||||||
toku_brt_cursor_print(cursor);
|
toku_brt_cursor_print(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
init_dbt(&child_splitk);
|
toku_init_dbt(&child_splitk);
|
||||||
r = push_some_brt_cmds_down(t, node, childnum,
|
r = push_some_brt_cmds_down(t, node, childnum,
|
||||||
&child_did_split, &childa, &childb, &child_splitk, brt_flush_debug, txn);
|
&child_did_split, &childa, &childb, &child_splitk, brt_flush_debug, txn);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
|
@ -100,29 +100,29 @@ static void test_pma_find (void) {
|
||||||
for (i=0; i<N; i++) pma->pairs[i]=0;
|
for (i=0; i<N; i++) pma->pairs[i]=0;
|
||||||
assert(toku_pma_index_limit(pma)==N);
|
assert(toku_pma_index_limit(pma)==N);
|
||||||
pma->compare_fun = toku_default_compare_fun;
|
pma->compare_fun = toku_default_compare_fun;
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "hello", 5));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "hello", 5));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
pma->pairs[5] = kv_pair_malloc("hello", 5, 0, 0);
|
pma->pairs[5] = kv_pair_malloc("hello", 5, 0, 0);
|
||||||
assert(toku_pma_index_limit(pma)==N);
|
assert(toku_pma_index_limit(pma)==N);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "hello", 5));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "hello", 5));
|
||||||
assert(toku_pma_index_limit(pma)==N);
|
assert(toku_pma_index_limit(pma)==N);
|
||||||
assert(r==5);
|
assert(r==5);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "there", 5));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "there", 5));
|
||||||
assert(r==6);
|
assert(r==6);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "aaa", 3));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "aaa", 3));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
||||||
pma->pairs[N-1] = kv_pair_malloc("there", 5, 0, 0);
|
pma->pairs[N-1] = kv_pair_malloc("there", 5, 0, 0);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "hello", 5));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "hello", 5));
|
||||||
assert(r==5);
|
assert(r==5);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "there", 5));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "there", 5));
|
||||||
assert(r==N-1);
|
assert(r==N-1);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "aaa", 3));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "aaa", 3));
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "hellob", 6));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "hellob", 6));
|
||||||
assert(r==6);
|
assert(r==6);
|
||||||
r=toku_pmainternal_find(pma, fill_dbt(&k, "zzz", 3));
|
r=toku_pmainternal_find(pma, toku_fill_dbt(&k, "zzz", 3));
|
||||||
assert(r==N);
|
assert(r==N);
|
||||||
|
|
||||||
for (i=0; i<N; i++)
|
for (i=0; i<N; i++)
|
||||||
|
@ -265,7 +265,7 @@ void add_fingerprint_and_check(u_int32_t rand4fingerprint, u_int32_t actual_fing
|
||||||
static void do_insert (PMA pma, const void *key, int keylen, const void *data, int datalen, u_int32_t rand4fingerprint, u_int32_t *sum, u_int32_t *expect_fingerprint) {
|
static void do_insert (PMA pma, const void *key, int keylen, const void *data, int datalen, u_int32_t rand4fingerprint, u_int32_t *sum, u_int32_t *expect_fingerprint) {
|
||||||
DBT k,v;
|
DBT k,v;
|
||||||
assert(*sum==*expect_fingerprint);
|
assert(*sum==*expect_fingerprint);
|
||||||
int r = toku_pma_insert(pma, fill_dbt(&k, key, keylen), fill_dbt(&v, data, datalen), NULL_ARGS, rand4fingerprint, sum);
|
int r = toku_pma_insert(pma, toku_fill_dbt(&k, key, keylen), toku_fill_dbt(&v, data, datalen), NULL_ARGS, rand4fingerprint, sum);
|
||||||
assert(r==BRT_OK);
|
assert(r==BRT_OK);
|
||||||
add_fingerprint_and_check(rand4fingerprint, *sum, expect_fingerprint, key, keylen, data, datalen);
|
add_fingerprint_and_check(rand4fingerprint, *sum, expect_fingerprint, key, keylen, data, datalen);
|
||||||
toku_pma_verify_fingerprint(pma, rand4fingerprint, *sum);
|
toku_pma_verify_fingerprint(pma, rand4fingerprint, *sum);
|
||||||
|
@ -274,7 +274,7 @@ static void do_insert (PMA pma, const void *key, int keylen, const void *data, i
|
||||||
static void do_delete (PMA pma, const void *key, int keylen, const void *data, int datalen, u_int32_t rand4fingerprint, u_int32_t *sum, u_int32_t *expect_fingerprint) {
|
static void do_delete (PMA pma, const void *key, int keylen, const void *data, int datalen, u_int32_t rand4fingerprint, u_int32_t *sum, u_int32_t *expect_fingerprint) {
|
||||||
DBT k;
|
DBT k;
|
||||||
assert(*sum==*expect_fingerprint);
|
assert(*sum==*expect_fingerprint);
|
||||||
int r = toku_pma_delete(pma, fill_dbt(&k, key, keylen), rand4fingerprint, sum, 0);
|
int r = toku_pma_delete(pma, toku_fill_dbt(&k, key, keylen), rand4fingerprint, sum, 0);
|
||||||
assert(r==BRT_OK);
|
assert(r==BRT_OK);
|
||||||
add_fingerprint_and_check(-rand4fingerprint, *sum, expect_fingerprint, key, keylen, data, datalen); // negative rand4 means subtract.
|
add_fingerprint_and_check(-rand4fingerprint, *sum, expect_fingerprint, key, keylen, data, datalen); // negative rand4 means subtract.
|
||||||
toku_pma_verify_fingerprint(pma, rand4fingerprint, *sum);
|
toku_pma_verify_fingerprint(pma, rand4fingerprint, *sum);
|
||||||
|
@ -301,7 +301,7 @@ static void test_pma_random_pick (void) {
|
||||||
assert(keylen==6); assert(vallen==6);
|
assert(keylen==6); assert(vallen==6);
|
||||||
assert(strcmp(key,"hello")==0);
|
assert(strcmp(key,"hello")==0);
|
||||||
assert(strcmp(val,"there")==0);
|
assert(strcmp(val,"there")==0);
|
||||||
r = toku_pma_delete(pma, fill_dbt(&k, "nothello", 9), rand4fingerprint, &sum, 0);
|
r = toku_pma_delete(pma, toku_fill_dbt(&k, "nothello", 9), rand4fingerprint, &sum, 0);
|
||||||
assert(r==DB_NOTFOUND);
|
assert(r==DB_NOTFOUND);
|
||||||
assert(sum==expect_fingerprint); // didn't change because nothing was deleted.
|
assert(sum==expect_fingerprint); // didn't change because nothing was deleted.
|
||||||
|
|
||||||
|
@ -356,13 +356,13 @@ static void test_find_insert (void) {
|
||||||
|
|
||||||
|
|
||||||
toku_pma_create(&pma, toku_default_compare_fun, null_db, null_filenum, 0);
|
toku_pma_create(&pma, toku_default_compare_fun, null_db, null_filenum, 0);
|
||||||
r=toku_pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v);
|
r=toku_pma_lookup(pma, toku_fill_dbt(&k, "aaa", 3), &v);
|
||||||
assert(r==DB_NOTFOUND);
|
assert(r==DB_NOTFOUND);
|
||||||
|
|
||||||
do_insert(pma, "aaa", 3, "aaadata", 7, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "aaa", 3, "aaadata", 7, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
|
|
||||||
init_dbt(&v);
|
toku_init_dbt(&v);
|
||||||
r=toku_pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v);
|
r=toku_pma_lookup(pma, toku_fill_dbt(&k, "aaa", 3), &v);
|
||||||
assert(r==BRT_OK);
|
assert(r==BRT_OK);
|
||||||
assert(v.size==7);
|
assert(v.size==7);
|
||||||
assert(toku_keycompare(v.data,v.size,"aaadata", 7)==0);
|
assert(toku_keycompare(v.data,v.size,"aaadata", 7)==0);
|
||||||
|
@ -370,13 +370,13 @@ static void test_find_insert (void) {
|
||||||
|
|
||||||
do_insert(pma, "bbb", 4, "bbbdata", 8, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "bbb", 4, "bbbdata", 8, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
|
|
||||||
init_dbt(&v);
|
toku_init_dbt(&v);
|
||||||
r=toku_pma_lookup(pma, fill_dbt(&k, "aaa", 3), &v);
|
r=toku_pma_lookup(pma, toku_fill_dbt(&k, "aaa", 3), &v);
|
||||||
assert(r==BRT_OK);
|
assert(r==BRT_OK);
|
||||||
assert(toku_keycompare(v.data,v.size,"aaadata", 7)==0);
|
assert(toku_keycompare(v.data,v.size,"aaadata", 7)==0);
|
||||||
|
|
||||||
init_dbt(&v);
|
toku_init_dbt(&v);
|
||||||
r=toku_pma_lookup(pma, fill_dbt(&k, "bbb", 4), &v);
|
r=toku_pma_lookup(pma, toku_fill_dbt(&k, "bbb", 4), &v);
|
||||||
assert(r==BRT_OK);
|
assert(r==BRT_OK);
|
||||||
assert(toku_keycompare(v.data,v.size,"bbbdata", 8)==0);
|
assert(toku_keycompare(v.data,v.size,"bbbdata", 8)==0);
|
||||||
|
|
||||||
|
@ -518,8 +518,8 @@ void test_pma_cursor_2 (void) {
|
||||||
PMA_CURSOR c=0;
|
PMA_CURSOR c=0;
|
||||||
int r;
|
int r;
|
||||||
DBT key,val;
|
DBT key,val;
|
||||||
init_dbt(&key); key.flags=DB_DBT_REALLOC;
|
toku_init_dbt(&key); key.flags=DB_DBT_REALLOC;
|
||||||
init_dbt(&val); val.flags=DB_DBT_REALLOC;
|
toku_init_dbt(&val); val.flags=DB_DBT_REALLOC;
|
||||||
r=toku_pma_create(&pma, toku_default_compare_fun, null_db, null_filenum, 0); assert(r==0);
|
r=toku_pma_create(&pma, toku_default_compare_fun, null_db, null_filenum, 0); assert(r==0);
|
||||||
r=toku_pma_cursor(pma, &c); assert(r==0); assert(c!=0);
|
r=toku_pma_cursor(pma, &c); assert(r==0); assert(c!=0);
|
||||||
r=toku_pma_cursor_set_position_last(c); assert(r==DB_NOTFOUND);
|
r=toku_pma_cursor_set_position_last(c); assert(r==DB_NOTFOUND);
|
||||||
|
@ -541,8 +541,8 @@ void test_pma_cursor_3 (void) {
|
||||||
do_insert(pma, "x", 2, "xx", 3, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "x", 2, "xx", 3, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
do_insert(pma, "m", 2, "mm", 3, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "m", 2, "mm", 3, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
do_insert(pma, "aa", 3, "a", 2, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "aa", 3, "a", 2, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
init_dbt(&key); key.flags=DB_DBT_REALLOC;
|
toku_init_dbt(&key); key.flags=DB_DBT_REALLOC;
|
||||||
init_dbt(&val); val.flags=DB_DBT_REALLOC;
|
toku_init_dbt(&val); val.flags=DB_DBT_REALLOC;
|
||||||
r=toku_pma_cursor(pma, &c); assert(r==0); assert(c!=0);
|
r=toku_pma_cursor(pma, &c); assert(r==0); assert(c!=0);
|
||||||
|
|
||||||
r=toku_pma_cursor_set_position_first(c); assert(r==0);
|
r=toku_pma_cursor_set_position_first(c); assert(r==0);
|
||||||
|
@ -582,8 +582,8 @@ void assert_cursor_val(PMA_CURSOR cursor, int v) {
|
||||||
DBT key, val;
|
DBT key, val;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
assert( v == *(int *)val.data);
|
assert( v == *(int *)val.data);
|
||||||
|
@ -689,8 +689,8 @@ void test_pma_cursor_delete(int n) {
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
|
|
||||||
DBT cursorkey, cursorval;
|
DBT cursorkey, cursorval;
|
||||||
init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
||||||
assert(error != 0);
|
assert(error != 0);
|
||||||
|
|
||||||
|
@ -698,8 +698,8 @@ void test_pma_cursor_delete(int n) {
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
|
|
||||||
int kk;
|
int kk;
|
||||||
init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
assert(cursorkey.size == sizeof kk);
|
assert(cursorkey.size == sizeof kk);
|
||||||
|
@ -713,8 +713,8 @@ void test_pma_cursor_delete(int n) {
|
||||||
do_delete(pma, &k, sizeof k, &k, sizeof k, rand4fingerprint, &sum, &expect_fingerprint);
|
do_delete(pma, &k, sizeof k, &k, sizeof k, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
|
|
||||||
/* cursor get should fail */
|
/* cursor get should fail */
|
||||||
init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
||||||
assert(error != 0);
|
assert(error != 0);
|
||||||
|
|
||||||
|
@ -723,8 +723,8 @@ void test_pma_cursor_delete(int n) {
|
||||||
assert(error != 0);
|
assert(error != 0);
|
||||||
else {
|
else {
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorkey); cursorkey.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&cursorval); cursorval.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
error = toku_pma_cursor_get_current(cursor, &cursorkey, &cursorval);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
assert(cursorkey.size == sizeof kk);
|
assert(cursorkey.size == sizeof kk);
|
||||||
|
@ -787,8 +787,8 @@ void test_pma_compare_fun (int wrong_endian_p) {
|
||||||
do_insert(pma, "00", 3, "00v", 4, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "00", 3, "00v", 4, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
do_insert(pma, "01", 3, "01v", 4, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "01", 3, "01v", 4, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
do_insert(pma, "11", 3, "11v", 4, rand4fingerprint, &sum, &expect_fingerprint);
|
do_insert(pma, "11", 3, "11v", 4, rand4fingerprint, &sum, &expect_fingerprint);
|
||||||
init_dbt(&key); key.flags=DB_DBT_REALLOC;
|
toku_init_dbt(&key); key.flags=DB_DBT_REALLOC;
|
||||||
init_dbt(&val); val.flags=DB_DBT_REALLOC;
|
toku_init_dbt(&val); val.flags=DB_DBT_REALLOC;
|
||||||
r=toku_pma_cursor(pma, &c); assert(r==0); assert(c!=0);
|
r=toku_pma_cursor(pma, &c); assert(r==0); assert(c!=0);
|
||||||
|
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
|
@ -1019,8 +1019,8 @@ void print_cursor(const char *str, PMA_CURSOR cursor) {
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
printf("cursor %s: ", str);
|
printf("cursor %s: ", str);
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
printf("%s ", (char*)key.data);
|
printf("%s ", (char*)key.data);
|
||||||
|
@ -1035,8 +1035,8 @@ void walk_cursor(const char *str, PMA_CURSOR cursor) {
|
||||||
|
|
||||||
printf("walk %s: ", str);
|
printf("walk %s: ", str);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
printf("%s ", (char*)key.data);
|
printf("%s ", (char*)key.data);
|
||||||
|
@ -1056,8 +1056,8 @@ void walk_cursor_reverse(const char *str, PMA_CURSOR cursor) {
|
||||||
|
|
||||||
printf("walk %s: ", str);
|
printf("walk %s: ", str);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
printf("%s ", (char*)key.data);
|
printf("%s ", (char*)key.data);
|
||||||
|
@ -1230,13 +1230,13 @@ void test_pma_bulk_insert_n(int n) {
|
||||||
k = toku_malloc(klen);
|
k = toku_malloc(klen);
|
||||||
assert(k);
|
assert(k);
|
||||||
strcpy(k, kstring);
|
strcpy(k, kstring);
|
||||||
fill_dbt(&keys[i], k, klen);
|
toku_fill_dbt(&keys[i], k, klen);
|
||||||
|
|
||||||
vlen = sizeof (int);
|
vlen = sizeof (int);
|
||||||
v = toku_malloc(vlen);
|
v = toku_malloc(vlen);
|
||||||
assert(v);
|
assert(v);
|
||||||
*v = i;
|
*v = i;
|
||||||
fill_dbt(&vals[i], v, vlen);
|
toku_fill_dbt(&vals[i], v, vlen);
|
||||||
|
|
||||||
expect_fingerprint += rand4fingerprint*toku_calccrc32_kvpair (k, klen, v, vlen);
|
expect_fingerprint += rand4fingerprint*toku_calccrc32_kvpair (k, klen, v, vlen);
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1253,7 @@ void test_pma_bulk_insert_n(int n) {
|
||||||
assert(n == toku_pma_n_entries(pma));
|
assert(n == toku_pma_n_entries(pma));
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
DBT val;
|
DBT val;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_lookup(pma, &keys[i], &val);
|
error = toku_pma_lookup(pma, &keys[i], &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
assert(vals[i].size == val.size);
|
assert(vals[i].size == val.size);
|
||||||
|
@ -1295,33 +1295,33 @@ void test_pma_insert_or_replace(void) {
|
||||||
u_int32_t expect_fingerprint = 0;
|
u_int32_t expect_fingerprint = 0;
|
||||||
r = toku_pma_create(&pma, toku_default_compare_fun, null_db, null_filenum, 0);
|
r = toku_pma_create(&pma, toku_default_compare_fun, null_db, null_filenum, 0);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
r = toku_pma_insert_or_replace(pma, fill_dbt(&dbtk, "aaa", 4), fill_dbt(&dbtv, "zzz", 4), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
|
r = toku_pma_insert_or_replace(pma, toku_fill_dbt(&dbtk, "aaa", 4), toku_fill_dbt(&dbtv, "zzz", 4), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
|
||||||
assert(r==0); assert(n_diff==-1);
|
assert(r==0); assert(n_diff==-1);
|
||||||
add_fingerprint_and_check(rand4fingerprint, sum, &expect_fingerprint, "aaa", 4, "zzz", 4);
|
add_fingerprint_and_check(rand4fingerprint, sum, &expect_fingerprint, "aaa", 4, "zzz", 4);
|
||||||
|
|
||||||
r = toku_pma_lookup(pma, fill_dbt(&dbtk, "aaa", 4), init_dbt(&dbtv));
|
r = toku_pma_lookup(pma, toku_fill_dbt(&dbtk, "aaa", 4), toku_init_dbt(&dbtv));
|
||||||
assert(r==0); assert(dbtv.size==4); assert(memcmp(dbtv.data, "zzz", 4)==0);
|
assert(r==0); assert(dbtv.size==4); assert(memcmp(dbtv.data, "zzz", 4)==0);
|
||||||
|
|
||||||
r = toku_pma_insert_or_replace(pma, fill_dbt(&dbtk, "bbbb", 5), fill_dbt(&dbtv, "ww", 3), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
|
r = toku_pma_insert_or_replace(pma, toku_fill_dbt(&dbtk, "bbbb", 5), toku_fill_dbt(&dbtv, "ww", 3), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
|
||||||
assert(r==0); assert(n_diff==-1);
|
assert(r==0); assert(n_diff==-1);
|
||||||
add_fingerprint_and_check(rand4fingerprint, sum, &expect_fingerprint, "bbbb", 5, "ww", 3);
|
add_fingerprint_and_check(rand4fingerprint, sum, &expect_fingerprint, "bbbb", 5, "ww", 3);
|
||||||
|
|
||||||
r = toku_pma_lookup(pma, fill_dbt(&dbtk, "aaa", 4), init_dbt(&dbtv));
|
r = toku_pma_lookup(pma, toku_fill_dbt(&dbtk, "aaa", 4), toku_init_dbt(&dbtv));
|
||||||
assert(r==0); assert(dbtv.size==4); assert(memcmp(dbtv.data, "zzz", 4)==0);
|
assert(r==0); assert(dbtv.size==4); assert(memcmp(dbtv.data, "zzz", 4)==0);
|
||||||
|
|
||||||
r = toku_pma_lookup(pma, fill_dbt(&dbtk, "bbbb", 5), init_dbt(&dbtv));
|
r = toku_pma_lookup(pma, toku_fill_dbt(&dbtk, "bbbb", 5), toku_init_dbt(&dbtv));
|
||||||
assert(r==0); assert(dbtv.size==3); assert(memcmp(dbtv.data, "ww", 3)==0);
|
assert(r==0); assert(dbtv.size==3); assert(memcmp(dbtv.data, "ww", 3)==0);
|
||||||
|
|
||||||
// replae bbbb
|
// replae bbbb
|
||||||
r = toku_pma_insert_or_replace(pma, fill_dbt(&dbtk, "bbbb", 5), fill_dbt(&dbtv, "xxxx", 5), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
|
r = toku_pma_insert_or_replace(pma, toku_fill_dbt(&dbtk, "bbbb", 5), toku_fill_dbt(&dbtv, "xxxx", 5), &n_diff, NULL_ARGS, rand4fingerprint, &sum);
|
||||||
assert(r==0); assert(n_diff==3);
|
assert(r==0); assert(n_diff==3);
|
||||||
expect_fingerprint -= rand4fingerprint*toku_calccrc32_kvpair("bbbb", 5, "ww", 3);
|
expect_fingerprint -= rand4fingerprint*toku_calccrc32_kvpair("bbbb", 5, "ww", 3);
|
||||||
add_fingerprint_and_check(rand4fingerprint, sum, &expect_fingerprint, "bbbb", 5, "xxxx", 5);
|
add_fingerprint_and_check(rand4fingerprint, sum, &expect_fingerprint, "bbbb", 5, "xxxx", 5);
|
||||||
|
|
||||||
r = toku_pma_lookup(pma, fill_dbt(&dbtk, "aaa", 4), init_dbt(&dbtv));
|
r = toku_pma_lookup(pma, toku_fill_dbt(&dbtk, "aaa", 4), toku_init_dbt(&dbtv));
|
||||||
assert(r==0); assert(dbtv.size==4); assert(memcmp(dbtv.data, "zzz", 4)==0);
|
assert(r==0); assert(dbtv.size==4); assert(memcmp(dbtv.data, "zzz", 4)==0);
|
||||||
|
|
||||||
r = toku_pma_lookup(pma, fill_dbt(&dbtk, "bbbb", 5), init_dbt(&dbtv));
|
r = toku_pma_lookup(pma, toku_fill_dbt(&dbtk, "bbbb", 5), toku_init_dbt(&dbtv));
|
||||||
assert(r==0); assert(dbtv.size==5); assert(memcmp(dbtv.data, "xxxx", 3)==0);
|
assert(r==0); assert(dbtv.size==5); assert(memcmp(dbtv.data, "xxxx", 3)==0);
|
||||||
|
|
||||||
r=toku_pma_free(&pma);
|
r=toku_pma_free(&pma);
|
||||||
|
@ -1420,8 +1420,8 @@ void test_pma_delete_random(int n) {
|
||||||
|
|
||||||
void assert_cursor_equal(PMA_CURSOR pmacursor, int v) {
|
void assert_cursor_equal(PMA_CURSOR pmacursor, int v) {
|
||||||
DBT key, val;
|
DBT key, val;
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
int r;
|
int r;
|
||||||
r = toku_pma_cursor_get_current(pmacursor, &key, &val);
|
r = toku_pma_cursor_get_current(pmacursor, &key, &val);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
@ -1436,8 +1436,8 @@ void assert_cursor_equal(PMA_CURSOR pmacursor, int v) {
|
||||||
|
|
||||||
void assert_cursor_nokey(PMA_CURSOR pmacursor) {
|
void assert_cursor_nokey(PMA_CURSOR pmacursor) {
|
||||||
DBT key, val;
|
DBT key, val;
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
int r;
|
int r;
|
||||||
r = toku_pma_cursor_get_current(pmacursor, &key, &val);
|
r = toku_pma_cursor_get_current(pmacursor, &key, &val);
|
||||||
assert(r != 0);
|
assert(r != 0);
|
||||||
|
@ -1546,8 +1546,8 @@ void test_pma_delete_insert() {
|
||||||
assert_cursor_nokey(pmacursor);
|
assert_cursor_nokey(pmacursor);
|
||||||
|
|
||||||
k = 1;
|
k = 1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_lookup(pma, &key, &val);
|
error = toku_pma_lookup(pma, &key, &val);
|
||||||
assert(error != 0);
|
assert(error != 0);
|
||||||
|
|
||||||
|
@ -1595,7 +1595,7 @@ void test_pma_double_delete() {
|
||||||
assert_cursor_nokey(pmacursor);
|
assert_cursor_nokey(pmacursor);
|
||||||
|
|
||||||
k = 1;
|
k = 1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
error = toku_pma_delete(pma, &key, rand4fingerprint, &sum, 0);
|
error = toku_pma_delete(pma, &key, rand4fingerprint, &sum, 0);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
assert(sum == expect_fingerprint);
|
assert(sum == expect_fingerprint);
|
||||||
|
@ -1727,8 +1727,8 @@ void test_pma_already_there() {
|
||||||
int k, v;
|
int k, v;
|
||||||
|
|
||||||
k = 1; v = 1;
|
k = 1; v = 1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_pma_insert(pma, &key, &val, NULL_ARGS, rand4fingerprint, &sum);
|
error = toku_pma_insert(pma, &key, &val, NULL_ARGS, rand4fingerprint, &sum);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
u_int32_t savesum = sum;
|
u_int32_t savesum = sum;
|
||||||
|
@ -1770,11 +1770,11 @@ void test_pma_cursor_set_key() {
|
||||||
|
|
||||||
for (i=0; i<n; i += 1) {
|
for (i=0; i<n; i += 1) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
error = toku_pma_cursor_set_key(cursor, &key);
|
error = toku_pma_cursor_set_key(cursor, &key);
|
||||||
if (i % 10 == 0) {
|
if (i % 10 == 0) {
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
int vv;
|
int vv;
|
||||||
|
@ -1827,13 +1827,13 @@ void test_pma_cursor_set_range() {
|
||||||
|
|
||||||
for (i=0; i<100; i += 1) {
|
for (i=0; i<100; i += 1) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
error = toku_pma_cursor_set_range(cursor, &key);
|
error = toku_pma_cursor_set_range(cursor, &key);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
assert(i > largest_key);
|
assert(i > largest_key);
|
||||||
} else {
|
} else {
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
int vv;
|
int vv;
|
||||||
|
@ -1897,8 +1897,8 @@ void test_pma_cursor_delete_under() {
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
int vv;
|
int vv;
|
||||||
|
@ -1959,8 +1959,8 @@ void test_pma_cursor_set_both() {
|
||||||
|
|
||||||
/* verify key not in pma fails */
|
/* verify key not in pma fails */
|
||||||
k = n+1; v = 0;
|
k = n+1; v = 0;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_pma_cursor_set_both(cursor, &key, &val);
|
error = toku_pma_cursor_set_both(cursor, &key, &val);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
|
|
||||||
|
@ -1968,8 +1968,8 @@ void test_pma_cursor_set_both() {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i+1;
|
v = i+1;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_pma_cursor_set_both(cursor, &key, &val);
|
error = toku_pma_cursor_set_both(cursor, &key, &val);
|
||||||
assert(error == DB_NOTFOUND);
|
assert(error == DB_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
@ -1978,13 +1978,13 @@ void test_pma_cursor_set_both() {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(i);
|
k = htonl(i);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
error = toku_pma_cursor_set_both(cursor, &key, &val);
|
error = toku_pma_cursor_set_both(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
|
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
error = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(error == 0);
|
assert(error == 0);
|
||||||
int vv;
|
int vv;
|
||||||
|
@ -2023,8 +2023,8 @@ void test_nodup_key_insert(int n) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
k = htonl(0);
|
k = htonl(0);
|
||||||
v = i;
|
v = i;
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
fill_dbt(&val, &v, sizeof v);
|
toku_fill_dbt(&val, &v, sizeof v);
|
||||||
r = toku_pma_insert(pma, &key, &val, NULL_ARGS, rand4fingerprint, &sum);
|
r = toku_pma_insert(pma, &key, &val, NULL_ARGS, rand4fingerprint, &sum);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
@ -2084,15 +2084,15 @@ void test_dup_key_insert(int n) {
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
k = htonl(2);
|
k = htonl(2);
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_pma_cursor_set_key(cursor, &key);
|
r = toku_pma_cursor_set_key(cursor, &key);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
assert(n == 0);
|
assert(n == 0);
|
||||||
} else {
|
} else {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
int kk;
|
int kk;
|
||||||
|
@ -2171,7 +2171,7 @@ void test_dup_key_delete(int n, int mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
k = htonl(2);
|
k = htonl(2);
|
||||||
r = toku_pma_delete(pma, fill_dbt(&key, &k, sizeof k), rand4fingerprint, &sum, 0);
|
r = toku_pma_delete(pma, toku_fill_dbt(&key, &k, sizeof k), rand4fingerprint, &sum, 0);
|
||||||
if (r != 0) assert(n == 0);
|
if (r != 0) assert(n == 0);
|
||||||
expect_fingerprint = sum_before_all_the_duplicates;
|
expect_fingerprint = sum_before_all_the_duplicates;
|
||||||
assert(sum == expect_fingerprint);
|
assert(sum == expect_fingerprint);
|
||||||
|
@ -2189,8 +2189,8 @@ void test_dup_key_delete(int n, int mode) {
|
||||||
int kk, vv;
|
int kk, vv;
|
||||||
|
|
||||||
k = htonl(1); v = 1;
|
k = htonl(1); v = 1;
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
assert(key.size == sizeof kk);
|
assert(key.size == sizeof kk);
|
||||||
|
@ -2206,8 +2206,8 @@ void test_dup_key_delete(int n, int mode) {
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
k = htonl(3); v = 3;
|
k = htonl(3); v = 3;
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
assert(key.size == sizeof kk);
|
assert(key.size == sizeof kk);
|
||||||
|
@ -2276,7 +2276,7 @@ void test_dupsort_key_insert(int n, int dup_data) {
|
||||||
r = toku_pma_cursor(pma, &cursor);
|
r = toku_pma_cursor(pma, &cursor);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
fill_dbt(&key, &k, sizeof k);
|
toku_fill_dbt(&key, &k, sizeof k);
|
||||||
r = toku_pma_cursor_set_key(cursor, &key);
|
r = toku_pma_cursor_set_key(cursor, &key);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
assert(n == 0);
|
assert(n == 0);
|
||||||
|
@ -2287,8 +2287,8 @@ void test_dupsort_key_insert(int n, int dup_data) {
|
||||||
qsort(values, n, sizeof (int), cmpint);
|
qsort(values, n, sizeof (int), cmpint);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&key); key.flags = DB_DBT_MALLOC;
|
||||||
init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
|
||||||
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
r = toku_pma_cursor_get_current(cursor, &key, &val);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
int kk;
|
int kk;
|
||||||
|
@ -2366,7 +2366,7 @@ void test_dup_key_lookup(int n, int mode) {
|
||||||
|
|
||||||
/* lookup should find the first insert and smallest value */
|
/* lookup should find the first insert and smallest value */
|
||||||
k = htonl(2);
|
k = htonl(2);
|
||||||
r = toku_pma_lookup(pma, fill_dbt(&key, &k, sizeof k), fill_dbt(&val, &v, sizeof v));
|
r = toku_pma_lookup(pma, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v));
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
int kk;
|
int kk;
|
||||||
assert(key.size == sizeof k);
|
assert(key.size == sizeof k);
|
||||||
|
|
50
newbrt/pma.c
50
newbrt/pma.c
|
@ -275,7 +275,7 @@ static int __pma_search(PMA pma, DBT *k, int lo, int hi, int *found) {
|
||||||
return __pma_search(pma, k, lo, omi, found);
|
return __pma_search(pma, k, lo, omi, found);
|
||||||
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
int cmp = pma->compare_fun(pma->db, k, fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
int cmp = pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
||||||
if (cmp > 0)
|
if (cmp > 0)
|
||||||
return __pma_search(pma, k, mi+1, hi, found);
|
return __pma_search(pma, k, mi+1, hi, found);
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
|
@ -301,7 +301,7 @@ static int __pma_right_search(PMA pma, DBT *k, int lo, int hi, int *found) {
|
||||||
return __pma_right_search(pma, k, lo, omi, found);
|
return __pma_right_search(pma, k, lo, omi, found);
|
||||||
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
int cmp = pma->compare_fun(pma->db, k, fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
int cmp = pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
||||||
if (cmp > 0)
|
if (cmp > 0)
|
||||||
return __pma_right_search(pma, k, mi+1, hi, found);
|
return __pma_right_search(pma, k, mi+1, hi, found);
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
|
@ -333,7 +333,7 @@ static int __pma_left_search(PMA pma, DBT *k, int lo, int hi, int *found) {
|
||||||
return __pma_left_search(pma, k, lo, omi, found);
|
return __pma_left_search(pma, k, lo, omi, found);
|
||||||
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
int cmp = pma->compare_fun(pma->db, k, fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
int cmp = pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
||||||
if (cmp > 0)
|
if (cmp > 0)
|
||||||
return __pma_left_search(pma, k, mi+1, hi, found);
|
return __pma_left_search(pma, k, mi+1, hi, found);
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
|
@ -365,9 +365,9 @@ static int __pma_dup_search(PMA pma, DBT *k, DBT *v, int lo, int hi, int *found)
|
||||||
return __pma_dup_search(pma, k, v, lo, omi, found);
|
return __pma_dup_search(pma, k, v, lo, omi, found);
|
||||||
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
struct kv_pair *kv = kv_pair_ptr(pma->pairs[mi]);
|
||||||
DBT k2, v2;
|
DBT k2, v2;
|
||||||
int cmp = pma->compare_fun(pma->db, k, fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
int cmp = pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv)));
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
cmp = pma->dup_compare_fun(pma->db, v, fill_dbt(&v2, kv_pair_val(kv), kv_pair_vallen(kv)));
|
cmp = pma->dup_compare_fun(pma->db, v, toku_fill_dbt(&v2, kv_pair_val(kv), kv_pair_vallen(kv)));
|
||||||
if (cmp > 0)
|
if (cmp > 0)
|
||||||
return __pma_dup_search(pma, k, v, mi+1, hi, found);
|
return __pma_dup_search(pma, k, v, mi+1, hi, found);
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
|
@ -403,7 +403,7 @@ int toku_pmainternal_find (PMA pma, DBT *k) {
|
||||||
// Found one.
|
// Found one.
|
||||||
kv = kv_pair_ptr(kv);
|
kv = kv_pair_ptr(kv);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
int cmp = pma->compare_fun(pma->db, k, fill_dbt(&k2, kv->key, kv->keylen));
|
int cmp = pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv->key, kv->keylen));
|
||||||
if (cmp==0) return mid;
|
if (cmp==0) return mid;
|
||||||
else if (cmp<0) {
|
else if (cmp<0) {
|
||||||
/* key is smaller than the midpoint, so look in the low half. */
|
/* key is smaller than the midpoint, so look in the low half. */
|
||||||
|
@ -434,7 +434,7 @@ int toku_pmainternal_find (PMA pma, DBT *k) {
|
||||||
if (lo>0 && lo < toku_pma_index_limit(pma) && pma->pairs[lo]) {
|
if (lo>0 && lo < toku_pma_index_limit(pma) && pma->pairs[lo]) {
|
||||||
//printf("lo=%d\n", lo);
|
//printf("lo=%d\n", lo);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
assert(0 >= pma->compare_fun(db, k, fill_dbt(&k2, pma->pairs[lo]->key, pma->pairs[lo]->keylen)));
|
assert(0 >= pma->compare_fun(db, k, toku_fill_dbt(&k2, pma->pairs[lo]->key, pma->pairs[lo]->keylen)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return lo;
|
return lo;
|
||||||
|
@ -445,7 +445,7 @@ int toku_pmainternal_find (PMA pma, DBT *k) {
|
||||||
if (lo>0 && lo < toku_pma_index_limit(pma) && pma->pairs[lo]) {
|
if (lo>0 && lo < toku_pma_index_limit(pma) && pma->pairs[lo]) {
|
||||||
//printf("lo=%d\n", lo);
|
//printf("lo=%d\n", lo);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
assert(0 >= pma->compare_fun(db, k, fill_dbt(&k2, pma->pairs[lo]->key, pma->pairs[lo]->keylen)));
|
assert(0 >= pma->compare_fun(db, k, toku_fill_dbt(&k2, pma->pairs[lo]->key, pma->pairs[lo]->keylen)));
|
||||||
}
|
}
|
||||||
return lo;
|
return lo;
|
||||||
#endif
|
#endif
|
||||||
|
@ -758,7 +758,7 @@ int toku_pma_cursor_get_current_data(PMA_CURSOR c, DBT *data) {
|
||||||
struct kv_pair *pair = pma->pairs[c->position];
|
struct kv_pair *pair = pma->pairs[c->position];
|
||||||
if (!kv_pair_valid(pair))
|
if (!kv_pair_valid(pair))
|
||||||
return BRT_KEYEMPTY;
|
return BRT_KEYEMPTY;
|
||||||
ybt_set_value(data, kv_pair_val(pair), kv_pair_vallen(pair), &c->sval);
|
toku_dbt_set_value(data, kv_pair_val(pair), kv_pair_vallen(pair), &c->sval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,8 +769,8 @@ int toku_pma_cursor_get_current(PMA_CURSOR c, DBT *key, DBT *val) {
|
||||||
struct kv_pair *pair = pma->pairs[c->position];
|
struct kv_pair *pair = pma->pairs[c->position];
|
||||||
if (!kv_pair_valid(pair))
|
if (!kv_pair_valid(pair))
|
||||||
return BRT_KEYEMPTY;
|
return BRT_KEYEMPTY;
|
||||||
ybt_set_value(key, kv_pair_key(pair), kv_pair_keylen(pair), &c->skey);
|
toku_dbt_set_value(key, kv_pair_key(pair), kv_pair_keylen(pair), &c->skey);
|
||||||
ybt_set_value(val, kv_pair_val(pair), kv_pair_vallen(pair), &c->sval);
|
toku_dbt_set_value(val, kv_pair_val(pair), kv_pair_vallen(pair), &c->sval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,7 +787,7 @@ int toku_pma_cursor_set_key(PMA_CURSOR c, DBT *key) {
|
||||||
DBT k2;
|
DBT k2;
|
||||||
struct kv_pair *pair = pma->pairs[here];
|
struct kv_pair *pair = pma->pairs[here];
|
||||||
if (kv_pair_valid(pair) &&
|
if (kv_pair_valid(pair) &&
|
||||||
pma->compare_fun(pma->db, key, fill_dbt(&k2, kv_pair_key(pair), kv_pair_keylen(pair)))==0) {
|
pma->compare_fun(pma->db, key, toku_fill_dbt(&k2, kv_pair_key(pair), kv_pair_keylen(pair)))==0) {
|
||||||
__pma_delete_resume(c->pma, c->position);
|
__pma_delete_resume(c->pma, c->position);
|
||||||
c->position = here;
|
c->position = here;
|
||||||
r = 0;
|
r = 0;
|
||||||
|
@ -805,8 +805,8 @@ int toku_pma_cursor_set_both(PMA_CURSOR c, DBT *key, DBT *val) {
|
||||||
DBT k2, v2;
|
DBT k2, v2;
|
||||||
struct kv_pair *pair = pma->pairs[here];
|
struct kv_pair *pair = pma->pairs[here];
|
||||||
if (kv_pair_valid(pair) &&
|
if (kv_pair_valid(pair) &&
|
||||||
pma->compare_fun(pma->db, key, fill_dbt(&k2, kv_pair_key(pair), kv_pair_keylen(pair))) == 0 &&
|
pma->compare_fun(pma->db, key, toku_fill_dbt(&k2, kv_pair_key(pair), kv_pair_keylen(pair))) == 0 &&
|
||||||
pma->compare_fun(pma->db, val, fill_dbt(&v2, kv_pair_val(pair), kv_pair_vallen(pair))) == 0) {
|
pma->compare_fun(pma->db, val, toku_fill_dbt(&v2, kv_pair_val(pair), kv_pair_vallen(pair))) == 0) {
|
||||||
__pma_delete_resume(c->pma, c->position);
|
__pma_delete_resume(c->pma, c->position);
|
||||||
c->position = here;
|
c->position = here;
|
||||||
r = 0;
|
r = 0;
|
||||||
|
@ -937,8 +937,8 @@ enum pma_errors toku_pma_lookup (PMA pma, DBT *k, DBT *v) {
|
||||||
DBT k2;
|
DBT k2;
|
||||||
struct kv_pair *pair;
|
struct kv_pair *pair;
|
||||||
pair = pma->pairs[here];
|
pair = pma->pairs[here];
|
||||||
if (kv_pair_valid(pair) && pma->compare_fun(pma->db, k, fill_dbt(&k2, pair->key, pair->keylen))==0) {
|
if (kv_pair_valid(pair) && pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, pair->key, pair->keylen))==0) {
|
||||||
return ybt_set_value(v, pair->key + pair->keylen, pair->vallen, &pma->sval);
|
return toku_dbt_set_value(v, pair->key + pair->keylen, pair->vallen, &pma->sval);
|
||||||
} else {
|
} else {
|
||||||
return DB_NOTFOUND;
|
return DB_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
@ -994,7 +994,7 @@ int toku_pma_insert (PMA pma, DBT *k, DBT *v, TOKUTXN txn, DISKOFF diskoff, u_in
|
||||||
if (idx < toku_pma_index_limit(pma) && pma->pairs[idx]) {
|
if (idx < toku_pma_index_limit(pma) && pma->pairs[idx]) {
|
||||||
DBT k2;
|
DBT k2;
|
||||||
struct kv_pair *kv = kv_pair_ptr(pma->pairs[idx]);
|
struct kv_pair *kv = kv_pair_ptr(pma->pairs[idx]);
|
||||||
if (0==pma->compare_fun(pma->db, k, fill_dbt(&k2, kv->key, kv->keylen))) {
|
if (0==pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv->key, kv->keylen))) {
|
||||||
if (kv_pair_deleted(pma->pairs[idx])) {
|
if (kv_pair_deleted(pma->pairs[idx])) {
|
||||||
pma_mfree_kv_pair(pma, pma->pairs[idx]);
|
pma_mfree_kv_pair(pma, pma->pairs[idx]);
|
||||||
pma->pairs[idx] = pma_malloc_kv_pair(pma, k->data, k->size, v->data, v->size);
|
pma->pairs[idx] = pma_malloc_kv_pair(pma, k->data, k->size, v->data, v->size);
|
||||||
|
@ -1033,7 +1033,7 @@ static int pma_next_key(PMA pma, DBT *k, int here, int n, int *found) {
|
||||||
if (here < n) {
|
if (here < n) {
|
||||||
struct kv_pair *kv = kv_pair_ptr(pma->pairs[here]);
|
struct kv_pair *kv = kv_pair_ptr(pma->pairs[here]);
|
||||||
DBT k2;
|
DBT k2;
|
||||||
if (0 == pma->compare_fun(pma->db, k, fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv))))
|
if (0 == pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv_pair_key(kv), kv_pair_keylen(kv))))
|
||||||
*found = 1;
|
*found = 1;
|
||||||
}
|
}
|
||||||
return here;
|
return here;
|
||||||
|
@ -1199,7 +1199,7 @@ int toku_pma_insert_or_replace (PMA pma, DBT *k, DBT *v,
|
||||||
DBT k2;
|
DBT k2;
|
||||||
// printf("%s:%d\n", __FILE__, __LINE__);
|
// printf("%s:%d\n", __FILE__, __LINE__);
|
||||||
kv = kv_pair_ptr(kv);
|
kv = kv_pair_ptr(kv);
|
||||||
if (0==pma->compare_fun(pma->db, k, fill_dbt(&k2, kv->key, kv->keylen))) {
|
if (0==pma->compare_fun(pma->db, k, toku_fill_dbt(&k2, kv->key, kv->keylen))) {
|
||||||
if (!kv_pair_deleted(pma->pairs[idx])) {
|
if (!kv_pair_deleted(pma->pairs[idx])) {
|
||||||
*replaced_v_size = kv->vallen;
|
*replaced_v_size = kv->vallen;
|
||||||
*fingerprint -= rand4fingerprint*toku_calccrc32_kvpair(kv_pair_key_const(kv), kv_pair_keylen(kv), kv_pair_val_const(kv), kv_pair_vallen(kv));
|
*fingerprint -= rand4fingerprint*toku_calccrc32_kvpair(kv_pair_key_const(kv), kv_pair_keylen(kv), kv_pair_val_const(kv), kv_pair_vallen(kv));
|
||||||
|
@ -1353,9 +1353,9 @@ static void __pma_relocate_kvpairs(PMA pma) {
|
||||||
|
|
||||||
static int __pma_compare_kv(PMA pma, struct kv_pair *a, struct kv_pair *b) {
|
static int __pma_compare_kv(PMA pma, struct kv_pair *a, struct kv_pair *b) {
|
||||||
DBT dbta, dbtb;
|
DBT dbta, dbtb;
|
||||||
int cmp = pma->compare_fun(pma->db, fill_dbt(&dbta, kv_pair_key(a), kv_pair_keylen(a)), fill_dbt(&dbtb, kv_pair_key(b), kv_pair_keylen(b)));
|
int cmp = pma->compare_fun(pma->db, toku_fill_dbt(&dbta, kv_pair_key(a), kv_pair_keylen(a)), toku_fill_dbt(&dbtb, kv_pair_key(b), kv_pair_keylen(b)));
|
||||||
if (cmp == 0 && (pma->dup_mode & TOKU_DB_DUPSORT)) {
|
if (cmp == 0 && (pma->dup_mode & TOKU_DB_DUPSORT)) {
|
||||||
cmp = pma->dup_compare_fun(pma->db, fill_dbt(&dbta, kv_pair_val(a), kv_pair_vallen(b)), fill_dbt(&dbtb, kv_pair_val(b), kv_pair_vallen(b)));
|
cmp = pma->dup_compare_fun(pma->db, toku_fill_dbt(&dbta, kv_pair_val(a), kv_pair_vallen(b)), toku_fill_dbt(&dbtb, kv_pair_val(b), kv_pair_vallen(b)));
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
@ -1562,16 +1562,16 @@ void toku_pma_verify(PMA pma) {
|
||||||
if (kv_pair_inuse(nextkv)) {
|
if (kv_pair_inuse(nextkv)) {
|
||||||
nextkv = kv_pair_ptr(nextkv);
|
nextkv = kv_pair_ptr(nextkv);
|
||||||
DBT kv_dbt, nextkv_dbt;
|
DBT kv_dbt, nextkv_dbt;
|
||||||
fill_dbt(&kv_dbt, kv_pair_key(kv), kv_pair_keylen(kv));
|
toku_fill_dbt(&kv_dbt, kv_pair_key(kv), kv_pair_keylen(kv));
|
||||||
fill_dbt(&nextkv_dbt, kv_pair_key(nextkv), kv_pair_keylen(nextkv));
|
toku_fill_dbt(&nextkv_dbt, kv_pair_key(nextkv), kv_pair_keylen(nextkv));
|
||||||
int r = pma->compare_fun(pma->db, &kv_dbt, &nextkv_dbt);
|
int r = pma->compare_fun(pma->db, &kv_dbt, &nextkv_dbt);
|
||||||
if (pma->dup_mode == 0)
|
if (pma->dup_mode == 0)
|
||||||
assert(r < 0);
|
assert(r < 0);
|
||||||
else if (pma->dup_mode & TOKU_DB_DUP)
|
else if (pma->dup_mode & TOKU_DB_DUP)
|
||||||
assert(r <= 0);
|
assert(r <= 0);
|
||||||
if (r == 0 && (pma->dup_mode & TOKU_DB_DUPSORT)) {
|
if (r == 0 && (pma->dup_mode & TOKU_DB_DUPSORT)) {
|
||||||
fill_dbt(&kv_dbt, kv_pair_val(kv), kv_pair_vallen(kv));
|
toku_fill_dbt(&kv_dbt, kv_pair_val(kv), kv_pair_vallen(kv));
|
||||||
fill_dbt(&nextkv_dbt, kv_pair_val(nextkv), kv_pair_vallen(nextkv));
|
toku_fill_dbt(&nextkv_dbt, kv_pair_val(nextkv), kv_pair_vallen(nextkv));
|
||||||
r = pma->dup_compare_fun(pma->db, &kv_dbt, &nextkv_dbt);
|
r = pma->dup_compare_fun(pma->db, &kv_dbt, &nextkv_dbt);
|
||||||
assert(r <= 0);
|
assert(r <= 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,17 +17,17 @@
|
||||||
#include "cachetable.h"
|
#include "cachetable.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
|
||||||
CACHETABLE ct;
|
static CACHETABLE ct;
|
||||||
struct cf_pair {
|
static struct cf_pair {
|
||||||
FILENUM filenum;
|
FILENUM filenum;
|
||||||
CACHEFILE cf;
|
CACHEFILE cf;
|
||||||
BRT brt;
|
BRT brt;
|
||||||
} *cf_pairs;
|
} *cf_pairs;
|
||||||
int n_cf_pairs=0, max_cf_pairs=0;
|
static int n_cf_pairs=0, max_cf_pairs=0;
|
||||||
|
|
||||||
DB * const null_db=0;
|
static DB * const null_db=0;
|
||||||
|
|
||||||
int find_cachefile (FILENUM fnum, CACHEFILE *cf, BRT *brt) {
|
static int find_cachefile (FILENUM fnum, CACHEFILE *cf, BRT *brt) {
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<n_cf_pairs; i++) {
|
for (i=0; i<n_cf_pairs; i++) {
|
||||||
if (fnum.fileid==cf_pairs[i].filenum.fileid) {
|
if (fnum.fileid==cf_pairs[i].filenum.fileid) {
|
||||||
|
@ -144,7 +144,7 @@ static void toku_recover_insertinleaf (struct logtype_insertinleaf *c) {
|
||||||
BRTNODE node = node_v;
|
BRTNODE node = node_v;
|
||||||
assert(node->height==0);
|
assert(node->height==0);
|
||||||
DBT key,data;
|
DBT key,data;
|
||||||
r = toku_pma_set_at_index(node->u.l.buffer, c->pmaidx, fill_dbt(&key, c->key.data, c->key.len), fill_dbt(&data, c->data.data, c->data.len));
|
r = toku_pma_set_at_index(node->u.l.buffer, c->pmaidx, toku_fill_dbt(&key, c->key.data, c->key.len), toku_fill_dbt(&data, c->data.data, c->data.len));
|
||||||
node->local_fingerprint += node->rand4fingerprint*toku_calccrc32_kvpair(c->key.data, c->key.len,c->data.data, c->data.len);
|
node->local_fingerprint += node->rand4fingerprint*toku_calccrc32_kvpair(c->key.data, c->key.len,c->data.data, c->data.len);
|
||||||
node->u.l.n_bytes_in_buffer += KEY_VALUE_OVERHEAD + c->key.len + c->data.len;
|
node->u.l.n_bytes_in_buffer += KEY_VALUE_OVERHEAD + c->key.len + c->data.len;
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|
|
@ -15,10 +15,11 @@
|
||||||
#include "log-internal.h"
|
#include "log-internal.h"
|
||||||
#include "log_header.h"
|
#include "log_header.h"
|
||||||
|
|
||||||
u_int32_t crc=0;
|
#if 0
|
||||||
u_int32_t actual_len=0;
|
static u_int32_t crc=0;
|
||||||
|
static u_int32_t actual_len=0;
|
||||||
|
|
||||||
int get_char(void) {
|
static int get_char(void) {
|
||||||
int v = getchar();
|
int v = getchar();
|
||||||
if (v==EOF) return v;
|
if (v==EOF) return v;
|
||||||
unsigned char c = v;
|
unsigned char c = v;
|
||||||
|
@ -27,7 +28,7 @@ int get_char(void) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t get_uint32 (void) {
|
static u_int32_t get_uint32 (void) {
|
||||||
u_int32_t a = get_char();
|
u_int32_t a = get_char();
|
||||||
u_int32_t b = get_char();
|
u_int32_t b = get_char();
|
||||||
u_int32_t c = get_char();
|
u_int32_t c = get_char();
|
||||||
|
@ -35,7 +36,7 @@ u_int32_t get_uint32 (void) {
|
||||||
return (a<<24)|(b<<16)|(c<<8)|d;
|
return (a<<24)|(b<<16)|(c<<8)|d;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int64_t get_uint64 (void) {
|
static u_int64_t get_uint64 (void) {
|
||||||
u_int32_t hi = get_uint32();
|
u_int32_t hi = get_uint32();
|
||||||
u_int32_t lo = get_uint32();
|
u_int32_t lo = get_uint32();
|
||||||
return ((((long long)hi) << 32)
|
return ((((long long)hi) << 32)
|
||||||
|
@ -43,52 +44,51 @@ u_int64_t get_uint64 (void) {
|
||||||
lo);
|
lo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_lsn (void) {
|
static void transcribe_lsn (void) {
|
||||||
long long value = get_uint64();
|
long long value = get_uint64();
|
||||||
printf(" lsn=%lld", value);
|
printf(" lsn=%lld", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_txnid (void) {
|
static void transcribe_txnid (void) {
|
||||||
long long value = get_uint64();
|
long long value = get_uint64();
|
||||||
printf(" txnid=%lld", value);
|
printf(" txnid=%lld", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_fileid (void) {
|
static void transcribe_fileid (void) {
|
||||||
u_int32_t value = get_uint32();
|
u_int32_t value = get_uint32();
|
||||||
printf(" fileid=%d", value);
|
printf(" fileid=%d", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void transcribe_diskoff (void) {
|
static void transcribe_diskoff (void) {
|
||||||
long long value = get_uint64();
|
long long value = get_uint64();
|
||||||
printf(" diskoff=%lld", value);
|
printf(" diskoff=%lld", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_crc32 (void) {
|
static void transcribe_crc32 (void) {
|
||||||
u_int32_t oldcrc=crc;
|
u_int32_t oldcrc=crc;
|
||||||
u_int32_t l = get_uint32();
|
u_int32_t l = get_uint32();
|
||||||
printf(" crc=%08x", l);
|
printf(" crc=%08x", l);
|
||||||
assert(l==oldcrc);
|
assert(l==oldcrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_mode (void) {
|
static void transcribe_mode (void) {
|
||||||
u_int32_t value = get_uint32();
|
u_int32_t value = get_uint32();
|
||||||
printf(" mode=0%o", value);
|
printf(" mode=0%o", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_filenum(void) {
|
static void transcribe_filenum(void) {
|
||||||
u_int32_t value = get_uint32();
|
u_int32_t value = get_uint32();
|
||||||
printf(" filenum=%d", value);
|
printf(" filenum=%d", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t len1;
|
static u_int32_t len1;
|
||||||
void transcribe_len1 (void) {
|
static void transcribe_len1 (void) {
|
||||||
len1 = get_uint32();
|
len1 = get_uint32();
|
||||||
//printf(" len=%d", len1);
|
//printf(" len=%d", len1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void transcribe_len (void) {
|
||||||
void transcribe_len (void) {
|
|
||||||
u_int32_t l = get_uint32();
|
u_int32_t l = get_uint32();
|
||||||
printf(" len=%d", l);
|
printf(" len=%d", l);
|
||||||
if (l!=actual_len) printf(" actual_len=%d", actual_len);
|
if (l!=actual_len) printf(" actual_len=%d", actual_len);
|
||||||
|
@ -96,8 +96,7 @@ void transcribe_len (void) {
|
||||||
assert(len1==actual_len);
|
assert(len1==actual_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void transcribe_key_or_data (char *what) {
|
||||||
void transcribe_key_or_data (char *what) {
|
|
||||||
u_int32_t l = get_uint32();
|
u_int32_t l = get_uint32();
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
printf(" %s(%d):\"", what, l);
|
printf(" %s(%d):\"", what, l);
|
||||||
|
@ -113,7 +112,7 @@ void transcribe_key_or_data (char *what) {
|
||||||
printf("\"");
|
printf("\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
void transcribe_header (void) {
|
static void transcribe_header (void) {
|
||||||
printf(" {size=%d", get_uint32());
|
printf(" {size=%d", get_uint32());
|
||||||
printf(" flags=%d", get_uint32());
|
printf(" flags=%d", get_uint32());
|
||||||
printf(" nodesize=%d", get_uint32());
|
printf(" nodesize=%d", get_uint32());
|
||||||
|
@ -128,6 +127,7 @@ void transcribe_header (void) {
|
||||||
}
|
}
|
||||||
printf("}");
|
printf("}");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void newmain (int count) {
|
static void newmain (int count) {
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void ybt_test0 (void) {
|
static void ybt_test0 (void) {
|
||||||
void *v0=0,*v1=0;
|
void *v0=0,*v1=0;
|
||||||
DBT t0,t1;
|
DBT t0,t1;
|
||||||
init_dbt(&t0);
|
toku_init_dbt(&t0);
|
||||||
init_dbt(&t1);
|
toku_init_dbt(&t1);
|
||||||
ybt_set_value(&t0, "hello", 6, &v0);
|
toku_dbt_set_value(&t0, "hello", 6, &v0);
|
||||||
ybt_set_value(&t1, "foo", 4, &v1);
|
toku_dbt_set_value(&t1, "foo", 4, &v1);
|
||||||
assert(t0.size==6);
|
assert(t0.size==6);
|
||||||
assert(strcmp(t0.data, "hello")==0);
|
assert(strcmp(t0.data, "hello")==0);
|
||||||
assert(t1.size==4);
|
assert(t1.size==4);
|
||||||
assert(strcmp(t1.data, "foo")==0);
|
assert(strcmp(t1.data, "foo")==0);
|
||||||
|
|
||||||
ybt_set_value(&t1, "byebye", 7, &v0); /* Use v0, not v1 */
|
toku_dbt_set_value(&t1, "byebye", 7, &v0); /* Use v0, not v1 */
|
||||||
// This assertion would be wrong, since v0 may have been realloc'd, and t0.data may now point
|
// This assertion would be wrong, since v0 may have been realloc'd, and t0.data may now point
|
||||||
// at the wrong place
|
// at the wrong place
|
||||||
//assert(strcmp(t0.data, "byebye")==0); /* t0's data should be changed too, since it used v0 */
|
//assert(strcmp(t0.data, "byebye")==0); /* t0's data should be changed too, since it used v0 */
|
||||||
|
@ -30,23 +30,23 @@ void ybt_test0 (void) {
|
||||||
memory_check_all_free();
|
memory_check_all_free();
|
||||||
|
|
||||||
/* See if we can probe to find out how big something is by setting ulen=0 with YBT_USERMEM */
|
/* See if we can probe to find out how big something is by setting ulen=0 with YBT_USERMEM */
|
||||||
init_dbt(&t0);
|
toku_init_dbt(&t0);
|
||||||
t0.flags = DB_DBT_USERMEM;
|
t0.flags = DB_DBT_USERMEM;
|
||||||
t0.ulen = 0;
|
t0.ulen = 0;
|
||||||
ybt_set_value(&t0, "hello", 6, 0);
|
toku_dbt_set_value(&t0, "hello", 6, 0);
|
||||||
assert(t0.data==0);
|
assert(t0.data==0);
|
||||||
assert(t0.size==6);
|
assert(t0.size==6);
|
||||||
|
|
||||||
/* Check realloc. */
|
/* Check realloc. */
|
||||||
init_dbt(&t0);
|
toku_init_dbt(&t0);
|
||||||
t0.flags = DB_DBT_REALLOC;
|
t0.flags = DB_DBT_REALLOC;
|
||||||
v0 = 0;
|
v0 = 0;
|
||||||
ybt_set_value(&t0, "internationalization", 21, &v0);
|
toku_dbt_set_value(&t0, "internationalization", 21, &v0);
|
||||||
assert(v0==0); /* Didn't change v0 */
|
assert(v0==0); /* Didn't change v0 */
|
||||||
assert(t0.size==21);
|
assert(t0.size==21);
|
||||||
assert(strcmp(t0.data, "internationalization")==0);
|
assert(strcmp(t0.data, "internationalization")==0);
|
||||||
|
|
||||||
ybt_set_value(&t0, "provincial", 11, &v0);
|
toku_dbt_set_value(&t0, "provincial", 11, &v0);
|
||||||
assert(t0.size==11);
|
assert(t0.size==11);
|
||||||
assert(strcmp(t0.data, "provincial")==0);
|
assert(strcmp(t0.data, "provincial")==0);
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
DBT *init_dbt (DBT *ybt) {
|
DBT *toku_init_dbt (DBT *ybt) {
|
||||||
memset(ybt, 0, sizeof(*ybt));
|
memset(ybt, 0, sizeof(*ybt));
|
||||||
return ybt;
|
return ybt;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBT *fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) {
|
DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) {
|
||||||
init_dbt(dbt);
|
toku_init_dbt(dbt);
|
||||||
dbt->size=len;
|
dbt->size=len;
|
||||||
dbt->data=(char*)k;
|
dbt->data=(char*)k;
|
||||||
return dbt;
|
return dbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ybt_set_value (DBT *ybt, bytevec val, ITEMLEN vallen, void **staticptrp) {
|
int toku_dbt_set_value (DBT *ybt, bytevec val, ITEMLEN vallen, void **staticptrp) {
|
||||||
if (ybt->flags==DB_DBT_MALLOC) {
|
if (ybt->flags==DB_DBT_MALLOC) {
|
||||||
domalloc:
|
domalloc:
|
||||||
ybt->data = toku_malloc(vallen);
|
ybt->data = toku_malloc(vallen);
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include "../include/db.h"
|
#include "../include/db.h"
|
||||||
|
|
||||||
|
|
||||||
DBT* init_dbt (DBT *);
|
DBT* toku_init_dbt (DBT *);
|
||||||
DBT *fill_dbt(DBT *dbt, bytevec k, ITEMLEN len);
|
DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len);
|
||||||
int ybt_set_value (DBT *, bytevec val, ITEMLEN vallen, void **staticptrp);
|
int toku_dbt_set_value (DBT *, bytevec val, ITEMLEN vallen, void **staticptrp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue