Search in sources :

Example 6 with BufferManagerImpl

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

the class TestSTree method testSearch.

@Test
public void testSearch() throws TeiidComponentException, TeiidProcessingException {
    // due to buffering changes we need to hold this in memory directly rather than serialize it out as that will lead to GC overhead errors
    BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(Integer.MAX_VALUE, 1);
    ElementSymbol e1 = new ElementSymbol("x");
    e1.setType(Integer.class);
    ElementSymbol e2 = new ElementSymbol("x");
    e2.setType(Integer.class);
    List elements = Arrays.asList(e1, e2);
    STree map = bm.createSTree(elements, "1", 2);
    int size = 1 << 16;
    for (int i = 0; i < size; i++) {
        assertNull(map.insert(Arrays.asList(i, i), InsertMode.NEW, -1));
        assertEquals(i + 1, map.getRowCount());
    }
    map.compact();
    for (int i = 0; i < size; i++) {
        TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
        assertNotNull(tb.nextTuple());
        assertNull(tb.nextTuple());
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) CollectionTupleSource(org.teiid.query.processor.CollectionTupleSource) List(java.util.List) Test(org.junit.Test)

Example 7 with BufferManagerImpl

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

the class TestSTree method testSearchWithRepeated.

@Test
public void testSearchWithRepeated() throws TeiidComponentException, TeiidProcessingException {
    // due to buffering changes we need to hold this in memory directly rather than serialize it out as that will lead to GC overhead errors
    BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(Integer.MAX_VALUE, 1);
    ElementSymbol e1 = new ElementSymbol("x");
    e1.setType(Integer.class);
    ElementSymbol e2 = new ElementSymbol("x");
    e2.setType(Integer.class);
    List<ElementSymbol> elements = Arrays.asList(e1, e2);
    STree map = bm.createSTree(elements, "1", 2);
    int size = 1 << 16;
    for (int i = 0; i < size; i++) {
        assertNull(map.insert(Arrays.asList(i, i * 2), InsertMode.NEW, -1));
        assertNull(map.insert(Arrays.asList(i, i * 2 + 1), InsertMode.NEW, -1));
        assertEquals((i + 1) * 2, map.getRowCount());
    }
    map.compact();
    for (int i = 0; i < size; i++) {
        TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
        for (int j = 0; j < 2; j++) {
            assertNotNull(tb.nextTuple());
        }
        assertNull(tb.nextTuple());
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) CollectionTupleSource(org.teiid.query.processor.CollectionTupleSource) Test(org.junit.Test)

Example 8 with BufferManagerImpl

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

the class TestLocalBufferService method testCheckMemPropertyGotSet.

@Test
public void testCheckMemPropertyGotSet() throws Exception {
    BufferServiceImpl svc = new BufferServiceImpl();
    svc.setDiskDirectory(UnitTestUtil.getTestScratchPath() + "/teiid/1");
    svc.setUseDisk(true);
    svc.setInlineLobs(false);
    svc.start();
    // all the properties are set
    // $NON-NLS-1$
    assertTrue("Not Directory", svc.getBufferDirectory().isDirectory());
    // $NON-NLS-1$
    assertTrue("does not exist", svc.getBufferDirectory().exists());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue("does not end with one", svc.getBufferDirectory().getParent().endsWith("1"));
    assertTrue(svc.isUseDisk());
    assertFalse(svc.isInlineLobs());
    BufferManagerImpl mgr = svc.getBufferManager();
    SplittableStorageManager ssm = (SplittableStorageManager) ((BufferFrontedFileStoreCache) mgr.getCache()).getStorageManager();
    assertTrue(((FileStorageManager) ssm.getStorageManager()).getDirectory().endsWith(svc.getBufferDirectory().getName()));
}
Also used : SplittableStorageManager(org.teiid.common.buffer.impl.SplittableStorageManager) BufferServiceImpl(org.teiid.services.BufferServiceImpl) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) FileStorageManager(org.teiid.common.buffer.impl.FileStorageManager) Test(org.junit.Test)

Example 9 with BufferManagerImpl

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

the class BaseQueryTest method doProcess.

protected void doProcess(QueryMetadataInterface metadata, String sql, CapabilitiesFinder capFinder, ProcessorDataManager dataManager, List[] expectedResults, boolean debug) throws Exception {
    CommandContext context = createCommandContext();
    BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
    bm.setProcessorBatchSize(context.getProcessorBatchSize());
    context.setBufferManager(bm);
    doProcess(metadata, sql, capFinder, dataManager, expectedResults, debug, context);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl)

Example 10 with BufferManagerImpl

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

the class TestProcessor method doProcess.

public static long doProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults, CommandContext context) throws Exception {
    BufferManager bufferMgr = context.getBufferManager();
    if (bufferMgr == null) {
        BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
        bm.setProcessorBatchSize(context.getProcessorBatchSize());
        context.setBufferManager(bm);
        bufferMgr = bm;
    }
    context.getNextRand(0);
    if (context.getTempTableStore() == null) {
        context.setTempTableStore(new TempTableStore(context.getConnectionId(), TransactionMode.ISOLATE_WRITES));
    }
    if (context.getGlobalTableStore() == null) {
        GlobalTableStoreImpl gts = new GlobalTableStoreImpl(bufferMgr, null, context.getMetadata());
        context.setGlobalTableStore(gts);
    }
    if (!(dataManager instanceof TempTableDataManager)) {
        SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
        cache.setTupleBufferCache(bufferMgr);
        dataManager = new TempTableDataManager(dataManager, bufferMgr, cache);
    }
    if (context.getQueryProcessorFactory() == null) {
        context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(bufferMgr, dataManager, new DefaultCapabilitiesFinder(), null, context.getMetadata()));
    }
    TupleBuffer id = null;
    long rowCount = 0;
    try {
        QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
        // processor.setNonBlocking(true);
        BatchCollector collector = processor.createBatchCollector();
        for (int i = 0; i < 100; i++) {
            try {
                id = collector.collectTuples();
                break;
            } catch (BlockedException e) {
            }
        }
        if (id == null) {
            fail("did not complete processing");
        }
        rowCount = id.getRowCount();
        if (DEBUG) {
            // $NON-NLS-1$
            System.out.println("\nResults:\n" + id.getSchema());
            TupleSource ts2 = id.createIndexedTupleSource();
            for (int j = 0; j < rowCount; j++) {
                // $NON-NLS-1$ //$NON-NLS-2$
                System.out.println("" + j + ": " + ts2.nextTuple());
            }
        }
        if (expectedResults != null) {
            examineResults(expectedResults, bufferMgr, id);
        }
    } finally {
        if (id != null) {
            id.remove();
        }
    }
    return rowCount;
}
Also used : TempTableStore(org.teiid.query.tempdata.TempTableStore) BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) SessionAwareCache(org.teiid.dqp.internal.process.SessionAwareCache) TempTableDataManager(org.teiid.query.tempdata.TempTableDataManager) TupleBuffer(org.teiid.common.buffer.TupleBuffer) BufferManager(org.teiid.common.buffer.BufferManager) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) BlockedException(org.teiid.common.buffer.BlockedException) CachedResults(org.teiid.dqp.internal.process.CachedResults) TupleSource(org.teiid.common.buffer.TupleSource) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) QueryProcessorFactoryImpl(org.teiid.dqp.internal.process.QueryProcessorFactoryImpl)

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