/* (non-Javadoc) * @see net.tomp2p.dht.DigestStorage#digest(net.tomp2p.peers.Number320, net.tomp2p.rpc.SimpleBloomFilter, net.tomp2p.rpc.SimpleBloomFilter, int, boolean, boolean) */ @Override public DigestInfo digest( Number320 locationAndDomainKey, SimpleBloomFilter<Number160> keyBloomFilter, SimpleBloomFilter<Number160> contentKeyBloomFilter, int limit, boolean ascending, boolean isBloomFilterAnd) { DigestInfo digestInfo = new DigestInfo(); RangeLock<Number640>.Range lock = lock(locationAndDomainKey); try { Number640 from = new Number640(locationAndDomainKey, Number160.ZERO, Number160.ZERO); Number640 to = new Number640(locationAndDomainKey, Number160.MAX_VALUE, Number160.MAX_VALUE); NavigableMap<Number640, Data> tmp = backend.subMap(from, to); tmp = filterCopyOrig(tmp, limit, ascending); for (Map.Entry<Number640, Data> entry : tmp.entrySet()) { if (isBloomFilterAnd) { if (keyBloomFilter == null || keyBloomFilter.contains(entry.getKey().contentKey())) { if (contentKeyBloomFilter == null || contentKeyBloomFilter.contains(entry.getValue().hash())) { if (!entry.getValue().hasPrepareFlag()) { digestInfo.put(entry.getKey(), entry.getValue().basedOnSet()); } } } } else { if (keyBloomFilter == null || !keyBloomFilter.contains(entry.getKey().contentKey())) { if (contentKeyBloomFilter == null || !contentKeyBloomFilter.contains(entry.getValue().hash())) { if (!entry.getValue().hasPrepareFlag()) { digestInfo.put(entry.getKey(), entry.getValue().basedOnSet()); } } } } } return digestInfo; } finally { lock.unlock(); } }
public NavigableMap<Number640, Data> get( Number640 from, Number640 to, SimpleBloomFilter<Number160> contentKeyBloomFilter, SimpleBloomFilter<Number160> versionKeyBloomFilter, SimpleBloomFilter<Number160> contentBloomFilter, int limit, boolean ascending, boolean isBloomFilterAnd) { RangeLock<Number640>.Range lock = rangeLock.lock(from, to); try { NavigableMap<Number640, Data> tmp = backend.subMap(from, to); tmp = filterCopy(tmp, limit, ascending); Iterator<Map.Entry<Number640, Data>> iterator = tmp.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<Number640, Data> entry = iterator.next(); if (isBloomFilterAnd) { if (!contentKeyBloomFilter.contains(entry.getKey().contentKey())) { entry.getValue().release(); iterator.remove(); continue; } if (!versionKeyBloomFilter.contains(entry.getKey().versionKey())) { entry.getValue().release(); iterator.remove(); continue; } if (!contentBloomFilter.contains(entry.getValue().hash())) { entry.getValue().release(); iterator.remove(); continue; } } else { if (contentKeyBloomFilter.contains(entry.getKey().contentKey())) { entry.getValue().release(); iterator.remove(); continue; } if (versionKeyBloomFilter.contains(entry.getKey().versionKey())) { entry.getValue().release(); iterator.remove(); continue; } if (contentBloomFilter.contains(entry.getValue().hash())) { entry.getValue().release(); iterator.remove(); continue; } } } return tmp; } finally { lock.unlock(); } }