Package org.teiid.query.eval

Examples of org.teiid.query.eval.Evaluator


  }
 
  @Override
  public void initialize(JoinNode joinNode) {
    super.initialize(joinNode);
    this.eval = new Evaluator(null, joinNode.getDataManager(), joinNode.getContext());
  }
View Full Code Here


    }
   
    public void open() throws TeiidComponentException, TeiidProcessingException {
      limit = -1;
      if (limitExpr != null) {
            Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList());
            limit = limitVal.intValue();
      }
        if (limit == 0) {
          return;
        }
        if (offsetExpr != null) {
            Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList());
            offset = offsetVal.intValue();
        } else {
            offset = 0;
        }
        offsetPhase = offset > 0;
View Full Code Here

            data.add(referenceValues.get(element));
            index++;
        }

        try {
      return new Evaluator(elementMap, env.getDataManager(), env.getProcessorContext()).evaluate(this.criteria, data);
    } catch (ExpressionEvaluationException e) {
            throw new TeiidComponentException(e);
    }
  }
View Full Code Here

              context.setVariableContext(this.contexts.get(i));
            }
            boolean needProcessing = false;
            if(shouldEvaluate != null && shouldEvaluate.get(i)) {
                updateCommand = (Command) updateCommand.clone();
                Evaluator eval = getEvaluator(Collections.emptyMap());
                eval.initialize(context, getDataManager());
                AccessNode.rewriteAndEvaluate(updateCommand, eval, context, context.getMetadata());
            }
            needProcessing = RelationalNodeUtil.shouldExecute(updateCommand, true);
            if (needProcessing) {
                commandsToExecute.add(updateCommand);
View Full Code Here

   
    final RelationalNode sourceNode = this.getChildren()[0];
   
    return new BatchCollector.BatchProducerTupleSource(sourceNode) {
     
      Evaluator eval = new Evaluator(elementMap, getDataManager(), getContext());
     
      @Override
      protected List updateTuple(List tuple) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
        int columns = collectedExpressions.size();
              List exprTuple = new ArrayList(columns);
              for(int col = 0; col<columns; col++) {
                  // The following call may throw BlockedException, but all state to this point
                  // is saved in class variables so we can start over on building this tuple
                  Object value = eval.evaluate(collectedExpressions.get(col), tuple);
                  exprTuple.add(value);
              }
              return exprTuple;
      }
    };
View Full Code Here

              }
         
          List filteredTuples = new ArrayList();
          for(int i=0; i<tuples.length; i++) {
                  try {
              if(new Evaluator(lookupMap, null, null).evaluate(query.getCriteria(), tuples[i])) {
                          filteredTuples.add(tuples[i]);
                      }
                  } catch(ExpressionEvaluationException e) {
                      throw new TeiidComponentException(e, e.getMessage());
                  }
          }
         
          tuples = new List[filteredTuples.size()];
          filteredTuples.toArray(tuples);
      }
    } else if ( command instanceof Insert || command instanceof Update || command instanceof Delete) {
      // add single update command to a list to be executed
      updateCommands.add(command);
    } else if ( command instanceof BatchedUpdateCommand ) {
      // add all update commands to a list to be executed
        updateCommands.addAll(((BatchedUpdateCommand) command).getUpdateCommands());
    }
   
    // if we had update commands added to the list, execute them now
    if ( updateCommands.size() > 0 ) {
        List<List<Integer>> filteredTuples = new ArrayList<List<Integer>>();
      for ( int c = 0; c < updateCommands.size(); c++ ) {
        Command cmd = updateCommands.get(c);
        if (cmd instanceof TranslatableProcedureContainer) {
          TranslatableProcedureContainer update = (TranslatableProcedureContainer)cmd;
          if ( update.getCriteria() != null ) {
              // Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
                  Map<Object, Integer> lookupMap = new HashMap<Object, Integer>();
                  for(int i=0; i<elements.size(); i++) {
                      Object element = elements.get(i);
                        mapElementToIndex(lookupMap, element, new Integer(i), group);       
                  }
                  for(int i=0; i<projectedSymbols.size(); i++) {
                    Object element = projectedSymbols.get(i);
                        mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
                  }
             
              int updated = 0;
              for(int i=0; i<tuples.length; i++) {
                      try {
                  if(new Evaluator(lookupMap, null, null).evaluate(update.getCriteria(), tuples[i])) {
                              updated++;
                          }
                      } catch(ExpressionEvaluationException e) {
                          throw new TeiidComponentException(e, e.getMessage());
                      }
View Full Code Here

TOP

Related Classes of org.teiid.query.eval.Evaluator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.