Search in sources :

Example 16 with BufferManager

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

the class TestQueryProcessor method testCloseBeforeInitialization.

@Test
public void testCloseBeforeInitialization() throws TeiidComponentException {
    BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
    FakeDataManager dataManager = new FakeDataManager();
    // $NON-NLS-1$ //$NON-NLS-2$
    CommandContext context = new CommandContext("pid", "group", null, null, 1);
    QueryProcessor processor = new QueryProcessor(null, context, bufferMgr, dataManager);
    processor.closeProcessing();
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 17 with BufferManager

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

the class TestProjectNode method helpSetupProject.

public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) {
    BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
    // $NON-NLS-1$ //$NON-NLS-2$
    CommandContext context = new CommandContext("pid", "test", null, null, 1);
    FakeRelationalNode dataNode = new FakeRelationalNode(2, data);
    dataNode.setElements(childElements);
    dataNode.initialize(context, mgr, null);
    ProjectNode projectNode = new ProjectNode(1);
    projectNode.setSelectSymbols(elements);
    projectNode.setElements(elements);
    projectNode.addChild(dataNode);
    projectNode.initialize(context, mgr, dataMgr);
    return projectNode;
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManager(org.teiid.common.buffer.BufferManager)

Example 18 with BufferManager

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

the class TestSortNode method testOnePass.

@Test
public void testOnePass() throws Exception {
    // $NON-NLS-1$
    ElementSymbol es1 = new ElementSymbol("e1");
    es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    // $NON-NLS-1$
    ElementSymbol es2 = new ElementSymbol("e2");
    es2.setType(DataTypeManager.DefaultDataClasses.INTEGER);
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    // $NON-NLS-1$
    TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1, es2), "test", TupleSourceType.PROCESSOR);
    tsid.addTuple(Arrays.asList(1, 1));
    tsid.addTuple(Arrays.asList(1, 2));
    tsid.close();
    // $NON-NLS-1$
    SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.SORT, bm, "test", tsid.getSchema());
    List<TupleBuffer> buffers = su.onePassSort(true);
    assertEquals(1, buffers.size());
    assertTrue(!buffers.get(0).isForwardOnly());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 19 with BufferManager

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

the class TestBatchIterator method testReset.

@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();
    // $NON-NLS-1$
    bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR), true);
    bi.mark();
    bi.nextTuple();
    bi.nextTuple();
    bi.reset();
    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 20 with BufferManager

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

the class TestBatchIterator method testDisableSave.

@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);
    // $NON-NLS-1$
    bi.setBuffer(tb, false);
    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());
}
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