private void loadViaRefresh(final CommandContext context, final String tableName, VDBMetaData vdb, MatTableInfo info) throws TeiidProcessingException, TeiidComponentException { info.setAsynchLoad(); DQPWorkContext workContext = createWorkContext(context, vdb); final String viewName = tableName.substring(RelationalPlanner.MAT_PREFIX.length()); workContext.runInContext(new Runnable() { @Override public void run() { executor.execute(REFRESH_SQL, Arrays.asList(viewName, Boolean.FALSE)); } }); }
public TupleSource registerRequest( CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException, TeiidProcessingException { if (parameterObject.info != null) { TupleSourceCache tsc = context.getTupleSourceCache(); if (tsc != null) { return tsc.getSharedTupleSource(context, command, modelName, parameterObject, bufferManager, this); } } TempTableStore tempTableStore = context.getTempTableStore(); if(tempTableStore != null) { try { TupleSource result = registerRequest(context, modelName, command); if (result != null) { return result; } } catch (BlockedException e) { throw new AssertionError("blocked is not expected"); //$NON-NLS-1$ } } return this.processorDataManager.registerRequest(context, command, modelName, parameterObject); }
final QueryMetadataInterface metadata = context.getMetadata(); if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEW)) { Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); String matViewName = metadata.getFullName(groupID); String matTableName = metadata.getFullName(matTableId); return loadGlobalTable(context, matTable, matTableName, globalStore); } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROWS)) { final Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); Object pk = metadata.getPrimaryKey(groupID); String matViewName = metadata.getFullName(groupID); return updateMatviewRows(context, metadata, groupID, globalStore, matViewName, ids, params); } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROW)) { final Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); Object pk = metadata.getPrimaryKey(groupID); final String matViewName = metadata.getFullName(groupID); return updateMatviewRows(context, metadata, groupID, globalStore, matViewName, ids, params);
dataTierMgr = new TempTableDataManager(processorDataManager, this.bufferManager, this.rsCache); dataTierMgr.setExecutor(new TempTableDataManager.RequestExecutor() { dataTierMgr.setEventDistributor(eventDistributor); LogManager.logDetail(LogConstants.CTX_DQP, "DQPCore started maxThreads", this.config.getMaxThreads(), "maxActivePlans", this.maxActivePlans, "source concurrency", this.userRequestSourceConcurrency); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return null; return registerQuery(context, contextStore, query); StoredProcedure proc = (StoredProcedure)command; if (CoreConstants.SYSTEM_ADMIN_MODEL.equals(modelName)) { TupleSource result = handleSystemProcedures(context, proc); if (result != null) { return result; return handleCachedProcedure(context, proc);
@Before public void setUp() { tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$ 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); }
private DQPWorkContext createWorkContext(final CommandContext context, VDBMetaData vdb) { SessionMetadata session = createTemporarySession(context.getUserName(), "asynch-mat-view-load", vdb); //$NON-NLS-1$ session.setSubject(context.getSubject()); session.setSecurityDomain(context.getSession().getSecurityDomain()); session.setSecurityContext(context.getSession().getSecurityContext()); DQPWorkContext workContext = new DQPWorkContext(); workContext.setAdmin(true); DQPWorkContext current = context.getDQPWorkContext(); workContext.setSession(session); workContext.setPolicies(current.getAllowedDataPolicies()); workContext.setSecurityHelper(current.getSecurityHelper()); return workContext; }
query.setCriteria(new CompareCriteria(keyElement, CompareCriteria.EQ, new Constant(keyValue))); ts = registerQuery(context, context.getTempTableStore(), query);
if (group.isGlobalTable()) { TempMetadataID matTableId = (TempMetadataID)group.getMetadataID(); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); final MatTableInfo info = globalStore.getMatTableInfo(tableName); return new ProxyTupleSource() {
final QueryMetadataInterface metadata = context.getMetadata(); if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEW)) { Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); String matViewName = metadata.getFullName(groupID); String matTableName = metadata.getFullName(matTableId); return loadGlobalTable(context, matTable, matTableName, globalStore); } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROWS)) { final Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); Object pk = metadata.getPrimaryKey(groupID); String matViewName = metadata.getFullName(groupID); return updateMatviewRows(context, metadata, groupID, globalStore, matViewName, ids, params); } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROW)) { final Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); Object pk = metadata.getPrimaryKey(groupID); final String matViewName = metadata.getFullName(groupID); return updateMatviewRows(context, metadata, groupID, globalStore, matViewName, ids, params);
dataTierMgr = new TempTableDataManager(processorDataManager, this.bufferManager, this.rsCache); dataTierMgr.setExecutor(new TempTableDataManager.RequestExecutor() { dataTierMgr.setEventDistributor(eventDistributor); LogManager.logDetail(LogConstants.CTX_DQP, "DQPCore started maxThreads", this.config.getMaxThreads(), "maxActivePlans", this.maxActivePlans, "source concurrency", this.userRequestSourceConcurrency); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return null; return registerQuery(context, contextStore, query); StoredProcedure proc = (StoredProcedure)command; if (CoreConstants.SYSTEM_ADMIN_MODEL.equals(modelName)) { TupleSource result = handleSystemProcedures(context, proc); if (result != null) { return result; return handleCachedProcedure(context, proc);
public void setUp(QueryMetadataInterface qmi, ProcessorDataManager dm, BufferManager bm) { tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$ metadata = new TempMetadataAdapter(qmi, tempStore.getMetadataStore()); metadata.setSession(true); SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); cache.setTupleBufferCache(bm); dataManager = new TempTableDataManager(dm, bm, cache); }
private DQPWorkContext createWorkContext(final CommandContext context, VDBMetaData vdb) { SessionMetadata session = createTemporarySession(context.getUserName(), "asynch-mat-view-load", vdb); //$NON-NLS-1$ session.setSubject(context.getSubject()); session.setSecurityDomain(context.getSession().getSecurityDomain()); session.setSecurityContext(context.getSession().getSecurityContext()); DQPWorkContext workContext = new DQPWorkContext(); workContext.setAdmin(true); DQPWorkContext current = context.getDQPWorkContext(); workContext.setSession(session); workContext.setPolicies(current.getAllowedDataPolicies()); workContext.setSecurityHelper(current.getSecurityHelper()); return workContext; }
query.setCriteria(new CompareCriteria(keyElement, CompareCriteria.EQ, new Constant(keyValue))); ts = registerQuery(context, context.getTempTableStore(), query);
if (group.isGlobalTable()) { TempMetadataID matTableId = (TempMetadataID)group.getMetadataID(); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); final MatTableInfo info = globalStore.getMatTableInfo(tableName); return new ProxyTupleSource() {
final QueryMetadataInterface metadata = context.getMetadata(); if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEW)) { Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); String matViewName = metadata.getFullName(groupID); String matTableName = metadata.getFullName(matTableId); return loadGlobalTable(context, matTable, matTableName, globalStore); } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROWS)) { final Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); Object pk = metadata.getPrimaryKey(groupID); String matViewName = metadata.getFullName(groupID); return updateMatviewRows(context, metadata, groupID, globalStore, matViewName, ids, params); } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROW)) { final Object groupID = validateMatView(metadata, (String)((Constant)proc.getParameter(2).getExpression()).getValue()); TempMetadataID matTableId = context.getGlobalTableStore().getGlobalTempTableMetadataId(groupID); final GlobalTableStore globalStore = getGlobalStore(context, matTableId); Object pk = metadata.getPrimaryKey(groupID); final String matViewName = metadata.getFullName(groupID); return updateMatviewRows(context, metadata, groupID, globalStore, matViewName, ids, params);
dataTierMgr = new TempTableDataManager(processorDataManager, this.bufferManager, this.rsCache); dataTierMgr.setExecutor(new TempTableDataManager.RequestExecutor() { dataTierMgr.setEventDistributor(eventDistributor); LogManager.logDetail(LogConstants.CTX_DQP, "DQPCore started maxThreads", this.config.getMaxThreads(), "maxActivePlans", this.maxActivePlans, "source concurrency", this.userRequestSourceConcurrency); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return null; return registerQuery(context, contextStore, query); StoredProcedure proc = (StoredProcedure)command; if (CoreConstants.SYSTEM_ADMIN_MODEL.equals(modelName)) { TupleSource result = handleSystemProcedures(context, proc); if (result != null) { return result; return handleCachedProcedure(context, proc);
@Test public void testInherentUpdateUsingTemp() throws Exception { TransformationMetadata metadata = RealMetadataFactory.fromDDL( "create foreign table g1 (e1 string primary key, e2 integer, e3 boolean, e4 double, FOREIGN KEY (e1) REFERENCES G2 (e1)) options (updatable true);" + " create foreign table g2 (e1 string primary key, e2 integer, e3 boolean, e4 double) options (updatable true);" + " create view v options (updatable true) as select g2.e1, g1.e2 from g1 inner join g2 on g1.e1 = g2.e1;" , "x", "pm1"); HardcodedDataManager hdm = new HardcodedDataManager(metadata); setUp(metadata, hdm); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); cache.setTupleBufferCache(bm); dataManager = new TempTableDataManager(hdm, bm, cache); execute("create temporary table x (e1 string, e2 integer, e3 string, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$ execute("insert into x values ('a', 1, 'b')", new List[] {Arrays.asList(1)}); TempMetadataID id = this.tempStore.getMetadataStore().getData().get("x"); //ensure that we're using the actual metadata assertNotNull(id); assertNotNull(this.metadata.getPrimaryKey(id)); hdm.addData("SELECT g_0.e1 FROM g1 AS g_0 WHERE g_0.e2 = 1", new List[] {Arrays.asList("a")}); hdm.addData("DELETE FROM g1 WHERE g1.e1 = 'a'", new List[] {Arrays.asList(1)}); execute("delete from v where e2 = (select max(e2) from x as z where e3 = z.e3)", new List[] {Arrays.asList(1)}, TestOptimizer.getGenericFinder()); //$NON-NLS-1$ }