2010-01-23 02:13:59 +00:00
|
|
|
#ifndef _MERGER_H_
|
|
|
|
#define _MERGER_H_
|
|
|
|
|
2010-03-17 21:51:26 +00:00
|
|
|
#include "logstore.h"
|
|
|
|
#include "datatuple.h"
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-03-13 00:05:06 +00:00
|
|
|
#include <stasis/common.h>
|
|
|
|
#undef try
|
|
|
|
#undef end
|
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
//TODO: 400 bytes overhead per tuple, this is nuts, check if this is true...
|
|
|
|
static const int RB_TREE_OVERHEAD = 400;
|
|
|
|
static const double MIN_R = 3.0;
|
2010-03-13 00:05:06 +00:00
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
struct logtable_mergedata
|
|
|
|
{
|
|
|
|
//merge threads
|
|
|
|
pthread_t diskmerge_thread;
|
|
|
|
pthread_t memmerge_thread;
|
|
|
|
};
|
|
|
|
|
|
|
|
class merge_scheduler
|
|
|
|
{
|
2010-03-17 21:51:26 +00:00
|
|
|
std::vector<std::pair<logtable<datatuple> *, logtable_mergedata*> > mergedata;
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
~merge_scheduler();
|
2010-05-19 23:42:06 +00:00
|
|
|
|
2010-03-17 21:51:26 +00:00
|
|
|
int addlogtable(logtable<datatuple> * ltable);
|
2010-02-10 21:49:50 +00:00
|
|
|
void startlogtable(int index, int64_t MAX_C0_SIZE = 100*1024*1024);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
struct logtable_mergedata *getMergeData(int index){return mergedata[index].second;}
|
|
|
|
|
|
|
|
void shutdown();
|
|
|
|
};
|
|
|
|
|
2010-02-18 23:31:57 +00:00
|
|
|
void* memMergeThread(void* arg);
|
2010-01-23 02:13:59 +00:00
|
|
|
void* diskMergeThread(void* arg);
|
|
|
|
|
|
|
|
#endif
|