use of org.teiid.query.tempdata.GlobalTableStoreImpl 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.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class TestCompositeGlobalTableStore method testCompositeGlobalTableStore.
@Test
public void testCompositeGlobalTableStore() throws VirtualDatabaseException {
CompositeVDB vdb = TestCompositeVDB.createCompositeVDB(new MetadataStore(), "foo");
GlobalTableStore gts = CompositeGlobalTableStore.createInstance(vdb, BufferManagerFactory.getStandaloneBufferManager(), null);
assertTrue(gts instanceof GlobalTableStoreImpl);
vdb.children = new LinkedHashMap<VDBKey, CompositeVDB>();
MetadataStore ms = new MetadataStore();
Schema s = new Schema();
s.setName("x");
ms.addSchema(s);
CompositeVDB imported = TestCompositeVDB.createCompositeVDB(ms, "foo");
GlobalTableStore gts1 = Mockito.mock(GlobalTableStore.class);
imported.getVDB().addAttchment(GlobalTableStore.class, gts1);
vdb.getChildren().put(new VDBKey("foo1", 1), imported);
CompositeGlobalTableStore cgts = (CompositeGlobalTableStore) CompositeGlobalTableStore.createInstance(vdb, BufferManagerFactory.getStandaloneBufferManager(), null);
assertEquals(gts1, cgts.getStoreForTable(RelationalPlanner.MAT_PREFIX + "X.Y"));
assertEquals(cgts.getPrimary(), cgts.getStore("Z"));
}
use of org.teiid.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class CommandContext method getSessionScopedStore.
public GlobalTableStoreImpl getSessionScopedStore(boolean create) {
GlobalTableStoreImpl impl = getSession().getAttachment(GlobalTableStoreImpl.class);
if (!create) {
return impl;
}
impl = getSession().getAttachment(GlobalTableStoreImpl.class);
if (impl == null) {
impl = new GlobalTableStoreImpl(getBufferManager(), null, getMetadata());
getSession().addAttchment(GlobalTableStoreImpl.class, impl);
}
return impl;
}
use of org.teiid.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class TestMaterialization method testDefaultMaterialization.
@Test
public void testDefaultMaterialization() throws Exception {
// $NON-NLS-1$
String userSql = "SELECT * from vgroup2";
TransformationMetadata metadata = RealMetadataFactory.exampleMaterializedView();
AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
Command command = helpGetCommand(userSql, metadata, null);
CommandContext cc = new CommandContext();
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata.getVdbMetaData(), metadata);
cc.setGlobalTableStore(gts);
ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP2.x FROM #MAT_MATVIEW.VGROUP2" }, plan);
Collection<Annotation> annotations = analysis.getAnnotations();
// $NON-NLS-1$
assertNotNull("Expected annotations but got none", annotations);
// $NON-NLS-1$
assertEquals("Expected one annotation", 1, annotations.size());
// $NON-NLS-1$
assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
use of org.teiid.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class TestMaterialization method testDefaultMaterializationWithCacheHint.
@Test
public void testDefaultMaterializationWithCacheHint() throws Exception {
// $NON-NLS-1$
String userSql = "SELECT * from vgroup4";
TransformationMetadata metadata = RealMetadataFactory.exampleMaterializedView();
AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
Command command = helpGetCommand(userSql, metadata, null);
CommandContext cc = new CommandContext();
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(null, metadata.getVdbMetaData(), metadata);
cc.setGlobalTableStore(gts);
ProcessorPlan plan = TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP4.x FROM #MAT_MATVIEW.VGROUP4" }, plan);
Collection<Annotation> annotations = analysis.getAnnotations();
// $NON-NLS-1$
assertNotNull("Expected annotations but got none", annotations);
// $NON-NLS-1$
assertEquals("Expected one annotation", 1, annotations.size());
// $NON-NLS-1$
assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW);
}
Aggregations