Ignore:
Timestamp:
07/31/19 13:51:01 (5 years ago)
Author:
yushan
Message:

backup for trunk with graph

Location:
XIOS/dev/dev_olga/src/filter
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/filter/binary_arithmetic_filter.cpp

    r804 r1686  
    11#include "binary_arithmetic_filter.hpp" 
     2#include "workflow_graph.hpp" 
     3#include "yacc_var.hpp" 
     4#include "file.hpp" 
     5 
    26 
    37namespace xios 
     
    711    , op(operatorExpr.getOpScalarField(op)) 
    812    , value(value) 
    9   { /* Nothing to do */ }; 
     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 
    1076 
    1177  CDataPacketPtr CScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    1682    packet->status = data[0]->status; 
    1783 
     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 
    1892    if (packet->status == CDataPacket::NO_ERROR) 
    1993      packet->data.reference(op(value, data[0]->data)); 
     
    26100    , op(operatorExpr.getOpFieldScalar(op)) 
    27101    , value(value) 
    28   { /* Nothing to do */ }; 
     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  } 
    29164 
    30165  CDataPacketPtr CFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    35170    packet->status = data[0]->status; 
    36171 
     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 
    37180    if (packet->status == CDataPacket::NO_ERROR) 
    38181      packet->data.reference(op(data[0]->data, value)); 
     
    44187    : CFilter(gc, 2, this) 
    45188    , op(operatorExpr.getOpFieldField(op)) 
    46   { /* Nothing to do */ }; 
     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  } 
    47268 
    48269  CDataPacketPtr CFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    51272    packet->date = data[0]->date; 
    52273    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     
    53283 
    54284    if (data[0]->status != CDataPacket::NO_ERROR) 
     
    64294    return packet; 
    65295  } 
     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 
    66302} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/binary_arithmetic_filter.hpp

    r1542 r1686  
    66#include "operator_expr.hpp" 
    77#include <unordered_map> 
     8#include <tuple> 
    89 
    910namespace xios 
     
    2324       */ 
    2425      CScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value); 
     26      StdString virtual GetName(void); 
     27 
    2528 
    2629    protected: 
     
    3538       */ 
    3639      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     40      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
     41       
     42 
    3743  }; // class CScalarFieldArithmeticFilter 
    3844 
     
    5157       */ 
    5258      CFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value); 
     59      StdString virtual GetName(void); 
     60 
    5361 
    5462    protected: 
     
    6371       */ 
    6472      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     73      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    6574  }; // class CFieldScalarArithmeticFilter 
    6675 
     
    7887       */ 
    7988      CFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op); 
     89      StdString virtual GetName(void); 
     90 
    8091 
    8192    protected: 
     
    89100       */ 
    90101      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     102      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    91103  }; // class CFieldFieldArithmeticFilter 
    92104} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/data_packet.hpp

    r1542 r1686  
    99namespace xios 
    1010{ 
     11  class CField; 
    1112  /*! 
    1213   * A packet corresponds to a timestamped array of data. 
     
    2627    Time timestamp;         //!< Timestamp of the data 
    2728    StatusCode status;      //!< Status of the packet 
    28  
     29    int src_filterID; 
     30    std::vector<int> filterIDoutputs; 
     31    CField *field; 
     32    int distance; 
     33     
    2934    /*! 
    3035     * Creates a deep copy of the packet. 
  • XIOS/dev/dev_olga/src/filter/file_server_writer_filter.cpp

    r1654 r1686  
    1616  void CFileServerWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    1717  { 
    18     field->writeUpdateData(data[0]->data);     
     18    field->writeUpdateData(data[0]->data); 
    1919  } 
    2020 
     
    2828    return true; 
    2929  } 
    30  
    31   int CFileServerWriterFilter::getFilterId(void) 
    32   { 
    33     return filterId; 
    34   } 
    35  
    3630} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/file_server_writer_filter.hpp

    r1653 r1686  
    3737      bool virtual isDataExpected(const CDate& date) const; 
    3838 
    39       /*! 
    40        * Returns filter's id needed in case of building workflow graph 
    41        */ 
    42       int getFilterId(); 
    43  
    4439    protected: 
    4540      /*! 
     
    5146 
    5247    private: 
    53       CField* field;           //<! The associated field 
     48      CField* field; //<! The associated field 
    5449      std::map<Time, CDataPacketPtr> packets; //<! The stored packets 
    55       int filterId;            //<! Filter's id needed in case of building a workflow 
    56  
    5750  }; // class CFileServerWriterFilter 
    5851} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/file_writer_filter.cpp

    r1654 r1686  
    44#include "utils.hpp" 
    55#include "workflow_graph.hpp" 
     6#include "graphviz.hpp" 
    67 
    78namespace xios 
    89{ 
    9   CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field, bool buildWorkflowGraph /* =false */) 
     10  CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field) 
    1011    : CInputPin(gc, 1) 
    1112    , field(field) 
     
    1415      ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)", 
    1516            "The field cannot be null."); 
    16     if (buildWorkflowGraph) 
     17  } 
     18 
     19  void CFileWriterFilter::buildGraph(std::vector<CDataPacketPtr> data) 
     20  { 
     21    bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph: false; 
     22     
     23    if(building_graph) 
    1724    { 
    18       filterId = InvalidableObject::count; 
    19       InvalidableObject::count++; 
     25      this->filterID = InvalidableObject::filterIdGenerator++; 
     26      int edgeID = InvalidableObject::edgeIdGenerator++; 
     27 
     28      CWorkflowGraph::allocNodeEdge(); 
     29      StdString namestring = to_string(this->field->name); 
     30      namestring.erase(0, 6); 
     31      namestring.erase(namestring.length()-1, 1); 
     32 
     33      CWorkflowGraph::addNode(this->filterID, namestring + "\\n("+this->field->file->getId()+".nc)", 6, 0, 1, data[0]); 
     34 
     35      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 
     36      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 
     37      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].clusterID =1; 
     38      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = ++(data[0]->distance); 
     39 
     40      if(CXios::isClient && CWorkflowGraph::build_begin)  
     41      { 
     42 
     43        CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
     44 
     45        (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
     46      } 
     47      else CWorkflowGraph::build_begin=true; 
    2048    } 
    2149  } 
     
    2351  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    2452  { 
     53    buildGraph(data); 
     54     
    2555    const bool detectMissingValue = ( !field->default_value.isEmpty() && 
    2656                               ( (!field->detect_missing_value.isEmpty() || field->detect_missing_value == true) 
     
    4171 
    4272    field->sendUpdateData(dataArray); 
    43  
    4473  } 
    4574 
     
    5382    return true; 
    5483  } 
    55  
    56   int CFileWriterFilter::getFilterId(void) 
    57   { 
    58     return filterId; 
    59   } 
    60  
    6184} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/file_writer_filter.hpp

    r1654 r1686  
    33 
    44#include "input_pin.hpp" 
     5#include "file.hpp" 
     6#include "duration.hpp" 
    57 
    68namespace xios 
     
    1416  { 
    1517    public: 
     18      int tag; 
     19      Time start_graph; 
     20      Time end_graph; 
     21      CField* field; //<! The associated field 
     22      int filterID; 
     23      int distance; 
     24 
    1625      /*! 
    1726       * Constructs the filter (with one input slot) associated to the specified field 
     
    2029       * \param gc the associated garbage collector 
    2130       * \param field the associated field 
    22        * \param[in] buildWorkflowGraph indicates whether the workflow will be visualized 
    2331       */ 
    24       CFileWriterFilter(CGarbageCollector& gc, CField* field, bool buildWorkflowGraph = false); 
     32      CFileWriterFilter(CGarbageCollector& gc, CField* field); 
    2533 
    26       inline StdString GetName(void) {return StdString("File writer filter");}; 
     34      inline StdString GetName(void) {return "File writer filter";}; 
     35 
    2736 
    2837      /*! 
     
    4049      bool virtual isDataExpected(const CDate& date) const; 
    4150 
    42       /*! 
    43        * Returns filter's id needed in case of building workflow graph 
    44        */ 
    45       int getFilterId(); 
    46  
    4751    protected: 
    4852      /*! 
     
    5256       */ 
    5357      void virtual onInputReady(std::vector<CDataPacketPtr> data); 
     58      void virtual buildGraph(std::vector<CDataPacketPtr> data); 
    5459 
    5560    private: 
    56       CField* field;                          //<! The associated field 
    5761      std::map<Time, CDataPacketPtr> packets; //<! The stored packets 
    58       int filterId;                           //<! Filter's id needed in case of building a workflow 
    59  
    6062  }; // class CFileWriterFilter 
    6163} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/filter.cpp

    r1653 r1686  
    33namespace xios 
    44{ 
    5   CFilter::CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine, bool buildWorkflowGraph /*= false*/) 
     5  CFilter::CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine) 
    66    : CInputPin(gc, inputSlotsCount) 
    7     , COutputPin(gc, false, buildWorkflowGraph) 
     7    , COutputPin(gc, false) 
    88    , engine(engine) 
    99    , inputSlotCount(inputSlotCount) 
  • XIOS/dev/dev_olga/src/filter/filter.hpp

    r1653 r1686  
    2323       * \param inputSlotsCount the number of input slots 
    2424       * \param engine the filter engine 
    25        * \param buildWorkflowGraph indicates whether data will be visualized 
    2625       */ 
    27       CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine, bool buildWorkflowGraph = false); 
     26      CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine); 
    2827 
    2928      StdString virtual GetName(void); 
     
    6564      bool virtual isDataExpected(const CDate& date) const; 
    6665 
     66       
     67       
     68 
     69      int filterID; 
     70      StdString expression; 
     71 
    6772    protected: 
    6873      IFilterEngine* engine; //!< The filter engine, might be the filter itself 
  • XIOS/dev/dev_olga/src/filter/garbage_collector.cpp

    r1653 r1686  
    33namespace xios 
    44{ 
     5  int InvalidableObject::filterIdGenerator = 0; 
    56 
    6   int InvalidableObject::count = 0; 
     7  int InvalidableObject::edgeIdGenerator = 0; 
     8 
     9  int InvalidableObject::clusterIdGenerator = 0; 
    710   
    811  void CGarbageCollector::registerObject(InvalidableObject* Object, Time timestamp) 
  • XIOS/dev/dev_olga/src/filter/garbage_collector.hpp

    r1653 r1686  
    2121    void virtual invalidate(Time timestamp) = 0; 
    2222   
    23     static int count; //!< Counter used to identify a filter in case building workflow graph 
     23     
     24 
     25    static int filterIdGenerator; 
     26 
     27    static int edgeIdGenerator; 
     28 
     29    static int clusterIdGenerator; 
     30 
     31     
    2432     
    2533  }; // struct InvalidableObject 
  • XIOS/dev/dev_olga/src/filter/input_pin.cpp

    r1653 r1686  
    1212    , triggers(slotsCount) 
    1313    , hasTriggers(false) 
    14   {   } 
     14  {  } 
    1515 
    1616  StdString CInputPin::GetName(void) 
     
    8383    inputs.erase(inputs.begin(), inputs.lower_bound(timestamp)); 
    8484  } 
    85  
    86   int CInputPin::getFilterId(void) 
    87   { 
    88     return -1; 
    89   } 
    90  
    9185} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/input_pin.hpp

    r1654 r1686  
    8181       */ 
    8282      void virtual invalidate(Time timestamp); 
    83        
    84       /*! 
    85        * Returns filter's id needed in case of building workflow graph 
    86        * This function should never be called from this class, instead functions defined in derived classes or in class COutputPin should be used 
    87        */ 
    88       int virtual getFilterId(); 
    8983 
    9084    protected: 
     
    130124      //! Whether some triggers have been set 
    131125      bool hasTriggers; 
    132  
    133126  }; // class CInputPin 
    134127} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/output_pin.cpp

    r1654 r1686  
    55namespace xios 
    66{ 
    7   COutputPin::COutputPin(CGarbageCollector& gc, bool manualTrigger /*= false*/, bool buildWorkflowGraph /* =false */) 
     7  COutputPin::COutputPin(CGarbageCollector& gc, bool manualTrigger /*= false*/) 
    88    : gc(gc) 
    99    , manualTrigger(manualTrigger) 
    10     , buildWorkflowGraph(buildWorkflowGraph) 
    11   { 
    12     if (buildWorkflowGraph) 
    13     { 
    14       filterId = InvalidableObject::count; 
    15       InvalidableObject::count++; 
    16     } 
    17   } 
     10  {  } 
    1811 
    1912  StdString COutputPin::GetName(void) 
     
    4033            "The packet cannot be null."); 
    4134 
    42     if (buildWorkflowGraph) 
    43     { 
    44         CWorkflowGraph::mapFilterTimestamps[this->getFilterId()].push_back(packet->timestamp); 
    45         CWorkflowGraph::timestamps.insert(packet->timestamp); 
    46     } 
    47  
    4835    if (manualTrigger) // Don't use canBeTriggered here, this function is virtual and can be overriden 
    4936    { 
     
    5239    } 
    5340    else 
    54     { 
    5541      deliverOuput(packet); 
    56     } 
    5742  } 
    5843 
     
    123108  } 
    124109 
    125   int COutputPin::getFilterId(void) 
     110  void COutputPin::setParentFiltersTag() 
    126111  { 
    127     return filterId; 
     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    } 
    128126  } 
    129127 
     128 
     129 
     130 
    130131} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/output_pin.hpp

    r1654 r1686  
    44#include "garbage_collector.hpp" 
    55#include "input_pin.hpp" 
     6#include "duration.hpp" 
    67 
    78namespace xios 
    89{ 
     10  class CField; 
     11  class CInputPin; 
     12  class CFilter; 
     13  class CDuration; 
    914  /*! 
    1015   * An output pin handles the connections with downstream filters. 
     
    1318  { 
    1419    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 
    1530      /*! 
    1631       * Constructs an ouput pin with manual or automatic trigger 
     
    1934       * \param gc the garbage collector associated with this ouput pin 
    2035       * \param slotsCount the number of slots 
    21        * \param buildWorkflowGraph indicates whether data will be visualized 
    2236       */ 
    23       COutputPin(CGarbageCollector& gc, bool manualTrigger = false, bool buildWorkflowGraph = false); 
     37      COutputPin(CGarbageCollector& gc, bool manualTrigger = false); 
    2438 
    2539      StdString virtual GetName(void); 
     
    6983      void virtual invalidate(Time timestamp); 
    7084 
    71       /*! 
    72        * Returns filter's id needed in case of building workflow graph 
    73        */ 
    74       int getFilterId(); 
     85      void virtual setParentFiltersTag(); 
     86 
    7587 
    7688    protected: 
     
    97109      CGarbageCollector& gc; //!< The garbage collector associated to the output pin 
    98110 
    99       //! Whether the ouput should be triggered manually 
     111      //!< Whether the ouput should be triggered manually 
    100112      bool manualTrigger; 
    101113 
    102       //! The list of connected filters and the corresponding slot numbers 
     114      //!< The list of connected filters and the corresponding slot numbers 
    103115      std::vector<std::pair<std::shared_ptr<CInputPin>, size_t> > outputs; 
    104116 
    105117      //! Output buffer, store the packets until the output is triggered 
    106118      std::map<Time, CDataPacketPtr> outputPackets; 
    107  
    108       //! Indicates whether the workflow will be visualized 
    109       bool buildWorkflowGraph; 
    110  
    111       //! Filter's id needed in case of building a workflow graph 
    112       int filterId; 
    113  
    114  
    115119  }; // class COutputPin 
    116120} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/pass_through_filter.cpp

    r1653 r1686  
    11#include "pass_through_filter.hpp" 
     2#include "workflow_graph.hpp" 
     3#include "field.hpp" 
     4#include "file.hpp" 
    25 
    36namespace xios 
    47{ 
    5   CPassThroughFilter::CPassThroughFilter(CGarbageCollector& gc, bool buildWorkflowGraph /*= false*/) 
    6     : CFilter(gc, 1, this, buildWorkflowGraph) 
    7   { /* Nothing to do */ } 
     8  CPassThroughFilter::CPassThroughFilter(CGarbageCollector& gc) 
     9    : 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); 
     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 
     42    } 
     43 
     44    data[0]->field = this->field; 
     45  } 
    846 
    947  CDataPacketPtr CPassThroughFilter::apply(std::vector<CDataPacketPtr> data) 
    1048  { 
     49    if(CXios::isClient) buildGraph(data); 
    1150    return data[0]; 
    1251  } 
  • XIOS/dev/dev_olga/src/filter/pass_through_filter.hpp

    r1653 r1686  
    1717       * 
    1818       * \param gc the associated garbage collector 
    19        * \param buildWorkflowGraph indicates whether data will be visualized 
    2019       */ 
    21       CPassThroughFilter(CGarbageCollector& gc, bool buildWorkflowGraph = false); 
     20      CPassThroughFilter(CGarbageCollector& gc); 
    2221 
    2322      inline StdString GetName(void) {return StdString("Pass through filter");}; 
     
    3130       */ 
    3231      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     32      void virtual buildGraph(std::vector<CDataPacketPtr> data); 
    3333  }; // class CPassThroughFilter 
    3434} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/source_filter.cpp

    r1654 r1686  
    1212                               const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/, 
    1313                               bool hasMissingValue /*= false*/, 
    14                                double defaultValue /*= 0.0*/, 
    15                                bool buildWorkflowGraph /*= false*/) 
    16     : COutputPin(gc, manualTrigger, buildWorkflowGraph) 
     14                               double defaultValue /*= 0.0*/) 
     15    : COutputPin(gc, manualTrigger) 
    1716    , grid(grid) 
    1817    , compression(compression) 
     
    2524            "Impossible to construct a source filter without providing a grid."); 
    2625  } 
    27    
     26 
     27  void CSourceFilter::buildGraph(CDataPacketPtr packet) 
     28  { 
     29    bool building_graph = this->tag ? packet->timestamp >= this->field->field_graph_start && packet->timestamp <= this->field->field_graph_end : false; 
     30    
     31    if(building_graph) 
     32    { 
     33      this->filterID = InvalidableObject::filterIdGenerator++;   
     34      packet->src_filterID=this->filterID; 
     35      packet->field = this->field; 
     36      packet->distance = 1; 
     37       
     38     
     39      CWorkflowGraph::allocNodeEdge(); 
     40 
     41      CWorkflowGraph::addNode(this->filterID, "Source Filter ", 1, 1, 0, packet); 
     42      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 
     43      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].field_id = this->field->getId(); 
     44      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = 1; 
     45 
     46      CWorkflowGraph::build_begin = true; 
     47    } 
     48 
     49  } 
     50 
     51 
    2852  template <int N> 
    2953  void CSourceFilter::streamData(CDate date, const CArray<double, N>& data) 
     
    6185      } 
    6286    } 
     87 
     88    if(CXios::isClient) buildGraph(packet); 
     89     
     90 
    6391 
    6492    onOutputReady(packet); 
  • XIOS/dev/dev_olga/src/filter/source_filter.hpp

    r1654 r1686  
    2727       * \param hasMissingValue whether data has missing value 
    2828       * \param defaultValue missing value to detect 
    29        * \param[in] buildWorkflowGraph indicates whether the workflow will be visualized 
    3029       */ 
    3130      CSourceFilter(CGarbageCollector& gc, CGrid* grid, 
     
    3433                    const CDuration offset = NoneDu, bool manualTrigger = false, 
    3534                    bool hasMissingValue = false, 
    36                     double defaultValue = 0.0, 
    37                                         bool buildWorkflowGraph = false); 
     35                    double defaultValue = 0.0); 
    3836 
    3937      inline StdString GetName(void) {return StdString("Source filter");}; 
     
    4947      template <int N> 
    5048      void streamData(CDate date, const CArray<double, N>& data); 
     49 
     50      void virtual buildGraph(CDataPacketPtr packet); 
    5151 
    5252      /*! 
     
    6666       */ 
    6767      void signalEndOfStream(CDate date); 
     68      int filterID; 
    6869 
    6970    private: 
     
    7475      const bool compression ; //!< indicates if data need to be compressed : on client side : true, on server side : false 
    7576      const bool mask ;        //!< indicates whether grid mask should be applied (true for clients, false for servers) 
    76        
    7777  }; // class CSourceFilter 
    7878} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/spatial_transform_filter.cpp

    r1653 r1686  
    55#include "timer.hpp" 
    66#include "workflow_graph.hpp" 
     7#include "file.hpp" 
    78 
    89namespace xios 
    910{ 
    10   CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, 
    11                                                    double outputValue, size_t inputSlotsCount, bool buildWorkflowGraph /*= false*/) 
    12     : CFilter(gc, inputSlotsCount, engine, buildWorkflowGraph), outputDefaultValue(outputValue) 
     11  CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount) 
     12    : CFilter(gc, inputSlotsCount, engine), outputDefaultValue(outputValue) 
    1313  { /* Nothing to do */ } 
    1414 
    1515  std::pair<std::shared_ptr<CSpatialTransformFilter>, std::shared_ptr<CSpatialTransformFilter> > 
    16   CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double missingValue, 
    17                                             bool buildWorkflowGraph) 
     16  CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double missingValue) 
    1817  { 
    1918    if (!srcGrid || !destGrid) 
     
    3231      double defaultValue  = (hasMissingValue) ? std::numeric_limits<double>::quiet_NaN() : 0.0; 
    3332 
     33 
    3434      const CGridTransformationSelector::ListAlgoType& algoList = gridTransformation->getAlgoList() ; 
    3535      CGridTransformationSelector::ListAlgoType::const_iterator it  ; 
     
    3939 
    4040      std::shared_ptr<CSpatialTransformFilter> filter ; 
    41       if( isSpatialTemporal) 
    42         filter = std::shared_ptr<CSpatialTransformFilter>(new CSpatialTemporalFilter(gc, engine, gridTransformation, defaultValue, inputCount, buildWorkflowGraph)); 
    43       else 
    44         filter = std::shared_ptr<CSpatialTransformFilter>(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount, buildWorkflowGraph)); 
    45  
     41      if( isSpatialTemporal) filter = std::shared_ptr<CSpatialTransformFilter>(new CSpatialTemporalFilter(gc, engine, gridTransformation, defaultValue, inputCount)); 
     42      else filter = std::shared_ptr<CSpatialTransformFilter>(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 
     43 
     44       
    4645      if (!lastFilter) 
    4746        lastFilter = filter; 
    4847      else 
    49       { 
    5048        filter->connectOutput(firstFilter, 0); 
    51         if (buildWorkflowGraph) 
    52         { 
    53           int filterOut = (std::static_pointer_cast<COutputPin>(filter))->getFilterId(); 
    54           int filterIn = (std::static_pointer_cast<COutputPin>(firstFilter))->getFilterId(); 
    55           // PASS field's id here 
    56           CWorkflowGraph::mapFieldToFilters["XXX"].push_back(filterOut); 
    57           CWorkflowGraph::mapFieldToFilters["XXX"].push_back(filterIn); 
    58           CWorkflowGraph::mapFilters[filterOut] = "Spatial transform filter"; 
    59           CWorkflowGraph::mapFilters[filterIn] = "Spatial transform filter"; 
    60         } 
    61       } 
    6249 
    6350      firstFilter = filter; 
     
    7966  { 
    8067    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 
    81     CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 
     68    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue, this->tag, this->start_graph, this->end_graph, this->field); 
    8269    if (outputPacket) 
    8370      onOutputReady(outputPacket); 
    8471  } 
    8572 
    86   CSpatialTemporalFilter::CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, 
    87                                                   CGridTransformation* gridTransformation, double outputValue, 
    88                                                   size_t inputSlotsCount, bool buildWorkflowGraph) 
    89     : CSpatialTransformFilter(gc, engine, outputValue, inputSlotsCount, buildWorkflowGraph), record(0) 
     73  CSpatialTemporalFilter::CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount) 
     74    : CSpatialTransformFilter(gc, engine, outputValue, inputSlotsCount), record(0) 
    9075  { 
    9176      const CGridTransformationSelector::ListAlgoType& algoList = gridTransformation->getAlgoList() ; 
     
    11398  { 
    11499    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 
    115     CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 
     100    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue, this->tag, this->start_graph, this->end_graph, this->field); 
    116101 
    117102    if (outputPacket) 
     
    138123        packet->data.resize(tmpData.numElements()); 
    139124        packet->data = tmpData; 
     125        packet->field = this->field; 
    140126        onOutputReady(packet); 
    141127        tmpData.resize(0) ; 
     
    176162  } 
    177163 
    178   CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue) 
    179   { 
     164  bool CSpatialTransformFilterEngine::buildGraph(std::vector<CDataPacketPtr> data, int tag, Time start_graph, Time end_graph, CField *field) 
     165  { 
     166    bool building_graph = tag ? data[0]->timestamp >= start_graph && data[0]->timestamp <= end_graph : false; 
     167    if(building_graph) 
     168    { 
     169      this->filterID = InvalidableObject::filterIdGenerator++; 
     170      int edgeID = InvalidableObject::edgeIdGenerator++;     
     171 
     172      CWorkflowGraph::allocNodeEdge(); 
     173 
     174      CWorkflowGraph::addNode(this->filterID, "Spatial Transform Filter", 4, 1, 1, data[0]); 
     175      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 
     176      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = field->record4graphXiosAttributes(); 
     177      if(field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +field->file->record4graphXiosAttributes(); 
     178 
     179 
     180      if(CWorkflowGraph::build_begin) 
     181      { 
     182        CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
     183 
     184        (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0; 
     185      } 
     186      else CWorkflowGraph::build_begin = true; 
     187    } 
     188 
     189    return building_graph; 
     190  } 
     191 
     192  CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue, int tag, Time start_graph, Time end_graph, CField *field) 
     193  { 
     194     
     195    bool BG = buildGraph(data, tag, start_graph, end_graph, field); 
     196 
    180197    CDataPacketPtr packet(new CDataPacket); 
    181198    packet->date = data[0]->date; 
     
    194211      if (0 != packet->data.numElements()) 
    195212        (packet->data)(0) = defaultValue; 
    196       apply(data[0]->data, packet->data); 
     213      if(BG) apply(data[0]->data, packet->data, this->filterID); 
     214      else apply(data[0]->data, packet->data); 
    197215    } 
    198216 
     
    200218  } 
    201219 
    202   void CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest) 
     220  void CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest, int filterID) 
    203221  { 
    204222    CTimer::get("CSpatialTransformFilterEngine::apply").resume();  
     
    313331        const std::vector<std::pair<int,double> >& localIndex_p = itRecv->second; 
    314332        int srcRank = itRecv->first; 
     333 
     334        if(filterID >=0) // building_graph 
     335        { 
     336           (*CWorkflowGraph::mapFilters_ptr_with_info)[filterID].filter_name = (*itAlgo)->getName(); 
     337        }  
    315338        if (srcRank != rank) 
    316339        { 
  • XIOS/dev/dev_olga/src/filter/spatial_transform_filter.hpp

    r1653 r1686  
    33 
    44#include "filter.hpp" 
     5#include "field.hpp" 
    56 
    67namespace xios 
     
    910  class CGridTransformation; 
    1011  class CSpatialTransformFilterEngine; 
     12 
     13  class CField; 
    1114 
    1215  /*! 
     
    2326       * \param outputValue default value of output pin 
    2427       * \param [in] inputSlotsCount number of input, by default there is only one for field src 
    25        * \param buildWorkflowGraph indicates whether data will be visualized 
    2628       */ 
    2729      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, 
    28                               double outputValue, size_t inputSlotsCount = 1, bool buildWorkflowGraph = false); 
     30                              double outputValue, size_t inputSlotsCount = 1); 
    2931 
    3032      inline StdString GetName(void) {return StdString("Spatial transform filter");}; 
     
    3840       * \param hasMissingValue whether field source has missing value 
    3941       * \param defaultValue default value 
    40        * \param buildWorkflowGraph indicates whether data will be visualized 
    4142       * \return the first and the last filters of the filter graph 
    4243       */ 
    4344      static std::pair<std::shared_ptr<CSpatialTransformFilter>, std::shared_ptr<CSpatialTransformFilter> > 
    44       buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue, bool buildWorkflowGraph = false); 
     45      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue); 
    4546 
    4647    protected: 
     
    7273       * \param outputValue default value of output pin 
    7374       * \param [in] inputSlotsCount number of input, by default there is only one for field src 
    74        * \param buildWorkflowGraph indicates whether data will be visualized 
    75        * 
    7675       */ 
    77       CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, 
    78                             double outputValue, size_t inputSlotsCount = 1, bool buildWorkflowGraph = false); 
     76      CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount = 1); 
    7977 
    8078 
     
    10199  { 
    102100    public: 
     101 
     102      int filterID; 
     103      int tag; 
     104      CField *field; 
    103105      /*! 
    104106       * Returns the engine wrapping the specified grid transformation. 
     
    117119       * \return the result of the grid transformation 
    118120       */ 
    119       CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0); 
     121      CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0, int tag=0, Time start_graph=0, Time end_graph=-1, CField *field=0); 
     122      bool buildGraph(std::vector<CDataPacketPtr> data, int tag=0, Time start_graph=0, Time end_graph=-1, CField *field=0); 
    120123 
    121124       /*! 
     
    144147       * \param dataDest the resulting transformed data 
    145148       */ 
    146       void apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest); 
     149      void apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest, int filterID=-1); 
    147150 
    148151      CGridTransformation* gridTransformation; //!< The grid transformation used by the engine 
  • XIOS/dev/dev_olga/src/filter/store_filter.cpp

    r1654 r1686  
    33#include "grid.hpp" 
    44#include "timer.hpp" 
     5#include "file.hpp" 
    56 
    67namespace xios 
     
    2122      ERROR("CStoreFilter::CStoreFilter(CContext* context, CGrid* grid)", 
    2223            "Impossible to construct a store filter without providing a grid."); 
    23 //    filterId = InvalidableObject::count; 
    24 //    InvalidableObject::count++; 
    2524  } 
    2625 
     
    7877  template CDataPacket::StatusCode CStoreFilter::getData<7>(Time timestamp, CArray<double, 7>& data); 
    7978 
     79  void CStoreFilter::buildGraph(std::vector<CDataPacketPtr> data) 
     80  { 
     81    bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 
     82 
     83    if(building_graph) 
     84    { 
     85      this->filterID = InvalidableObject::filterIdGenerator++; 
     86      int edgeID = InvalidableObject::edgeIdGenerator++; 
     87 
     88      CWorkflowGraph::allocNodeEdge(); 
     89  
     90      CWorkflowGraph::addNode(this->filterID, "Store Filter", 7, 0, 1, data[0]); 
     91      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = ++(data[0]->distance); 
     92      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 
     93      if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); 
     94 
     95      // if(CXios::isClient) std::cout<<"CStoreFilter::apply filter tag = "<<this->tag<<std::endl; 
     96 
     97      if(CXios::isClient && CWorkflowGraph::build_begin)  
     98      { 
     99        CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]);; 
     100        (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0; 
     101      } 
     102      else CWorkflowGraph::build_begin = true; 
     103    } 
     104  } 
     105 
    80106  void CStoreFilter::onInputReady(std::vector<CDataPacketPtr> data) 
    81107  { 
     108    buildGraph(data); 
    82109 
    83110    CDataPacketPtr packet; 
     
    128155    packets.erase(packets.begin(), packets.lower_bound(timestamp)); 
    129156  } 
    130  
    131   int CStoreFilter::getFilterId(void) 
    132   { 
    133     return filterId; 
    134   } 
    135  
    136157} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/store_filter.hpp

    r1653 r1686  
    33 
    44#include "input_pin.hpp" 
     5#include "workflow_graph.hpp" 
     6 
    57 
    68namespace xios 
     
    810  class CContext; 
    911  class CGrid; 
     12  class CField; 
    1013 
    1114  /*! 
     
    7376      void virtual invalidate(Time timestamp); 
    7477 
    75       /*! 
    76        * Returns filter's id needed in case of building workflow graph 
    77        */ 
    78       int getFilterId(); 
     78      int filterID; 
     79      int tag; 
     80      Time start_graph; 
     81      Time end_graph; 
     82      CField *field; 
     83      int distance; 
     84 
    7985 
    8086    protected: 
     
    8591       */ 
    8692      void virtual onInputReady(std::vector<CDataPacketPtr> data); 
     93      void virtual buildGraph(std::vector<CDataPacketPtr> data); 
    8794 
    8895    private: 
    89       CGarbageCollector& gc;            //!< The garbage collector associated to the filter 
    90       CContext* context;                //!< The context to which the data belongs 
    91       CGrid* grid;                      //!< The grid attached to the data the filter can accept 
    92       const bool detectMissingValues;   //!< Whether missing values should be detected 
    93       const double missingValue;        //!< The value to use to replace missing values 
     96      CGarbageCollector& gc; //!< The garbage collector associated to the filter 
     97      CContext* context; //!< The context to which the data belongs 
     98      CGrid* grid; //!< The grid attached to the data the filter can accept 
     99      const bool detectMissingValues; //!< Whether missing values should be detected 
     100      const double missingValue; //!< The value to use to replace missing values 
    94101      std::map<Time, CDataPacketPtr> packets; //<! The stored packets 
    95       int filterId;                     //!< Filter's id needed in case of building a workflow 
    96  
    97102  }; // class CStoreFilter 
    98103} // namespace xios 
  • XIOS/dev/dev_olga/src/filter/temporal_filter.cpp

    r1653 r1686  
    22#include "functor_type.hpp" 
    33#include "calendar_util.hpp" 
     4#include "workflow_graph.hpp" 
     5#include "file.hpp" 
    46 
    57namespace xios 
     
    911  CTemporalFilter::CTemporalFilter(CGarbageCollector& gc, const std::string& opId, 
    1012                                   const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, 
    11                                    bool ignoreMissingValue /*= false*/, bool buildWorkflowGraph /*= false*/) 
    12     : CFilter(gc, 1, this, buildWorkflowGraph) 
     13                                   bool ignoreMissingValue /*= false*/) 
     14    : CFilter(gc, 1, this) 
    1315    , functor(createFunctor(opId, ignoreMissingValue, tmpData)) 
    1416    , isOnceOperation(functor->timeType() == func::CFunctor::once) 
     
    2527    , nbOperationDates(1) 
    2628    , nbSamplingDates(0) 
     29//    , nextOperationDate(initDate + opFreq + this->samplingOffset) 
    2730    , isFirstOperation(true) 
     31    , temp_op(opId) 
    2832  { 
    2933  } 
    3034 
     35   
     36 
     37 
     38 
     39  bool CTemporalFilter::buildGraph(std::vector<CDataPacketPtr> data) 
     40  { 
     41    bool building_graph=this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 
     42    
     43    if(building_graph) 
     44    { 
     45      if(this->filterIDoutputs.size()==0) this->filterID = InvalidableObject::filterIdGenerator++; 
     46      int edgeID = InvalidableObject::edgeIdGenerator++; 
     47       
     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(); 
     63      } 
     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);  
     77    } 
     78 
     79    return building_graph; 
     80  } 
     81 
     82 
    3183  CDataPacketPtr CTemporalFilter::apply(std::vector<CDataPacketPtr> data) 
    3284  { 
     85    bool BG = buildGraph(data); 
     86 
    3387    CDataPacketPtr packet; 
    3488 
     
    77131 
    78132        isFirstOperation = false; 
     133         
     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        } 
    79144      } 
    80145    } 
     
    90155  bool CTemporalFilter::isDataExpected(const CDate& date) const 
    91156  { 
     157//    return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 
    92158    return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date > initDate + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth); 
    93159  } 
  • XIOS/dev/dev_olga/src/filter/temporal_filter.hpp

    r1653 r1686  
    2929      CTemporalFilter(CGarbageCollector& gc, const std::string& opId, 
    3030                      const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, 
    31                       bool ignoreMissingValue = false, bool buildWorkflowGraph = false); 
     31                      bool ignoreMissingValue = false); 
    3232 
    3333      inline StdString GetName(void) {return StdString("Temporal filter");}; 
     
    4040       */ 
    4141      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     42      bool virtual buildGraph(std::vector<CDataPacketPtr> data); 
    4243 
    4344      /*! 
     
    5455       */ 
    5556      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; 
    5661 
    5762    private: 
  • XIOS/dev/dev_olga/src/filter/ternary_arithmetic_filter.cpp

    r1162 r1686  
    11#include "ternary_arithmetic_filter.hpp" 
     2#include "workflow_graph.hpp" 
     3#include "yacc_var.hpp" 
     4#include "file.hpp" 
    25 
    36namespace xios 
     
    811    , value1(value1) 
    912    , value2(value2) 
    10   { /* Nothing to do */ }; 
     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  } 
    1175 
    1276  CDataPacketPtr CScalarScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    1680    packet->timestamp = data[0]->timestamp; 
    1781    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; 
    1890 
    1991    if (packet->status == CDataPacket::NO_ERROR) 
     
    28100    , value1(value1) 
    29101    , value2(value2) 
    30   { /* Nothing to do */ }; 
     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  } 
    31164 
    32165  CDataPacketPtr CScalarFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    36169    packet->timestamp = data[0]->timestamp; 
    37170    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; 
    38179 
    39180    if (packet->status == CDataPacket::NO_ERROR) 
     
    47188    , op(operatorExpr.getOpScalarFieldField(op)) 
    48189    , value(value) 
    49   { /* Nothing to do */ }; 
     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  } 
    50267 
    51268  CDataPacketPtr CScalarFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    55272    packet->timestamp = data[0]->timestamp; 
    56273    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; 
    57282 
    58283    if (data[0]->status != CDataPacket::NO_ERROR) 
     
    75300    , value1(value1) 
    76301    , value2(value2) 
    77   { /* Nothing to do */ }; 
     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  } 
    78364 
    79365  CDataPacketPtr CFieldScalarScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    84370    packet->status = data[0]->status; 
    85371 
     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 
    86380    if (packet->status == CDataPacket::NO_ERROR) 
    87381      packet->data.reference(op(data[0]->data, value1, value2)); 
     
    95389    , op(operatorExpr.getOpFieldScalarField(op)) 
    96390    , value(value) 
    97   { /* Nothing to do */ }; 
     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  } 
    98468 
    99469  CDataPacketPtr CFieldScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    103473    packet->timestamp = data[0]->timestamp; 
    104474    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; 
    105483 
    106484    if (data[0]->status != CDataPacket::NO_ERROR) 
     
    120498    , op(operatorExpr.getOpFieldFieldScalar(op)) 
    121499    , value(value) 
    122   { /* Nothing to do */ }; 
     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  } 
    123578 
    124579  CDataPacketPtr CFieldFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    128583    packet->timestamp = data[0]->timestamp; 
    129584    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; 
    130593 
    131594    if (data[0]->status != CDataPacket::NO_ERROR) 
     
    145608    : CFilter(gc, 3, this) 
    146609    , op(operatorExpr.getOpFieldFieldField(op)) 
    147   { /* Nothing to do */ }; 
     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  } 
    148700 
    149701  CDataPacketPtr CFieldFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    153705    packet->timestamp = data[0]->timestamp; 
    154706    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; 
    155715 
    156716    if (data[0]->status != CDataPacket::NO_ERROR) 
  • XIOS/dev/dev_olga/src/filter/ternary_arithmetic_filter.hpp

    r1162 r1686  
    55#include <string> 
    66#include "operator_expr.hpp" 
     7#include <tuple> 
    78 
    89namespace xios 
     
    3637       */ 
    3738      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     39      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    3840  }; // class CScalarScalarFieldArithmeticFilter 
    3941 
     
    6769       */ 
    6870      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     71      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    6972  }; // class CScalarScalarFieldArithmeticFilter 
    7073 
     
    9598       */ 
    9699      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     100      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    97101  }; // class CScalarScalarFieldArithmeticFilter 
    98102 
     
    127131       */ 
    128132      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     133      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    129134  }; // class CFieldScalarScalarArithmeticFilter 
    130135 
     
    156161       */ 
    157162      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     163      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    158164  }; // class CFieldScalarFieldArithmeticFilter 
    159165 
     
    185191       */ 
    186192      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     193      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    187194  }; // class CFieldFielScalardArithmeticFilter 
    188195 
     
    212219       */ 
    213220      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     221      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    214222  }; // class CFieldFielFieldArithmeticFilter 
    215223 
  • XIOS/dev/dev_olga/src/filter/unary_arithmetic_filter.cpp

    r643 r1686  
    11#include "unary_arithmetic_filter.hpp" 
     2#include "workflow_graph.hpp" 
     3#include "yacc_var.hpp" 
     4#include "file.hpp" 
    25 
    36namespace xios 
     
    69    : CFilter(gc, 1, this) 
    710    , op(operatorExpr.getOpField(op)) 
    8   { /* Nothing to do */ }; 
     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  } 
    970 
    1071  CDataPacketPtr CUnaryArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
     
    1576    packet->status = data[0]->status; 
    1677 
     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 
    1786    if (packet->status == CDataPacket::NO_ERROR) 
    1887      packet->data.reference(op(data[0]->data)); 
  • XIOS/dev/dev_olga/src/filter/unary_arithmetic_filter.hpp

    r642 r1686  
    3434       */ 
    3535      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     36      std::tuple<int, int, int> virtual buildGraph(std::vector<CDataPacketPtr> data); 
    3637  }; // class CUnaryArithmeticFilter 
    3738} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.