Commit 77ab644e authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Rename a bunch of symbols to toku_symbols. Addresses #8.

git-svn-id: file:///svn/tokudb@824 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9f54dcef
......@@ -104,7 +104,7 @@ void long_long_to_array (unsigned char *a, unsigned long long l) {
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);
dbt->size = size;
dbt->data = data;
......@@ -118,7 +118,7 @@ void insert (long long v) {
long_long_to_array(kc, v);
memset(vc, 0, sizeof vc);
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);
if (do_transactions) {
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);
{
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);
}
......
......@@ -55,7 +55,7 @@ void insert (long long v) {
long_long_to_array(kc, v);
memset(vc, 0, sizeof vc);
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);
}
......
......@@ -383,9 +383,9 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl
bytevec val; ITEMLEN vallen;
toku_verify_counts(result);
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);
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;
}
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);
{
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;
}
result->u.l.n_bytes_in_buffer += keylen + vallen + KEY_VALUE_OVERHEAD;
......
This diff is collapsed.
......@@ -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;
if (brt->flags & TOKU_DB_DUPSORT) {
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)
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 {
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;
}
......@@ -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) {
DBT k2;
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 {
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) {
int again_split=-1; BRTNODE againa,againb;
DBT againk;
init_dbt(&againk);
toku_init_dbt(&againk);
//printf("%s:%d hello!\n", __FILE__, __LINE__);
r = brtnode_put_cmd(t, child, cmd,
&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 */
HASHTABLE_ITERATE(old_h, skey, skeylen, sval, svallen, type, ({
DBT skd, svd;
fill_dbt(&skd, skey, skeylen);
fill_dbt(&svd, sval, svallen);
toku_fill_dbt(&skd, skey, skeylen);
toku_fill_dbt(&svd, sval, svallen);
BRT_CMD brtcmd;
brtcmd.type = type; brtcmd.u.id.key = &skd; brtcmd.u.id.val = &svd;
//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;
BRT_CMD brtcmd;
fill_dbt(&hk, key, keylen);
fill_dbt(&hv, val, vallen);
toku_fill_dbt(&hk, key, keylen);
toku_fill_dbt(&hv, val, vallen);
brtcmd.type = type;
brtcmd.u.id.key = &hk;
brtcmd.u.id.val = &hv;
//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);
r = push_a_brt_cmd_down (t, node, child, childnum,
&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)) {
result = brt_lookup_node(brt, node->u.n.children[childnum], k, v, node);
if (result != 0) {
ybt_set_value(v, hanswer, hanswerlen, &brt->sval);
toku_dbt_set_value(v, hanswer, hanswerlen, &brt->sval);
result = 0;
}
} else {
//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);
result = 0;
}
} 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) {
assert(type == BRT_INSERT);
ybt_set_value(v, hanswer, hanswerlen, &brt->sval);
toku_dbt_set_value(v, hanswer, hanswerlen, &brt->sval);
result = 0;
} else
result = DB_NOTFOUND;
......@@ -1943,7 +1943,7 @@ int toku_brt_delete(BRT brt, DBT *key) {
BRT_CMD brtcmd;
DBT val;
init_dbt(&val);
toku_init_dbt(&val);
val.size = 0;
brtcmd.type = BRT_DELETE;
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);
}
init_dbt(&child_splitk);
toku_init_dbt(&child_splitk);
r = push_some_brt_cmds_down(t, node, childnum,
&child_did_split, &childa, &childb, &child_splitk, brt_flush_debug, txn);
assert(r == 0);
......
This diff is collapsed.
This diff is collapsed.
......@@ -17,17 +17,17 @@
#include "cachetable.h"
#include "key.h"
CACHETABLE ct;
struct cf_pair {
static CACHETABLE ct;
static struct cf_pair {
FILENUM filenum;
CACHEFILE cf;
BRT brt;
} *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;
for (i=0; i<n_cf_pairs; i++) {
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;
assert(node->height==0);
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->u.l.n_bytes_in_buffer += KEY_VALUE_OVERHEAD + c->key.len + c->data.len;
assert(r==0);
......
......@@ -15,10 +15,11 @@
#include "log-internal.h"
#include "log_header.h"
u_int32_t crc=0;
u_int32_t actual_len=0;
#if 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();
if (v==EOF) return v;
unsigned char c = v;
......@@ -27,7 +28,7 @@ int get_char(void) {
return v;
}
u_int32_t get_uint32 (void) {
static u_int32_t get_uint32 (void) {
u_int32_t a = get_char();
u_int32_t b = 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;
}
u_int64_t get_uint64 (void) {
static u_int64_t get_uint64 (void) {
u_int32_t hi = get_uint32();
u_int32_t lo = get_uint32();
return ((((long long)hi) << 32)
......@@ -43,52 +44,51 @@ u_int64_t get_uint64 (void) {
lo);
}
void transcribe_lsn (void) {
static void transcribe_lsn (void) {
long long value = get_uint64();
printf(" lsn=%lld", value);
}
void transcribe_txnid (void) {
static void transcribe_txnid (void) {
long long value = get_uint64();
printf(" txnid=%lld", value);
}
void transcribe_fileid (void) {
static void transcribe_fileid (void) {
u_int32_t value = get_uint32();
printf(" fileid=%d", value);
}
void transcribe_diskoff (void) {
static void transcribe_diskoff (void) {
long long value = get_uint64();
printf(" diskoff=%lld", value);
}
void transcribe_crc32 (void) {
static void transcribe_crc32 (void) {
u_int32_t oldcrc=crc;
u_int32_t l = get_uint32();
printf(" crc=%08x", l);
assert(l==oldcrc);
}
void transcribe_mode (void) {
static void transcribe_mode (void) {
u_int32_t value = get_uint32();
printf(" mode=0%o", value);
}
void transcribe_filenum(void) {
static void transcribe_filenum(void) {
u_int32_t value = get_uint32();
printf(" filenum=%d", value);
}
u_int32_t len1;
void transcribe_len1 (void) {
static u_int32_t len1;
static void transcribe_len1 (void) {
len1 = get_uint32();
//printf(" len=%d", len1);
}
void transcribe_len (void) {
static void transcribe_len (void) {
u_int32_t l = get_uint32();
printf(" len=%d", l);
if (l!=actual_len) printf(" actual_len=%d", actual_len);
......@@ -96,8 +96,7 @@ void transcribe_len (void) {
assert(len1==actual_len);
}
void transcribe_key_or_data (char *what) {
static void transcribe_key_or_data (char *what) {
u_int32_t l = get_uint32();
unsigned int i;
printf(" %s(%d):\"", what, l);
......@@ -113,7 +112,7 @@ void transcribe_key_or_data (char *what) {
printf("\"");
}
void transcribe_header (void) {
static void transcribe_header (void) {
printf(" {size=%d", get_uint32());
printf(" flags=%d", get_uint32());
printf(" nodesize=%d", get_uint32());
......@@ -128,6 +127,7 @@ void transcribe_header (void) {
}
printf("}");
}
#endif
static void newmain (int count) {
int i;
......
......@@ -8,19 +8,19 @@
#include <assert.h>
#include <string.h>
void ybt_test0 (void) {
static void ybt_test0 (void) {
void *v0=0,*v1=0;
DBT t0,t1;
init_dbt(&t0);
init_dbt(&t1);
ybt_set_value(&t0, "hello", 6, &v0);
ybt_set_value(&t1, "foo", 4, &v1);
toku_init_dbt(&t0);
toku_init_dbt(&t1);
toku_dbt_set_value(&t0, "hello", 6, &v0);
toku_dbt_set_value(&t1, "foo", 4, &v1);
assert(t0.size==6);
assert(strcmp(t0.data, "hello")==0);
assert(t1.size==4);
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
// at the wrong place
//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();
/* 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.ulen = 0;
ybt_set_value(&t0, "hello", 6, 0);
toku_dbt_set_value(&t0, "hello", 6, 0);
assert(t0.data==0);
assert(t0.size==6);
/* Check realloc. */
init_dbt(&t0);
toku_init_dbt(&t0);
t0.flags = DB_DBT_REALLOC;
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(t0.size==21);
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(strcmp(t0.data, "provincial")==0);
......
......@@ -4,19 +4,19 @@
#include <errno.h>
#include <string.h>
DBT *init_dbt (DBT *ybt) {
DBT *toku_init_dbt (DBT *ybt) {
memset(ybt, 0, sizeof(*ybt));
return ybt;
}
DBT *fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) {
init_dbt(dbt);
DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len) {
toku_init_dbt(dbt);
dbt->size=len;
dbt->data=(char*)k;
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) {
domalloc:
ybt->data = toku_malloc(vallen);
......
......@@ -8,9 +8,9 @@
#include "../include/db.h"
DBT* init_dbt (DBT *);
DBT *fill_dbt(DBT *dbt, bytevec k, ITEMLEN len);
int ybt_set_value (DBT *, bytevec val, ITEMLEN vallen, void **staticptrp);
DBT* toku_init_dbt (DBT *);
DBT *toku_fill_dbt(DBT *dbt, bytevec k, ITEMLEN len);
int toku_dbt_set_value (DBT *, bytevec val, ITEMLEN vallen, void **staticptrp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment