public double getCacheHitRatio() { return this.getRequestCount() == 0?0:((double)this.getCacheHitCount()/this.getRequestCount())*100; }
public double getCacheHitRatio() { return this.getRequestCount() == 0?0:((double)this.getCacheHitCount()/this.getRequestCount())*100; }
public CacheStatisticsMetadata buildCacheStats(String name) { CacheStatisticsMetadata stats = new CacheStatisticsMetadata(); stats.setName(name); stats.setHitRatio(this.getRequestCount() == 0?0:((double)this.getCacheHitCount()/this.getRequestCount())*100); stats.setTotalEntries(this.getTotalCacheEntries()); stats.setRequestCount(this.getRequestCount()); return stats; } }
@Test public void testPreparedPlanInvalidation() throws Exception { helpTestPlanInvalidation("select * from #temp a, #temp b limit 10"); assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount()); }
@Test public void testPreparedPlanSimpleNoInvalidation() throws Exception { helpTestPlanInvalidation("select * from #temp"); assertEquals(3, this.core.getPrepPlanCache().getCacheHitCount()); }
assertEquals("TEIID30558 Error converting parameter number 1 with value \"x\" of class java.lang.String to expected type integer.", qe.getMessage()); //$NON-NLS-1$ assertEquals(0, prepCache.getCacheHitCount()); assertEquals(1, prepCache.getCacheHitCount());
exHitCount = prepPlanCache.getCacheHitCount() + 2; } else { exHitCount = prepPlanCache.getCacheHitCount() + 1; assertEquals("should reuse the plan", exHitCount, prepPlanCache.getCacheHitCount()); //$NON-NLS-1$ assertEquals(exHitCount, prepPlanCache.getCacheHitCount());
ResultsMessage rm = execute(userName, sessionid, reqMsg); assertEquals(10, rm.getResultsList().size()); //$NON-NLS-1$ assertEquals(0, this.core.getRsCache().getCacheHitCount()); assertEquals(10, rm.getResultsList().size()); //$NON-NLS-1$ assertEquals(1, this.core.getRsCache().getCacheHitCount()); assertEquals(10, rm.getResultsList().size()); //$NON-NLS-1$ assertEquals(1, this.core.getRsCache().getCacheHitCount());
@Test public void testLimit() throws Exception { // Create query String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$ List<?> values = Arrays.asList("0"); //$NON-NLS-1$ SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0); //$NON-NLS-1$ helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, RealMetadataFactory.example1VDB()); helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, RealMetadataFactory.example1VDB()); //make sure the plan wasn't reused assertEquals(1, planCache.getCacheHitCount()); }
/** * help process a physical callable statement */ private void helpProcess(String sql, List values, List[] expected, HardcodedDataManager dataManager) throws TeiidComponentException, TeiidProcessingException, Exception { SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0); //$NON-NLS-1$ PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(sql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.exampleBQTCached(), planCache, 1, true, false, RealMetadataFactory.exampleBQTVDB()); TestProcessor.doProcess(plan.processPlan, dataManager, expected, plan.context); TestPreparedStatement.helpGetProcessorPlan(sql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.exampleBQTCached(), planCache, 1, true, false, RealMetadataFactory.exampleBQTVDB()); assertEquals(0, planCache.getCacheHitCount()); }
assertEquals(10, rm.getResultsList().size()); //$NON-NLS-1$ assertEquals(1, this.core.getPrepPlanCache().getCacheHitCount()); assertEquals(10, rm.getResultsList().size()); //$NON-NLS-1$ assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());