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

CP.h

Go to the documentation of this file.
00001 #ifndef CP_H 00002 #define CP_H 00003 00004 #include "CPStorage.h" 00005 #include "CPViewDescription.h" 00006 #include "TupleQueue.h" 00007 #include "CPView.h" 00008 #include <vector> 00009 #include <map> 00010 #include "common.h" 00011 00012 BOREALIS_NAMESPACE_BEGIN; 00013 00014 #define MAX_ENQUEUED 1000 00015 00016 class CPView; 00017 00018 class CP 00019 { 00020 00021 // friend class CPView; 00022 00023 public: 00024 00025 struct ltstr 00026 { 00027 bool operator()(string s1, string s2) const 00028 { 00029 return strcmp(s1.c_str(), s2.c_str()) < 0; 00030 } 00031 }; 00032 00033 00035 CP(ptr<CPViewDescription> cp_desc); 00036 00038 ~CP() {}; 00039 00041 void setStartPointer(string view_id, char* start); 00042 00044 void setEndPointer(string view_id, char* end); 00045 00047 void setPointers(string view_id, char* start, char* end); 00048 00050 ptr<CPView> createImplictView(string base_view_id); 00051 00053 ptr<CPView> createExplicitView(ptr<CPViewDescription> desc); 00054 00056 void enqueue(const void *tuple); 00057 00059 vector<char*> extract(char* first, char* last); 00060 vector<char*> extract(char* first, char* last, vector<ptr<Expression> > keys); 00061 00062 char* extract(string tuple_key, vector<ptr<Expression> > keys); 00063 00064 // NEW -- SINCE TUPLE_IDs ARE IN HEADER 00066 char* extract(int tuple_id); 00067 00070 vector<char*> extract(int start_order_by, int end_order_by, ptr<Expression> order_by_field, bool revisions); 00071 00072 ptr<CPStorage> getStorage(); 00073 00075 ptr<CPView> getCPView(string view_id); 00076 00077 map<string, ptr<CPView>, ltstr> getAllCPViews() { return _my_cp_views; } 00078 00080 void removeCPView(string view_id); 00081 00083 char* findFirstPointerToVal(int val, ptr<Expression> order_by); 00084 00086 char* findLastPointerToVal(int val, ptr<Expression> order_by); 00087 00088 // TODO stuff 00089 // 1. how is bulk copying of tuples to storage done? The listener is supposed to 00090 // copy the TupleQueue to CP's storage. How's that done??? 00091 00092 //adds a view to its list of views 00093 void setView(string view_id); 00094 00095 void addView(string view_id, ptr<CPView> cp_view); 00096 00097 //discards tuples that are not used by any views 00098 void discardTuples(); 00099 00100 string as_string() const 00101 { 00102 return string() + "CP{num_views=" + _my_cp_views.size() + ",num_tuples=" + _cp_storage->getNumTuples() + "}"; 00103 } 00104 00105 bool isLater(char* p1, char* p2); 00106 00107 private: 00108 // maps CPView's view_ids to start pointers 00109 typedef map<string, char*, ltstr> StartPointers; 00110 StartPointers _start_pointers; 00111 00112 // maps CPView's view_ids to end pointers 00113 typedef map<string, char*, ltstr> EndPointers; 00114 EndPointers _end_pointers; 00115 00116 // all views current on "this" CP 00117 typedef map<string, ptr<CPView>, ltstr> CPViewMap; 00118 CPViewMap _my_cp_views; 00119 00120 // where do I store tuples? => here 00121 ptr<CPStorage> _cp_storage; 00122 00123 // int32 MAX_QUEUED; 00124 int32 _enqueued_count; 00125 00126 //just for testing replaySince(), should be removed afterwards 00127 char* replaySinceTuple; 00128 }; 00129 00130 BOREALIS_NAMESPACE_END; 00131 00132 #endif // CP_H

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