Search in sources :

Example 1 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestTupleSourceCache method testNodeId.

@Test
public void testNodeId() throws Exception {
    TupleSourceCache tsc = new TupleSourceCache();
    HardcodedDataManager pdm = new HardcodedDataManager() {

        @Override
        public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
            assertEquals(1, parameterObject.nodeID);
            return Mockito.mock(TupleSource.class);
        }
    };
    CommandContext context = TestProcessor.createCommandContext();
    BufferManagerImpl bufferMgr = BufferManagerFactory.createBufferManager();
    Command command = new Insert();
    RegisterRequestParameter parameterObject = new RegisterRequestParameter("z", 1, 1);
    parameterObject.info = new RegisterRequestParameter.SharedAccessInfo();
    tsc.getSharedTupleSource(context, command, "x", parameterObject, bufferMgr, pdm);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) Command(org.teiid.query.sql.lang.Command) Insert(org.teiid.query.sql.lang.Insert) RegisterRequestParameter(org.teiid.query.processor.RegisterRequestParameter) Test(org.junit.Test)

Example 2 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestDQPCore method testFinalRow.

@Test
public void testFinalRow() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT A.IntKey FROM BQT1.SmallA as A";
    // $NON-NLS-1$
    String userName = "1";
    // $NON-NLS-1$
    String sessionid = "1";
    RequestMessage reqMsg = exampleRequestMessage(sql);
    reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
    DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
    DQPWorkContext.getWorkContext().getSession().setUserName(userName);
    ((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(10);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(10, rm.getResultsList().size());
    RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
    while (item.isProcessing()) ;
    synchronized (item) {
        for (int i = 0; i < 100; i++) {
            Thread.sleep(10);
        }
    }
    assertEquals(10, item.resultsBuffer.getRowCount());
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) Test(org.junit.Test)

Example 3 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestDQPCore method testBufferReuse.

@Test
public void testBufferReuse() throws Exception {
    // the sql should return 100 rows
    // $NON-NLS-1$
    String sql = "SELECT A.IntKey FROM BQT1.SmallA as A, BQT1.SmallA as B ORDER BY A.IntKey";
    // $NON-NLS-1$
    String userName = "1";
    // $NON-NLS-1$
    String sessionid = "1";
    RequestMessage reqMsg = exampleRequestMessage(sql);
    reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
    DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
    DQPWorkContext.getWorkContext().getSession().setUserName(userName);
    ((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(1);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(8, rm.getResultsList().size());
    RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
    assertEquals(100, item.resultsBuffer.getRowCount());
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) Test(org.junit.Test)

Example 4 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestSTree method testOrderedInsert.

@Test
public void testOrderedInsert() throws TeiidComponentException {
    BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
    bm.setProcessorBatchSize(4);
    ElementSymbol e1 = new ElementSymbol("x");
    e1.setType(Integer.class);
    List<ElementSymbol> elements = Arrays.asList(e1);
    STree map = bm.createSTree(elements, "1", 1);
    int size = (1 << 16) + (1 << 4) + 1;
    for (int i = 0; i < size; i++) {
        assertNull(map.insert(Arrays.asList(i), InsertMode.ORDERED, size));
        assertEquals(i + 1, map.getRowCount());
    }
    assertEquals(4, map.getHeight());
    for (int i = 0; i < size; i++) {
        assertNotNull(map.remove(Arrays.asList(i)));
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) Test(org.junit.Test)

Example 5 with BufferManagerImpl

use of org.teiid.common.buffer.impl.BufferManagerImpl in project teiid by teiid.

the class TestSTree method testUnOrderedInsert.

@Test
public void testUnOrderedInsert() throws TeiidComponentException {
    BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
    bm.setProcessorBatchSize(16);
    ElementSymbol e1 = new ElementSymbol("x");
    e1.setType(Integer.class);
    List elements = Arrays.asList(e1);
    STree map = bm.createSTree(elements, "1", 1);
    int size = (1 << 16) + (1 << 4) + 1;
    int logSize = map.getExpectedHeight(size);
    for (int i = 0; i < size; i++) {
        assertNull(map.insert(Arrays.asList(i), InsertMode.NEW, logSize));
        assertEquals(i + 1, map.getRowCount());
    }
    assertTrue(5 >= map.getHeight());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) List(java.util.List) Test(org.junit.Test)

Aggregations

BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)34 Test (org.junit.Test)24 CommandContext (org.teiid.query.util.CommandContext)13 List (java.util.List)11 ArrayList (java.util.ArrayList)8 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)8 RequestMessage (org.teiid.client.RequestMessage)6 ResultsMessage (org.teiid.client.ResultsMessage)5 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)5 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)4 TupleSource (org.teiid.common.buffer.TupleSource)3 BufferFrontedFileStoreCache (org.teiid.common.buffer.impl.BufferFrontedFileStoreCache)3 FileStorageManager (org.teiid.common.buffer.impl.FileStorageManager)3 RegisterRequestParameter (org.teiid.query.processor.RegisterRequestParameter)3 Command (org.teiid.query.sql.lang.Command)3 BufferServiceImpl (org.teiid.services.BufferServiceImpl)3 HashMap (java.util.HashMap)2 BlockedException (org.teiid.common.buffer.BlockedException)2 BufferManager (org.teiid.common.buffer.BufferManager)2 TupleBatch (org.teiid.common.buffer.TupleBatch)2