From 6f82ae268a14bed6c25f749b6d20846fc0dc7c50 Mon Sep 17 00:00:00 2001 From: sears Date: Thu, 9 Jun 2011 01:16:55 +0000 Subject: [PATCH] remove more template stuff git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@2668 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe --- logserver.cpp | 2 +- logserver.h | 6 ++-- logstore.cpp | 76 +++++++++++++++------------------------ logstore.h | 59 +++++++++++++++--------------- mergeManager.cpp | 6 ++-- mergeManager.h | 7 ++-- merger.cpp | 10 +++--- merger.h | 5 ++- newserver.cpp | 6 ++-- requestDispatch.cpp | 36 +++++++++---------- requestDispatch.h | 32 ++++++++--------- server.cpp | 6 ++-- simpleServer.cpp | 2 +- simpleServer.h | 4 +-- test/check_datapage.cpp | 8 ++--- test/check_gen.cpp | 6 ++-- test/check_logtable.cpp | 4 +-- test/check_logtree.cpp | 4 +-- test/check_merge.cpp | 6 ++-- test/check_mergelarge.cpp | 6 ++-- test/check_mergetuple.cpp | 6 ++-- test/check_testAndSet.cpp | 8 ++--- 22 files changed, 142 insertions(+), 163 deletions(-) diff --git a/logserver.cpp b/logserver.cpp index 1c4c854..06a70bd 100644 --- a/logserver.cpp +++ b/logserver.cpp @@ -19,7 +19,7 @@ #include void *serverLoop(void *args); -void logserver::startserver(logtable *ltable) +void logserver::startserver(logtable *ltable) { sys_alive = true; this->ltable = ltable; diff --git a/logserver.h b/logserver.h index 6125986..fb688fc 100644 --- a/logserver.h +++ b/logserver.h @@ -39,7 +39,7 @@ struct pthread_data { int *workitem; //id of the socket to work - logtable *ltable; + logtable *ltable; bool *sys_alive; #ifdef STATS_ENABLED @@ -97,7 +97,7 @@ public: delete qlock; } - void startserver(logtable *ltable); + void startserver(logtable *ltable); void stopserver(); @@ -126,7 +126,7 @@ private: int * self_pipe; // write a byte to self_pipe[1] to wake up select(). std::vector th_list; // list of threads - logtable *ltable; + logtable *ltable; #ifdef STATS_ENABLED int num_reqs; diff --git a/logstore.cpp b/logstore.cpp index 82c31ef..37f21cd 100644 --- a/logstore.cpp +++ b/logstore.cpp @@ -22,8 +22,7 @@ static inline double tv_to_double(struct timeval tv) // LOG TABLE IMPLEMENTATION ///////////////////////////////////////////////////////////////// -template -logtable::logtable(int log_mode, pageid_t max_c0_size, pageid_t internal_region_size, pageid_t datapage_region_size, pageid_t datapage_size) +logtable::logtable(int log_mode, pageid_t max_c0_size, pageid_t internal_region_size, pageid_t datapage_region_size, pageid_t datapage_size) { recovering = true; this->max_c0_size = max_c0_size; @@ -68,8 +67,7 @@ logtable::logtable(int log_mode, pageid_t max_c0_size, pageid_t internal_ stasis_log_file_permissions); } -template -logtable::~logtable() +logtable::~logtable() { delete merge_mgr; // shuts down pretty print thread. @@ -94,8 +92,7 @@ logtable::~logtable() delete tmerger; } -template -void logtable::init_stasis() { +void logtable::init_stasis() { DataPage::register_stasis_page_impl(); stasis_buffer_manager_hint_writes_are_sequential = 1; @@ -103,11 +100,9 @@ void logtable::init_stasis() { } -template -void logtable::deinit_stasis() { Tdeinit(); } +void logtable::deinit_stasis() { Tdeinit(); } -template -recordid logtable::allocTable(int xid) +recordid logtable::allocTable(int xid) { table_rec = Talloc(xid, sizeof(tbl_header)); mergeStats * stats = 0; @@ -128,8 +123,8 @@ recordid logtable::allocTable(int xid) return table_rec; } -template -void logtable::openTable(int xid, recordid rid) { + +void logtable::openTable(int xid, recordid rid) { table_rec = rid; Tread(xid, table_rec, &tbl_header); tree_c2 = new diskTreeComponent(xid, tbl_header.c2_root, tbl_header.c2_state, tbl_header.c2_dp_state, 0); @@ -143,16 +138,14 @@ void logtable::openTable(int xid, recordid rid) { } -template -void logtable::logUpdate(datatuple * tup) { +void logtable::logUpdate(datatuple * tup) { byte * buf = tup->to_bytes(); LogEntry * e = stasis_log_write_update(log_file, 0, INVALID_PAGE, 0/*Page**/, 0/*op*/, buf, tup->byte_length()); log_file->write_entry_done(log_file,e); free(buf); } -template -void logtable::replayLog() { +void logtable::replayLog() { lsn_t start = tbl_header.log_trunc; LogHandle * lh = start ? getLSNHandle(log_file, start) : getLogHandle(log_file); const LogEntry * e; @@ -173,13 +166,12 @@ void logtable::replayLog() { } -template -lsn_t logtable::get_log_offset() { +lsn_t logtable::get_log_offset() { if(recovering || !log_mode) { return INVALID_LSN; } return log_file->next_available_lsn(log_file); } -template -void logtable::truncate_log() { + +void logtable::truncate_log() { if(recovering) { printf("Not truncating log until recovery is complete.\n"); } else { @@ -190,8 +182,7 @@ void logtable::truncate_log() { } } -template -void logtable::update_persistent_header(int xid, lsn_t trunc_lsn) { +void logtable::update_persistent_header(int xid, lsn_t trunc_lsn) { tbl_header.c2_root = tree_c2->get_root_rid(); tbl_header.c2_dp_state = tree_c2->get_datapage_allocator_rid(); @@ -210,8 +201,7 @@ void logtable::update_persistent_header(int xid, lsn_t trunc_lsn) { Tset(xid, table_rec, &tbl_header); } -template -void logtable::flushTable() +void logtable::flushTable() { struct timeval start_tv, stop_tv; double start, stop; @@ -269,8 +259,7 @@ void logtable::flushTable() c0_flushing = false; } -template -datatuple * logtable::findTuple(int xid, const datatuple::key_t key, size_t keySize) +datatuple * logtable::findTuple(int xid, const datatuple::key_t key, size_t keySize) { //prepare a search tuple datatuple *search_tuple = datatuple::create(key, keySize); @@ -450,8 +439,7 @@ datatuple * logtable::findTuple(int xid, const datatuple::key_t key, size * returns the first record found with the matching key * (not to be used together with diffs) **/ -template -datatuple * logtable::findTuple_first(int xid, datatuple::key_t key, size_t keySize) +datatuple * logtable::findTuple_first(int xid, datatuple::key_t key, size_t keySize) { //prepare a search tuple datatuple * search_tuple = datatuple::create(key, keySize); @@ -545,9 +533,7 @@ datatuple * logtable::findTuple_first(int xid, datatuple::key_t key, size } - -template -datatuple * logtable::insertTupleHelper(datatuple *tuple) +datatuple * logtable::insertTupleHelper(datatuple *tuple) { bool need_free = false; if(!tuple->isDelete() && expiry != 0) { @@ -560,10 +546,10 @@ datatuple * logtable::insertTupleHelper(datatuple *tuple) memcpy(newkey, tuple->strippedkey(), kl); newkey[kl] = 0; memcpy(newkey+kl+1, &ts, ts_sz); - TUPLE * old = tuple; + datatuple * old = tuple; tuple = datatuple::create(newkey, kl+ 1+ ts_sz, tuple->data(), tuple->datalen()); assert(tuple->strippedkeylen() == old->strippedkeylen()); - assert(!TUPLE::compare_obj(tuple, old)); + assert(!datatuple::compare_obj(tuple, old)); free(newkey); need_free = true; } //find the previous tuple with same key in the memtree if exists @@ -590,12 +576,12 @@ datatuple * logtable::insertTupleHelper(datatuple *tuple) tree_c0->insert(t); } - if(need_free) { TUPLE::freetuple(tuple); } + if(need_free) { datatuple::freetuple(tuple); } return pre_t; } -template -void logtable::insertManyTuples(datatuple ** tuples, int tuple_count) { + +void logtable::insertManyTuples(datatuple ** tuples, int tuple_count) { for(int i = 0; i < tuple_count; i++) { merge_mgr->read_tuple_from_small_component(0, tuples[i]); } @@ -625,8 +611,7 @@ void logtable::insertManyTuples(datatuple ** tuples, int tuple_count) { merge_mgr->read_tuple_from_large_component(0, num_old_tups, sum_old_tup_lens); } -template -void logtable::insertTuple(datatuple *tuple) +void logtable::insertTuple(datatuple *tuple) { if(log_mode && !recovering) { logUpdate(tuple); @@ -653,8 +638,7 @@ void logtable::insertTuple(datatuple *tuple) DEBUG("tree size %d tuples %lld bytes.\n", tsize, tree_bytes); } -template -bool logtable::testAndSetTuple(datatuple *tuple, datatuple *tuple2) +bool logtable::testAndSetTuple(datatuple *tuple, datatuple *tuple2) { bool succ = false; static pthread_mutex_t test_and_set_mut = PTHREAD_MUTEX_INITIALIZER; @@ -682,12 +666,11 @@ bool logtable::testAndSetTuple(datatuple *tuple, datatuple *tuple2) return succ; } -template -void logtable::registerIterator(iterator * it) { +void logtable::registerIterator(iterator * it) { its.push_back(it); } -template -void logtable::forgetIterator(iterator * it) { + +void logtable::forgetIterator(iterator * it) { for(unsigned int i = 0; i < its.size(); i++) { if(its[i] == it) { its.erase(its.begin()+i); @@ -695,11 +678,10 @@ void logtable::forgetIterator(iterator * it) { } } } -template -void logtable::bump_epoch() { + +void logtable::bump_epoch() { epoch++; for(unsigned int i = 0; i < its.size(); i++) { its[i]->invalidate(); } } -template class logtable; diff --git a/logstore.h b/logstore.h index 631b39a..aef2898 100644 --- a/logstore.h +++ b/logstore.h @@ -17,7 +17,6 @@ class logtable_mergedata; -template class logtable { public: @@ -205,11 +204,11 @@ public: template class mergeManyIterator { public: - explicit mergeManyIterator(ITRA* a, ITRN** iters, int num_iters, TUPLE*(*merge)(const TUPLE*,const TUPLE*), int (*cmp)(const TUPLE*,const TUPLE*)) : + explicit mergeManyIterator(ITRA* a, ITRN** iters, int num_iters, datatuple*(*merge)(const datatuple*,const datatuple*), int (*cmp)(const datatuple*,const datatuple*)) : num_iters_(num_iters+1), first_iter_(a), iters_((ITRN**)malloc(sizeof(*iters_) * num_iters)), // exactly the number passed in - current_((TUPLE**)malloc(sizeof(*current_) * (num_iters_))), // one more than was passed in + current_((datatuple**)malloc(sizeof(*current_) * (num_iters_))), // one more than was passed in last_iter_(-1), cmp_(cmp), merge_(merge), @@ -225,7 +224,7 @@ public: delete(first_iter_); for(int i = 0; i < num_iters_; i++) { if(i != last_iter_) { - if(current_[i]) TUPLE::freetuple(current_[i]); + if(current_[i]) datatuple::freetuple(current_[i]); } } for(int i = 1; i < num_iters_; i++) { @@ -235,16 +234,16 @@ public: free(iters_); free(dups); } - TUPLE * peek() { - TUPLE * ret = next_callerFrees(); + datatuple * peek() { + datatuple * ret = next_callerFrees(); last_iter_ = -1; // don't advance iterator on next peek() or getnext() call. return ret; } - TUPLE * next_callerFrees() { + datatuple * next_callerFrees() { int num_dups = 0; if(last_iter_ != -1) { // get the value after the one we just returned to the user - //TUPLE::freetuple(current_[last_iter_]); // should never be null + //datatuple::freetuple(current_[last_iter_]); // should never be null if(last_iter_ == 0) { current_[last_iter_] = first_iter_->next_callerFrees(); } else if(last_iter_ != -1){ @@ -272,7 +271,7 @@ public: } } } - TUPLE * ret; + datatuple * ret; if(!merge_) { ret = current_[min]; } else { @@ -281,7 +280,7 @@ public: } // advance the iterators that match the tuple we're returning. for(int i = 0; i < num_dups; i++) { - TUPLE::freetuple(current_[dups[i]]); // should never be null + datatuple::freetuple(current_[dups[i]]); // should never be null current_[dups[i]] = iters_[dups[i]-1]->next_callerFrees(); } last_iter_ = min; // mark the min iter to be advance at the next invocation of next(). This saves us a copy in the non-merging case. @@ -292,12 +291,12 @@ public: int num_iters_; ITRA * first_iter_; ITRN ** iters_; - TUPLE ** current_; + datatuple ** current_; int last_iter_; - int (*cmp_)(const TUPLE*,const TUPLE*); - TUPLE*(*merge_)(const TUPLE*,const TUPLE*); + int (*cmp_)(const datatuple*,const datatuple*); + datatuple*(*merge_)(const datatuple*,const datatuple*); // temporary variables initiaized once for effiency int * dups; @@ -323,7 +322,7 @@ public: // rwlc_unlock(ltable->header_mut); } - explicit iterator(logtable* ltable,TUPLE *key) + explicit iterator(logtable* ltable,datatuple *key) : ltable(ltable), epoch(ltable->get_epoch()), merge_it_(NULL), @@ -346,16 +345,16 @@ public: ltable->forgetIterator(this); invalidate(); pthread_mutex_unlock(<able->rb_mut); - if(last_returned) TUPLE::freetuple(last_returned); + if(last_returned) datatuple::freetuple(last_returned); rwlc_unlock(ltable->header_mut); } private: - TUPLE * getnextHelper() { + datatuple * getnextHelper() { // rwlc_readlock(ltable->header_mut); revalidate(); - TUPLE * tmp = merge_it_->next_callerFrees(); + datatuple * tmp = merge_it_->next_callerFrees(); if(last_returned && tmp) { - int res = TUPLE::compare(last_returned->strippedkey(), last_returned->strippedkeylen(), tmp->strippedkey(), tmp->strippedkeylen()); + int res = datatuple::compare(last_returned->strippedkey(), last_returned->strippedkeylen(), tmp->strippedkey(), tmp->strippedkeylen()); if(res >= 0) { int al = last_returned->strippedkeylen(); char * a =(char*)malloc(al + 1); @@ -372,21 +371,21 @@ public: } if(last_returned) { - TUPLE::freetuple(last_returned); + datatuple::freetuple(last_returned); } last_returned = tmp; // rwlc_unlock(ltable->header_mut); return last_returned; } public: - TUPLE * getnextIncludingTombstones() { - TUPLE * ret = getnextHelper(); + datatuple * getnextIncludingTombstones() { + datatuple * ret = getnextHelper(); ret = ret ? ret->create_copy() : NULL; return ret; } - TUPLE * getnext() { - TUPLE * ret; + datatuple * getnext() { + datatuple * ret; while((ret = getnextHelper()) && ret->isDelete()) { } // getNextHelper handles its own memory. ret = ret ? ret->create_copy() : NULL; // XXX hate making copy! Caller should not manage our memory. return ret; @@ -423,8 +422,8 @@ public: merge_it_t* merge_it_; - TUPLE * last_returned; - TUPLE * key; + datatuple * last_returned; + datatuple * key; bool valid; int reval_count; static const int reval_period = 100; @@ -475,13 +474,13 @@ public: disk_it[3] = ltable->get_tree_c2()->open_iterator(t); inner_merge_it_t * inner_merge_it = - new inner_merge_it_t(c0_it, c0_mergeable_it, 1, NULL, TUPLE::compare_obj); - merge_it_ = new merge_it_t(inner_merge_it, disk_it, 4, NULL, TUPLE::compare_obj); // XXX Hardcodes comparator, and does not handle merges + new inner_merge_it_t(c0_it, c0_mergeable_it, 1, NULL, datatuple::compare_obj); + merge_it_ = new merge_it_t(inner_merge_it, disk_it, 4, NULL, datatuple::compare_obj); // XXX Hardcodes comparator, and does not handle merges if(last_returned) { - TUPLE * junk = merge_it_->peek(); - if(junk && !TUPLE::compare(junk->strippedkey(), junk->strippedkeylen(), last_returned->strippedkey(), last_returned->strippedkeylen())) { + datatuple * junk = merge_it_->peek(); + if(junk && !datatuple::compare(junk->strippedkey(), junk->strippedkeylen(), last_returned->strippedkey(), last_returned->strippedkeylen())) { // we already returned junk - TUPLE::freetuple(merge_it_->next_callerFrees()); + datatuple::freetuple(merge_it_->next_callerFrees()); } } valid = true; diff --git a/mergeManager.cpp b/mergeManager.cpp index ae2e24f..e82fd57 100644 --- a/mergeManager.cpp +++ b/mergeManager.cpp @@ -499,7 +499,7 @@ void mergeManager::init_helper(void) { pthread_create(&pp_thread, 0, merge_manager_pretty_print_thread, (void*)this); } -mergeManager::mergeManager(logtable *ltable): +mergeManager::mergeManager(logtable *ltable): UPDATE_PROGRESS_PERIOD(0.005), ltable(ltable) { c0 = new mergeStats(0, ltable ? ltable->max_c0_size : 10000000); @@ -507,7 +507,7 @@ mergeManager::mergeManager(logtable *ltable): c2 = new mergeStats(2, 0); init_helper(); } -mergeManager::mergeManager(logtable *ltable, int xid, recordid rid): +mergeManager::mergeManager(logtable *ltable, int xid, recordid rid): UPDATE_PROGRESS_PERIOD(0.005), ltable(ltable) { marshalled_header h; @@ -537,7 +537,7 @@ void mergeManager::marshal(int xid, recordid rid) { void mergeManager::pretty_print(FILE * out) { #if EXTENDED_STATS - logtable * lt = (logtable*)ltable; + logtable * lt = ltable; bool have_c0 = false; bool have_c0m = false; bool have_c1 = false; diff --git a/mergeManager.h b/mergeManager.h index c5bf077..264ac9f 100644 --- a/mergeManager.h +++ b/mergeManager.h @@ -15,7 +15,6 @@ #include #include -template class logtable; class mergeStats; @@ -37,8 +36,8 @@ public: uint64_t long_tv(struct timeval& tv) { return (1000000ULL * (uint64_t)tv.tv_sec) + ((uint64_t)tv.tv_usec); } - mergeManager(logtable *ltable); - mergeManager(logtable *ltable, int xid, recordid rid); + mergeManager(logtable *ltable); + mergeManager(logtable *ltable, int xid, recordid rid); void marshal(int xid, recordid rid); recordid talloc(int xid); ~mergeManager(); @@ -94,7 +93,7 @@ private: * * TODO: remove mergeManager->ltable? */ - logtable* ltable; + logtable* ltable; mergeStats * c0; /// Per-tree component statistics for c0 and c0_mergeable (the latter should always be null...) mergeStats * c1; /// Per-tree component statistics for c1 and c1_mergeable. mergeStats * c2; /// Per-tree component statistics for c2. diff --git a/merger.cpp b/merger.cpp index 400ae17..c46d51c 100644 --- a/merger.cpp +++ b/merger.cpp @@ -12,7 +12,7 @@ static void* diskMerge_thr(void* arg) { return ((merge_scheduler*)arg)->diskMergeThread(); } -merge_scheduler::merge_scheduler(logtable *ltable) : ltable_(ltable), MIN_R(3.0) { } +merge_scheduler::merge_scheduler(logtable *ltable) : ltable_(ltable), MIN_R(3.0) { } merge_scheduler::~merge_scheduler() { } void merge_scheduler::shutdown() { @@ -26,7 +26,7 @@ void merge_scheduler::start() { pthread_create(&disk_merge_thread_, 0, diskMerge_thr, this); } -bool insert_filter(logtable * ltable, datatuple * t, bool dropDeletes) { +bool insert_filter(logtable * ltable, datatuple * t, bool dropDeletes) { if(t->isDelete()) { if(dropDeletes || ! ltable->mightBeAfterMemMerge(t)) { return false; @@ -41,7 +41,7 @@ template void merge_iterators(int xid, diskTreeComponent * forceMe, ITA *itrA, ITB *itrB, - logtable *ltable, + logtable *ltable, diskTreeComponent *scratch_tree, mergeStats * stats, bool dropDeletes); @@ -339,7 +339,7 @@ static void periodically_force(int xid, int *i, diskTreeComponent * forceMe, sta } } -static int garbage_collect(logtable * ltable_, datatuple ** garbage, int garbage_len, int next_garbage, bool force = false) { +static int garbage_collect(logtable * ltable_, datatuple ** garbage, int garbage_len, int next_garbage, bool force = false) { if(next_garbage == garbage_len || force) { pthread_mutex_lock(<able_->rb_mut); for(int i = 0; i < next_garbage; i++) { @@ -375,7 +375,7 @@ void merge_iterators(int xid, diskTreeComponent * forceMe, ITA *itrA, //iterator on c1 or c2 ITB *itrB, //iterator on c0 or c1, respectively - logtable *ltable, + logtable *ltable, diskTreeComponent *scratch_tree, mergeStats * stats, bool dropDeletes // should be true iff this is biggest component ) diff --git a/merger.h b/merger.h index 02b7534..43734fb 100644 --- a/merger.h +++ b/merger.h @@ -2,7 +2,6 @@ #define _MERGER_H_ #include "logstore.h" -#include "datatuple.h" #include #undef try @@ -10,7 +9,7 @@ class merge_scheduler { public: - merge_scheduler(logtable * ltable); + merge_scheduler(logtable * ltable); ~merge_scheduler(); void start(); @@ -22,7 +21,7 @@ public: private: pthread_t mem_merge_thread_; pthread_t disk_merge_thread_; - logtable * ltable_; + logtable * ltable_; const double MIN_R; }; diff --git a/newserver.cpp b/newserver.cpp index 9f99f58..12a58b4 100644 --- a/newserver.cpp +++ b/newserver.cpp @@ -51,14 +51,14 @@ int main(int argc, char *argv[]) } } - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); recordid table_root = ROOT_RECORD; { - logtable ltable(log_mode, c0_size); + logtable ltable(log_mode, c0_size); ltable.expiry = expiry_delta; if(TrecordType(xid, ROOT_RECORD) == INVALID_SLOT) { @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) printf("Deinitializing stasis...\n"); fflush(stdout); } - logtable::deinit_stasis(); + logtable::deinit_stasis(); printf("Shutdown complete\n"); } diff --git a/requestDispatch.cpp b/requestDispatch.cpp index 87bdb2c..a2c7f33 100644 --- a/requestDispatch.cpp +++ b/requestDispatch.cpp @@ -8,21 +8,21 @@ #include "regionAllocator.h" template -inline int requestDispatch::op_insert(logtable * ltable, HANDLE fd, datatuple * tuple) { +inline int requestDispatch::op_insert(logtable * ltable, HANDLE fd, datatuple * tuple) { //insert/update/delete ltable->insertTuple(tuple); //step 4: send response return writeoptosocket(fd, LOGSTORE_RESPONSE_SUCCESS); } template -inline int requestDispatch::op_test_and_set(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2) { +inline int requestDispatch::op_test_and_set(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2) { //insert/update/delete bool succ = ltable->testAndSetTuple(tuple, tuple2); //step 4: send response return writeoptosocket(fd, succ ? LOGSTORE_RESPONSE_SUCCESS : LOGSTORE_RESPONSE_FAIL); } template -inline int requestDispatch::op_bulk_insert(logtable *ltable, HANDLE fd) { +inline int requestDispatch::op_bulk_insert(logtable *ltable, HANDLE fd) { int err = writeoptosocket(fd, LOGSTORE_RESPONSE_RECEIVING_TUPLES); datatuple ** tups = (datatuple **) malloc(sizeof(tups[0]) * 100); int tups_size = 100; @@ -46,7 +46,7 @@ inline int requestDispatch::op_bulk_insert(logtable *ltable, return err; } template -inline int requestDispatch::op_find(logtable * ltable, HANDLE fd, datatuple * tuple) { +inline int requestDispatch::op_find(logtable * ltable, HANDLE fd, datatuple * tuple) { //find the tuple datatuple *dt = ltable->findTuple_first(-1, tuple->strippedkey(), tuple->strippedkeylen()); @@ -91,12 +91,12 @@ inline int requestDispatch::op_find(logtable * ltable, HANDLE return err; } template -inline int requestDispatch::op_scan(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2, size_t limit) { +inline int requestDispatch::op_scan(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2, size_t limit) { size_t count = 0; int err = writeoptosocket(fd, LOGSTORE_RESPONSE_SENDING_TUPLES); if(!err) { - logtable::iterator * itr = new logtable::iterator(ltable, tuple); + logtable::iterator * itr = new logtable::iterator(ltable, tuple); datatuple * t; while(!err && (t = itr->getnext())) { if(tuple2) { // are we at the end of range? @@ -116,17 +116,17 @@ inline int requestDispatch::op_scan(logtable * ltable, HANDLE return err; } template -inline int requestDispatch::op_flush(logtable * ltable, HANDLE fd) { +inline int requestDispatch::op_flush(logtable * ltable, HANDLE fd) { ltable->flushTable(); return writeoptosocket(fd, LOGSTORE_RESPONSE_SUCCESS); } template -inline int requestDispatch::op_shutdown(logtable * ltable, HANDLE fd) { +inline int requestDispatch::op_shutdown(logtable * ltable, HANDLE fd) { ltable->accepting_new_requests = false; return writeoptosocket(fd, LOGSTORE_RESPONSE_SUCCESS); } template -inline int requestDispatch::op_stat_space_usage(logtable * ltable, HANDLE fd) { +inline int requestDispatch::op_stat_space_usage(logtable * ltable, HANDLE fd) { int xid = Tbegin(); @@ -224,13 +224,13 @@ inline int requestDispatch::op_stat_space_usage(logtable * lt return err; } template -inline int requestDispatch::op_stat_perf_report(logtable * ltable, HANDLE fd) { +inline int requestDispatch::op_stat_perf_report(logtable * ltable, HANDLE fd) { } template -inline int requestDispatch::op_stat_histogram(logtable * ltable, HANDLE fd, size_t limit) { +inline int requestDispatch::op_stat_histogram(logtable * ltable, HANDLE fd, size_t limit) { if(limit < 3) { return writeoptosocket(fd, LOGSTORE_PROTOCOL_ERROR); @@ -288,7 +288,7 @@ inline int requestDispatch::op_stat_histogram(logtable * ltab return err; } template -inline int requestDispatch::op_dbg_blockmap(logtable * ltable, HANDLE fd) { +inline int requestDispatch::op_dbg_blockmap(logtable * ltable, HANDLE fd) { // produce a list of stasis regions int xid = Tbegin(); @@ -392,8 +392,8 @@ inline int requestDispatch::op_dbg_blockmap(logtable * ltable } template -inline int requestDispatch::op_dbg_drop_database(logtable * ltable, HANDLE fd) { - logtable::iterator * itr = new logtable::iterator(ltable); +inline int requestDispatch::op_dbg_drop_database(logtable * ltable, HANDLE fd) { + logtable::iterator * itr = new logtable::iterator(ltable); datatuple * del; fprintf(stderr, "DROPPING DATABASE...\n"); long long n = 0; @@ -418,11 +418,11 @@ inline int requestDispatch::op_dbg_drop_database(logtable * l return writeoptosocket(fd, LOGSTORE_RESPONSE_SUCCESS); } template -inline int requestDispatch::op_dbg_noop(logtable * ltable, HANDLE fd) { +inline int requestDispatch::op_dbg_noop(logtable * ltable, HANDLE fd) { return writeoptosocket(fd, LOGSTORE_RESPONSE_SUCCESS); } template -inline int requestDispatch::op_dbg_set_log_mode(logtable * ltable, HANDLE fd, datatuple * tuple) { +inline int requestDispatch::op_dbg_set_log_mode(logtable * ltable, HANDLE fd, datatuple * tuple) { if(tuple->rawkeylen() != sizeof(int)) { abort(); return writeoptosocket(fd, LOGSTORE_PROTOCOL_ERROR); @@ -434,7 +434,7 @@ inline int requestDispatch::op_dbg_set_log_mode(logtable * lt } } template -int requestDispatch::dispatch_request(HANDLE f, logtable*ltable) { +int requestDispatch::dispatch_request(HANDLE f, logtable *ltable) { //step 1: read the opcode network_op_t opcode = readopfromsocket(f, LOGSTORE_CLIENT_REQUEST); if(opcode == LOGSTORE_CONN_CLOSED_ERROR) { @@ -471,7 +471,7 @@ int requestDispatch::dispatch_request(HANDLE f, logtable*ltab } template -int requestDispatch::dispatch_request(network_op_t opcode, datatuple * tuple, datatuple * tuple2, logtable * ltable, HANDLE fd) { +int requestDispatch::dispatch_request(network_op_t opcode, datatuple * tuple, datatuple * tuple2, logtable * ltable, HANDLE fd) { int err = 0; #if 0 if(tuple) { diff --git a/requestDispatch.h b/requestDispatch.h index d737b3f..cdc529a 100644 --- a/requestDispatch.h +++ b/requestDispatch.h @@ -13,23 +13,23 @@ template class requestDispatch { private: - static inline int op_insert(logtable * ltable, HANDLE fd, datatuple * tuple); - static inline int op_test_and_set(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2); - static inline int op_find(logtable * ltable, HANDLE fd, datatuple * tuple); - static inline int op_scan(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2, size_t limit); - static inline int op_bulk_insert(logtable * ltable, HANDLE fd); - static inline int op_flush(logtable * ltable, HANDLE fd); - static inline int op_shutdown(logtable * ltable, HANDLE fd); - static inline int op_stat_space_usage(logtable * ltable, HANDLE fd); - static inline int op_stat_perf_report(logtable * ltable, HANDLE fd); - static inline int op_stat_histogram(logtable * ltable, HANDLE fd, size_t limit); - static inline int op_dbg_blockmap(logtable * ltable, HANDLE fd); - static inline int op_dbg_drop_database(logtable * ltable, HANDLE fd); - static inline int op_dbg_noop(logtable * ltable, HANDLE fd); - static inline int op_dbg_set_log_mode(logtable * ltable, HANDLE fd, datatuple * tuple); + static inline int op_insert(logtable * ltable, HANDLE fd, datatuple * tuple); + static inline int op_test_and_set(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2); + static inline int op_find(logtable * ltable, HANDLE fd, datatuple * tuple); + static inline int op_scan(logtable * ltable, HANDLE fd, datatuple * tuple, datatuple * tuple2, size_t limit); + static inline int op_bulk_insert(logtable * ltable, HANDLE fd); + static inline int op_flush(logtable * ltable, HANDLE fd); + static inline int op_shutdown(logtable * ltable, HANDLE fd); + static inline int op_stat_space_usage(logtable * ltable, HANDLE fd); + static inline int op_stat_perf_report(logtable * ltable, HANDLE fd); + static inline int op_stat_histogram(logtable * ltable, HANDLE fd, size_t limit); + static inline int op_dbg_blockmap(logtable * ltable, HANDLE fd); + static inline int op_dbg_drop_database(logtable * ltable, HANDLE fd); + static inline int op_dbg_noop(logtable * ltable, HANDLE fd); + static inline int op_dbg_set_log_mode(logtable * ltable, HANDLE fd, datatuple * tuple); public: - static int dispatch_request(HANDLE f, logtable * ltable); - static int dispatch_request(network_op_t opcode, datatuple * tuple, datatuple * tuple2, logtable * ltable, HANDLE fd); + static int dispatch_request(HANDLE f, logtable * ltable); + static int dispatch_request(network_op_t opcode, datatuple * tuple, datatuple * tuple2, logtable * ltable, HANDLE fd); }; #endif /* REQUESTDISPATCH_H_ */ diff --git a/server.cpp b/server.cpp index 9a15aa2..9b80b9c 100644 --- a/server.cpp +++ b/server.cpp @@ -37,7 +37,7 @@ void terminate (int param) printf("Deinitializing stasis...\n"); fflush(stdout); - logtable::deinit_stasis(); + logtable::deinit_stasis(); exit(0); } @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) prev_fn = signal (SIGINT,terminate); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) printf("note: running w/ 2GB c0 for benchmarking"); // XXX build a separate test server and deployment server? } - logtable ltable(c0_size); + logtable ltable(c0_size); recordid table_root = ROOT_RECORD; if(TrecordType(xid, ROOT_RECORD) == INVALID_SLOT) { diff --git a/simpleServer.cpp b/simpleServer.cpp index 0875792..20c5784 100644 --- a/simpleServer.cpp +++ b/simpleServer.cpp @@ -53,7 +53,7 @@ void * simpleServer::worker(int self) { } } -simpleServer::simpleServer(logtable * ltable, int max_threads, int port): +simpleServer::simpleServer(logtable * ltable, int max_threads, int port): ltable(ltable), port(port), max_threads(max_threads), diff --git a/simpleServer.h b/simpleServer.h index 095a18b..555111c 100644 --- a/simpleServer.h +++ b/simpleServer.h @@ -15,11 +15,11 @@ public: static const int DEFAULT_PORT = 32432; static const int DEFAULT_THREADS = 1000; - simpleServer(logtable * ltable, int max_threads = DEFAULT_THREADS, int port = DEFAULT_PORT); + simpleServer(logtable * ltable, int max_threads = DEFAULT_THREADS, int port = DEFAULT_PORT); bool acceptLoop(); ~simpleServer(); private: - logtable* ltable; + logtable* ltable; int port; int max_threads; int * thread_fd; diff --git a/test/check_datapage.cpp b/test/check_datapage.cpp index 0f4582d..c40860b 100644 --- a/test/check_datapage.cpp +++ b/test/check_datapage.cpp @@ -28,7 +28,7 @@ void insertWithConcurrentReads(size_t NUM_ENTRIES) { sync(); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); @@ -120,7 +120,7 @@ void insertWithConcurrentReads(size_t NUM_ENTRIES) { Tcommit(xid); - logtable::deinit_stasis(); + logtable::deinit_stasis(); } void insertProbeIter(size_t NUM_ENTRIES) @@ -131,7 +131,7 @@ void insertProbeIter(size_t NUM_ENTRIES) sync(); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); @@ -219,7 +219,7 @@ void insertProbeIter(size_t NUM_ENTRIES) Tcommit(xid); - logtable::deinit_stasis(); + logtable::deinit_stasis(); } diff --git a/test/check_gen.cpp b/test/check_gen.cpp index 92a5172..baa0fd9 100644 --- a/test/check_gen.cpp +++ b/test/check_gen.cpp @@ -15,11 +15,11 @@ int main(int argc, char **argv) sync(); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); - logtable *ltable = new logtable(1000, 10000, 5); + logtable *ltable = new logtable(1000, 10000, 5); recordid table_root = ltable->allocTable(xid); @@ -34,7 +34,7 @@ int main(int argc, char **argv) delete ro_alloc; Tcommit(xid); delete ltable; - logtable::deinit_stasis(); + logtable::deinit_stasis(); diff --git a/test/check_logtable.cpp b/test/check_logtable.cpp index 7fd0dfd..f904443 100644 --- a/test/check_logtable.cpp +++ b/test/check_logtable.cpp @@ -28,7 +28,7 @@ void insertProbeIter(size_t NUM_ENTRIES) sync(); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); @@ -116,7 +116,7 @@ void insertProbeIter(size_t NUM_ENTRIES) printf("Random Reads completed.\n"); Tcommit(xid); - logtable::deinit_stasis(); + logtable::deinit_stasis(); } /** @test diff --git a/test/check_logtree.cpp b/test/check_logtree.cpp index b4b264a..585c075 100644 --- a/test/check_logtree.cpp +++ b/test/check_logtree.cpp @@ -36,7 +36,7 @@ void insertProbeIter_str(int NUM_ENTRIES) system("rm -rf stasis_log/"); sync(); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); @@ -138,7 +138,7 @@ void insertProbeIter_str(int NUM_ENTRIES) delete it; delete ro_alloc; Tcommit(xid); - logtable::deinit_stasis(); + logtable::deinit_stasis(); } diff --git a/test/check_merge.cpp b/test/check_merge.cpp index dab96ee..f5ff0e9 100644 --- a/test/check_merge.cpp +++ b/test/check_merge.cpp @@ -26,7 +26,7 @@ void insertProbeIter(size_t NUM_ENTRIES) unlink("logfile.txt"); system("rm -rf stasis_log/"); - logtable::init_stasis(); + logtable::init_stasis(); //data generation std::vector * data_arr = new std::vector; @@ -51,7 +51,7 @@ void insertProbeIter(size_t NUM_ENTRIES) int xid = Tbegin(); - logtable * ltable = new logtable(10 * 1024 * 1024, 1000, 10000, 5); + logtable * ltable = new logtable(10 * 1024 * 1024, 1000, 10000, 5); merge_scheduler mscheduler(ltable); recordid table_root = ltable->allocTable(xid); @@ -149,7 +149,7 @@ void insertProbeIter(size_t NUM_ENTRIES) Tcommit(xid); delete ltable; - logtable::deinit_stasis(); + logtable::deinit_stasis(); } diff --git a/test/check_mergelarge.cpp b/test/check_mergelarge.cpp index 9c00b4e..8fd735c 100644 --- a/test/check_mergelarge.cpp +++ b/test/check_mergelarge.cpp @@ -26,7 +26,7 @@ void insertProbeIter(size_t NUM_ENTRIES) unlink("logfile.txt"); system("rm -rf stasis_log/"); - logtable::init_stasis(); + logtable::init_stasis(); //data generation // std::vector * data_arr = new std::vector; @@ -45,7 +45,7 @@ void insertProbeIter(size_t NUM_ENTRIES) int xid = Tbegin(); - logtable *ltable = new logtable(10*1024*1024, 1000, 10000, 100); + logtable *ltable = new logtable(10*1024*1024, 1000, 10000, 100); merge_scheduler mscheduler(ltable); recordid table_root = ltable->allocTable(xid); @@ -92,7 +92,7 @@ void insertProbeIter(size_t NUM_ENTRIES) printf("merge threads finished.\n"); gettimeofday(&stop_tv,0); printf("run time: %6.1f\n", (tv_to_double(stop_tv) - tv_to_double(start_tv))); - logtable::deinit_stasis(); + logtable::deinit_stasis(); } diff --git a/test/check_mergetuple.cpp b/test/check_mergetuple.cpp index df37595..0299b7d 100644 --- a/test/check_mergetuple.cpp +++ b/test/check_mergetuple.cpp @@ -28,7 +28,7 @@ void insertProbeIter(size_t NUM_ENTRIES) sync(); - logtable::init_stasis(); + logtable::init_stasis(); double delete_freq = .05; double update_freq = .15; @@ -103,7 +103,7 @@ void insertProbeIter(size_t NUM_ENTRIES) int xid = Tbegin(); - logtable *ltable = new logtable(10 * 1024 * 1024, 1000, 1000, 40); + logtable *ltable = new logtable(10 * 1024 * 1024, 1000, 1000, 40); merge_scheduler mscheduler(ltable); recordid table_root = ltable->allocTable(xid); @@ -248,7 +248,7 @@ void insertProbeIter(size_t NUM_ENTRIES) Tcommit(xid); delete ltable; - logtable::deinit_stasis(); + logtable::deinit_stasis(); } diff --git a/test/check_testAndSet.cpp b/test/check_testAndSet.cpp index cd1f01b..04a92e3 100644 --- a/test/check_testAndSet.cpp +++ b/test/check_testAndSet.cpp @@ -28,7 +28,7 @@ unsigned char vals[NUM_THREADS]; -logtable * ltable; +logtable * ltable; int myucharcmp(const void * ap, const void * bp) { unsigned char a = *(unsigned char*)ap; @@ -59,10 +59,10 @@ void insertProbeIter(size_t NUM_ENTRIES) unlink("logfile.txt"); system("rm -rf stasis_log/"); - logtable::init_stasis(); + logtable::init_stasis(); int xid = Tbegin(); - ltable = new logtable(10 * 1024 * 1024, 1000, 10000, 5); + ltable = new logtable(10 * 1024 * 1024, 1000, 10000, 5); merge_scheduler mscheduler(ltable); @@ -92,7 +92,7 @@ void insertProbeIter(size_t NUM_ENTRIES) mscheduler.shutdown(); delete ltable; - logtable::deinit_stasis(); + logtable::deinit_stasis(); printf("\npass\n"); }