Package org.teiid.query.processor

Examples of org.teiid.query.processor.BatchIterator


        selectNode.addChild(child);
        selectNode.initialize(context, mgr, dataMgr);
       
        selectNode.open();
       
        BatchIterator iterator = new BatchIterator(selectNode);
       
        for (int i = 0; i < expected.length; i++) {
          while (true) {
            try {
              assertEquals("Rows don't match at " + i, expected[i], iterator.nextTuple()); //$NON-NLS-1$
              break;
            } catch (BlockedException e) {
              continue;
            } catch (QueryProcessor.ExpiredTimeSliceException e) {
              continue;
            }
          }
    } 
        assertFalse(iterator.hasNext());
  }
View Full Code Here


        return outputPhase();
    }

    private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException {
      if (this.sortUtility == null) {
          this.sortUtility = new SortUtility(new BatchIterator(getChildren()[0]), items, this.mode, getBufferManager(),
                                              getConnectionID(), getChildren()[0].getElements());
    }
    this.output = this.sortUtility.sort();
    if (this.outputTs == null) {
      this.outputTs = this.output.createIndexedTupleSource();
View Full Code Here

            CommandContext subContext = getContext().clone();
            subContext.setVariableContext(this.currentVarContext);
            subContext.setTempTableStore(getTempTableStore());
            state = new CursorState();
            state.processor = new QueryProcessor(command, subContext, this.bufferMgr, this.dataMgr);
            state.ts = new BatchIterator(state.processor);
            if (procAssignments != null && state.processor.getOutputElements().size() - procAssignments.size() > 0) {
              state.resultsBuffer = bufferMgr.createTupleBuffer(state.processor.getOutputElements().subList(0, state.processor.getOutputElements().size() - procAssignments.size()), getContext().getConnectionID(), TupleSourceType.PROCESSOR);
            }
              this.currentState = state;
          }
View Full Code Here

        if (this.iterator == null) {
            if (this.buffer != null) {
                iterator = buffer.createIndexedTupleSource();
            } else {
                // return a TupleBatch tuplesource iterator
                BatchIterator bi = new BatchIterator(this.source);
                if (implicitBuffer != ImplicitBuffer.NONE) {
                  bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK);
                }
                this.iterator = bi;
            }
        }
        return this.iterator;
View Full Code Here

        TupleSource ts = null;
        if (this.buffer != null) {
          this.buffer.setForwardOnly(true);
          ts = this.buffer.createIndexedTupleSource();
        } else {
          ts = new BatchIterator(this.source);
        }
        this.sortUtility = new SortUtility(ts, expressions, Collections.nCopies(expressions.size(), OrderBy.ASC),
            sortOption == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT, this.source.getBufferManager(), this.source.getConnectionID(), source.getElements());
        this.markDistinct(sortOption == SortOption.SORT_DISTINCT && expressions.size() == this.getOuterVals().size());
    }
View Full Code Here

     * @see org.teiid.query.processor.xml.PlanExecutor#execute(java.util.Map)
     */
    public void execute(Map referenceValues) throws TeiidComponentException, BlockedException, TeiidProcessingException {       
        if (this.tupleSource == null) {
          setReferenceValues(referenceValues);
            this.tupleSource = new BatchIterator(internalProcessor);
        }
        //force execution
        this.tupleSource.hasNext();
    }   
View Full Code Here

@SuppressWarnings("nls")
public class TestBatchIterator {

  @Test public void testReset() throws Exception {
    BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
      Arrays.asList(1),
      Arrays.asList(1),
      Arrays.asList(1)
    }, 1));
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")), "test", TupleSourceType.PROCESSOR), true)//$NON-NLS-1$
    bi.mark();
    bi.nextTuple();
    bi.nextTuple();
    bi.reset();
    bi.nextTuple();
  }
View Full Code Here

    bi.reset();
    bi.nextTuple();
  }
 
  @Test public void testReset1() throws Exception {
    BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
      Arrays.asList(1),
      Arrays.asList(2),
      Arrays.asList(3)
    }, 2));
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")), "test", TupleSourceType.PROCESSOR);
    bi.setBuffer(tb, true)//$NON-NLS-1$
    bi.nextTuple();
    bi.mark();
    bi.nextTuple();
    bi.reset();
    assertEquals(2, bi.getCurrentIndex());
    assertEquals(2, bi.nextTuple().get(0));
  }
View Full Code Here

    assertEquals(2, bi.getCurrentIndex());
    assertEquals(2, bi.nextTuple().get(0));
  }
 
  @Test public void testReset2() throws Exception {
    BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
      Arrays.asList(1),
      Arrays.asList(2),
    }, 2));
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")), "test", TupleSourceType.PROCESSOR);
    bi.setBuffer(tb, true)//$NON-NLS-1$
    bi.hasNext();
    bi.mark();
    bi.nextTuple();
    bi.nextTuple();
    assertNull(bi.nextTuple());
    bi.reset();
    bi.hasNext();
    assertEquals(1, bi.getCurrentIndex());
    assertEquals(1, bi.nextTuple().get(0));
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.processor.BatchIterator

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.