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