Search in sources :

Example 26 with BufferManager

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

the class TestMaterialization method setUp.

@Before
public void setUp() {
    // $NON-NLS-1$
    tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES);
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    TransformationMetadata actualMetadata = RealMetadataFactory.exampleMaterializedView();
    globalStore = new GlobalTableStoreImpl(bm, actualMetadata.getVdbMetaData(), actualMetadata);
    metadata = new TempMetadataAdapter(actualMetadata, tempStore.getMetadataStore());
    hdm = new HardcodedDataManager();
    hdm.addData("SELECT MatSrc.MatSrc.x FROM MatSrc.MatSrc", new List[] { Arrays.asList((String) null), Arrays.asList("one"), Arrays.asList("two"), Arrays.asList("three") });
    hdm.addData("SELECT MatTable.info.e1, MatTable.info.e2 FROM MatTable.info", new List[] { Arrays.asList("a", 1), Arrays.asList("a", 2) });
    hdm.addData("SELECT MatTable.info.e2, MatTable.info.e1 FROM MatTable.info", new List[] { Arrays.asList(1, "a"), Arrays.asList(2, "a") });
    SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
    cache.setTupleBufferCache(bm);
    dataManager = new TempTableDataManager(hdm, bm, cache);
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) TempTableStore(org.teiid.query.tempdata.TempTableStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) SessionAwareCache(org.teiid.dqp.internal.process.SessionAwareCache) TempTableDataManager(org.teiid.query.tempdata.TempTableDataManager) BufferManager(org.teiid.common.buffer.BufferManager) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) CachedResults(org.teiid.dqp.internal.process.CachedResults) Before(org.junit.Before)

Example 27 with BufferManager

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

the class TestBatchIterator method testBatchReadDuringMark.

@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();
    // $NON-NLS-1$
    bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR), true);
    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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 28 with BufferManager

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

the class TestBatchIterator method testNoSaveForwardOnly.

@Test
public void testNoSaveForwardOnly() throws Exception {
    BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 2) {

        @Override
        public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
            TupleBatch tb = super.nextBatchDirect();
            tb.setRowOffset(tb.getBeginRow() + 3);
            return tb;
        }
    });
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR);
    tb.setForwardOnly(true);
    // $NON-NLS-1$
    bi.setBuffer(tb, false);
    tb.addTuple(Arrays.asList(2));
    tb.addTuple(Arrays.asList(2));
    tb.addTuple(Arrays.asList(2));
    assertEquals(3, bi.getBuffer().getManagedRowCount());
    bi.nextTuple();
    // pull the first batch
    assertEquals(2, bi.available());
    assertEquals(0, bi.getBuffer().getManagedRowCount());
    for (int i = 0; i < 2; i++) {
        assertNotNull(bi.nextTuple());
        assertEquals(0, bi.getBuffer().getManagedRowCount());
    }
    bi.readAhead(3);
    assertEquals(2, bi.getBuffer().getManagedRowCount());
    for (int i = 0; i < 4; i++) {
        assertNotNull(bi.nextTuple());
        assertEquals(0, bi.getBuffer().getManagedRowCount());
    }
    assertNull(bi.nextTuple());
    assertEquals(0, bi.getBuffer().getManagedRowCount());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) TeiidComponentException(org.teiid.core.TeiidComponentException) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) BlockedException(org.teiid.common.buffer.BlockedException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 29 with BufferManager

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

the class TestBatchIterator method testReadAheadMark.

@Test
public void testReadAheadMark() 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), Arrays.asList(1) }, 2));
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR);
    // $NON-NLS-1$
    bi.setBuffer(tb, true);
    bi.nextTuple();
    assertEquals(1, bi.available());
    assertEquals(0, bi.getBuffer().getRowCount());
    bi.readAhead(100);
    assertEquals(4, bi.getBuffer().getRowCount());
    // shouldn't keep reading
    bi.readAhead(2);
    assertEquals(4, bi.getBuffer().getRowCount());
    bi.readAhead(5);
    assertEquals(6, bi.getBuffer().getRowCount());
    // does nothing
    bi.readAhead(8);
    for (int i = 0; i < 6; i++) {
        assertNotNull(bi.nextTuple());
    }
    assertNull(bi.nextTuple());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 30 with BufferManager

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

the class TestBatchIterator method testReadAhead.

@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);
    // $NON-NLS-1$
    bi.setBuffer(tb, false);
    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());
    // does nothing
    bi.readAhead(8);
    for (int i = 0; i < 5; i++) {
        assertNotNull(bi.nextTuple());
    }
    assertNull(bi.nextTuple());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Aggregations

BufferManager (org.teiid.common.buffer.BufferManager)46 Test (org.junit.Test)32 List (java.util.List)23 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)22 CommandContext (org.teiid.query.util.CommandContext)18 ArrayList (java.util.ArrayList)17 TupleBuffer (org.teiid.common.buffer.TupleBuffer)16 FakeRelationalNode (org.teiid.query.processor.relational.FakeRelationalNode)8 BlockedException (org.teiid.common.buffer.BlockedException)6 BigDecimal (java.math.BigDecimal)5 TupleSource (org.teiid.common.buffer.TupleSource)5 CachedResults (org.teiid.dqp.internal.process.CachedResults)5 SessionAwareCache (org.teiid.dqp.internal.process.SessionAwareCache)5 FakeTupleSource (org.teiid.query.processor.FakeTupleSource)5 AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)5 TupleBatch (org.teiid.common.buffer.TupleBatch)4 TempTableDataManager (org.teiid.query.tempdata.TempTableDataManager)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ClobImpl (org.teiid.core.types.ClobImpl)2 ClobType (org.teiid.core.types.ClobType)2