private Iterable<T> lookInCache(Iterable<T> objects) { RecentInfoCache infoCache = reader.getRecentInfoCache(); List<T> missing = null; for (T obj : objects) { List<ObjectInfo> info = infoCache.get(obj); if (info != null) { onResult(obj, info); if (progress != null) progress.update(1); } else { if (missing == null) { if (objects instanceof List<?>) missing = new ArrayList<T>(((List<?>) objects).size()); else missing = new ArrayList<T>(); } missing.add(obj); } } if (missing != null) return missing; return Collections.emptyList(); }
private Iterable<T> lookInCache(Iterable<T> objects) { RecentInfoCache infoCache = reader.getRecentInfoCache(); List<T> missing = null; for (T obj : objects) { if (needChunkOnly && obj instanceof RefDataUtil.IdWithChunk) { push(obj, ((RefDataUtil.IdWithChunk) obj).getChunkKey()); continue; } List<ObjectInfo> info = infoCache.get(obj); if (info != null && !info.isEmpty()) { push(obj, info.get(0)); } else { if (missing == null) { if (objects instanceof List<?>) missing = new ArrayList<T>(((List<?>) objects).size()); else missing = new ArrayList<T>(); } missing.add(obj); } } if (missing != null) return missing; return Collections.emptyList(); }
private Iterable<T> lookInCache(Iterable<T> objects) { RecentInfoCache infoCache = reader.getRecentInfoCache(); List<T> missing = null; for (T obj : objects) { if (needChunkOnly && obj instanceof RefDataUtil.IdWithChunk) { push(obj, ((RefDataUtil.IdWithChunk) obj).getChunkKey()); continue; } List<ObjectInfo> info = infoCache.get(obj); if (info != null && !info.isEmpty()) { push(obj, info.get(0)); } else { if (missing == null) { if (objects instanceof List<?>) missing = new ArrayList<T>(((List<?>) objects).size()); else missing = new ArrayList<T>(); } missing.add(obj); } } if (missing != null) return missing; return Collections.emptyList(); }
private Iterable<T> lookInCache(Iterable<T> objects) { RecentInfoCache infoCache = reader.getRecentInfoCache(); List<T> missing = null; for (T obj : objects) { List<ObjectInfo> info = infoCache.get(obj); if (info != null) { onResult(obj, info); if (progress != null) progress.update(1); } else { if (missing == null) { if (objects instanceof List<?>) missing = new ArrayList<T>(((List<?>) objects).size()); else missing = new ArrayList<T>(); } missing.add(obj); } } if (missing != null) return missing; return Collections.emptyList(); }
private List<ObjectInfo> find(AnyObjectId obj) throws DhtException { List<ObjectInfo> info = recentInfo.get(obj); if (info != null) return info; stats.cntObjectIndex_Load++; ObjectIndexKey idxKey = ObjectIndexKey.create(repo, obj); Context opt = Context.READ_REPAIR; Sync<Map<ObjectIndexKey, Collection<ObjectInfo>>> sync = Sync.create(); db.objectIndex().get(opt, Collections.singleton(idxKey), sync); try { Collection<ObjectInfo> m; m = sync.get(getOptions().getTimeout()).get(idxKey); if (m == null || m.isEmpty()) return Collections.emptyList(); info = new ArrayList<ObjectInfo>(m); ObjectInfo.sort(info); recentInfo.put(obj, info); return info; } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }
private List<ObjectInfo> find(AnyObjectId obj) throws DhtException { List<ObjectInfo> info = recentInfo.get(obj); if (info != null) return info; stats.cntObjectIndex_Load++; ObjectIndexKey idxKey = ObjectIndexKey.create(repo, obj); Context opt = Context.READ_REPAIR; Sync<Map<ObjectIndexKey, Collection<ObjectInfo>>> sync = Sync.create(); db.objectIndex().get(opt, Collections.singleton(idxKey), sync); try { Collection<ObjectInfo> m; m = sync.get(getOptions().getTimeout()).get(idxKey); if (m == null || m.isEmpty()) return Collections.emptyList(); info = new ArrayList<ObjectInfo>(m); ObjectInfo.sort(info); recentInfo.put(obj, info); return info; } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }