IndexedTupleSource getIterator() throws TeiidComponentException, TeiidProcessingException { if (this.iterator == null) { if (this.buffer != null) { iterator = buffer.createIndexedTupleSource(); } else { // return a TupleBatch tuplesource iterator BatchIterator bi = new BatchIterator(this.source); if (this.collector != null) { bi.setBuffer(this.collector.getTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK); if (implicitBuffer == ImplicitBuffer.NONE) { bi.getBuffer().setForwardOnly(true); } this.collector = null; } else if (implicitBuffer != ImplicitBuffer.NONE) { bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK); } this.iterator = bi; } } return this.iterator; }
IndexedTupleSource getIterator() throws TeiidComponentException, TeiidProcessingException { if (this.iterator == null) { if (this.buffer != null) { iterator = buffer.createIndexedTupleSource(); } else { // return a TupleBatch tuplesource iterator BatchIterator bi = new BatchIterator(this.source); if (this.collector != null) { bi.setBuffer(this.collector.getTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK); if (implicitBuffer == ImplicitBuffer.NONE) { bi.getBuffer().setForwardOnly(true); } this.collector = null; } else if (implicitBuffer != ImplicitBuffer.NONE) { bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK); } this.iterator = bi; } } return this.iterator; }
IndexedTupleSource getIterator() throws TeiidComponentException, TeiidProcessingException { if (this.iterator == null) { if (this.buffer != null) { iterator = buffer.createIndexedTupleSource(); } else { // return a TupleBatch tuplesource iterator BatchIterator bi = new BatchIterator(this.source); if (this.collector != null) { bi.setBuffer(this.collector.getTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK); if (implicitBuffer == ImplicitBuffer.NONE) { bi.getBuffer().setForwardOnly(true); } this.collector = null; } else if (implicitBuffer != ImplicitBuffer.NONE) { bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK); } this.iterator = bi; } } return this.iterator; }
@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", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR), true); //$NON-NLS-1$ bi.mark(); bi.nextTuple(); bi.nextTuple(); bi.reset(); bi.nextTuple(); }
this.buffer.setForwardOnly(true); } else { ts = new BatchIterator(this.source);
this.buffer.setForwardOnly(true); } else { ts = new BatchIterator(this.source);
this.buffer.setForwardOnly(true); } else { ts = new BatchIterator(this.source);
state.usesLocalTemp = usesLocalTemp; state.processor = new QueryProcessor(command, subContext, this.bufferMgr, this); state.ts = new BatchIterator(state.processor); if (mode == Mode.HOLD && 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);
@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", null, DataTypeManager.DefaultDataClasses.INTEGER)), "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)); }
@Test public void testDisableSave() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), }, 2)); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR); bi.setBuffer(tb, false); //$NON-NLS-1$ bi.setPosition(2); assertTrue(bi.hasNext()); tb.setForwardOnly(true); bi.setPosition(1); bi.disableSave(); for (int i = 0; i < 6; i++) { assertNotNull(bi.nextTuple()); } assertNull(bi.nextTuple()); assertEquals(0, tb.getManagedRowCount()); }
private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.sortUtility == null) { TupleSource ts = null; TupleBuffer working = null; if (!getChildren()[0].hasBuffer()) { ts = new BatchIterator(getChildren()[0]); } else { working = getChildren()[0].getBuffer(-1); } this.sortUtility = new SortUtility(ts, items, this.mode, getBufferManager(), getConnectionID(), getChildren()[0].getElements()); if (ts == null) { this.sortUtility.setWorkingBuffer(working); } } this.output = this.sortUtility.sort(rowLimit); if (this.outputTs == null) { this.outputTs = this.output.createIndexedTupleSource(); } this.phase = OUTPUT; }
private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.sortUtility == null) { TupleSource ts = null; TupleBuffer working = null; if (!getChildren()[0].hasBuffer()) { ts = new BatchIterator(getChildren()[0]); } else { working = getChildren()[0].getBuffer(-1); } this.sortUtility = new SortUtility(ts, items, this.mode, getBufferManager(), getConnectionID(), getChildren()[0].getElements()); if (ts == null) { this.sortUtility.setWorkingBuffer(working); } } this.output = this.sortUtility.sort(rowLimit); if (this.outputTs == null) { this.outputTs = this.output.createIndexedTupleSource(); } this.phase = OUTPUT; }
private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.sortUtility == null) { TupleSource ts = null; TupleBuffer working = null; if (!getChildren()[0].hasBuffer()) { ts = new BatchIterator(getChildren()[0]); } else { working = getChildren()[0].getBuffer(-1); } this.sortUtility = new SortUtility(ts, items, this.mode, getBufferManager(), getConnectionID(), getChildren()[0].getElements()); if (ts == null) { this.sortUtility.setWorkingBuffer(working); } } this.output = this.sortUtility.sort(rowLimit); if (this.outputTs == null) { this.outputTs = this.output.createIndexedTupleSource(); } this.phase = OUTPUT; }
@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", null, DataTypeManager.DefaultDataClasses.INTEGER)), "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)); }
@Test public void testReadAheadMark() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1),
@Test public void testBatchReadDuringMark() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), }, 2)); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR), true); //$NON-NLS-1$ bi.mark(); assertNotNull(bi.nextTuple()); assertNotNull(bi.nextTuple()); assertNotNull(bi.nextTuple()); bi.reset(); assertNotNull(bi.nextTuple()); assertNotNull(bi.nextTuple()); assertNotNull(bi.nextTuple()); assertNotNull(bi.nextTuple()); assertNull(bi.nextTuple()); }
@Test public void testReadAhead() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), }, 2)); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR); bi.setBuffer(tb, false); //$NON-NLS-1$ bi.nextTuple(); assertEquals(1, bi.available()); assertEquals(2, bi.getBuffer().getRowCount()); bi.readAhead(100); assertEquals(4, bi.getBuffer().getRowCount()); //shouldn't keep reading bi.readAhead(3); assertEquals(4, bi.getBuffer().getRowCount()); bi.readAhead(5); assertEquals(6, bi.getBuffer().getRowCount()); bi.readAhead(8); //does nothing for (int i = 0; i < 5; i++) { assertNotNull(bi.nextTuple()); } assertNull(bi.nextTuple()); }
@Test public void testNoSaveForwardOnly() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1),
BatchIterator iterator = new BatchIterator(selectNode);
if (this.tupleSource == null) { setReferenceValues(referenceValues); this.tupleSource = new BatchIterator(internalProcessor); if (openOnly) { internalProcessor.init();