Ignore:
Timestamp:
06/25/19 16:14:54 (5 years ago)
Author:
yushan
Message:

MARK: Dynamic workflow graph developement. Branch up to date with trunk @1663.

File:
1 edited

Legend:

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

    r804 r1677  
    11#include "binary_arithmetic_filter.hpp" 
     2#include "workflow_graph.hpp" 
    23 
    34namespace xios 
     
    78    , op(operatorExpr.getOpScalarField(op)) 
    89    , value(value) 
    9   { /* Nothing to do */ }; 
     10  {  
     11    StdString input_op_expression=op; 
     12    if(input_op_expression == "add") 
     13      op_expression = "+"; 
     14    else if(input_op_expression == "minus") 
     15      op_expression = "-"; 
     16    else if(input_op_expression == "mult") 
     17      op_expression = "x"; 
     18    else if(input_op_expression == "div") 
     19      op_expression = "/"; 
     20    else if(input_op_expression == "eq") 
     21      op_expression = "="; 
     22    else if(input_op_expression == "lt") 
     23      op_expression = "<"; 
     24    else if(input_op_expression == "gt") 
     25      op_expression = ">"; 
     26    else if(input_op_expression == "le") 
     27      op_expression = "<="; 
     28    else if(input_op_expression == "ge") 
     29      op_expression = ">="; 
     30    else if(input_op_expression == "ne") 
     31      op_expression = "!="; 
     32    else 
     33      op_expression = " "; 
     34  }; 
    1035 
    1136  CDataPacketPtr CScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
    1237  { 
     38    if(this->tag) 
     39    { 
     40      this->filterID = InvalidableObject::filterIdGenerator++;     
     41 
     42      if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >; 
     43      if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>; 
     44 
     45      (*CWorkflowGraph::mapFilters_ptr)[this->filterID] = "S "+op_expression +" F Filter" ; 
     46      std::cout<<"CScalarFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 
     47 
     48      StdString str = data[0]->fieldID +" ts=" + to_string(data[0]->timestamp); 
     49      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[0]->src_filterID); 
     50      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 
     51    } 
     52 
    1353    CDataPacketPtr packet(new CDataPacket); 
    1454    packet->date = data[0]->date; 
    1555    packet->timestamp = data[0]->timestamp; 
    1656    packet->status = data[0]->status; 
     57    if(this->tag) packet->src_filterID = this->filterID; 
     58    packet->fieldID = this->output_field_id; 
    1759 
    1860    if (packet->status == CDataPacket::NO_ERROR) 
     
    2668    , op(operatorExpr.getOpFieldScalar(op)) 
    2769    , value(value) 
    28   { /* Nothing to do */ }; 
     70  {  
     71    StdString input_op_expression=op; 
     72    if(input_op_expression == "add") 
     73      op_expression = "+"; 
     74    else if(input_op_expression == "minus") 
     75      op_expression = "-"; 
     76    else if(input_op_expression == "mult") 
     77      op_expression = "x"; 
     78    else if(input_op_expression == "div") 
     79      op_expression = "/"; 
     80    else if(input_op_expression == "pow") 
     81      op_expression = "^"; 
     82    else if(input_op_expression == "eq") 
     83      op_expression = "="; 
     84    else if(input_op_expression == "lt") 
     85      op_expression = "<"; 
     86    else if(input_op_expression == "gt") 
     87      op_expression = ">"; 
     88    else if(input_op_expression == "le") 
     89      op_expression = "<="; 
     90    else if(input_op_expression == "ge") 
     91      op_expression = ">="; 
     92    else if(input_op_expression == "ne") 
     93      op_expression = "!="; 
     94    else 
     95      op_expression = " "; 
     96  }; 
    2997 
    3098  CDataPacketPtr CFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
    3199  { 
     100    if(this->tag) 
     101    { 
     102      this->filterID = InvalidableObject::filterIdGenerator++; 
     103  
     104      if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >; 
     105      if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>; 
     106 
     107      (*CWorkflowGraph::mapFilters_ptr)[this->filterID] = "F "+op_expression +" S Filter" ; 
     108      std::cout<<"CFieldScalarArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 
     109 
     110      StdString str = data[0]->fieldID +" ts=" + to_string(data[0]->timestamp); 
     111      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[0]->src_filterID); 
     112      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 
     113    } 
     114 
    32115    CDataPacketPtr packet(new CDataPacket); 
    33116    packet->date = data[0]->date; 
    34117    packet->timestamp = data[0]->timestamp; 
    35118    packet->status = data[0]->status; 
     119    if(this->tag) packet->src_filterID = this->filterID; 
     120    packet->fieldID = this->output_field_id; 
     121     
    36122 
    37123    if (packet->status == CDataPacket::NO_ERROR) 
     
    44130    : CFilter(gc, 2, this) 
    45131    , op(operatorExpr.getOpFieldField(op)) 
    46   { /* Nothing to do */ }; 
     132  {  
     133    StdString input_op_expression=op; 
     134    if(input_op_expression == "add") 
     135      op_expression = "+"; 
     136    else if(input_op_expression == "minus") 
     137      op_expression = "-"; 
     138    else if(input_op_expression == "mult") 
     139      op_expression = "x"; 
     140    else if(input_op_expression == "div") 
     141      op_expression = "/"; 
     142    else if(input_op_expression == "pow") 
     143      op_expression = "^"; 
     144    else if(input_op_expression == "eq") 
     145      op_expression = "="; 
     146    else if(input_op_expression == "lt") 
     147      op_expression = "<"; 
     148    else if(input_op_expression == "gt") 
     149      op_expression = ">"; 
     150    else if(input_op_expression == "le") 
     151      op_expression = "<="; 
     152    else if(input_op_expression == "ge") 
     153      op_expression = ">="; 
     154    else if(input_op_expression == "ne") 
     155      op_expression = "!="; 
     156    else 
     157      op_expression = " "; 
     158  }; 
    47159 
    48160  CDataPacketPtr CFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 
    49161  { 
     162    if(this->tag) 
     163    { 
     164 
     165      this->filterID = InvalidableObject::filterIdGenerator++; 
     166    
     167      if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >; 
     168      if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>; 
     169 
     170      (*CWorkflowGraph::mapFilters_ptr)[this->filterID] = "F "+op_expression +" F Filter" ; 
     171      std::cout<<"CFieldFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 
     172 
     173      StdString str = data[0]->fieldID +" ts=" + to_string(data[0]->timestamp); 
     174      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[0]->src_filterID); 
     175      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 
     176 
     177      str = data[1]->fieldID +" ts=" + to_string(data[0]->timestamp); 
     178 
     179      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[1]->src_filterID); 
     180      (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 
     181    } 
     182 
     183 
    50184    CDataPacketPtr packet(new CDataPacket); 
    51185    packet->date = data[0]->date; 
    52186    packet->timestamp = data[0]->timestamp; 
     187    if(this->tag) packet->src_filterID = this->filterID; 
     188    packet->fieldID = this->output_field_id; 
     189     
    53190 
    54191    if (data[0]->status != CDataPacket::NO_ERROR) 
     
    64201    return packet; 
    65202  } 
     203 
     204  StdString CScalarFieldArithmeticFilter::GetName(void)    { return StdString("CScalarFieldArithmeticFilter"); } 
     205  StdString CFieldScalarArithmeticFilter::GetName(void)    { return StdString("CFieldScalarArithmeticFilter"); } 
     206  StdString CFieldFieldArithmeticFilter::GetName(void)     { return StdString("CFieldFieldArithmeticFilter"); } 
     207 
     208 
    66209} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.