diskTreeComponentIterator -> diskTreeComponent::iterator

git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@671 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
sears 2010-03-09 00:09:38 +00:00
parent 85ca7a935c
commit 452ee97442
7 changed files with 37 additions and 37 deletions

View file

@ -748,7 +748,7 @@ void diskTreeComponent::print_tree(int xid, pageid_t pid, int64_t depth) {
//diskTreeComponentIterator implementation //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(); if(root.page == 0 && root.slot == 0 && root.size == -1) abort();
p = loadPage(xid,root.page); p = loadPage(xid,root.page);
readlock(p->rwlatch,0); readlock(p->rwlatch,0);
@ -787,7 +787,7 @@ diskTreeComponentIterator::diskTreeComponentIterator(int xid, recordid root) {
justOnePage = (depth == 0); 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(); if(root.page == NULLRID.page && root.slot == NULLRID.slot) abort();
p = loadPage(xid,root.page); p = loadPage(xid,root.page);
@ -831,7 +831,7 @@ diskTreeComponentIterator::diskTreeComponentIterator(int xid, recordid root, con
/** /**
* move to the next page * move to the next page
**/ **/
int diskTreeComponentIterator::next() int diskTreeComponent::iterator::next()
{ {
if(done) return 0; if(done) return 0;
@ -879,7 +879,7 @@ int diskTreeComponentIterator::next()
} }
} }
void diskTreeComponentIterator::close() { void diskTreeComponent::iterator::close() {
if(p) { if(p) {
unlock(p->rwlatch); unlock(p->rwlatch);

View file

@ -134,37 +134,36 @@ private:
DataPage<datatuple>::RegionAllocator* region_alloc; DataPage<datatuple>::RegionAllocator* region_alloc;
};
class diskTreeComponentIterator {
public: public:
diskTreeComponentIterator(int xid, recordid root); class iterator {
diskTreeComponentIterator(int xid, recordid root, const byte* key, len_t keylen); public:
int next(); iterator(int xid, recordid root);
void close(); iterator(int xid, recordid root, const byte* key, len_t keylen);
int next();
void close();
inline size_t key (byte **key) { inline size_t key (byte **key) {
*key = (byte*)(t+1); *key = (byte*)(t+1);
return current.size - sizeof(indexnode_rec); return current.size - sizeof(indexnode_rec);
} }
inline size_t value(byte **value) { inline size_t value(byte **value) {
*value = (byte*)&(t->ptr); *value = (byte*)&(t->ptr);
return sizeof(t->ptr); return sizeof(t->ptr);
} }
inline void tupleDone() { } inline void tupleDone() { }
inline void releaseLock() { } inline void releaseLock() { }
private: private:
Page * p; Page * p;
int xid_; int xid_;
bool done; bool done;
recordid current; recordid current;
indexnode_rec *t; indexnode_rec *t;
int justOnePage; int justOnePage;
};
}; };
#endif /* DISKTREECOMPONENT_H_ */ #endif /* DISKTREECOMPONENT_H_ */

View file

@ -12,9 +12,9 @@ void diskTreeIterator<TUPLE>::init_iterators(TUPLE * key1, TUPLE * key2) {
lsmIterator_ = NULL; lsmIterator_ = NULL;
} else { } else {
if(key1) { if(key1) {
lsmIterator_ = new diskTreeComponentIterator(-1, tree_, key1->key(), key1->keylen()); lsmIterator_ = new diskTreeComponent::iterator(-1, tree_, key1->key(), key1->keylen());
} else { } else {
lsmIterator_ = new diskTreeComponentIterator(-1, tree_); lsmIterator_ = new diskTreeComponent::iterator(-1, tree_);
} }
} }
} }

View file

@ -166,7 +166,7 @@ private:
private: private:
recordid tree_; //root of the tree recordid tree_; //root of the tree
diskTreeComponentIterator* lsmIterator_; diskTreeComponent::iterator* lsmIterator_;
pageid_t curr_pageid; //current page id pageid_t curr_pageid; //current page id
DataPage<TUPLE> *curr_page; //current page DataPage<TUPLE> *curr_page; //current page

View file

@ -595,12 +595,13 @@ int op_stat_histogram(pthread_data* data, size_t limit) {
} }
int xid = Tbegin(); 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; size_t count = 0;
int err = 0; int err = 0;
while(it->next()) { count++; } while(it->next()) { count++; }
it->close(); it->close();
delete(it);
uint64_t stride; uint64_t stride;
@ -619,7 +620,7 @@ int op_stat_histogram(pthread_data* data, size_t limit) {
size_t cur_stride = 0; size_t cur_stride = 0;
size_t i = 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()) { while(it->next()) {
i++; i++;
if(i == count || !cur_stride) { // do we want to send this key? (this matches the first, last and interior keys) if(i == count || !cur_stride) { // do we want to send this key? (this matches the first, last and interior keys)

View file

@ -24,7 +24,7 @@ int main(int argc, char **argv)
// lsmTableHandle<PAGELAYOUT>* h = TlsmTableStart<PAGELAYOUT>(lsmTable, INVALID_COL); // lsmTableHandle<PAGELAYOUT>* h = TlsmTableStart<PAGELAYOUT>(lsmTable, INVALID_COL);
xid = Tbegin(); 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(); it->close();
delete it; delete it;
Tcommit(xid); Tcommit(xid);

View file

@ -129,7 +129,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
int64_t count = 0; int64_t count = 0;
diskTreeComponentIterator * it = new diskTreeComponentIterator(xid, tree); diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid, tree);
while(it->next()) { while(it->next()) {
byte * key; byte * key;