Package org.teiid.common.buffer

Examples of org.teiid.common.buffer.IndexedTupleSource


      }
      leftSource.getSource().reset();
      super.openLeft();
    }
   
    IndexedTupleSource its = leftSource.getIterator();
   
    while (its.hasNext() || leftSource.getCurrentTuple() != null) {
     
      List<?> leftTuple = leftSource.getCurrentTuple();
      if (leftTuple == null) {
        leftTuple = leftSource.saveNext();
      }
      updateContext(leftTuple, leftSource.getSource().getElements());
     
      if (rightMap != null && !rightSource.open) {
        for (Map.Entry<ElementSymbol, Expression> entry : rightMap.asMap().entrySet()) {
          joinNode.getContext().getVariableContext().setValue(entry.getKey(), eval.evaluate(entry.getValue(), null));
        }
        rightSource.getSource().reset();
        super.openRight();
      }
     
      IndexedTupleSource right = rightSource.getIterator();
     
      while (right.hasNext() || rightSource.getCurrentTuple() != null) {
       
        List<?> rightTuple = rightSource.getCurrentTuple();
        if (rightTuple == null) {
          rightTuple = rightSource.saveNext();
        }
View Full Code Here


    /**
     * @throws TeiidComponentException
     * @see org.teiid.query.sql.util.ValueIteratorSource#getValueIterator(org.teiid.query.sql.symbol.Expression)
     */
    public ValueIterator getValueIterator(Expression valueExpression) throws  TeiidComponentException {
      IndexedTupleSource its = buffer.createIndexedTupleSource();
      int index = 0;
      if (valueExpression != null) {
        index = buffer.getSchema().indexOf(valueExpression);
        Assertion.assertTrue(index != -1);
      }
View Full Code Here

      }
      if (result == null) {
      if (buffer.getRowCount() > buffer.getBatchSize()) {
        return null;
      }
      IndexedTupleSource its = buffer.createIndexedTupleSource();
          int index = 0;
          if (valueExpression != null) {
            index = buffer.getSchema().indexOf(valueExpression);
          }
          Assertion.assertTrue(index != -1);
          if (((SingleElementSymbol)buffer.getSchema().get(index)).getType() == DataTypeManager.DefaultDataClasses.BIG_DECIMAL) {
            result = new TreeSet<Object>();
        } else {
          result = new HashSet<Object>();
        }
          while (its.hasNext()) {
            Object value = its.nextTuple().get(index);
            if (value != null) {
              result.add(value);
            }
          }
          its.closeSource();
          if (cachedSets == null) {
            cachedSets = new HashMap<Expression, Set<Object>>();
          }
        cachedSets.put(valueExpression, result);
      }
View Full Code Here

      index = this.joinNode.getBufferManager().createSTree(reordered, this.joinNode.getConnectionID(), keyLength);
      index.setPreferMemory(true);
      if (!state.isDistinct()) {
        index.getComparator().setDistinctIndex(keyLength-2);
      }
      IndexedTupleSource its = state.getTupleBuffer().createIndexedTupleSource(!joinNode.isDependent());
      int rowId = 0;
      List<?> lastTuple = null;
      boolean sortedDistinct = sorted && !state.isDistinct();
      int sizeHint = index.getExpectedHeight(state.getTupleBuffer().getRowCount());
      outer: while (its.hasNext()) {
        //detect if sorted and distinct
        List<?> originalTuple = its.nextTuple();
        //remove the tuple if it has null
        for (int i : state.getExpressionIndexes()) {
          if (originalTuple.get(i) == null) {
            continue outer;
          }
        }
        if (sortedDistinct && lastTuple != null && this.compare(lastTuple, originalTuple, state.getExpressionIndexes(), state.getExpressionIndexes()) == 0) {
          sortedDistinct = false;
        }
        lastTuple = originalTuple;
        List<Object> tuple = (List<Object>) RelationalNode.projectTuple(reorderedSortIndex, originalTuple);
        if (!state.isDistinct()) {
          tuple.add(keyLength - 1, rowId++);
        }
        index.insert(tuple, sorted?InsertMode.ORDERED:InsertMode.NEW, sizeHint);
      }
      if (!sorted) {
        index.compact();
      }
      its.closeSource();
      this.reverseIndexes = new int[elements.size()];
      for (int i = 0; i < reverseIndexes.length; i++) {
        int oldIndex = reorderedSortIndex[i];
        this.reverseIndexes[oldIndex] = i + (!state.isDistinct()&&i>=keyLength-1?1:0);
      }
View Full Code Here

TOP

Related Classes of org.teiid.common.buffer.IndexedTupleSource

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.