From 452ee97442adb767a396c39f47921905c2dd2c76 Mon Sep 17 00:00:00 2001 From: sears Date: Tue, 9 Mar 2010 00:09:38 +0000 Subject: [PATCH] diskTreeComponentIterator -> diskTreeComponent::iterator git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@671 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe --- diskTreeComponent.cpp | 8 +++---- diskTreeComponent.h | 51 +++++++++++++++++++++--------------------- logiterators.cpp | 4 ++-- logiterators.h | 2 +- logserver.cpp | 5 +++-- test/check_gen.cpp | 2 +- test/check_logtree.cpp | 2 +- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/diskTreeComponent.cpp b/diskTreeComponent.cpp index a8c8ad6..6c20ab7 100644 --- a/diskTreeComponent.cpp +++ b/diskTreeComponent.cpp @@ -748,7 +748,7 @@ void diskTreeComponent::print_tree(int xid, pageid_t pid, int64_t depth) { //diskTreeComponentIterator implementation ///////////////////////////////////////////////// -diskTreeComponentIterator::diskTreeComponentIterator(int xid, recordid root) { +diskTreeComponent::iterator::iterator(int xid, recordid root) { if(root.page == 0 && root.slot == 0 && root.size == -1) abort(); p = loadPage(xid,root.page); readlock(p->rwlatch,0); @@ -787,7 +787,7 @@ diskTreeComponentIterator::diskTreeComponentIterator(int xid, recordid root) { justOnePage = (depth == 0); } -diskTreeComponentIterator::diskTreeComponentIterator(int xid, recordid root, const byte* key, len_t keylen) { +diskTreeComponent::iterator::iterator(int xid, recordid root, const byte* key, len_t keylen) { if(root.page == NULLRID.page && root.slot == NULLRID.slot) abort(); p = loadPage(xid,root.page); @@ -831,7 +831,7 @@ diskTreeComponentIterator::diskTreeComponentIterator(int xid, recordid root, con /** * move to the next page **/ -int diskTreeComponentIterator::next() +int diskTreeComponent::iterator::next() { if(done) return 0; @@ -879,7 +879,7 @@ int diskTreeComponentIterator::next() } } -void diskTreeComponentIterator::close() { +void diskTreeComponent::iterator::close() { if(p) { unlock(p->rwlatch); diff --git a/diskTreeComponent.h b/diskTreeComponent.h index dd8c564..edce8f0 100644 --- a/diskTreeComponent.h +++ b/diskTreeComponent.h @@ -134,37 +134,36 @@ private: DataPage::RegionAllocator* region_alloc; -}; - -class diskTreeComponentIterator { - public: - diskTreeComponentIterator(int xid, recordid root); - diskTreeComponentIterator(int xid, recordid root, const byte* key, len_t keylen); - int next(); - void close(); + class iterator { + public: + iterator(int xid, recordid root); + iterator(int xid, recordid root, const byte* key, len_t keylen); + int next(); + void close(); - inline size_t key (byte **key) { - *key = (byte*)(t+1); - return current.size - sizeof(indexnode_rec); - } + inline size_t key (byte **key) { + *key = (byte*)(t+1); + return current.size - sizeof(indexnode_rec); + } - inline size_t value(byte **value) { - *value = (byte*)&(t->ptr); - return sizeof(t->ptr); - } + inline size_t value(byte **value) { + *value = (byte*)&(t->ptr); + return sizeof(t->ptr); + } - inline void tupleDone() { } - inline void releaseLock() { } + inline void tupleDone() { } + inline void releaseLock() { } -private: - Page * p; - int xid_; - bool done; - recordid current; - indexnode_rec *t; - int justOnePage; + private: + Page * p; + int xid_; + bool done; + recordid current; + indexnode_rec *t; + int justOnePage; + + }; }; - #endif /* DISKTREECOMPONENT_H_ */ diff --git a/logiterators.cpp b/logiterators.cpp index 86fce37..e4036cb 100644 --- a/logiterators.cpp +++ b/logiterators.cpp @@ -12,9 +12,9 @@ void diskTreeIterator::init_iterators(TUPLE * key1, TUPLE * key2) { lsmIterator_ = NULL; } else { if(key1) { - lsmIterator_ = new diskTreeComponentIterator(-1, tree_, key1->key(), key1->keylen()); + lsmIterator_ = new diskTreeComponent::iterator(-1, tree_, key1->key(), key1->keylen()); } else { - lsmIterator_ = new diskTreeComponentIterator(-1, tree_); + lsmIterator_ = new diskTreeComponent::iterator(-1, tree_); } } } diff --git a/logiterators.h b/logiterators.h index 3654dad..cdcd5ea 100644 --- a/logiterators.h +++ b/logiterators.h @@ -166,7 +166,7 @@ private: private: recordid tree_; //root of the tree - diskTreeComponentIterator* lsmIterator_; + diskTreeComponent::iterator* lsmIterator_; pageid_t curr_pageid; //current page id DataPage *curr_page; //current page diff --git a/logserver.cpp b/logserver.cpp index f3cc3ae..91fbfa5 100644 --- a/logserver.cpp +++ b/logserver.cpp @@ -595,12 +595,13 @@ int op_stat_histogram(pthread_data* data, size_t limit) { } int xid = Tbegin(); - diskTreeComponentIterator * it = new diskTreeComponentIterator(xid, data->ltable->get_tree_c2()->get_root_rec()); + diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid, data->ltable->get_tree_c2()->get_root_rec()); size_t count = 0; int err = 0; while(it->next()) { count++; } it->close(); + delete(it); uint64_t stride; @@ -619,7 +620,7 @@ int op_stat_histogram(pthread_data* data, size_t limit) { size_t cur_stride = 0; size_t i = 0; - it = new diskTreeComponentIterator(xid, data->ltable->get_tree_c2()->get_root_rec()); + it = new diskTreeComponent::iterator(xid, data->ltable->get_tree_c2()->get_root_rec()); while(it->next()) { i++; if(i == count || !cur_stride) { // do we want to send this key? (this matches the first, last and interior keys) diff --git a/test/check_gen.cpp b/test/check_gen.cpp index d36323c..e6f95c7 100644 --- a/test/check_gen.cpp +++ b/test/check_gen.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) // lsmTableHandle* h = TlsmTableStart(lsmTable, INVALID_COL); xid = Tbegin(); - diskTreeComponentIterator * it = new diskTreeComponentIterator(xid,ltable.get_tree_c2()->get_root_rec() ); + diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid,ltable.get_tree_c2()->get_root_rec() ); it->close(); delete it; Tcommit(xid); diff --git a/test/check_logtree.cpp b/test/check_logtree.cpp index 7bfce28..f1b660c 100644 --- a/test/check_logtree.cpp +++ b/test/check_logtree.cpp @@ -129,7 +129,7 @@ void insertProbeIter_str(int NUM_ENTRIES) int64_t count = 0; - diskTreeComponentIterator * it = new diskTreeComponentIterator(xid, tree); + diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid, tree); while(it->next()) { byte * key;