2010-01-23 02:13:59 +00:00
|
|
|
#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
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
|
2010-01-28 02:20:49 +00:00
|
|
|
template <class MEMTREE, class TUPLE>
|
|
|
|
class memTreeIterator
|
|
|
|
{
|
2010-01-23 02:13:59 +00:00
|
|
|
private:
|
|
|
|
typedef typename MEMTREE::const_iterator MTITER;
|
|
|
|
|
2010-01-28 02:20:49 +00:00
|
|
|
public:
|
2010-02-04 22:19:42 +00:00
|
|
|
memTreeIterator( MEMTREE *s ) : first_(true), done_(false), it_(s->begin()), itend_(s->end()) { }
|
|
|
|
memTreeIterator( MEMTREE *s, TUPLE &key ) : first_(true), done_(false), it_(s->find(key)), itend_(s->end()) { }
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-01-28 02:20:49 +00:00
|
|
|
~memTreeIterator() { }
|
|
|
|
|
|
|
|
TUPLE* getnext() {
|
2010-02-04 22:19:42 +00:00
|
|
|
if(done_) { return NULL; }
|
|
|
|
if(first_) { first_ = 0;} else { it_++; }
|
|
|
|
if(it_==itend_) { done_= true; return NULL; }
|
2010-02-10 21:49:50 +00:00
|
|
|
|
|
|
|
return (*it_)->create_copy();
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2010-01-28 02:20:49 +00:00
|
|
|
explicit memTreeIterator() { abort(); }
|
|
|
|
void operator=(memTreeIterator & t) { abort(); }
|
|
|
|
int operator-(memTreeIterator & t) { abort(); }
|
|
|
|
private:
|
|
|
|
bool first_;
|
2010-02-04 22:19:42 +00:00
|
|
|
bool done_;
|
2010-01-28 02:20:49 +00:00
|
|
|
MTITER it_;
|
|
|
|
MTITER itend_;
|
2010-01-23 02:13:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template <class TUPLE>
|
|
|
|
class treeIterator
|
|
|
|
{
|
|
|
|
|
2010-01-28 02:20:49 +00:00
|
|
|
public:
|
2010-01-23 02:13:59 +00:00
|
|
|
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(); }
|
2010-01-28 02:20:49 +00:00
|
|
|
int operator-(treeIterator & t) { abort(); }
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|