Changeset 2019 for XIOS/dev/dev_trunk_graph/src/filter
- Timestamp:
- 01/22/21 12:00:29 (3 years ago)
- Location:
- XIOS/dev/dev_trunk_graph/src/filter
- Files:
-
- 22 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_graph/src/filter/binary_arithmetic_filter.cpp
r1686 r2019 1 1 #include "binary_arithmetic_filter.hpp" 2 #include "workflow_graph.hpp"3 #include "yacc_var.hpp"4 #include "file.hpp"5 6 2 7 3 namespace xios … … 11 7 , op(operatorExpr.getOpScalarField(op)) 12 8 , value(value) 13 { 14 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 15 }; 16 17 std::tuple<int, int, int> CScalarFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 18 { 19 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 20 // bool building_graph = true; 21 int unique_filter_id; 22 bool firstround; 23 24 if(building_graph) 25 { 26 CWorkflowGraph::allocNodeEdge(); 27 28 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 29 30 // first round 31 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 32 { 33 firstround = true; 34 this->filterID = InvalidableObject::filterIdGenerator++; 35 int edgeID = InvalidableObject::edgeIdGenerator++; 36 37 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 38 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 39 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 40 41 42 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 43 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 44 45 46 if(CWorkflowGraph::build_begin) 47 { 48 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 49 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 50 51 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 52 } 53 else CWorkflowGraph::build_begin = true; 54 55 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 56 unique_filter_id = this->filterID; 57 } 58 // not first round 59 else 60 { 61 firstround=false; 62 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 63 if(data[0]->src_filterID != unique_filter_id) 64 { 65 int edgeID = InvalidableObject::edgeIdGenerator++; 66 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 67 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 68 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 69 } 70 } 71 } 72 73 return std::make_tuple(building_graph, firstround, unique_filter_id); 74 } 75 9 { /* Nothing to do */ }; 76 10 77 11 CDataPacketPtr CScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 81 15 packet->timestamp = data[0]->timestamp; 82 16 packet->status = data[0]->status; 83 84 std::tuple<int, int, int> graph = buildGraph(data);85 86 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);87 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;88 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;89 90 packet->field = this->field;91 17 92 18 if (packet->status == CDataPacket::NO_ERROR) … … 100 26 , op(operatorExpr.getOpFieldScalar(op)) 101 27 , value(value) 102 { 103 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 104 }; 105 106 std::tuple<int, int, int> CFieldScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 107 { 108 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 109 // bool building_graph = true; 110 int unique_filter_id; 111 bool firstround; 112 113 if(building_graph) 114 { 115 CWorkflowGraph::allocNodeEdge(); 116 117 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 118 119 // first round 120 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 121 { 122 firstround = true; 123 this->filterID = InvalidableObject::filterIdGenerator++; 124 int edgeID = InvalidableObject::edgeIdGenerator++; 125 126 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 127 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 128 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 129 130 131 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 132 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 133 134 135 if(CWorkflowGraph::build_begin) 136 { 137 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 138 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 139 140 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 141 } 142 else CWorkflowGraph::build_begin = true; 143 144 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 145 unique_filter_id = this->filterID; 146 } 147 // not first round 148 else 149 { 150 firstround=false; 151 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 152 if(data[0]->src_filterID != unique_filter_id) 153 { 154 int edgeID = InvalidableObject::edgeIdGenerator++; 155 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 156 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 157 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 158 } 159 } 160 } 161 162 return std::make_tuple(building_graph, firstround, unique_filter_id); 163 } 28 { /* Nothing to do */ }; 164 29 165 30 CDataPacketPtr CFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 169 34 packet->timestamp = data[0]->timestamp; 170 35 packet->status = data[0]->status; 171 172 std::tuple<int, int, int> graph = buildGraph(data);173 174 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);175 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;176 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;177 178 packet->field = this->field;179 36 180 37 if (packet->status == CDataPacket::NO_ERROR) … … 187 44 : CFilter(gc, 2, this) 188 45 , op(operatorExpr.getOpFieldField(op)) 189 { 190 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 191 }; 192 193 std::tuple<int, int, int> CFieldFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 194 { 195 bool building_graph = this->tag ? ((data[0]->timestamp >= this->field->field_graph_start && data[0]->timestamp <= this->field->field_graph_end) && (data[0]->timestamp == data[1]->timestamp)) : false; 196 197 int unique_filter_id; 198 199 bool firstround; 200 201 if(building_graph) 202 { 203 CWorkflowGraph::allocNodeEdge(); 204 205 // std::cout<<"CFieldFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 206 207 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 208 209 // first round 210 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 211 { 212 firstround = true; 213 this->filterID = InvalidableObject::filterIdGenerator++; 214 int edgeID = InvalidableObject::edgeIdGenerator++; 215 216 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 217 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 218 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 219 220 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 221 222 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 223 if(CWorkflowGraph::build_begin) 224 { 225 226 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 227 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 228 229 edgeID = InvalidableObject::edgeIdGenerator++; 230 231 CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 232 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 233 234 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 235 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 236 } 237 CWorkflowGraph::build_begin = true; 238 239 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 240 unique_filter_id = this->filterID; 241 242 } 243 // not first round 244 else 245 { 246 firstround = false; 247 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 248 if(data[0]->src_filterID != unique_filter_id) 249 { 250 int edgeID = InvalidableObject::edgeIdGenerator++; 251 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 252 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 253 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 254 } 255 if(data[1]->src_filterID != unique_filter_id) 256 { 257 int edgeID = InvalidableObject::edgeIdGenerator++; 258 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); 259 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 260 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 261 } 262 263 } 264 } 265 266 return std::make_tuple(building_graph, firstround, unique_filter_id); 267 } 46 { /* Nothing to do */ }; 268 47 269 48 CDataPacketPtr CFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 272 51 packet->date = data[0]->date; 273 52 packet->timestamp = data[0]->timestamp; 274 275 std::tuple<int, int, int> graph = buildGraph(data);276 277 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);278 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;279 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;280 281 packet->field = this->field;282 283 53 284 54 if (data[0]->status != CDataPacket::NO_ERROR) … … 294 64 return packet; 295 65 } 296 297 StdString CScalarFieldArithmeticFilter::GetName(void) { return StdString("CScalarFieldArithmeticFilter"); }298 StdString CFieldScalarArithmeticFilter::GetName(void) { return StdString("CFieldScalarArithmeticFilter"); }299 StdString CFieldFieldArithmeticFilter::GetName(void) { return StdString("CFieldFieldArithmeticFilter"); }300 301 302 66 } // namespace xios -
XIOS/dev/dev_trunk_graph/src/filter/binary_arithmetic_filter.hpp
r1686 r2019 6 6 #include "operator_expr.hpp" 7 7 #include <unordered_map> 8 #include <tuple>9 8 10 9 namespace xios … … 24 23 */ 25 24 CScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value); 26 StdString virtual GetName(void);27 28 25 29 26 protected: … … 38 35 */ 39 36 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 40 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);41 42 43 37 }; // class CScalarFieldArithmeticFilter 44 38 … … 57 51 */ 58 52 CFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value); 59 StdString virtual GetName(void);60 61 53 62 54 protected: … … 71 63 */ 72 64 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 73 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);74 65 }; // class CFieldScalarArithmeticFilter 75 66 … … 87 78 */ 88 79 CFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op); 89 StdString virtual GetName(void);90 91 80 92 81 protected: … … 100 89 */ 101 90 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 102 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);103 91 }; // class CFieldFieldArithmeticFilter 104 92 } // namespace xios -
XIOS/dev/dev_trunk_graph/src/filter/data_packet.hpp
r1686 r2019 6 6 #include "array_new.hpp" 7 7 #include "date.hpp" 8 #include "graph_package.hpp" 8 9 9 10 namespace xios 10 11 { 11 class CField;12 12 /*! 13 13 * A packet corresponds to a timestamped array of data. … … 23 23 }; 24 24 25 CGraphDataPackage * graphPackage; 26 25 27 CArray<double, 1> data; //!< Array containing the data 26 28 CDate date; //!< Date associated to the data 27 29 Time timestamp; //!< Timestamp of the data 28 30 StatusCode status; //!< Status of the packet 29 int src_filterID; 30 std::vector<int> filterIDoutputs; 31 CField *field; 32 int distance; 33 31 34 32 /*! 35 33 * Creates a deep copy of the packet. … … 37 35 * \return a deep copy of the packet 38 36 */ 39 CDataPacket* copy() const { 37 CDataPacket* copy() const 38 { 40 39 CDataPacket* p = new CDataPacket; 41 40 p->data.resize(data.shape()); … … 44 43 p->timestamp = timestamp; 45 44 p->status = status; 45 p->graphPackage = graphPackage; 46 46 return p; 47 47 }; 48 49 50 CDataPacket() : graphPackage(nullptr) {} 51 48 52 }; // struct CDataPacket 49 53 -
XIOS/dev/dev_trunk_graph/src/filter/filter.cpp
r1686 r2019 5 5 CFilter::CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine) 6 6 : CInputPin(gc, inputSlotsCount) 7 , COutputPin(gc , false)7 , COutputPin(gc) 8 8 , engine(engine) 9 9 , inputSlotCount(inputSlotCount) 10 10 { /* Nothing to do */ } 11 12 StdString CFilter::GetName(void) { return StdString("Filter"); }13 11 14 12 void CFilter::onInputReady(std::vector<CDataPacketPtr> data) -
XIOS/dev/dev_trunk_graph/src/filter/filter.hpp
r1686 r2019 25 25 */ 26 26 CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine); 27 28 StdString virtual GetName(void);29 27 30 28 /*! … … 64 62 bool virtual isDataExpected(const CDate& date) const; 65 63 66 67 68 69 int filterID;70 StdString expression;71 72 64 protected: 73 65 IFilterEngine* engine; //!< The filter engine, might be the filter itself -
XIOS/dev/dev_trunk_graph/src/filter/garbage_collector.cpp
r1686 r2019 3 3 namespace xios 4 4 { 5 int InvalidableObject::filterIdGenerator = 0;6 7 int InvalidableObject::edgeIdGenerator = 0;8 9 int InvalidableObject::clusterIdGenerator = 0;10 11 5 void CGarbageCollector::registerObject(InvalidableObject* Object, Time timestamp) 12 6 { -
XIOS/dev/dev_trunk_graph/src/filter/garbage_collector.hpp
r1686 r2019 20 20 */ 21 21 void virtual invalidate(Time timestamp) = 0; 22 23 24 25 static int filterIdGenerator;26 27 static int edgeIdGenerator;28 29 static int clusterIdGenerator;30 31 32 33 22 }; // struct InvalidableObject 34 23 -
XIOS/dev/dev_trunk_graph/src/filter/input_pin.cpp
r1686 r2019 3 3 #include "garbage_collector.hpp" 4 4 #include "exception.hpp" 5 #include "workflow_graph.hpp"6 5 7 6 namespace xios … … 12 11 , triggers(slotsCount) 13 12 , hasTriggers(false) 14 { } 15 16 StdString CInputPin::GetName(void) 17 { 18 return StdString("Input pin"); 19 } 13 { /* Nothing to do */ } 20 14 21 15 void CInputPin::setInput(size_t inputSlot, CDataPacketPtr packet) -
XIOS/dev/dev_trunk_graph/src/filter/input_pin.hpp
r1686 r2019 26 26 */ 27 27 CInputPin(CGarbageCollector& gc, size_t slotsCount); 28 29 StdString virtual GetName(void);30 28 31 29 /*! -
XIOS/dev/dev_trunk_graph/src/filter/output_pin.cpp
r1686 r2019 1 1 #include "output_pin.hpp" 2 2 #include "exception.hpp" 3 #include "workflow_graph.hpp"4 3 5 4 namespace xios … … 7 6 COutputPin::COutputPin(CGarbageCollector& gc, bool manualTrigger /*= false*/) 8 7 : gc(gc) 9 , manualTrigger(manualTrigger) 10 { } 11 12 StdString COutputPin::GetName(void) 13 { 14 return StdString("Output pin"); 15 } 8 , manualTrigger(manualTrigger), graphEnabled(false) 9 { /* Nothing to do */ } 16 10 17 11 void COutputPin::connectOutput(std::shared_ptr<CInputPin> inputPin, size_t inputSlot) … … 107 101 outputPackets.erase(outputPackets.begin(), outputPackets.lower_bound(timestamp)); 108 102 } 109 110 void COutputPin::setParentFiltersTag()111 {112 for(int i=0; i<parent_filters.size(); i++)113 {114 115 if(parent_filters[i]->start_graph<0) parent_filters[i]->start_graph = start_graph;116 else parent_filters[i]->start_graph = min(parent_filters[i]->start_graph, start_graph);117 118 119 if(parent_filters[i]->end_graph<0) parent_filters[i]->end_graph = end_graph;120 else parent_filters[i]->end_graph = max(parent_filters[i]->end_graph, end_graph);121 122 123 parent_filters[i]->tag += tag;124 parent_filters[i]->setParentFiltersTag();125 }126 }127 128 129 130 131 103 } // namespace xios -
XIOS/dev/dev_trunk_graph/src/filter/output_pin.hpp
r1686 r2019 4 4 #include "garbage_collector.hpp" 5 5 #include "input_pin.hpp" 6 #include " duration.hpp"6 #include "graph_package.hpp" 7 7 8 8 namespace xios 9 9 { 10 class CField;11 class CInputPin;12 class CFilter;13 class CDuration;14 10 /*! 15 11 * An output pin handles the connections with downstream filters. … … 18 14 { 19 15 public: 20 int tag;21 Time start_graph;22 Time end_graph;23 CField *field;24 int distance;25 26 27 28 std::vector< std::shared_ptr<COutputPin> > parent_filters;29 30 16 /*! 31 17 * Constructs an ouput pin with manual or automatic trigger … … 37 23 COutputPin(CGarbageCollector& gc, bool manualTrigger = false); 38 24 39 StdString virtual GetName(void);40 41 25 /*! 42 26 * Connects to a specific slot of the input pin of a downstream filter. … … 82 66 */ 83 67 void virtual invalidate(Time timestamp); 84 85 void virtual setParentFiltersTag(); 86 68 CGraphPackage *graphPackage; 69 bool graphEnabled; 87 70 88 71 protected: -
XIOS/dev/dev_trunk_graph/src/filter/pass_through_filter.cpp
r1688 r2019 1 1 #include "pass_through_filter.hpp" 2 2 #include "workflow_graph.hpp" 3 #include "field.hpp" 4 #include "file.hpp" 3 #include <algorithm> 5 4 6 5 namespace xios … … 8 7 CPassThroughFilter::CPassThroughFilter(CGarbageCollector& gc) 9 8 : CFilter(gc, 1, this) 10 { 11 } 12 13 void CPassThroughFilter::buildGraph(std::vector<CDataPacketPtr> data) 14 { 15 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 16 // bool building_graph = this->tag ? data[0]->timestamp >= this->field->field_graph_start && data[0]->timestamp <= this->field->field_graph_end : false; 17 18 if(building_graph) 19 { 20 // std::cout<<"CPassThroughFilter::apply field_id = "<<this->field->getId()<<" start = "<<start_graph<<" end = "<<end_graph<<std::endl; 21 this->filterID = InvalidableObject::filterIdGenerator++; 22 int edgeID = InvalidableObject::edgeIdGenerator++; 23 24 CWorkflowGraph::allocNodeEdge(); 25 26 CWorkflowGraph::addNode(this->filterID, "Pass Through Filter\\n("+data[0]->field->getId()+")", 2, 1, 1, data[0]); 27 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 28 29 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 30 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 31 32 33 if(CWorkflowGraph::build_begin) 34 { 35 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 36 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0; 37 } 38 else CWorkflowGraph::build_begin = true; 39 40 data[0]->src_filterID=this->filterID; 41 data[0]->distance++; 42 43 } 44 45 data[0]->field = this->field; 46 } 9 { /* Nothing to do */ } 47 10 48 11 CDataPacketPtr CPassThroughFilter::apply(std::vector<CDataPacketPtr> data) 49 12 { 50 if(CXios::isClient) buildGraph(data);13 buildWorkflowGraph(data); 51 14 return data[0]; 52 15 } 16 17 void CPassThroughFilter::buildWorkflowGraph(std::vector<CDataPacketPtr> data) 18 { 19 if(this->graphEnabled) 20 { 21 this->graphPackage->filterId = CWorkflowGraph::getNodeSize(); 22 23 if(!data[0]->graphPackage) 24 { 25 data[0]->graphPackage = new CGraphDataPackage; 26 data[0]->graphPackage->fromFilter = -1; 27 } 28 29 data[0]->graphPackage->currentField = this->graphPackage->inFields[0]; 30 std::rotate(this->graphPackage->inFields.begin(), this->graphPackage->inFields.begin() + 1, this->graphPackage->inFields.end()); 31 32 CWorkflowGraph::addNode("Pass through filter", 2, false, 1, data[0]); 33 CWorkflowGraph::addEdge(data[0]->graphPackage->fromFilter, this->graphPackage->filterId, data[0]); 34 data[0]->graphPackage->fromFilter = this->graphPackage->filterId; 35 36 } 37 } 38 39 53 40 } // namespace xios 41 -
XIOS/dev/dev_trunk_graph/src/filter/pass_through_filter.hpp
r1686 r2019 20 20 CPassThroughFilter(CGarbageCollector& gc); 21 21 22 inline StdString GetName(void) {return StdString("Pass through filter");};23 24 22 protected: 25 23 /*! … … 30 28 */ 31 29 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 32 void virtual buildGraph(std::vector<CDataPacketPtr> data); 30 void buildWorkflowGraph(std::vector<CDataPacketPtr> data); 31 33 32 }; // class CPassThroughFilter 34 33 } // namespace xios -
XIOS/dev/dev_trunk_graph/src/filter/temporal_filter.cpp
r1686 r2019 3 3 #include "calendar_util.hpp" 4 4 #include "workflow_graph.hpp" 5 #include "file.hpp"6 5 7 6 namespace xios … … 27 26 , nbOperationDates(1) 28 27 , nbSamplingDates(0) 29 // , nextOperationDate(initDate + opFreq + this->samplingOffset)30 28 , isFirstOperation(true) 31 , temp_op(opId)32 29 { 33 30 } 34 31 35 36 37 38 39 bool CTemporalFilter::buildGraph(std::vector<CDataPacketPtr> data) 32 void CTemporalFilter::buildWorkflowGraph(std::vector<CDataPacketPtr> data) 40 33 { 41 bool building_graph=this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 42 43 if(building_graph) 34 if(this->graphEnabled) 44 35 { 45 if(this->filterIDoutputs.size()==0) this->filterID = InvalidableObject::filterIdGenerator++; 46 int edgeID = InvalidableObject::edgeIdGenerator++; 36 if(!data[0]->graphPackage) data[0]->graphPackage = new CGraphDataPackage; 37 data[0]->graphPackage->currentField = this->graphPackage->inFields[0]; 38 std::rotate(this->graphPackage->inFields.begin(), this->graphPackage->inFields.begin() + 1, this->graphPackage->inFields.end()); 47 39 48 // std::cout<<"CTemporalFilter::apply filter tag = "<<this->tag<<" start = "<<this->start_graph<<" end = "<<this->end_graph<<std::endl; 49 50 CWorkflowGraph::allocNodeEdge(); 51 52 if(this->filterIDoutputs.size()==0) 53 { 54 CWorkflowGraph::addNode(this->filterID, "Temporal Filter\\n("+this->temp_op+")", 5, 1, 0, data[0]); 55 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].transform_type = this->temp_op; 56 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].inputs_complete = false ; 57 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].clusterID = 1 ; 58 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = (data[0]->distance); 59 60 61 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 62 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 40 if(this->graphPackage->sourceFilterIds.size()==0) 41 { 42 this->graphPackage->filterId = CWorkflowGraph::getNodeSize(); 43 CWorkflowGraph::addNode("Temporal filter", 3, false, 0, data[0]); 63 44 } 64 65 if(CWorkflowGraph::build_begin) 66 { 67 68 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 69 70 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 71 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb += 1 ; 72 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = max(data[0]->distance+1, (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance); 73 } 74 75 76 this->filterIDoutputs.push_back(data[0]->src_filterID); 45 46 CWorkflowGraph::addEdge(data[0]->graphPackage->fromFilter, this->graphPackage->filterId, data[0]); 47 data[0]->graphPackage->fromFilter = this->graphPackage->filterId; 48 this->graphPackage->sourceFilterIds.push_back(data[0]->graphPackage->fromFilter); 77 49 } 78 50 79 return building_graph;80 51 } 81 82 83 52 CDataPacketPtr CTemporalFilter::apply(std::vector<CDataPacketPtr> data) 84 53 { 85 b ool BG = buildGraph(data);86 54 buildWorkflowGraph(data); 55 87 56 CDataPacketPtr packet; 88 57 … … 126 95 packet->data.resize(tmpData.numElements()); 127 96 packet->data = tmpData; 97 packet->graphPackage = data[0]->graphPackage; 128 98 } 129 99 else … … 132 102 isFirstOperation = false; 133 103 134 packet->field = this->field;135 136 if(BG)137 {138 packet->src_filterID=this->filterID;139 packet->distance = data[0]->distance+1;140 this->filterIDoutputs.clear();141 CWorkflowGraph::build_begin=true;142 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].inputs_complete = true ;143 }144 104 } 145 105 } … … 155 115 bool CTemporalFilter::isDataExpected(const CDate& date) const 156 116 { 157 // return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate);158 117 return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date > initDate + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth); 159 118 } -
XIOS/dev/dev_trunk_graph/src/filter/temporal_filter.hpp
r1686 r2019 31 31 bool ignoreMissingValue = false); 32 32 33 inline StdString GetName(void) {return StdString("Temporal filter");};34 35 33 /*! 36 34 * Applies the temporal operation to the input data and returns the result when it is ready. … … 40 38 */ 41 39 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 42 bool virtual buildGraph(std::vector<CDataPacketPtr> data); 40 41 void buildWorkflowGraph(std::vector<CDataPacketPtr> data); 43 42 44 43 /*! … … 55 54 */ 56 55 bool virtual isDataExpected(const CDate& date) const; 57 std::vector<int > filterIDoutputs;58 std::vector<std::pair<int, int> > filterIDoutputs_pair;59 60 StdString temp_op;61 56 62 57 private: -
XIOS/dev/dev_trunk_graph/src/filter/ternary_arithmetic_filter.cpp
r1686 r2019 1 1 #include "ternary_arithmetic_filter.hpp" 2 #include "workflow_graph.hpp"3 #include "yacc_var.hpp"4 #include "file.hpp"5 2 6 3 namespace xios … … 11 8 , value1(value1) 12 9 , value2(value2) 13 { 14 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 15 /* Nothing to do */ 16 }; 17 18 std::tuple<int, int, int> CScalarScalarFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 19 { 20 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 21 int unique_filter_id; 22 bool firstround; 23 24 if(building_graph) 25 { 26 CWorkflowGraph::allocNodeEdge(); 27 28 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 29 30 // first round 31 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 32 { 33 firstround = true; 34 this->filterID = InvalidableObject::filterIdGenerator++; 35 int edgeID = InvalidableObject::edgeIdGenerator++; 36 37 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 38 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 39 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 40 41 42 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 43 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 44 45 46 if(CWorkflowGraph::build_begin) 47 { 48 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 49 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 50 51 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 52 } 53 else CWorkflowGraph::build_begin = true; 54 55 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 56 unique_filter_id = this->filterID; 57 } 58 // not first round 59 else 60 { 61 firstround=false; 62 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 63 if(data[0]->src_filterID != unique_filter_id) 64 { 65 int edgeID = InvalidableObject::edgeIdGenerator++; 66 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 67 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 68 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 69 } 70 } 71 } 72 73 return std::make_tuple(building_graph, firstround, unique_filter_id); 74 } 10 { /* Nothing to do */ }; 75 11 76 12 CDataPacketPtr CScalarScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 80 16 packet->timestamp = data[0]->timestamp; 81 17 packet->status = data[0]->status; 82 83 std::tuple<int, int, int> graph = buildGraph(data);84 85 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);86 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;87 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;88 89 packet->field = this->field;90 18 91 19 if (packet->status == CDataPacket::NO_ERROR) … … 100 28 , value1(value1) 101 29 , value2(value2) 102 { 103 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 104 /* Nothing to do */ 105 }; 106 107 std::tuple<int, int, int> CScalarFieldScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 108 { 109 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 110 int unique_filter_id; 111 bool firstround; 112 113 if(building_graph) 114 { 115 CWorkflowGraph::allocNodeEdge(); 116 117 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 118 119 // first round 120 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 121 { 122 firstround = true; 123 this->filterID = InvalidableObject::filterIdGenerator++; 124 int edgeID = InvalidableObject::edgeIdGenerator++; 125 126 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 127 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 128 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 129 130 131 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 132 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 133 134 135 if(CWorkflowGraph::build_begin) 136 { 137 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 138 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 139 140 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 141 } 142 else CWorkflowGraph::build_begin = true; 143 144 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 145 unique_filter_id = this->filterID; 146 } 147 // not first round 148 else 149 { 150 firstround=false; 151 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 152 if(data[0]->src_filterID != unique_filter_id) 153 { 154 int edgeID = InvalidableObject::edgeIdGenerator++; 155 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 156 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 157 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 158 } 159 } 160 } 161 162 return std::make_tuple(building_graph, firstround, unique_filter_id); 163 } 30 { /* Nothing to do */ }; 164 31 165 32 CDataPacketPtr CScalarFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 169 36 packet->timestamp = data[0]->timestamp; 170 37 packet->status = data[0]->status; 171 172 std::tuple<int, int, int> graph = buildGraph(data);173 174 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);175 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;176 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;177 178 packet->field = this->field;179 38 180 39 if (packet->status == CDataPacket::NO_ERROR) … … 188 47 , op(operatorExpr.getOpScalarFieldField(op)) 189 48 , value(value) 190 { 191 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 192 /* Nothing to do */ 193 }; 194 195 std::tuple<int, int, int> CScalarFieldFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 196 { 197 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 198 int unique_filter_id; 199 200 bool firstround; 201 202 if(building_graph) 203 { 204 CWorkflowGraph::allocNodeEdge(); 205 206 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 207 208 // first round 209 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 210 { 211 firstround = true; 212 this->filterID = InvalidableObject::filterIdGenerator++; 213 int edgeID = InvalidableObject::edgeIdGenerator++; 214 215 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 216 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 217 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 218 219 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 220 221 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 222 if(CWorkflowGraph::build_begin) 223 { 224 225 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 226 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 227 228 edgeID = InvalidableObject::edgeIdGenerator++; 229 230 CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 231 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 232 233 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 234 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 235 } 236 CWorkflowGraph::build_begin = true; 237 238 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 239 unique_filter_id = this->filterID; 240 241 } 242 // not first round 243 else 244 { 245 firstround = false; 246 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 247 if(data[0]->src_filterID != unique_filter_id) 248 { 249 int edgeID = InvalidableObject::edgeIdGenerator++; 250 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 251 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 252 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 253 } 254 if(data[1]->src_filterID != unique_filter_id) 255 { 256 int edgeID = InvalidableObject::edgeIdGenerator++; 257 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); 258 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 259 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 260 } 261 262 } 263 } 264 265 return std::make_tuple(building_graph, firstround, unique_filter_id); 266 } 49 { /* Nothing to do */ }; 267 50 268 51 CDataPacketPtr CScalarFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 272 55 packet->timestamp = data[0]->timestamp; 273 56 packet->status = data[0]->status; 274 275 std::tuple<int, int, int> graph = buildGraph(data);276 277 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);278 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;279 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;280 281 packet->field = this->field;282 57 283 58 if (data[0]->status != CDataPacket::NO_ERROR) … … 300 75 , value1(value1) 301 76 , value2(value2) 302 { 303 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 304 /* Nothing to do */ 305 }; 306 307 std::tuple<int, int, int> CFieldScalarScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 308 { 309 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 310 int unique_filter_id; 311 bool firstround; 312 313 if(building_graph) 314 { 315 CWorkflowGraph::allocNodeEdge(); 316 317 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 318 319 // first round 320 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 321 { 322 firstround = true; 323 this->filterID = InvalidableObject::filterIdGenerator++; 324 int edgeID = InvalidableObject::edgeIdGenerator++; 325 326 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 327 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 328 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 329 330 331 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 332 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 333 334 335 if(CWorkflowGraph::build_begin) 336 { 337 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 338 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 339 340 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 341 } 342 else CWorkflowGraph::build_begin = true; 343 344 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 345 unique_filter_id = this->filterID; 346 } 347 // not first round 348 else 349 { 350 firstround=false; 351 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 352 if(data[0]->src_filterID != unique_filter_id) 353 { 354 int edgeID = InvalidableObject::edgeIdGenerator++; 355 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 356 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 357 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 358 } 359 } 360 } 361 362 return std::make_tuple(building_graph, firstround, unique_filter_id); 363 } 77 { /* Nothing to do */ }; 364 78 365 79 CDataPacketPtr CFieldScalarScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 369 83 packet->timestamp = data[0]->timestamp; 370 84 packet->status = data[0]->status; 371 372 std::tuple<int, int, int> graph = buildGraph(data);373 374 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);375 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;376 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;377 378 packet->field = this->field;379 85 380 86 if (packet->status == CDataPacket::NO_ERROR) … … 389 95 , op(operatorExpr.getOpFieldScalarField(op)) 390 96 , value(value) 391 { 392 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 393 /* Nothing to do */ 394 }; 395 396 std::tuple<int, int, int> CFieldScalarFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 397 { 398 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 399 int unique_filter_id; 400 401 bool firstround; 402 403 if(building_graph) 404 { 405 CWorkflowGraph::allocNodeEdge(); 406 407 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 408 409 // first round 410 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 411 { 412 firstround = true; 413 this->filterID = InvalidableObject::filterIdGenerator++; 414 int edgeID = InvalidableObject::edgeIdGenerator++; 415 416 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 417 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 418 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 419 420 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 421 422 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 423 if(CWorkflowGraph::build_begin) 424 { 425 426 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 427 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 428 429 edgeID = InvalidableObject::edgeIdGenerator++; 430 431 CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 432 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 433 434 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 435 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 436 } 437 CWorkflowGraph::build_begin = true; 438 439 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 440 unique_filter_id = this->filterID; 441 442 } 443 // not first round 444 else 445 { 446 firstround = false; 447 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 448 if(data[0]->src_filterID != unique_filter_id) 449 { 450 int edgeID = InvalidableObject::edgeIdGenerator++; 451 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 452 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 453 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 454 } 455 if(data[1]->src_filterID != unique_filter_id) 456 { 457 int edgeID = InvalidableObject::edgeIdGenerator++; 458 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); 459 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 460 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 461 } 462 463 } 464 } 465 466 return std::make_tuple(building_graph, firstround, unique_filter_id); 467 } 97 { /* Nothing to do */ }; 468 98 469 99 CDataPacketPtr CFieldScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 473 103 packet->timestamp = data[0]->timestamp; 474 104 packet->status = data[0]->status; 475 476 std::tuple<int, int, int> graph = buildGraph(data);477 478 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);479 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;480 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;481 482 packet->field = this->field;483 105 484 106 if (data[0]->status != CDataPacket::NO_ERROR) … … 498 120 , op(operatorExpr.getOpFieldFieldScalar(op)) 499 121 , value(value) 500 { 501 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 502 std::cout<<"expression = "<<expression; 503 /* Nothing to do */ 504 }; 505 506 std::tuple<int, int, int> CFieldFieldScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 507 { 508 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 509 int unique_filter_id; 510 511 bool firstround; 512 513 if(building_graph) 514 { 515 CWorkflowGraph::allocNodeEdge(); 516 517 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 518 519 // first round 520 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 521 { 522 firstround = true; 523 this->filterID = InvalidableObject::filterIdGenerator++; 524 int edgeID = InvalidableObject::edgeIdGenerator++; 525 526 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 527 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 528 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 529 530 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 531 532 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 533 if(CWorkflowGraph::build_begin) 534 { 535 536 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 537 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 538 539 edgeID = InvalidableObject::edgeIdGenerator++; 540 541 CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 542 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 543 544 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 545 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 546 } 547 CWorkflowGraph::build_begin = true; 548 549 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 550 unique_filter_id = this->filterID; 551 552 } 553 // not first round 554 else 555 { 556 firstround = false; 557 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 558 if(data[0]->src_filterID != unique_filter_id) 559 { 560 int edgeID = InvalidableObject::edgeIdGenerator++; 561 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 562 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 563 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 564 } 565 if(data[1]->src_filterID != unique_filter_id) 566 { 567 int edgeID = InvalidableObject::edgeIdGenerator++; 568 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); 569 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 570 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 571 } 572 573 } 574 } 575 576 return std::make_tuple(building_graph, firstround, unique_filter_id); 577 } 122 { /* Nothing to do */ }; 578 123 579 124 CDataPacketPtr CFieldFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 583 128 packet->timestamp = data[0]->timestamp; 584 129 packet->status = data[0]->status; 585 586 std::tuple<int, int, int> graph = buildGraph(data);587 588 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);589 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;590 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;591 592 packet->field = this->field;593 130 594 131 if (data[0]->status != CDataPacket::NO_ERROR) … … 608 145 : CFilter(gc, 3, this) 609 146 , op(operatorExpr.getOpFieldFieldField(op)) 610 { 611 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 612 /* Nothing to do */ 613 }; 614 615 std::tuple<int, int, int> CFieldFieldFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 616 { 617 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 618 int unique_filter_id; 619 620 bool firstround; 621 622 if(building_graph) 623 { 624 CWorkflowGraph::allocNodeEdge(); 625 626 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 627 628 // first round 629 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 630 { 631 firstround = true; 632 this->filterID = InvalidableObject::filterIdGenerator++; 633 int edgeID = InvalidableObject::edgeIdGenerator++; 634 635 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 636 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 637 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 638 639 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 640 641 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 642 if(CWorkflowGraph::build_begin) 643 { 644 645 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 646 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 647 648 edgeID = InvalidableObject::edgeIdGenerator++; 649 650 CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 651 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 652 653 edgeID = InvalidableObject::edgeIdGenerator++; 654 655 CWorkflowGraph::addEdge(edgeID, this->filterID, data[2]); 656 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 657 658 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 659 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 660 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[2]->src_filterID].filter_filled = 0 ; 661 } 662 CWorkflowGraph::build_begin = true; 663 664 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 665 unique_filter_id = this->filterID; 666 667 } 668 // not first round 669 else 670 { 671 firstround = false; 672 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 673 if(data[0]->src_filterID != unique_filter_id) 674 { 675 int edgeID = InvalidableObject::edgeIdGenerator++; 676 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 677 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 678 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 679 } 680 if(data[1]->src_filterID != unique_filter_id) 681 { 682 int edgeID = InvalidableObject::edgeIdGenerator++; 683 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); 684 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 685 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 686 } 687 if(data[2]->src_filterID != unique_filter_id) 688 { 689 int edgeID = InvalidableObject::edgeIdGenerator++; 690 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[2]); 691 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[2]->src_filterID].filter_filled = 0 ; 692 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 693 } 694 695 } 696 } 697 698 return std::make_tuple(building_graph, firstround, unique_filter_id); 699 } 147 { /* Nothing to do */ }; 700 148 701 149 CDataPacketPtr CFieldFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 705 153 packet->timestamp = data[0]->timestamp; 706 154 packet->status = data[0]->status; 707 708 std::tuple<int, int, int> graph = buildGraph(data);709 710 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);711 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;712 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;713 714 packet->field = this->field;715 155 716 156 if (data[0]->status != CDataPacket::NO_ERROR) -
XIOS/dev/dev_trunk_graph/src/filter/ternary_arithmetic_filter.hpp
r1686 r2019 5 5 #include <string> 6 6 #include "operator_expr.hpp" 7 #include <tuple>8 7 9 8 namespace xios … … 37 36 */ 38 37 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 39 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);40 38 }; // class CScalarScalarFieldArithmeticFilter 41 39 … … 69 67 */ 70 68 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 71 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);72 69 }; // class CScalarScalarFieldArithmeticFilter 73 70 … … 98 95 */ 99 96 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 100 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);101 97 }; // class CScalarScalarFieldArithmeticFilter 102 98 … … 131 127 */ 132 128 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 133 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);134 129 }; // class CFieldScalarScalarArithmeticFilter 135 130 … … 161 156 */ 162 157 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 163 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);164 158 }; // class CFieldScalarFieldArithmeticFilter 165 159 … … 191 185 */ 192 186 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 193 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);194 187 }; // class CFieldFielScalardArithmeticFilter 195 188 … … 219 212 */ 220 213 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 221 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);222 214 }; // class CFieldFielFieldArithmeticFilter 223 215 -
XIOS/dev/dev_trunk_graph/src/filter/unary_arithmetic_filter.cpp
r1686 r2019 1 1 #include "unary_arithmetic_filter.hpp" 2 #include "workflow_graph.hpp"3 #include "yacc_var.hpp"4 #include "file.hpp"5 2 6 3 namespace xios … … 9 6 : CFilter(gc, 1, this) 10 7 , op(operatorExpr.getOpField(op)) 11 { 12 expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 13 }; 14 15 std::tuple<int, int, int> CUnaryArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) 16 { 17 bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 18 int unique_filter_id; 19 bool firstround; 20 21 if(building_graph) 22 { 23 CWorkflowGraph::allocNodeEdge(); 24 size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 25 26 // first round 27 if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 28 { 29 firstround=true; 30 this->filterID = InvalidableObject::filterIdGenerator++; 31 int edgeID = InvalidableObject::edgeIdGenerator++; 32 33 CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 34 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 35 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 36 37 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 38 if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 39 40 if(CWorkflowGraph::build_begin) 41 { 42 43 CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 44 (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 45 46 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 47 } 48 else CWorkflowGraph::build_begin = true; 49 50 (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; 51 unique_filter_id = this->filterID; 52 } 53 else 54 { 55 firstround=false; 56 unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 57 if(data[0]->src_filterID != unique_filter_id) 58 { 59 int edgeID = InvalidableObject::edgeIdGenerator++; 60 CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); 61 (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 62 (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 63 } 64 } 65 66 } 67 68 return std::make_tuple(building_graph, firstround, unique_filter_id); 69 } 8 { /* Nothing to do */ }; 70 9 71 10 CDataPacketPtr CUnaryArithmeticFilter::apply(std::vector<CDataPacketPtr> data) … … 76 15 packet->status = data[0]->status; 77 16 78 std::tuple<int, int, int> graph = buildGraph(data);79 80 if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph);81 if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1;82 if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance;83 84 packet->field = this->field;85 86 17 if (packet->status == CDataPacket::NO_ERROR) 87 18 packet->data.reference(op(data[0]->data)); -
XIOS/dev/dev_trunk_graph/src/filter/unary_arithmetic_filter.hpp
r1686 r2019 34 34 */ 35 35 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 36 std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);37 36 }; // class CUnaryArithmeticFilter 38 37 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.