Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

CPView.h

Go to the documentation of this file.
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 //Constructors 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 //Destructor 00022 ~CPView(); 00023 00024 //Getter for unique id 00025 string getID(); 00026 00027 //Getter for description 00028 ptr<CPViewDescription> getDescription(); 00029 00030 //returns all unseen tuples packaged into a StreamEvent object 00031 vector<char*> read(); 00032 00033 //returns all tuples available on that CPView 00034 vector<char*> replayAll(); 00035 00036 //returns all tuples of this CPView starting from t 00037 vector<char*> replaySince(char* t); 00038 00039 //moves man_start_ptr of this CPView to point to tuple t 00040 void trimStorage(char* t); 00041 00042 00043 // ------------- DIFFERENT WAYS TO REPLAY FROM CPVIEW ---------------- 00044 00045 //places on the corresponding queue tuples between t1 and t2, appended with id 00046 void replay(char* t1, char* t2, bool includeRevisions, int id); 00047 00048 // replays tuples between t1 and t2 with key for tuples given 00049 void replay(char* t1, char* t2, vector<ptr<Expression> > keys); 00050 00051 // replays tuple with the given tuple_key 00052 void replay(string tuple_key, vector<ptr<Expression> > keys, int revision_id); 00053 00054 // replay with given tuple key and change revision_id in replayed tuples 00055 void replay(int tuple_id, int revision_id); 00056 00057 // replays tuples from start_order_by to end_order_by 00058 void replay(int start_order_by, int end_order_by, int revision_id); 00059 00060 // replays tuples from start_order_by to end_order_by 00061 // includes a tuple with fake_flag = true to signal end of replay 00062 void replayWithEndMarker(int start_order_by, int end_order_by, int revision_id); 00063 00064 // make a fake (fake_flag=true) HISTORICAL tuple with revision_id 00065 char* makeFakeTuple(int revision_id); 00066 00067 // ------------------------------------ 00068 00069 00070 //places on the corresponding queue deletion tuples for tuples between t1 and t2 00071 void undo(char* t1, char* t2); 00072 00073 //when partitioning happens on an arc that this view is on, this command initializes 00074 //manual start/end pointers and makes this view manula type 00075 void makeBoundary(); 00076 00077 // is called by CP on all its views every time CP recieves new tuples to update 00078 //start/end pointers according to spec and current state of stream/CP 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 //checks if tuple pointed to by p is within scope of this CPView (>= first CPView's tuple) 00089 bool checkFirst(char* ptr); 00090 //checks if tuple pointed to by p is within scope of this CPView (<= first CPView's tuple) 00091 bool checkLast(char* ptr); 00092 //returns true if order_by value of tuple pointed to by p1is >= to value of p2's tuple 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 // alter the tuple : change type to historical and change revision_id to given 00105 vector<char*> modifyMultipleTuples(vector<char*> tuples, int tuple_size, TupleType type, int revision_id, bool revisions); 00106 // char* modifyTuple(char *tuple, int tuple_size, int type, int revision_id); 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; // tuple description of the tuple on cpview's stream 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

Generated on Fri Nov 12 15:15:20 2004 for Borealis by doxygen 1.3.8