Package org.teiid.query.sql.util

Examples of org.teiid.query.sql.util.ValueIterator


    if(leftValue == null) {
            return null;
        }
        Boolean result = Boolean.FALSE;

        ValueIterator valueIter = null;
        if (criteria instanceof SetCriteria) {
          SetCriteria set = (SetCriteria)criteria;
          if (set.isAllConstants()) {
            boolean exists = set.getValues().contains(new Constant(leftValue, criteria.getExpression().getType()));
            if (!exists) {
              if (set.getValues().contains(Constant.NULL_CONSTANT)) {
                return null;
              }
              return criteria.isNegated();
            }
            return !criteria.isNegated();
          }
          valueIter = new CollectionValueIterator(((SetCriteria)criteria).getValues());
        } else if (criteria instanceof DependentSetCriteria){
          ContextReference ref = (ContextReference)criteria;
        ValueIteratorSource vis = (ValueIteratorSource)getContext(criteria).getVariableContext().getGlobalValue(ref.getContextSymbol());
        Set<Object> values;
        try {
          values = vis.getCachedSet(ref.getValueExpression());
        } catch (TeiidProcessingException e) {
          throw new ExpressionEvaluationException(e, e.getMessage());
        }
          if (values != null) {
            return values.contains(leftValue);
          }
          //there are too many values to justify a linear search or holding
          //them in memory
          return true;
        } else if (criteria instanceof SubquerySetCriteria) {
          try {
        valueIter = evaluateSubquery((SubquerySetCriteria)criteria, tuple);
      } catch (TeiidProcessingException e) {
        throw new ExpressionEvaluationException(e, e.getMessage());
      }
        } else {
          throw new AssertionError("unknown set criteria type"); //$NON-NLS-1$
        }
        while(valueIter.hasNext()) {
            Object possibleValue = valueIter.next();
            Object value = null;
            if(possibleValue instanceof Expression) {
          try {
            value = evaluate((Expression) possibleValue, tuple);
          } catch(ExpressionEvaluationException e) {
View Full Code Here


        Boolean result = Boolean.FALSE;
        if (criteria.getPredicateQuantifier() == SubqueryCompareCriteria.ALL){
            result = Boolean.TRUE;
        }

        ValueIterator valueIter;
    try {
      valueIter = evaluateSubquery(criteria, tuple);
    } catch (TeiidProcessingException e) {
      throw new ExpressionEvaluationException(e, e.getMessage());
    }
        while(valueIter.hasNext()) {
            Object value = valueIter.next();

            if(value != null) {
              int compare = compareValues(leftValue, value);
                // Compare two non-null values using specified operator
                switch(criteria.getOperator()) {
View Full Code Here

    }

    public boolean evaluate(ExistsCriteria criteria, List<?> tuple)
        throws BlockedException, TeiidComponentException, ExpressionEvaluationException {

        ValueIterator valueIter;
    try {
      valueIter = evaluateSubquery(criteria, tuple);
    } catch (TeiidProcessingException e) {
      throw new ExpressionEvaluationException(e, e.getMessage());
    }
        if(valueIter.hasNext()) {
            return !criteria.isNegated();
        }
        return criteria.isNegated();
    }
View Full Code Here

 
  private Object evaluate(ScalarSubquery scalarSubquery, List<?> tuple)
      throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
   
      Object result = null;
        ValueIterator valueIter;
    try {
      valueIter = evaluateSubquery(scalarSubquery, tuple);
    } catch (TeiidProcessingException e) {
      throw new ExpressionEvaluationException(e, e.getMessage());
    }
      if(valueIter.hasNext()) {
          result = valueIter.next();
          if(valueIter.hasNext()) {
              // The subquery should be scalar, but has produced
              // more than one result value - this is an exception case
              throw new ExpressionEvaluationException("ERR.015.006.0058", QueryPlugin.Util.getString("ERR.015.006.0058", scalarSubquery.getCommand())); //$NON-NLS-1$ //$NON-NLS-2$
          }
      }
View Full Code Here

              }
              dvs = new DependentValueSource(sortUtility.sort());
              for (SetState setState : dependentSetStates) {
                    setState.valueIterator = dvs.getValueIterator(setState.valueExpression);
                    if (setState.maxNdv > 0 && setState.maxNdv < dvs.getTupleBuffer().getRowCount()) {
                      ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
                      Comparable last = null;
                      int distinctCount = 0;
                      while (vi.hasNext()) {
                        Comparable next = (Comparable) vi.next();
                        if (last == null || next.compareTo(last) != 0) {
                          distinctCount++;
                        }
                        last = next;
                      }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.util.ValueIterator

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.