use of org.teiid.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class TestMaterialization method testDefaultMaterializationWithPK.
@Test
public void testDefaultMaterializationWithPK() throws Exception {
// $NON-NLS-1$
String userSql = "SELECT * from vgroup3 where x = 'foo'";
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);
RelationalPlan plan = (RelationalPlan) TestOptimizer.getPlan(command, metadata, getGenericFinder(), analysis, true, cc);
assertEquals(1f, plan.getRootNode().getEstimateNodeCardinality());
TestOptimizer.checkAtomicQueries(new String[] { "SELECT #MAT_MATVIEW.VGROUP3.x, #MAT_MATVIEW.VGROUP3.y FROM #MAT_MATVIEW.VGROUP3 WHERE #MAT_MATVIEW.VGROUP3.x = 'foo'" }, 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 setUp.
@Before
public void setUp() {
// $NON-NLS-1$
tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES);
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
TransformationMetadata actualMetadata = RealMetadataFactory.exampleMaterializedView();
globalStore = new GlobalTableStoreImpl(bm, actualMetadata.getVdbMetaData(), actualMetadata);
metadata = new TempMetadataAdapter(actualMetadata, tempStore.getMetadataStore());
hdm = new HardcodedDataManager();
hdm.addData("SELECT MatSrc.MatSrc.x FROM MatSrc.MatSrc", new List[] { Arrays.asList((String) null), Arrays.asList("one"), Arrays.asList("two"), Arrays.asList("three") });
hdm.addData("SELECT MatTable.info.e1, MatTable.info.e2 FROM MatTable.info", new List[] { Arrays.asList("a", 1), Arrays.asList("a", 2) });
hdm.addData("SELECT MatTable.info.e2, MatTable.info.e1 FROM MatTable.info", new List[] { Arrays.asList(1, "a"), Arrays.asList(2, "a") });
SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
cache.setTupleBufferCache(bm);
dataManager = new TempTableDataManager(hdm, bm, cache);
}
use of org.teiid.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class TestTempTables method testIsolateReads.
@Test
public void testIsolateReads() throws Exception {
GlobalTableStoreImpl gtsi = new GlobalTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), RealMetadataFactory.example1Cached().getVdbMetaData(), RealMetadataFactory.example1Cached());
tempStore = gtsi.getTempTableStore();
metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
// $NON-NLS-1$
execute("create local temporary table x (e1 string, e2 integer)", new List[] { Arrays.asList(0) });
for (int i = 0; i < 300; i++) {
// $NON-NLS-1$
execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] { Arrays.asList(6) });
}
setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
execute("select count(e1) from x", new List[] { Arrays.asList(1500) });
gtsi.updateMatViewRow("X", Arrays.asList(2l), true);
tc = null;
// outside of the transaction we can see the row removed
execute("select count(e1) from x", new List[] { Arrays.asList(1499) });
// back in the transaction we see the original state
setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
execute("select count(e1) from x", new List[] { Arrays.asList(1500) });
synch.afterCompletion(Status.STATUS_COMMITTED);
}
use of org.teiid.query.tempdata.GlobalTableStoreImpl in project teiid by teiid.
the class CompositeGlobalTableStore method createInstance.
public static GlobalTableStore createInstance(CompositeVDB vdb, BufferManager bufferManager, ObjectReplicator replicator) {
VDBMetaData vdbMetadata = vdb.getVDB();
QueryMetadataInterface metadata = vdbMetadata.getAttachment(TransformationMetadata.class);
GlobalTableStore gts = new GlobalTableStoreImpl(bufferManager, vdbMetadata, metadata);
if (replicator != null) {
try {
gts = replicator.replicate(vdbMetadata.getFullName(), GlobalTableStore.class, gts, 300000);
} catch (Exception e) {
LogManager.logError(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40088, gts));
}
}
if (vdb.getChildren() == null) {
return gts;
}
TreeMap<String, GlobalTableStore> stores = new TreeMap<String, GlobalTableStore>(String.CASE_INSENSITIVE_ORDER);
buildStoreMap(vdb, stores);
return new CompositeGlobalTableStore(stores, gts, metadata);
}
Aggregations