00001
#ifndef CPVIEW_H
00002
#define CPVIEW_H
00003
00004
#include "TupleQueue.h"
00005
#include <Stream.h>
00006
#include <Expression.h>
00007
#include "CPViewDescription.h"
00008
00009 BOREALIS_NAMESPACE_BEGIN;
00010
00011 class CPView {
00012
00013
friend class CP;
00014
00015
public:
00016
00017
00018
CPView(ptr<CPView> base_view, ptr<CP> base_cp, string new_view_id);
00019
CPView(ptr<CPViewDescription> desc, ptr<CP> base_cp, string new_view_id, TupleDescription tuple_desc);
00020
00021
00022
~CPView();
00023
00024
00025 string
getID();
00026
00027
00028 ptr<CPViewDescription>
getDescription();
00029
00030
00031 vector<char*>
read();
00032
00033
00034 vector<char*>
replayAll();
00035
00036
00037 vector<char*>
replaySince(
char* t);
00038
00039
00040
void trimStorage(
char* t);
00041
00042
00043
00044
00045
00046
void replay(
char* t1,
char* t2,
bool includeRevisions,
int id);
00047
00048
00049
void replay(
char* t1,
char* t2, vector<ptr<Expression> > keys);
00050
00051
00052
void replay(string tuple_key, vector<ptr<Expression> > keys,
int revision_id);
00053
00054
00055
void replay(
int tuple_id,
int revision_id);
00056
00057
00058
void replay(
int start_order_by,
int end_order_by,
int revision_id);
00059
00060
00061
00062
void replayWithEndMarker(
int start_order_by,
int end_order_by,
int revision_id);
00063
00064
00065
char*
makeFakeTuple(
int revision_id);
00066
00067
00068
00069
00070
00071
void undo(
char* t1,
char* t2);
00072
00073
00074
00075
void makeBoundary();
00076
00077
00078
00079
void updatePtrs(
char* last_tuple);
00080
00081
void updateAutoStartPtr(
char* last_tuple);
00082
void updateAutoEndPtr(
char* last_tuple);
00083
00084
00085
void initAutoStartPtr();
00086
void initAutoEndPtr();
00087
00088
00089
bool checkFirst(
char* ptr);
00090
00091
bool checkLast(
char* ptr);
00092
00093
bool isLater(
char* p1,
char* p2);
00094
00095
void setTupleQueue(ptr<TupleQueue> tq);
00096 ptr<TupleQueue>
getTupleQueue() {
return _tq; }
00097
00098 ptr<Expression>
getOrderByField() {
00099
return _order_by_field;
00100 }
00101
00102
private:
00103
00104
00105 vector<char*> modifyMultipleTuples(vector<char*> tuples,
int tuple_size, TupleType type,
int revision_id,
bool revisions);
00106
00107
00108
00109
enum ViewType {AUTO, MANUAL, BOTH};
00110
00111 ViewType _view_type;
00112
char* _man_start_ptr;
00113
char* _man_end_ptr;
00114
char* _auto_start_ptr;
00115
char* _auto_end_ptr;
00116
00117 ptr<CP> _cp;
00118 ptr<TupleQueue> _tq;
00119 string _view_id;
00120 CPViewDescription _view_desc;
00121 ptr<Expression> _order_by_field;
00122
00123 TupleDescription _tuple_desc;
00124
00125 CPViewDescription::CPViewType _cp_view_type;
00126 CPViewDescription::OrderByMethod _order_by_method;
00127
00128 };
00129
00130 BOREALIS_NAMESPACE_END;
00131
00132
#endif
00133
00134