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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations