Examples of TupleSource


Examples of org.teiid.common.buffer.TupleSource

  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;
      if (ii.ordering == null && orderBy != null) {
        SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID, projectedCols);
        tb = sort.sort();
      } else if (agg) {
        int count = 0;
        while (ts.nextTuple() != null) {
          count++;
        }
        return new CollectionTupleSource(Arrays.asList(Collections.nCopies(projectedCols.size(), count)).iterator());
      } else if (updatable) {
        tb = bm.createTupleBuffer(projectedCols, sessionID, TupleSourceType.PROCESSOR);
        List<?> next = null;
        while ((next = ts.nextTuple()) != null) {
          tb.addTuple(next);
        }
      } else {
        usingQueryTupleSource = true;
        return ts;
      }
      tb.close();
      return tb.createIndexedTupleSource(true);
    } finally {
      if (!usingQueryTupleSource) {
        //ensure the buffers get released
        ts.closeSource();
      }
    }
  }
View Full Code Here

Examples of org.teiid.common.buffer.TupleSource

      } finally {
        bm.releaseBuffers(reserved);
        try {
          if (!success) {
            undoLog.setFinal(true);
            TupleSource undoTs = undoLog.createIndexedTupleSource();
            List<?> tuple = null;
            while ((tuple = undoTs.nextTuple()) != null) {
              undo(tuple);
            }
          }
        } catch (TeiidException e) {
          LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage());
View Full Code Here

Examples of org.teiid.common.buffer.TupleSource

     */
    static void examineResults(List[] expectedResults,BufferManager bufferMgr,TupleBuffer tsID)
        throws TeiidComponentException,SQLException, TeiidProcessingException {
       
        // Create QueryResults from TupleSource
        TupleSource ts = tsID.createIndexedTupleSource();
        int count = tsID.getRowCount();  

    if(DEBUG) {
            System.out.println("\nResults:\n" + tsID.getSchema()); //$NON-NLS-1$
            TupleSource ts2 = tsID.createIndexedTupleSource();
            for(int j=0; j<count; j++) {
                System.out.println("" + j + ": " + ts2.nextTuple());   //$NON-NLS-1$ //$NON-NLS-2$
            }   
            ts2.closeSource();
        }
       
        // Compare actual to expected row count
        assertEquals("Did not get expected row count: ", expectedResults.length, count); //$NON-NLS-1$
    
View Full Code Here

Examples of org.teiid.common.buffer.TupleSource

    public void sort(SortOption sortOption) throws TeiidComponentException, TeiidProcessingException {
      if (sortOption == SortOption.ALREADY_SORTED) {
        return;
      }
      if (this.sortUtility == null) {
        TupleSource ts = null;
        if (this.buffer != null) {
          this.buffer.setForwardOnly(true);
          ts = this.buffer.createIndexedTupleSource();
        } else {
          ts = new BatchIterator(this.source);
View Full Code Here

Examples of org.teiid.common.buffer.TupleSource

            }
            TupleBuffer sorted = sortUtility.sort();
            sorted.setForwardOnly(true);
            try {
              // Add all input to proxy
              TupleSource sortedSource = sorted.createIndexedTupleSource();
              while(true) {
                  List tuple = sortedSource.nextTuple();
                  if(tuple == null) {
                      break;
                  }
                  this.proxy.addInputDirect(tuple.get(0), null);
              }
View Full Code Here

Examples of org.teiid.common.buffer.TupleSource

            registerNext();
          }
         
          //drain the tuple source(s)
          for (int i = 0; i < this.tupleSources.size(); i++) {
            TupleSource tupleSource = tupleSources.get(i);
            try {
              List<?> tuple = null;
             
              while ((tuple = tupleSource.nextTuple()) != null) {
                      returnedRows = true;
                      addBatchRow(tuple);
                     
                      if (isBatchFull()) {
                        return pullBatch();
                      }
              }
             
                  //end of source
                    tupleSource.closeSource();
                    tupleSources.remove(i--);
                if (reserved > 0) {
                      reserved -= schemaSize;
                      getBufferManager().releaseBuffers(schemaSize);
                }
View Full Code Here

Examples of org.teiid.common.buffer.TupleSource

       
        InsertValueSource valueSource = null;
        if (insert.getQueryExpression() != null) {
          valueSource = translate(insert.getQueryExpression());
        } else if (insert.getTupleSource() != null) {
          final TupleSource ts = insert.getTupleSource();
          valueSource = new IteratorValueSource<List<?>>(new Iterator<List<?>>() {
           
            List<?> next;
       
        @Override
        public void remove() {
          throw new UnsupportedOperationException();
        }
       
        @Override
        public List<?> next() {
          if (hasNext()) {
            List<?> result = next;
            next = null;
            return result;
          }
          throw new NoSuchElementException();
        }
       
        @Override
        public boolean hasNext() {
          if (next != null) {
            return true;
          }
          try {
            next = ts.nextTuple();
          } catch (TeiidException e) {
            throw new TeiidRuntimeException(e);
          }
          return next != null;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.