@Test public void testQuery() throws IOException, BlurException, TException { _thriftCache.clear(); assertEquals(0, _thriftCache.getMisses()); assertEquals(0, _thriftCache.getHits()); BlurQuery blurQuery1 = new BlurQuery(); blurQuery1.setUserContext("user1"); BlurResults blurResults1 = _thriftCacheServer.query(_table, blurQuery1); assertEquals(1, _thriftCache.getMisses()); assertEquals(0, _thriftCache.getHits()); BlurQuery blurQuery2 = new BlurQuery(); blurQuery1.setUserContext("user2"); BlurResults blurResults2 = _thriftCacheServer.query(_table, blurQuery2); assertEquals(1, _thriftCache.getMisses()); assertEquals(1, _thriftCache.getHits()); assertFalse(blurResults1 == blurResults2); assertEquals(blurResults1, blurResults2); }
@Override public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException { boolean useCacheIfPresent = blurQuery.isUseCacheIfPresent(); boolean cacheResult = blurQuery.isCacheResult(); BlurQuery copy = new BlurQuery(blurQuery); copy.useCacheIfPresent = false; copy.maxQueryTime = 0; copy.uuid = null; copy.userContext = null; copy.cacheResult = false; copy.startTime = 0; ThriftCacheKey<BlurQuery> key = _thriftCache.getKey(table, getShards(table), copy, BlurQuery.class); Lock lock = getOrCreateLock(key); try { lock.lock(); if (useCacheIfPresent) { BlurResults results = _thriftCache.get(key, BlurResults.class); if (results != null) { return results; } } BlurResults blurResults = super.query(table, blurQuery); if (cacheResult) { return _thriftCache.put(key, blurResults); } return blurResults; } finally { lock.unlock(); } }
ThriftCacheServer extends FilteredBlurServer { @Override public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException { boolean useCacheIfPresent = blurQuery.isUseCacheIfPresent(); boolean cacheResult = blurQuery.isCacheResult(); BlurQuery copy = new BlurQuery(blurQuery); copy.useCacheIfPresent = false; copy.maxQueryTime = 0; copy.uuid = null; copy.userContext = null; copy.cacheResult = false; copy.startTime = 0; ThriftCacheKey<BlurQuery> key = _thriftCache.getKey(table, getShards(table), copy, BlurQuery.class); Lock lock = getOrCreateLock(key); try { lock.lock(); if (useCacheIfPresent) { BlurResults results = _thriftCache.get(key, BlurResults.class); if (results != null) { return results; } } BlurResults blurResults = super.query(table, blurQuery); if (cacheResult) { return _thriftCache.put(key, blurResults); } return blurResults; } finally { lock.unlock(); } } }
ThriftCacheServer extends FilteredBlurServer { @Override public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException { boolean useCacheIfPresent = blurQuery.isUseCacheIfPresent(); boolean cacheResult = blurQuery.isCacheResult(); BlurQuery copy = new BlurQuery(blurQuery); copy.useCacheIfPresent = false; copy.maxQueryTime = 0; copy.uuid = null; copy.userContext = null; copy.cacheResult = false; copy.startTime = 0; ThriftCacheKey<BlurQuery> key = _thriftCache.getKey(table, getShards(table), copy, BlurQuery.class); Lock lock = getOrCreateLock(key); try { lock.lock(); if (useCacheIfPresent) { BlurResults results = _thriftCache.get(key, BlurResults.class); if (results != null) { return results; } } BlurResults blurResults = super.query(table, blurQuery); if (cacheResult) { return _thriftCache.put(key, blurResults); } return blurResults; } finally { lock.unlock(); } } ThriftCacheServer(BlurConfiguration configuration, Iface iface, IndexServer indexServer,
      ThriftCache thriftCache); }
ThriftCacheServer extends FilteredBlurServer { @Override public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException { boolean useCacheIfPresent = blurQuery.isUseCacheIfPresent(); boolean cacheResult = blurQuery.isCacheResult(); BlurQuery copy = new BlurQuery(blurQuery); copy.useCacheIfPresent = false; copy.maxQueryTime = 0; copy.uuid = null; copy.userContext = null; copy.cacheResult = false; copy.startTime = 0; ThriftCacheKey<BlurQuery> key = _thriftCache.getKey(table, getShards(table), copy, BlurQuery.class); Lock lock = getOrCreateLock(key); try { lock.lock(); if (useCacheIfPresent) { BlurResults results = _thriftCache.get(key, BlurResults.class); if (results != null) { return results; } } BlurResults blurResults = super.query(table, blurQuery); if (cacheResult) { return _thriftCache.put(key, blurResults); } return blurResults; } finally { lock.unlock(); } } ThriftCacheServer(BlurConfiguration configuration, Iface iface, IndexServer indexServer,
      ThriftCache thriftCache); @Override void loadIndex(String table, List<String> externalIndexPaths); @Override TableStats tableStats(String table); @Override BlurResults query(String table, BlurQuery blurQuery); @Override FetchResult fetchRow(String table, Selector selector); @Override List<FetchResult> fetchRowBatch(String table, List<Selector> selectors); }
ThriftCacheServer extends FilteredBlurServer { @Override public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException { boolean useCacheIfPresent = blurQuery.isUseCacheIfPresent(); boolean cacheResult = blurQuery.isCacheResult(); BlurQuery copy = new BlurQuery(blurQuery); copy.useCacheIfPresent = false; copy.maxQueryTime = 0; copy.uuid = null; copy.userContext = null; copy.cacheResult = false; copy.startTime = 0; ThriftCacheKey<BlurQuery> key = _thriftCache.getKey(table, getShards(table), copy, BlurQuery.class); Lock lock = getOrCreateLock(key); try { lock.lock(); if (useCacheIfPresent) { BlurResults results = _thriftCache.get(key, BlurResults.class); if (results != null) { return results; } } BlurResults blurResults = super.query(table, blurQuery); if (cacheResult) { return _thriftCache.put(key, blurResults); } return blurResults; } finally { lock.unlock(); } } ThriftCacheServer(BlurConfiguration configuration, Iface iface, IndexServer indexServer,
      ThriftCache thriftCache); @Override void loadIndex(String table, List<String> externalIndexPaths); @Override TableStats tableStats(String table); @Override BlurResults query(String table, BlurQuery blurQuery); @Override FetchResult fetchRow(String table, Selector selector); @Override List<FetchResult> fetchRowBatch(String table, List<Selector> selectors);  }