094a0d41ee
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@532 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
83 lines
1.8 KiB
C++
83 lines
1.8 KiB
C++
#ifndef _LOG_ITERATORS_H_
|
|
#define _LOG_ITERATORS_H_
|
|
|
|
#include <assert.h>
|
|
#include <stasis/iterator.h>
|
|
|
|
#undef begin
|
|
#undef end
|
|
|
|
template <class TUPLE>
|
|
class DataPage;
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
// memTreeIterator
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
template <class MEMTREE, class TUPLE>
|
|
class memTreeIterator
|
|
{
|
|
private:
|
|
typedef typename MEMTREE::const_iterator MTITER;
|
|
|
|
public:
|
|
memTreeIterator( MEMTREE *s ) : first_(true), it_(s->begin()), itend_(s->end()) { }
|
|
memTreeIterator( MEMTREE *s, TUPLE &key ) : first_(true), it_(s->find(key)), itend_(s->end()) { }
|
|
|
|
~memTreeIterator() { }
|
|
|
|
TUPLE* getnext() {
|
|
if(it_==itend_) { return NULL; }
|
|
if(first_) { first_ = 0;} else { it_++; }
|
|
TUPLE *t = new TUPLE();
|
|
t->clone(*it_);
|
|
return t;
|
|
}
|
|
|
|
|
|
private:
|
|
explicit memTreeIterator() { abort(); }
|
|
void operator=(memTreeIterator & t) { abort(); }
|
|
int operator-(memTreeIterator & t) { abort(); }
|
|
private:
|
|
bool first_;
|
|
MTITER it_;
|
|
MTITER itend_;
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
template <class TUPLE>
|
|
class treeIterator
|
|
{
|
|
|
|
public:
|
|
explicit treeIterator(recordid tree);
|
|
|
|
explicit treeIterator(recordid tree,TUPLE &key);
|
|
|
|
~treeIterator();
|
|
|
|
TUPLE * getnext();
|
|
|
|
private:
|
|
inline void init_helper();
|
|
|
|
explicit treeIterator() { abort(); }
|
|
void operator=(treeIterator & t) { abort(); }
|
|
int operator-(treeIterator & t) { abort(); }
|
|
|
|
private:
|
|
recordid tree_; //root of the tree
|
|
|
|
lladdIterator_t * lsmIterator_; //logtree iterator
|
|
|
|
pageid_t curr_pageid; //current page id
|
|
DataPage<TUPLE> *curr_page; //current page
|
|
typedef typename DataPage<TUPLE>::RecordIterator DPITR_T;
|
|
DPITR_T *dp_itr;
|
|
TUPLE *curr_tuple; //current tuple
|
|
};
|
|
|
|
#endif
|
|
|