Search in sources :

Example 6 with GlobalTableStoreImpl

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) AnalysisRecord(org.teiid.query.analysis.AnalysisRecord) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Annotation(org.teiid.client.plan.Annotation) Test(org.junit.Test)

Example 7 with GlobalTableStoreImpl

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);
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) TempTableStore(org.teiid.query.tempdata.TempTableStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) SessionAwareCache(org.teiid.dqp.internal.process.SessionAwareCache) TempTableDataManager(org.teiid.query.tempdata.TempTableDataManager) BufferManager(org.teiid.common.buffer.BufferManager) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) CachedResults(org.teiid.dqp.internal.process.CachedResults) Before(org.junit.Before)

Example 8 with GlobalTableStoreImpl

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);
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) Test(org.junit.Test)

Example 9 with GlobalTableStoreImpl

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);
}
Also used : GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) TreeMap(java.util.TreeMap) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Aggregations

GlobalTableStoreImpl (org.teiid.query.tempdata.GlobalTableStoreImpl)9 Test (org.junit.Test)5 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)4 Annotation (org.teiid.client.plan.Annotation)3 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)3 Command (org.teiid.query.sql.lang.Command)3 CommandContext (org.teiid.query.util.CommandContext)3 BufferManager (org.teiid.common.buffer.BufferManager)2 CachedResults (org.teiid.dqp.internal.process.CachedResults)2 SessionAwareCache (org.teiid.dqp.internal.process.SessionAwareCache)2 TempMetadataAdapter (org.teiid.query.metadata.TempMetadataAdapter)2 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)2 GlobalTableStore (org.teiid.query.tempdata.GlobalTableStore)2 TempTableDataManager (org.teiid.query.tempdata.TempTableDataManager)2 TempTableStore (org.teiid.query.tempdata.TempTableStore)2 TreeMap (java.util.TreeMap)1 Before (org.junit.Before)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)1 BlockedException (org.teiid.common.buffer.BlockedException)1