Ignore:
Timestamp:
07/08/19 16:58:12 (5 years ago)
Author:
yushan
Message:

MARK: Dynamic workflow graph developement. Branch up to date with trunk @1676. Arithmetic filter unified

File:
1 edited

Legend:

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

    r1679 r1680  
    11#include "binary_arithmetic_filter.hpp" 
    22#include "workflow_graph.hpp" 
     3#include "yacc_var.hpp" 
     4#include "file.hpp" 
    35 
    46 
     
    1012    , value(value) 
    1113  {  
    12     StdString input_op_expression=op; 
    13     if(input_op_expression == "add") 
    14       op_expression = "+"; 
    15     else if(input_op_expression == "minus") 
    16       op_expression = "-"; 
    17     else if(input_op_expression == "mult") 
    18       op_expression = "x"; 
    19     else if(input_op_expression == "div") 
    20       op_expression = "/"; 
    21     else if(input_op_expression == "eq") 
    22       op_expression = "="; 
    23     else if(input_op_expression == "lt") 
    24       op_expression = "<"; 
    25     else if(input_op_expression == "gt") 
    26       op_expression = ">"; 
    27     else if(input_op_expression == "le") 
    28       op_expression = "<="; 
    29     else if(input_op_expression == "ge") 
    30       op_expression = ">="; 
    31     else if(input_op_expression == "ne") 
    32       op_expression = "!="; 
    33     else 
    34       op_expression = " "; 
     14    expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 
    3515  }; 
    3616 
     
    3818  { 
    3919    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; 
    4022 
    4123    if(building_graph) 
    4224    { 
    43       this->filterID = InvalidableObject::filterIdGenerator++;    
    44       int edgeID = InvalidableObject::edgeIdGenerator++;  
    45  
    46       if(CWorkflowGraph::mapFieldToFilters_ptr_with_info==0) CWorkflowGraph::mapFieldToFilters_ptr_with_info = new std::unordered_map <int, graph_info_box_edge >; 
    47       if(CWorkflowGraph::mapFilters_ptr_with_info==0) CWorkflowGraph::mapFilters_ptr_with_info = new std::unordered_map <int, graph_info_box_node>; 
    48  
    49       std::cout<<"CScalarFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 
    50  
    51       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_name = "S "+op_expression +" F Filter" ; 
    52       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_class = 2 ; 
    53       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_filled = 1 ; 
    54       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb = 1 ; 
    55       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].date = data[0]->date ; 
    56       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].timestamp = data[0]->timestamp ; 
    57  
    58       if(CWorkflowGraph::build_begin) 
    59       { 
    60         CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
    61  
    62         (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
     25      CWorkflowGraph::allocNodeEdge(); 
     26 
     27      size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 
     28 
     29      // first round 
     30      if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 
     31      { 
     32        this->filterID = InvalidableObject::filterIdGenerator++; 
     33        int edgeID = InvalidableObject::edgeIdGenerator++; 
     34 
     35        CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 
     36        (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 
     37 
     38        (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->recordXiosAttributes(); 
     39        if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->recordXiosAttributes(); 
     40       
     41 
     42        if(CWorkflowGraph::build_begin) 
     43        { 
     44          CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
     45          (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 
     46 
     47          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
     48        } 
     49        else CWorkflowGraph::build_begin = true; 
     50 
     51        (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID;  
     52        unique_filter_id = this->filterID; 
    6353      } 
    64       else CWorkflowGraph::build_begin = true; 
     54      // not first round 
     55      else  
     56      { 
     57        unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 
     58        if(data[0]->src_filterID != unique_filter_id) 
     59        { 
     60          int edgeID = InvalidableObject::edgeIdGenerator++; 
     61          CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]);   
     62          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ;  
     63          (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 
     64        } 
     65       
     66         
     67      }   
    6568    } 
    6669 
     
    6972    packet->timestamp = data[0]->timestamp; 
    7073    packet->status = data[0]->status; 
    71     if(building_graph) packet->src_filterID = this->filterID; 
     74    if(building_graph) packet->src_filterID = unique_filter_id; 
    7275    packet->field = this->field; 
    7376 
     
    8386    , value(value) 
    8487  {  
    85     StdString input_op_expression=op; 
    86     if(input_op_expression == "add") 
    87       op_expression = "+"; 
    88     else if(input_op_expression == "minus") 
    89       op_expression = "-"; 
    90     else if(input_op_expression == "mult") 
    91       op_expression = "x"; 
    92     else if(input_op_expression == "div") 
    93       op_expression = "/"; 
    94     else if(input_op_expression == "pow") 
    95       op_expression = "^"; 
    96     else if(input_op_expression == "eq") 
    97       op_expression = "="; 
    98     else if(input_op_expression == "lt") 
    99       op_expression = "<"; 
    100     else if(input_op_expression == "gt") 
    101       op_expression = ">"; 
    102     else if(input_op_expression == "le") 
    103       op_expression = "<="; 
    104     else if(input_op_expression == "ge") 
    105       op_expression = ">="; 
    106     else if(input_op_expression == "ne") 
    107       op_expression = "!="; 
    108     else 
    109       op_expression = " "; 
     88    expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 
    11089  }; 
    11190 
     
    11392  { 
    11493    bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 
     94    // bool building_graph = true; 
     95    int unique_filter_id; 
    11596 
    11697    if(building_graph) 
    11798    { 
    118       this->filterID = InvalidableObject::filterIdGenerator++; 
    119       int edgeID = InvalidableObject::edgeIdGenerator++; 
    120   
    121       if(CWorkflowGraph::mapFieldToFilters_ptr_with_info==0) CWorkflowGraph::mapFieldToFilters_ptr_with_info = new std::unordered_map <int, graph_info_box_edge >; 
    122       if(CWorkflowGraph::mapFilters_ptr_with_info==0) CWorkflowGraph::mapFilters_ptr_with_info = new std::unordered_map <int, graph_info_box_node>; 
    123  
    124       std::cout<<"CFieldScalarArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 
    125  
    126       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_name = "F "+op_expression +" S Filter" ; 
    127       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_class = 2 ; 
    128       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_filled = 1 ; 
    129       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb = 1 ; 
    130       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].date = data[0]->date ; 
    131       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].timestamp = data[0]->timestamp ; 
    132  
    133       if(CWorkflowGraph::build_begin) 
    134       { 
    135         CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
    136  
    137         (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
     99      CWorkflowGraph::allocNodeEdge(); 
     100 
     101      size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 
     102 
     103      // first round 
     104      if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 
     105      { 
     106        this->filterID = InvalidableObject::filterIdGenerator++; 
     107        int edgeID = InvalidableObject::edgeIdGenerator++; 
     108 
     109        CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 
     110        (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 
     111 
     112        (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->recordXiosAttributes(); 
     113        if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->recordXiosAttributes(); 
     114       
     115 
     116        if(CWorkflowGraph::build_begin) 
     117        { 
     118          CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
     119          (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 
     120 
     121          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
     122        } 
     123        else CWorkflowGraph::build_begin = true; 
     124 
     125        (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID;  
     126        unique_filter_id = this->filterID; 
    138127      } 
    139       else CWorkflowGraph::build_begin = true; 
     128      // not first round 
     129      else  
     130      { 
     131        unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 
     132        if(data[0]->src_filterID != unique_filter_id) 
     133        { 
     134          int edgeID = InvalidableObject::edgeIdGenerator++; 
     135          CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]);   
     136          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ;  
     137          (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 
     138        } 
     139       
     140         
     141      }   
    140142    } 
    141143 
     
    144146    packet->timestamp = data[0]->timestamp; 
    145147    packet->status = data[0]->status; 
    146     if(building_graph) packet->src_filterID = this->filterID; 
     148    if(building_graph) packet->src_filterID = unique_filter_id; 
    147149    packet->field = this->field; 
    148150     
     
    158160    , op(operatorExpr.getOpFieldField(op)) 
    159161  {  
    160     StdString input_op_expression=op; 
    161     if(input_op_expression == "add") 
    162       op_expression = "+"; 
    163     else if(input_op_expression == "minus") 
    164       op_expression = "-"; 
    165     else if(input_op_expression == "mult") 
    166       op_expression = "x"; 
    167     else if(input_op_expression == "div") 
    168       op_expression = "/"; 
    169     else if(input_op_expression == "pow") 
    170       op_expression = "^"; 
    171     else if(input_op_expression == "eq") 
    172       op_expression = "="; 
    173     else if(input_op_expression == "lt") 
    174       op_expression = "<"; 
    175     else if(input_op_expression == "gt") 
    176       op_expression = ">"; 
    177     else if(input_op_expression == "le") 
    178       op_expression = "<="; 
    179     else if(input_op_expression == "ge") 
    180       op_expression = ">="; 
    181     else if(input_op_expression == "ne") 
    182       op_expression = "!="; 
    183     else 
    184       op_expression = " "; 
     162    expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); 
    185163  }; 
    186164 
     
    188166  { 
    189167    bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; 
     168    // bool building_graph = true; 
     169    int unique_filter_id; 
    190170 
    191171    if(building_graph) 
    192     { 
    193  
    194       this->filterID = InvalidableObject::filterIdGenerator++; 
    195       int edgeID = InvalidableObject::edgeIdGenerator++; 
    196     
    197       if(CWorkflowGraph::mapFieldToFilters_ptr_with_info==0) CWorkflowGraph::mapFieldToFilters_ptr_with_info = new std::unordered_map <int, graph_info_box_edge >; 
    198       if(CWorkflowGraph::mapFilters_ptr_with_info==0) CWorkflowGraph::mapFilters_ptr_with_info = new std::unordered_map <int, graph_info_box_node>; 
     172    {   
     173      CWorkflowGraph::allocNodeEdge(); 
    199174 
    200175      std::cout<<"CFieldFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 
    201176 
    202       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_name = "F "+op_expression +" F Filter" ; 
    203       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_class = 2 ; 
    204       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_filled = 1 ; 
    205       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb = 2 ; 
    206       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].date = data[0]->date ; 
    207       (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].timestamp = data[0]->timestamp ; 
    208  
    209       if(CWorkflowGraph::build_begin) 
    210       { 
    211  
    212         CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
    213  
    214         edgeID = InvalidableObject::edgeIdGenerator++; 
    215  
    216         CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 
    217  
    218         (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
    219         (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 
     177      size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); 
     178 
     179      // first round 
     180      if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) 
     181      { 
     182        this->filterID = InvalidableObject::filterIdGenerator++; 
     183        int edgeID = InvalidableObject::edgeIdGenerator++; 
     184     
     185        CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); 
     186        (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->recordXiosAttributes(); 
     187        if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->recordXiosAttributes(); 
     188     
     189        (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; 
     190        if(CWorkflowGraph::build_begin) 
     191        { 
     192 
     193          CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
     194          (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 
     195 
     196          edgeID = InvalidableObject::edgeIdGenerator++; 
     197 
     198          CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); 
     199          (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; 
     200 
     201          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; 
     202          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 
     203        } 
     204        CWorkflowGraph::build_begin = true; 
     205 
     206        (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID;  
     207        unique_filter_id = this->filterID; 
     208  
    220209      } 
    221       CWorkflowGraph::build_begin = true; 
     210      // not first round 
     211      else  
     212      { 
     213        unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; 
     214        if(data[0]->src_filterID != unique_filter_id) 
     215        { 
     216          int edgeID = InvalidableObject::edgeIdGenerator++; 
     217          CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]);  
     218          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ;  
     219          (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 
     220        } 
     221        if(data[1]->src_filterID != unique_filter_id) 
     222        {  
     223          int edgeID = InvalidableObject::edgeIdGenerator++; 
     224          CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]);   
     225          (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; 
     226          (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; 
     227        } 
     228         
     229      }   
    222230    } 
    223231 
     
    226234    packet->date = data[0]->date; 
    227235    packet->timestamp = data[0]->timestamp; 
    228     if(building_graph) packet->src_filterID = this->filterID; 
     236    if(building_graph) packet->src_filterID = unique_filter_id; 
    229237    packet->field = this->field; 
    230238     
Note: See TracChangeset for help on using the changeset viewer.