Search in sources :

Example 1 with QueryProcessorFactoryImpl

use of org.teiid.dqp.internal.process.QueryProcessorFactoryImpl 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)

Example 2 with QueryProcessorFactoryImpl

use of org.teiid.dqp.internal.process.QueryProcessorFactoryImpl in project teiid by teiid.

the class TestMaterialization method execute.

private void execute(String sql, List<?>... expectedResults) throws Exception {
    CommandContext cc = TestProcessor.createCommandContext();
    cc.setTempTableStore(tempStore);
    cc.setGlobalTableStore(globalStore);
    cc.setMetadata(metadata);
    CapabilitiesFinder finder = new DefaultCapabilitiesFinder();
    previousPlan = TestProcessor.helpGetPlan(TestProcessor.helpParse(sql), metadata, finder, cc);
    cc.setQueryProcessorFactory(new QueryProcessorFactoryImpl(BufferManagerFactory.getStandaloneBufferManager(), dataManager, finder, null, metadata));
    TestProcessor.doProcess(previousPlan, dataManager, expectedResults, cc);
}
Also used : CapabilitiesFinder(org.teiid.query.optimizer.capabilities.CapabilitiesFinder) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) CommandContext(org.teiid.query.util.CommandContext) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) QueryProcessorFactoryImpl(org.teiid.dqp.internal.process.QueryProcessorFactoryImpl)

Aggregations

QueryProcessorFactoryImpl (org.teiid.dqp.internal.process.QueryProcessorFactoryImpl)2 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)2 BlockedException (org.teiid.common.buffer.BlockedException)1 BufferManager (org.teiid.common.buffer.BufferManager)1 TupleBuffer (org.teiid.common.buffer.TupleBuffer)1 TupleSource (org.teiid.common.buffer.TupleSource)1 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)1 CachedResults (org.teiid.dqp.internal.process.CachedResults)1 SessionAwareCache (org.teiid.dqp.internal.process.SessionAwareCache)1 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)1 GlobalTableStoreImpl (org.teiid.query.tempdata.GlobalTableStoreImpl)1 TempTableDataManager (org.teiid.query.tempdata.TempTableDataManager)1 TempTableStore (org.teiid.query.tempdata.TempTableStore)1 CommandContext (org.teiid.query.util.CommandContext)1