@Test public void testFetchRowBatch1() throws BlurException, TException { _thriftCache.clear(); assertEquals(0, _thriftCache.getMisses()); assertEquals(0, _thriftCache.getHits()); Selector selector1 = new Selector(); selector1.setLocationId("1"); List<FetchResult> fetchRowBatch1 = _thriftCacheServer.fetchRowBatch(_table, Arrays.asList(selector1)); assertEquals(1, _thriftCache.getMisses()); assertEquals(0, _thriftCache.getHits()); Selector selector2 = new Selector(); selector2.setLocationId("1"); List<FetchResult> fetchRowBatch2 = _thriftCacheServer.fetchRowBatch(_table, Arrays.asList(selector2)); assertEquals(1, _thriftCache.getMisses()); assertEquals(1, _thriftCache.getHits()); assertFalse(fetchRowBatch1 == fetchRowBatch2); assertEquals(fetchRowBatch1, fetchRowBatch2); }
@Override public List<FetchResult> fetchRowBatch(String table, List<Selector> selectors) throws BlurException, TException { Map<Integer, FetchResult> resultMap = new TreeMap<Integer, FetchResult>(); Map<Integer, Integer> requestMapping = new HashMap<Integer, Integer>(); List<Selector> selectorRequest = new ArrayList<Selector>(); for (int i = 0; i < selectors.size(); i++) { Selector selector = selectors.get(i); Selector copy = new Selector(selector); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), copy, Selector.class); FetchResult fetchResult = _thriftCache.get(key, FetchResult.class); if (fetchResult != null) { resultMap.put(i, fetchResult); } else { int index = selectorRequest.size(); requestMapping.put(index, i); selectorRequest.add(selector); } } if (selectorRequest.size() != 0) { List<FetchResult> missingResults = super.fetchRowBatch(table, selectorRequest); for (int i = 0; i < missingResults.size(); i++) { Selector selector = selectorRequest.get(i); FetchResult fetchResult = missingResults.get(i); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), new Selector(selector), Selector.class); _thriftCache.put(key, fetchResult); int originalIndex = requestMapping.get(i); resultMap.put(originalIndex, fetchResult); } } return toList(resultMap); }
ThriftCacheServer extends FilteredBlurServer { @Override public List<FetchResult> fetchRowBatch(String table, List<Selector> selectors) throws BlurException, TException { Map<Integer, FetchResult> resultMap = new TreeMap<Integer, FetchResult>(); Map<Integer, Integer> requestMapping = new HashMap<Integer, Integer>(); List<Selector> selectorRequest = new ArrayList<Selector>(); for (int i = 0; i < selectors.size(); i++) { Selector selector = selectors.get(i); Selector copy = new Selector(selector); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), copy, Selector.class); FetchResult fetchResult = _thriftCache.get(key, FetchResult.class); if (fetchResult != null) { resultMap.put(i, fetchResult); } else { int index = selectorRequest.size(); requestMapping.put(index, i); selectorRequest.add(selector); } } if (selectorRequest.size() != 0) { List<FetchResult> missingResults = super.fetchRowBatch(table, selectorRequest); for (int i = 0; i < missingResults.size(); i++) { Selector selector = selectorRequest.get(i); FetchResult fetchResult = missingResults.get(i); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), new Selector(selector), Selector.class); _thriftCache.put(key, fetchResult); int originalIndex = requestMapping.get(i); resultMap.put(originalIndex, fetchResult); } } return toList(resultMap); } }
ThriftCacheServer extends FilteredBlurServer { @Override public List<FetchResult> fetchRowBatch(String table, List<Selector> selectors) throws BlurException, TException { Map<Integer, FetchResult> resultMap = new TreeMap<Integer, FetchResult>(); Map<Integer, Integer> requestMapping = new HashMap<Integer, Integer>(); List<Selector> selectorRequest = new ArrayList<Selector>(); for (int i = 0; i < selectors.size(); i++) { Selector selector = selectors.get(i); Selector copy = new Selector(selector); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), copy, Selector.class); FetchResult fetchResult = _thriftCache.get(key, FetchResult.class); if (fetchResult != null) { resultMap.put(i, fetchResult); } else { int index = selectorRequest.size(); requestMapping.put(index, i); selectorRequest.add(selector); } } if (selectorRequest.size() != 0) { List<FetchResult> missingResults = super.fetchRowBatch(table, selectorRequest); for (int i = 0; i < missingResults.size(); i++) { Selector selector = selectorRequest.get(i); FetchResult fetchResult = missingResults.get(i); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), new Selector(selector), Selector.class); _thriftCache.put(key, fetchResult); int originalIndex = requestMapping.get(i); resultMap.put(originalIndex, fetchResult); } } return toList(resultMap); } ThriftCacheServer(BlurConfiguration configuration, Iface iface, IndexServer indexServer,
      ThriftCache thriftCache); }
ThriftCacheServer extends FilteredBlurServer { @Override public List<FetchResult> fetchRowBatch(String table, List<Selector> selectors) throws BlurException, TException { Map<Integer, FetchResult> resultMap = new TreeMap<Integer, FetchResult>(); Map<Integer, Integer> requestMapping = new HashMap<Integer, Integer>(); List<Selector> selectorRequest = new ArrayList<Selector>(); for (int i = 0; i < selectors.size(); i++) { Selector selector = selectors.get(i); Selector copy = new Selector(selector); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), copy, Selector.class); FetchResult fetchResult = _thriftCache.get(key, FetchResult.class); if (fetchResult != null) { resultMap.put(i, fetchResult); } else { int index = selectorRequest.size(); requestMapping.put(index, i); selectorRequest.add(selector); } } if (selectorRequest.size() != 0) { List<FetchResult> missingResults = super.fetchRowBatch(table, selectorRequest); for (int i = 0; i < missingResults.size(); i++) { Selector selector = selectorRequest.get(i); FetchResult fetchResult = missingResults.get(i); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), new Selector(selector), Selector.class); _thriftCache.put(key, fetchResult); int originalIndex = requestMapping.get(i); resultMap.put(originalIndex, fetchResult); } } return toList(resultMap); } 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 List<FetchResult> fetchRowBatch(String table, List<Selector> selectors) throws BlurException, TException { Map<Integer, FetchResult> resultMap = new TreeMap<Integer, FetchResult>(); Map<Integer, Integer> requestMapping = new HashMap<Integer, Integer>(); List<Selector> selectorRequest = new ArrayList<Selector>(); for (int i = 0; i < selectors.size(); i++) { Selector selector = selectors.get(i); Selector copy = new Selector(selector); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), copy, Selector.class); FetchResult fetchResult = _thriftCache.get(key, FetchResult.class); if (fetchResult != null) { resultMap.put(i, fetchResult); } else { int index = selectorRequest.size(); requestMapping.put(index, i); selectorRequest.add(selector); } } if (selectorRequest.size() != 0) { List<FetchResult> missingResults = super.fetchRowBatch(table, selectorRequest); for (int i = 0; i < missingResults.size(); i++) { Selector selector = selectorRequest.get(i); FetchResult fetchResult = missingResults.get(i); ThriftCacheKey<Selector> key = _thriftCache.getKey(table, getShards(table), new Selector(selector), Selector.class); _thriftCache.put(key, fetchResult); int originalIndex = requestMapping.get(i); resultMap.put(originalIndex, fetchResult); } } return toList(resultMap); } 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);  }