Commit d7288dff authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make all external symbols in cachefile.o be start with toku_. Addresses #8

git-svn-id: file:///svn/tokudb@674 c7de825b-a66e-492c-adef-691d508d4ae1
parent f1b088cb
...@@ -37,7 +37,7 @@ void setup (void) { ...@@ -37,7 +37,7 @@ void setup (void) {
void shutdown (void) { void shutdown (void) {
int r; int r;
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
void long_long_to_array (unsigned char *a, unsigned long long l) { void long_long_to_array (unsigned char *a, unsigned long long l) {
int i; int i;
...@@ -53,7 +53,7 @@ void insert (long long v) { ...@@ -53,7 +53,7 @@ void insert (long long v) {
memset(vc, 0, sizeof vc); memset(vc, 0, sizeof vc);
long_long_to_array(vc, v); long_long_to_array(vc, v);
brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0, 0); brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0, 0);
if (do_verify) cachetable_verify(ct); if (do_verify) toku_cachetable_verify(ct);
} }
void serial_insert_from (long long from) { void serial_insert_from (long long from) {
......
This diff is collapsed.
...@@ -58,8 +58,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve ...@@ -58,8 +58,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve
BRTNODE node; BRTNODE node;
void *node_v; void *node_v;
int r; int r;
if ((r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, if ((r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, (void*)(long)brt->h->nodesize))) brtnode_flush_callback, brtnode_fetch_callback, (void*)(long)brt->h->nodesize)))
return r; return r;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
node=node_v; node=node_v;
...@@ -116,7 +116,7 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve ...@@ -116,7 +116,7 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve
} }
} }
} }
if ((r = cachetable_unpin(brt->cf, off, 0, 0))) return r; if ((r = toku_cachetable_unpin(brt->cf, off, 0, 0))) return r;
return result; return result;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -67,7 +67,7 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)), ...@@ -67,7 +67,7 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)),
LSN modified_lsn __attribute__((__unused__)), LSN modified_lsn __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))) { BOOL rename_p __attribute__((__unused__))) {
int *v = value; int *v = value;
//cachetable_print_state(ct); //toku_cachetable_print_state(ct);
//printf("Flush %lld %d\n", key, (int)value); //printf("Flush %lld %d\n", key, (int)value);
assert((long)v==(long)key); assert((long)v==(long)key);
item_becomes_not_present(f, key); item_becomes_not_present(f, key);
...@@ -86,10 +86,10 @@ void verify_cachetable_against_present (void) { ...@@ -86,10 +86,10 @@ void verify_cachetable_against_present (void) {
for (i=0; i<n_present; i++) { for (i=0; i<n_present; i++) {
void *v; void *v;
int r; int r;
assert(cachetable_maybe_get_and_pin(present_items[i].cf, assert(toku_cachetable_maybe_get_and_pin(present_items[i].cf,
present_items[i].key, present_items[i].key,
&v)==0); &v)==0);
r = cachetable_unpin(present_items[i].cf, present_items[i].key, CACHETABLE_CLEAN, test_object_size); r = toku_cachetable_unpin(present_items[i].cf, present_items[i].key, CACHETABLE_CLEAN, test_object_size);
} }
} }
...@@ -101,19 +101,19 @@ void test_chaining (void) { ...@@ -101,19 +101,19 @@ void test_chaining (void) {
char fname[N_FILES][FILENAME_LEN]; char fname[N_FILES][FILENAME_LEN];
int r; int r;
long i, trial; long i, trial;
r = create_cachetable(&ct, N_PRESENT_LIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_create_cachetable(&ct, N_PRESENT_LIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<N_FILES; i++) { for (i=0; i<N_FILES; i++) {
r = snprintf(fname[i], FILENAME_LEN, "cachetabletest2.%ld.dat", i); r = snprintf(fname[i], FILENAME_LEN, "cachetabletest2.%ld.dat", i);
assert(r>0 && r<FILENAME_LEN); assert(r>0 && r<FILENAME_LEN);
unlink(fname[i]); unlink(fname[i]);
r = cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, 0777); assert(r==0); r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, 0777); assert(r==0);
} }
for (i=0; i<N_PRESENT_LIMIT; i++) { for (i=0; i<N_PRESENT_LIMIT; i++) {
int fnum = i%N_FILES; int fnum = i%N_FILES;
//printf("%s:%d Add %d\n", __FILE__, __LINE__, i); //printf("%s:%d Add %d\n", __FILE__, __LINE__, i);
r = cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0); r = toku_cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0);
item_becomes_present(f[fnum], i); item_becomes_present(f[fnum], i);
r = cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0); r = toku_cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0);
//print_ints(); //print_ints();
} }
for (trial=0; trial<TRIALS; trial++) { for (trial=0; trial<TRIALS; trial++) {
...@@ -122,18 +122,18 @@ void test_chaining (void) { ...@@ -122,18 +122,18 @@ void test_chaining (void) {
int whichone = random()%n_present; int whichone = random()%n_present;
void *value; void *value;
//printf("Touching %d (%lld, %p)\n", whichone, present_items[whichone].key, present_items[whichone].cf); //printf("Touching %d (%lld, %p)\n", whichone, present_items[whichone].key, present_items[whichone].cf);
r = cachetable_get_and_pin(present_items[whichone].cf, r = toku_cachetable_get_and_pin(present_items[whichone].cf,
present_items[whichone].key, present_items[whichone].key,
&value, &value,
NULL, NULL,
flush_forchain, flush_forchain,
fetch_forchain, fetch_forchain,
(void*)(long)present_items[whichone].key (void*)(long)present_items[whichone].key
); );
assert(r==0); assert(r==0);
r = cachetable_unpin(present_items[whichone].cf, r = toku_cachetable_unpin(present_items[whichone].cf,
present_items[whichone].key, present_items[whichone].key,
CACHETABLE_CLEAN, test_object_size); CACHETABLE_CLEAN, test_object_size);
assert(r==0); assert(r==0);
} }
...@@ -141,11 +141,11 @@ void test_chaining (void) { ...@@ -141,11 +141,11 @@ void test_chaining (void) {
int fnum = i%N_FILES; int fnum = i%N_FILES;
// i is always incrementing, so we need not worry about inserting a duplicate // i is always incrementing, so we need not worry about inserting a duplicate
//printf("%s:%d Add {%d,%p}\n", __FILE__, __LINE__, i, f[fnum]); //printf("%s:%d Add {%d,%p}\n", __FILE__, __LINE__, i, f[fnum]);
r = cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0); r = toku_cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0);
item_becomes_present(f[fnum], i); item_becomes_present(f[fnum], i);
//print_ints(); //print_ints();
//cachetable_print_state(ct); //cachetable_print_state(ct);
r = cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0); r = toku_cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0);
verify_cachetable_against_present(); verify_cachetable_against_present();
if (random()%10==0) { if (random()%10==0) {
...@@ -153,15 +153,15 @@ void test_chaining (void) { ...@@ -153,15 +153,15 @@ void test_chaining (void) {
//printf("Close %d (%p), now n_present=%d\n", i, f[i], n_present); //printf("Close %d (%p), now n_present=%d\n", i, f[i], n_present);
//print_ints(); //print_ints();
CACHEFILE oldcf=f[i]; CACHEFILE oldcf=f[i];
r = cachefile_close(&f[i]); assert(r==0); r = toku_cachefile_close(&f[i]); assert(r==0);
file_is_not_present(oldcf); file_is_not_present(oldcf);
r = cachetable_openf(&f[i], ct, fname[i], O_RDWR, 0777); assert(r==0); r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR, 0777); assert(r==0);
} }
} }
for (i=0; i<N_FILES; i++) { for (i=0; i<N_FILES; i++) {
r = cachefile_close(&f[i]); assert(r==0); r = toku_cachefile_close(&f[i]); assert(r==0);
} }
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
......
...@@ -65,7 +65,7 @@ struct cachefile { ...@@ -65,7 +65,7 @@ struct cachefile {
FILENUM filenum; FILENUM filenum;
}; };
int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER logger) { int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER logger) {
TAGMALLOC(CACHETABLE, t); TAGMALLOC(CACHETABLE, t);
int i; int i;
t->n_in_table = 0; t->n_in_table = 0;
...@@ -86,7 +86,7 @@ int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKU ...@@ -86,7 +86,7 @@ int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKU
return 0; return 0;
} }
static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) { int toku_cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) {
int r; int r;
CACHEFILE extant; CACHEFILE extant;
struct stat statbuf; struct stat statbuf;
...@@ -118,13 +118,13 @@ static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) { ...@@ -118,13 +118,13 @@ static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) {
} }
} }
int cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) { int toku_cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) {
int fd = open(fname, flags, mode); int fd = open(fname, flags, mode);
if (fd<0) return errno; if (fd<0) return errno;
return cachetable_openfd (cf, t, fd); return toku_cachetable_openfd (cf, t, fd);
} }
CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) { static CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) {
if (list==0) return 0; if (list==0) return 0;
else if (list==cf) { else if (list==cf) {
return list->next; return list->next;
...@@ -136,7 +136,7 @@ CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) { ...@@ -136,7 +136,7 @@ CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) {
static int cachefile_flush_and_remove (CACHEFILE cf); static int cachefile_flush_and_remove (CACHEFILE cf);
int cachefile_close (CACHEFILE *cfp) { int toku_cachefile_close (CACHEFILE *cfp) {
CACHEFILE cf = *cfp; CACHEFILE cf = *cfp;
assert(cf->refcount>0); assert(cf->refcount>0);
cf->refcount--; cf->refcount--;
...@@ -156,7 +156,7 @@ int cachefile_close (CACHEFILE *cfp) { ...@@ -156,7 +156,7 @@ int cachefile_close (CACHEFILE *cfp) {
} }
} }
int cachetable_assert_all_unpinned (CACHETABLE t) { int toku_cachetable_assert_all_unpinned (CACHETABLE t) {
int i; int i;
int some_pinned=0; int some_pinned=0;
for (i=0; i<t->table_size; i++) { for (i=0; i<t->table_size; i++) {
...@@ -172,7 +172,7 @@ int cachetable_assert_all_unpinned (CACHETABLE t) { ...@@ -172,7 +172,7 @@ int cachetable_assert_all_unpinned (CACHETABLE t) {
return some_pinned; return some_pinned;
} }
int cachefile_count_pinned (CACHEFILE cf, int print_them) { int toku_cachefile_count_pinned (CACHEFILE cf, int print_them) {
int i; int i;
int n_pinned=0; int n_pinned=0;
CACHETABLE t = cf->cachetable; CACHETABLE t = cf->cachetable;
...@@ -189,11 +189,13 @@ int cachefile_count_pinned (CACHEFILE cf, int print_them) { ...@@ -189,11 +189,13 @@ int cachefile_count_pinned (CACHEFILE cf, int print_them) {
return n_pinned; return n_pinned;
} }
#if 0
unsigned int ct_hash_longlong (unsigned long long l) { unsigned int ct_hash_longlong (unsigned long long l) {
unsigned int r = hash_key((unsigned char*)&l, 8); unsigned int r = hash_key((unsigned char*)&l, 8);
printf("%lld --> %d --> %d\n", l, r, r%64); printf("%lld --> %d --> %d\n", l, r, r%64);
return r; return r;
} }
#endif
static unsigned int hashit (CACHETABLE t, CACHEKEY key) { static unsigned int hashit (CACHETABLE t, CACHEKEY key) {
return hash_key((unsigned char*)&key, sizeof(key))%t->table_size; return hash_key((unsigned char*)&key, sizeof(key))%t->table_size;
...@@ -353,7 +355,7 @@ static int cachetable_insert_at(CACHEFILE cachefile, int h, CACHEKEY key, void * ...@@ -353,7 +355,7 @@ static int cachetable_insert_at(CACHEFILE cachefile, int h, CACHEKEY key, void *
return 0; return 0;
} }
int cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size, int toku_cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) { cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) {
WHEN_TRACE_CT(printf("%s:%d CT cachetable_put(%lld)=%p\n", __FILE__, __LINE__, key, value)); WHEN_TRACE_CT(printf("%s:%d CT cachetable_put(%lld)=%p\n", __FILE__, __LINE__, key, value));
{ {
...@@ -375,7 +377,7 @@ int cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size, ...@@ -375,7 +377,7 @@ int cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size,
return r; return r;
} }
int cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long *sizep, int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long *sizep,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) { cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
int tsize __attribute__((__unused__)) = t->table_size; int tsize __attribute__((__unused__)) = t->table_size;
...@@ -410,7 +412,7 @@ int cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long ...@@ -410,7 +412,7 @@ int cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long
return 0; return 0;
} }
int cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value) { int toku_cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR p; PAIR p;
for (p=t->table[hashit(t,key)]; p; p=p->hash_chain) { for (p=t->table[hashit(t,key)]; p; p=p->hash_chain) {
...@@ -426,7 +428,7 @@ int cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value ...@@ -426,7 +428,7 @@ int cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value
} }
int cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) { int toku_cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR p; PAIR p;
WHEN_TRACE_CT(printf("%s:%d unpin(%lld)", __FILE__, __LINE__, key)); WHEN_TRACE_CT(printf("%s:%d unpin(%lld)", __FILE__, __LINE__, key));
...@@ -450,7 +452,7 @@ int cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) { ...@@ -450,7 +452,7 @@ int cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) {
// effect: Move an object from one key to another key. // effect: Move an object from one key to another key.
// requires: The object is pinned in the table // requires: The object is pinned in the table
int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) { int toku_cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR *ptr_to_p,p; PAIR *ptr_to_p,p;
for (ptr_to_p = &t->table[hashit(t, oldkey)], p = *ptr_to_p; for (ptr_to_p = &t->table[hashit(t, oldkey)], p = *ptr_to_p;
...@@ -468,7 +470,7 @@ int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) { ...@@ -468,7 +470,7 @@ int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) {
return -1; return -1;
} }
int cachetable_flush (CACHETABLE t) { static int cachetable_flush (CACHETABLE t) {
int i; int i;
for (i=0; i<t->table_size; i++) { for (i=0; i<t->table_size; i++) {
PAIR p; PAIR p;
...@@ -478,11 +480,11 @@ int cachetable_flush (CACHETABLE t) { ...@@ -478,11 +480,11 @@ int cachetable_flush (CACHETABLE t) {
return 0; return 0;
} }
void cachefile_verify (CACHEFILE cf) { void toku_cachefile_verify (CACHEFILE cf) {
cachetable_verify(cf->cachetable); toku_cachetable_verify(cf->cachetable);
} }
void cachetable_verify (CACHETABLE t) { void toku_cachetable_verify (CACHETABLE t) {
// First clear all the verify flags by going through the hash chains // First clear all the verify flags by going through the hash chains
{ {
int i; int i;
...@@ -569,7 +571,7 @@ static int cachefile_flush_and_remove (CACHEFILE cf) { ...@@ -569,7 +571,7 @@ static int cachefile_flush_and_remove (CACHEFILE cf) {
} }
/* Require that it all be flushed. */ /* Require that it all be flushed. */
int cachetable_close (CACHETABLE *tp) { int toku_cachetable_close (CACHETABLE *tp) {
CACHETABLE t=*tp; CACHETABLE t=*tp;
int i; int i;
int r; int r;
...@@ -583,7 +585,7 @@ int cachetable_close (CACHETABLE *tp) { ...@@ -583,7 +585,7 @@ int cachetable_close (CACHETABLE *tp) {
return 0; return 0;
} }
int cachetable_remove (CACHEFILE cachefile, CACHEKEY key, int write_me) { int toku_cachetable_remove (CACHEFILE cachefile, CACHEKEY key, int write_me) {
/* Removing something already present is OK. */ /* Removing something already present is OK. */
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR p; PAIR p;
...@@ -644,13 +646,13 @@ int cachefile_pread (CACHEFILE cf, void *buf, size_t count, off_t offset) { ...@@ -644,13 +646,13 @@ int cachefile_pread (CACHEFILE cf, void *buf, size_t count, off_t offset) {
} }
#endif #endif
int cachefile_fd (CACHEFILE cf) { int toku_cachefile_fd (CACHEFILE cf) {
return cf->fd; return cf->fd;
} }
/* debug functions */ /* debug functions */
void cachetable_print_state (CACHETABLE ct) { void toku_cachetable_print_state (CACHETABLE ct) {
int i; int i;
for (i=0; i<ct->table_size; i++) { for (i=0; i<ct->table_size; i++) {
PAIR p = ct->table[i]; PAIR p = ct->table[i];
...@@ -664,7 +666,7 @@ int cachefile_fd (CACHEFILE cf) { ...@@ -664,7 +666,7 @@ int cachefile_fd (CACHEFILE cf) {
} }
} }
void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr) { void toku_cachetable_get_state (CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr) {
if (num_entries_ptr) if (num_entries_ptr)
*num_entries_ptr = ct->n_in_table; *num_entries_ptr = ct->n_in_table;
if (hash_size_ptr) if (hash_size_ptr)
...@@ -675,8 +677,8 @@ void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_pt ...@@ -675,8 +677,8 @@ void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_pt
*size_limit_ptr = ct->size_limit; *size_limit_ptr = ct->size_limit;
} }
int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr, int toku_cachetable_get_key_state (CACHETABLE ct, CACHEKEY key, void **value_ptr,
int *dirty_ptr, long long *pin_ptr, long *size_ptr) { int *dirty_ptr, long long *pin_ptr, long *size_ptr) {
PAIR p; PAIR p;
for (p = ct->table[hashit(ct, key)]; p; p = p->hash_chain) { for (p = ct->table[hashit(ct, key)]; p; p = p->hash_chain) {
if (p->key == key) { if (p->key == key) {
...@@ -694,7 +696,7 @@ int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr, ...@@ -694,7 +696,7 @@ int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr,
return 1; return 1;
} }
int cachetable_checkpoint (CACHETABLE ct) { int toku_cachetable_checkpoint (CACHETABLE ct) {
// Single threaded checkpoint. // Single threaded checkpoint.
// In future: for multithreaded checkpoint we should not proceed if the previous checkpoint has not finished. // In future: for multithreaded checkpoint we should not proceed if the previous checkpoint has not finished.
// Requires: Everything is unpinned. (In the multithreaded version we have to wait for things to get unpinned and then // Requires: Everything is unpinned. (In the multithreaded version we have to wait for things to get unpinned and then
...@@ -737,10 +739,10 @@ int cachetable_checkpoint (CACHETABLE ct) { ...@@ -737,10 +739,10 @@ int cachetable_checkpoint (CACHETABLE ct) {
return 0; return 0;
} }
TOKULOGGER cachefile_logger (CACHEFILE cf) { TOKULOGGER toku_cachefile_logger (CACHEFILE cf) {
return cf->cachetable->logger; return cf->cachetable->logger;
} }
FILENUM cachefile_filenum (CACHEFILE cf) { FILENUM toku_cachefile_filenum (CACHEFILE cf) {
return cf->filenum; return cf->filenum;
} }
...@@ -23,9 +23,10 @@ typedef struct cachefile *CACHEFILE; ...@@ -23,9 +23,10 @@ typedef struct cachefile *CACHEFILE;
* table_size is the initial size of the cache table hash table (in number of entries) * table_size is the initial size of the cache table hash table (in number of entries)
* size limit is the upper bound of the sum of size of the entries in the cache table (total number of bytes) * size limit is the upper bound of the sum of size of the entries in the cache table (total number of bytes)
*/ */
int create_cachetable(CACHETABLE */*result*/, long size_limit, LSN initial_lsn, TOKULOGGER); int toku_create_cachetable(CACHETABLE */*result*/, long size_limit, LSN initial_lsn, TOKULOGGER);
int cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname*/, int flags, mode_t mode); int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname*/, int flags, mode_t mode);
int toku_cachetable_openfd (CACHEFILE *,CACHETABLE, int /*fd*/);
typedef void (cachetable_flush_func_t)(CACHEFILE, CACHEKEY key, void*value, long size, BOOL write_me, BOOL keep_me, LSN modified_lsn, BOOL rename_p); typedef void (cachetable_flush_func_t)(CACHEFILE, CACHEKEY key, void*value, long size, BOOL write_me, BOOL keep_me, LSN modified_lsn, BOOL rename_p);
typedef cachetable_flush_func_t *CACHETABLE_FLUSH_FUNC_T; typedef cachetable_flush_func_t *CACHETABLE_FLUSH_FUNC_T;
...@@ -35,50 +36,50 @@ typedef int (cachetable_fetch_func_t)(CACHEFILE, CACHEKEY key, void **value, lon ...@@ -35,50 +36,50 @@ typedef int (cachetable_fetch_func_t)(CACHEFILE, CACHEKEY key, void **value, lon
typedef cachetable_fetch_func_t *CACHETABLE_FETCH_FUNC_T; typedef cachetable_fetch_func_t *CACHETABLE_FETCH_FUNC_T;
/* Error if already present. On success, pin the value. */ /* Error if already present. On success, pin the value. */
int cachetable_put(CACHEFILE cf, CACHEKEY key, void* value, long size, int toku_cachetable_put(CACHEFILE cf, CACHEKEY key, void* value, long size,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs); cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs);
int cachetable_get_and_pin(CACHEFILE, CACHEKEY, void**/*value*/, long *sizep, int toku_cachetable_get_and_pin(CACHEFILE, CACHEKEY, void**/*value*/, long *sizep,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs); cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs);
/* If the the item is already in memory, then return 0 and store it in the void**. /* If the the item is already in memory, then return 0 and store it in the void**.
* If the item is not in memory, then return nonzero. */ * If the item is not in memory, then return nonzero. */
int cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, void**); int toku_cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, void**);
/* cachetable object state wrt external memory */ /* cachetable object state wrt external memory */
#define CACHETABLE_CLEAN 0 #define CACHETABLE_CLEAN 0
#define CACHETABLE_DIRTY 1 #define CACHETABLE_DIRTY 1
int cachetable_unpin(CACHEFILE, CACHEKEY, int dirty, long size); /* Note whether it is dirty when we unpin it. */ int toku_cachetable_unpin(CACHEFILE, CACHEKEY, int dirty, long size); /* Note whether it is dirty when we unpin it. */
int cachetable_remove (CACHEFILE, CACHEKEY, int /*write_me*/); /* Removing something already present is OK. */ int toku_cachetable_remove (CACHEFILE, CACHEKEY, int /*write_me*/); /* Removing something already present is OK. */
int cachetable_assert_all_unpinned (CACHETABLE); int toku_cachetable_assert_all_unpinned (CACHETABLE);
int cachefile_count_pinned (CACHEFILE, int /*printthem*/ ); int toku_cachefile_count_pinned (CACHEFILE, int /*printthem*/ );
/* Rename whatever is at oldkey to be newkey. Requires that the object be pinned. */ /* Rename whatever is at oldkey to be newkey. Requires that the object be pinned. */
int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey); int toku_cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey);
//int cachetable_fsync_all (CACHETABLE); /* Flush everything to disk, but keep it in cache. */ //int cachetable_fsync_all (CACHETABLE); /* Flush everything to disk, but keep it in cache. */
int cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */ int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */
int cachefile_close (CACHEFILE*); int toku_cachefile_close (CACHEFILE*);
//int cachefile_flush (CACHEFILE); /* Flush everything related to the VOID* to disk and free all memory. Don't destroy the cachetable. */ //int cachefile_flush (CACHEFILE); /* Flush everything related to the VOID* to disk and free all memory. Don't destroy the cachetable. */
// Return on success (different from pread and pwrite) // Return on success (different from pread and pwrite)
//int cachefile_pwrite (CACHEFILE, const void *buf, size_t count, off_t offset); //int cachefile_pwrite (CACHEFILE, const void *buf, size_t count, off_t offset);
//int cachefile_pread (CACHEFILE, void *buf, size_t count, off_t offset); //int cachefile_pread (CACHEFILE, void *buf, size_t count, off_t offset);
int cachefile_fd (CACHEFILE); int toku_cachefile_fd (CACHEFILE);
// Useful for debugging // Useful for debugging
void cachetable_print_state (CACHETABLE ct); void toku_cachetable_print_state (CACHETABLE ct);
void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr); void toku_cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr);
int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr, int toku_cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr,
int *dirty_ptr, long long *pin_ptr, long *size_ptr); int *dirty_ptr, long long *pin_ptr, long *size_ptr);
void cachefile_verify (CACHEFILE cf); // Verify the whole cachetable that the CF is in. Slow. void toku_cachefile_verify (CACHEFILE cf); // Verify the whole cachetable that the CF is in. Slow.
void cachetable_verify (CACHETABLE t); // Slow... void toku_cachetable_verify (CACHETABLE t); // Slow...
TOKULOGGER cachefile_logger (CACHEFILE); TOKULOGGER toku_cachefile_logger (CACHEFILE);
FILENUM cachefile_filenum (CACHEFILE); FILENUM toku_cachefile_filenum (CACHEFILE);
#endif #endif
...@@ -21,10 +21,10 @@ int tokulogger_find_next_unused_log_file(const char *directory, long long *resul ...@@ -21,10 +21,10 @@ int tokulogger_find_next_unused_log_file(const char *directory, long long *resul
enum { enum {
LT_COMMIT = 'C', LT_COMMIT = 'C',
LT_DELETE = 'D', LT_DELETE = 'D',
LT_FCREATE = 'F',
LT_INSERT_WITH_NO_OVERWRITE = 'I', LT_INSERT_WITH_NO_OVERWRITE = 'I',
LT_CHECKPOINT = 'P', LT_CHECKPOINT = 'P',
LT_BLOCK_RENAME = 'R', LT_BLOCK_RENAME = 'R',
LT_FCREATE_TMP = 'T',
LT_UNLINK = 'U' LT_UNLINK = 'U'
}; };
......
...@@ -263,7 +263,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd ...@@ -263,7 +263,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd
return tokulogger_finish(logger, &wbuf); return tokulogger_finish(logger, &wbuf);
} }
int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) { int tokulogger_log_fcreate (TOKUTXN txn, const char *fname, int mode) {
if (txn==0) return 0; if (txn==0) return 0;
const int fnamelen = strlen(fname); const int fnamelen = strlen(fname);
const int buflen = (+1 // log command const int buflen = (+1 // log command
...@@ -275,7 +275,7 @@ int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) { ...@@ -275,7 +275,7 @@ int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) {
unsigned char buf[buflen]; unsigned char buf[buflen];
struct wbuf wbuf; struct wbuf wbuf;
wbuf_init (&wbuf, buf, buflen); wbuf_init (&wbuf, buf, buflen);
wbuf_char (&wbuf, LT_FCREATE_TMP); wbuf_char (&wbuf, LT_FCREATE);
wbuf_bytes(&wbuf, fname, fnamelen); wbuf_bytes(&wbuf, fname, fnamelen);
wbuf_int (&wbuf, mode); wbuf_int (&wbuf, mode);
return tokulogger_finish(txn->logger, &wbuf); return tokulogger_finish(txn->logger, &wbuf);
......
...@@ -16,7 +16,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd ...@@ -16,7 +16,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd
int tokutxn_begin (TOKUTXN /*parent*/,TOKUTXN *, TXNID txnid64, TOKULOGGER logger); int tokutxn_begin (TOKUTXN /*parent*/,TOKUTXN *, TXNID txnid64, TOKULOGGER logger);
int tokulogger_log_fcreate_tmp (TOKUTXN, const char */*fname*/, int /*mode*/); int tokulogger_log_fcreate (TOKUTXN, const char */*fname*/, int /*mode*/);
int tokulogger_log_unlink (TOKUTXN, const char */*fname*/); int tokulogger_log_unlink (TOKUTXN, const char */*fname*/);
......
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