public void putPlan(String key, PreparedPlan plan, Determinism determinismLevel) { if (this.globalState.planCache == null) { return; } CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(), getConnectionId(), getUserName()); this.globalState.planCache.put(id, determinismLevel, plan, null); }
public void putPlan(String key, PreparedPlan plan, Determinism determinismLevel) { if (this.globalState.planCache == null) { return; } CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(), getConnectionId(), getUserName()); this.globalState.planCache.put(id, determinismLevel, plan, null); }
public void putPlan(String key, PreparedPlan plan, Determinism determinismLevel) { if (this.globalState.planCache == null) { return; } CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(), getConnectionId(), getUserName()); this.globalState.planCache.put(id, determinismLevel, plan, null); }
@Test public void testSessionSpecfic() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); cache.put(id, Determinism.SESSION_DETERMINISTIC, result, null); // make sure that in the case of session specific; we do not call prepare // as session is local only call for distributed Mockito.verify(result, times(0)).prepare((BufferManager)anyObject()); Object c = cache.get(id); Mockito.verify(result, times(0)).restore((BufferManager)anyObject()); assertTrue(result==c); }
@Override protected TupleSource createTupleSource() throws TeiidComponentException, TeiidProcessingException { TupleBuffer tb = bc.collectTuples(); CachedResults cr = new CachedResults(); cr.setResults(tb, qp.getProcessorPlan()); Determinism determinismLevel = qp.getContext().getDeterminismLevel(); if (hint != null && hint.getDeterminism() != null) { LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hint.getDeterminism() }); //$NON-NLS-1$ //$NON-NLS-2$ determinismLevel = hint.getDeterminism(); } cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null); context.setDeterminismLevel(determinismLevel); success = true; return tb.createIndexedTupleSource(); }
this.dataTierManagerImpl.requestMgr.getRsCache().put(cid, determinismLevel, cr, cd.getTtl()); tb = null;
@Override protected TupleSource createTupleSource() throws TeiidComponentException, TeiidProcessingException { TupleBuffer tb = bc.collectTuples(); CachedResults cr = new CachedResults(); cr.setResults(tb, qp.getProcessorPlan()); Determinism determinismLevel = qp.getContext().getDeterminismLevel(); if (hint != null && hint.getDeterminism() != null) { LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hint.getDeterminism() }); //$NON-NLS-1$ //$NON-NLS-2$ determinismLevel = hint.getDeterminism(); } cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null); context.setDeterminismLevel(determinismLevel); success = true; return tb.createIndexedTupleSource(); }
@Override protected TupleSource createTupleSource() throws TeiidComponentException, TeiidProcessingException { TupleBuffer tb = bc.collectTuples(); CachedResults cr = new CachedResults(); cr.setResults(tb, qp.getProcessorPlan()); Determinism determinismLevel = qp.getContext().getDeterminismLevel(); if (hint != null && hint.getDeterminism() != null) { LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hint.getDeterminism() }); //$NON-NLS-1$ //$NON-NLS-2$ determinismLevel = hint.getDeterminism(); } cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null); context.setDeterminismLevel(determinismLevel); success = true; return tb.createIndexedTupleSource(); }
this.dataTierManagerImpl.requestMgr.getRsCache().put(cid, determinismLevel, cr, cd.getTtl()); tb = null;
this.dataTierManagerImpl.requestMgr.getRsCache().put(cid, determinismLevel, cr, cd.getTtl()); tb = null;
@Test public void testPutPreparedPlan(){ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0); CacheID id = new CacheID(token, pi, EXAMPLE_QUERY + 1); //No PreparedPlan at the begining assertNull(cache.get(id)); //create one cache.put(id, Determinism.SESSION_DETERMINISTIC, new PreparedPlan(), null); //should have one now assertNotNull("Unable to get prepared plan from cache", cache.get(id)); //$NON-NLS-1$ }
private void helpPutPreparedPlans(SessionAwareCache<PreparedPlan> cache, DQPWorkContext session, int start, int count){ for(int i=0; i<count; i++){ Command dummy; try { dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + (start + i)); } catch (QueryParserException e) { throw new RuntimeException(e); } CacheID id = new CacheID(session, pi, dummy.toString()); PreparedPlan pPlan = new PreparedPlan(); cache.put(id, Determinism.SESSION_DETERMINISTIC, pPlan, null); pPlan.setCommand(dummy); pPlan.setPlan(new RelationalPlan(new ProjectNode(i)), new CommandContext()); AnalysisRecord analysisRecord = new AnalysisRecord(true, false); pPlan.setAnalysisRecord(analysisRecord); ArrayList<Reference> refs = new ArrayList<Reference>(); refs.add(new Reference(1)); pPlan.setReferences(refs); } }
@Test public void testUserSpecfic() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); Mockito.stub(result.prepare((BufferManager)anyObject())).toReturn(true); Mockito.stub(result.restore((BufferManager)anyObject())).toReturn(true); cache.put(id, Determinism.USER_DETERMINISTIC, result, null); // make sure that in the case of session specific; we do not call prepare // as session is local only call for distributed Mockito.verify(result, times(1)).prepare((BufferManager)anyObject()); id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Object c = cache.get(id); Mockito.verify(result, times(1)).restore((BufferManager)anyObject()); assertTrue(result==c); }
@Test public void testNoScope() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); Mockito.stub(result.prepare((BufferManager)anyObject())).toReturn(true); Mockito.stub(result.restore((BufferManager)anyObject())).toReturn(true); cache.put(id, Determinism.VDB_DETERMINISTIC, result, null); // make sure that in the case of session specific; we do not call prepare // as session is local only call for distributed Mockito.verify(result, times(1)).prepare((BufferManager)anyObject()); id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Object c = cache.get(id); Mockito.verify(result, times(1)).restore((BufferManager)anyObject()); assertTrue(result==c); }
@Test public void testClear() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); DQPWorkContext context = buildWorkContext(); CacheID id = new CacheID(context, new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); Mockito.stub(result.prepare((BufferManager)anyObject())).toReturn(true); Mockito.stub(result.restore((BufferManager)anyObject())).toReturn(true); id = new CacheID(context, new ParseInfo(), "SELECT * FROM FOO"); cache.put(id, Determinism.VDB_DETERMINISTIC, result, null); id = new CacheID(context, new ParseInfo(), "SELECT * FROM FOO1"); cache.put(id, Determinism.VDB_DETERMINISTIC, result, null); assertEquals(2, cache.getTotalCacheEntries()); cache.clearForVDB(context.getVdbName(), context.getVdbVersion()); assertEquals(0, cache.getTotalCacheEntries()); }
@Test public void testRemove() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); Mockito.stub(result.prepare((BufferManager)anyObject())).toReturn(true); Mockito.stub(result.restore((BufferManager)anyObject())).toReturn(true); id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); cache.put(id, Determinism.VDB_DETERMINISTIC, result, null); Object c = cache.get(id); assertTrue(result==c); assertTrue(cache.remove(id, Determinism.VDB_DETERMINISTIC) != null); assertNull(cache.get(id)); //session scope cache.put(id, Determinism.SESSION_DETERMINISTIC, result, null); assertTrue(cache.get(id) != null); assertTrue(cache.remove(id, Determinism.SESSION_DETERMINISTIC) != null); assertNull(cache.get(id)); }
@Test public void testVDBRemoval() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); Mockito.stub(result.prepare((BufferManager)anyObject())).toReturn(true); Mockito.stub(result.restore((BufferManager)anyObject())).toReturn(true); id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); cache.put(id, Determinism.VDB_DETERMINISTIC, result, null); Object c = cache.get(id); assertTrue(result==c); cache.clearForVDB("vdb-name", "1"); assertNull(cache.get(id)); }
LogManager.logDetail(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("failed_to_cache")); //$NON-NLS-1$ dqpCore.getRsCache().put(cid, determinismLevel, cr, originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);
LogManager.logDetail(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("failed_to_cache")); //$NON-NLS-1$ dqpCore.getRsCache().put(cid, determinismLevel, cr, originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);
LogManager.logDetail(LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("failed_to_cache")); //$NON-NLS-1$ dqpCore.getRsCache().put(cid, determinismLevel, cr, originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);