Package org.teiid.common.buffer

Examples of org.teiid.common.buffer.TupleBrowser


  private TupleSource createTupleSource(
      final List<? extends SingleElementSymbol> projectedCols,
      final Criteria condition, OrderBy orderBy, IndexInfo ii, boolean agg)
      throws TeiidComponentException, TeiidProcessingException {
    TupleBrowser browser = ii.createTupleBrowser();
    TupleSource ts = new QueryTupleSource(browser, columnMap, agg?getColumns():projectedCols, condition);
   
    boolean usingQueryTupleSource = false;
    try {
      TupleBuffer tb = null;
View Full Code Here


        return CollectionTupleSource.createUpdateCountTupleSource(updateCount);
    }
 
  public TupleSource update(Criteria crit, final SetClauseList update) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
    final boolean primaryKeyChangePossible = canChangePrimaryKey(update);
    final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
    UpdateProcessor up = new UpdateProcessor(crit, browser) {
     
      protected TupleBuffer changeSet;
      protected UpdateProcessor changeSetProcessor;
     
      @Override
      protected void tuplePassed(List tuple)
          throws ExpressionEvaluationException,
          BlockedException, TeiidComponentException {
        List<Object> newTuple = new ArrayList<Object>(tuple);
          for (Map.Entry<ElementSymbol, Expression> entry : update.getClauseMap().entrySet()) {
            newTuple.set((Integer)columnMap.get(entry.getKey()), eval.evaluate(entry.getValue(), tuple));
          }
          if (primaryKeyChangePossible) {
            browser.removed();
            deleteTuple(tuple);
            if (changeSet == null) {
              changeSet = bm.createTupleBuffer(columns, sessionID, TupleSourceType.PROCESSOR);
            }
            changeSet.addTuple(newTuple);
          } else {
            browser.update(newTuple);
          }
      }
     
      @Override
      protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
View Full Code Here

    }
    return false;
  }
 
  public TupleSource delete(Criteria crit) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
    final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
    UpdateProcessor up = new UpdateProcessor(crit, browser) {
      @Override
      protected void tuplePassed(List tuple)
          throws ExpressionEvaluationException,
          BlockedException, TeiidComponentException {
        browser.removed();
        deleteTuple(tuple);
      }
     
      @Override
      protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
View Full Code Here

      LogManager.logDetail(LogConstants.CTX_DQP, "Using index for ordering"); //$NON-NLS-1$
      direction = ordering;
    }
    if (valueTs != null) {
      LogManager.logDetail(LogConstants.CTX_DQP, "Using index value set"); //$NON-NLS-1$
      return new TupleBrowser(this.table.getTree(), valueTs, direction);
    }
    if (!valueSet.isEmpty()) {
      LogManager.logDetail(LogConstants.CTX_DQP, "Using index value set"); //$NON-NLS-1$
      CollectionTupleSource cts = null;
      if (direction == OrderBy.ASC) {
        cts = new CollectionTupleSource(valueSet.iterator());
      } else {
        cts = new CollectionTupleSource(new Iterator<List<Object>>() {
          ListIterator<List<Object>> iter = valueSet.listIterator(valueSet.size());
          @Override
          public boolean hasNext() {
            return iter.hasPrevious();
          }
          @Override
          public List<Object> next() {
            return iter.previous();
          }
          @Override
          public void remove() {
            throw new UnsupportedOperationException();
          }
        });
      }
      return new TupleBrowser(this.table.getTree(), cts, direction);
    }
    if (lower != null || upper != null) {
      LogManager.logDetail(LogConstants.CTX_DQP, "Using index for range query", lower, upper); //$NON-NLS-1$
    }
    return new TupleBrowser(this.table.getTree(), lower, upper, direction);
  }
View Full Code Here

          currentTuple = this.currentSource.nextTuple();
          if (currentTuple == null) {
            return;
          }
            List<?> key = RelationalNode.projectTuple(this.notSortedSource.getExpressionIndexes(), this.currentTuple);
            tb = new TupleBrowser(this.index, new CollectionTupleSource(Arrays.asList(key).iterator()), OrderBy.ASC);
        }
        if (sortedTuple == null) {
          sortedTuple = tb.nextTuple();
       
          if (sortedTuple == null) {
View Full Code Here

TOP

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

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.