Search in sources :

Example 46 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testOffsetMultipleOfBatchSize.

@Test
public void testOffsetMultipleOfBatchSize() throws Exception {
    LimitNode node = getOffsetNode(100, new FakeRelationalNode(2, getRows(300), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(50, batch.getEndRow());
    assertEquals(Arrays.asList(new Object[] { new Integer(101) }), batch.getTuple(1));
    assertFalse(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 47 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testOffsetInSecondBatch.

@Test
public void testOffsetInSecondBatch() throws Exception {
    LimitNode node = getOffsetNode(55, new FakeRelationalNode(2, getRows(100), 50));
    // batch 1
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(45, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(45, batch.getEndRow());
    assertEquals(Arrays.asList(new Object[] { new Integer(56) }), batch.getTuple(1));
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 48 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testLimitProducesMultipleBatches.

@Test
public void testLimitProducesMultipleBatches() throws Exception {
    LimitNode node = getLimitNode(130, new FakeRelationalNode(2, getRows(300), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(50, batch.getEndRow());
    assertFalse(batch.getTerminationFlag());
    batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(51, batch.getBeginRow());
    assertEquals(100, batch.getEndRow());
    assertFalse(batch.getTerminationFlag());
    batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(30, batch.getRowCount());
    assertEquals(101, batch.getBeginRow());
    assertEquals(130, batch.getEndRow());
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 49 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testOffsetWithoutLimit.

@Test
public void testOffsetWithoutLimit() throws Exception {
    LimitNode node = new LimitNode(1, null, new Constant(new Integer(10)));
    node.addChild(new FakeRelationalNode(2, getRows(10), 50));
    node.open();
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(0, batch.getRowCount());
    assertTrue(batch.getTerminationFlag());
}
Also used : Constant(org.teiid.query.sql.symbol.Constant) TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 50 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testLimitInSecondBatch.

@Test
public void testLimitInSecondBatch() throws Exception {
    LimitNode node = getLimitNode(55, new FakeRelationalNode(2, getRows(100), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(50, batch.getEndRow());
    assertFalse(batch.getTerminationFlag());
    batch = node.nextBatch();
    assertEquals(5, batch.getRowCount());
    assertEquals(51, batch.getBeginRow());
    assertEquals(55, batch.getEndRow());
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Aggregations

TupleBatch (org.teiid.common.buffer.TupleBatch)61 Test (org.junit.Test)26 List (java.util.List)23 ArrayList (java.util.ArrayList)22 BlockedException (org.teiid.common.buffer.BlockedException)17 CommandContext (org.teiid.query.util.CommandContext)10 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)9 TeiidProcessingException (org.teiid.core.TeiidProcessingException)8 TeiidComponentException (org.teiid.core.TeiidComponentException)6 BufferManager (org.teiid.common.buffer.BufferManager)4 TupleBuffer (org.teiid.common.buffer.TupleBuffer)4 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)3 TransactionContext (org.teiid.dqp.service.TransactionContext)3 TransactionService (org.teiid.dqp.service.TransactionService)3 ExpressionEvaluationException (org.teiid.api.exception.query.ExpressionEvaluationException)2 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)2 TeiidException (org.teiid.core.TeiidException)2 QueryProcessor (org.teiid.query.processor.QueryProcessor)2 FakeRelationalNode (org.teiid.query.processor.relational.FakeRelationalNode)2 CacheHint (org.teiid.query.sql.lang.CacheHint)2