Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Enhancements to DHT - speed up deletion of containers when selscted from whole index - correctly eliminate all references to unavailable URLs, not just the first encountered
hermens9324b5b6c54f
diff --git a/source/de/anomic/yacy/dht/Dispatcher.java b/source/de/anomic/yacy/dht/Dispatcher.javaindex a6982873b..80be6e5da 100755--- a/source/de/anomic/yacy/dht/Dispatcher.java+++ b/source/de/anomic/yacy/dht/Dispatcher.java@@ -191,20 +191,34 @@ public class Dispatcher {containers.add(container);}// then remove the container from the backend- HashSet<String> urlHashes = new HashSet<String>();- Iterator<WordReference> it;- for (ReferenceContainer<WordReference> c: containers) {- urlHashes.clear();- it = c.entries();- while (it.hasNext()) {- urlHashes.add(it.next().metadataHash());+ final ArrayList<ReferenceContainer<WordReference>> rc;+ if (ram) {+ // selection was only from ram, so we have to carefully remove only the selected entries+ HashSet<String> urlHashes = new HashSet<String>();+ Iterator<WordReference> it;+ for (ReferenceContainer<WordReference> c: containers) {+ urlHashes.clear();+ it = c.entries();+ while (it.hasNext()) {+ urlHashes.add(it.next().metadataHash());+ }+ if (this.log.isFine()) this.log.logFine("selected " + urlHashes.size() + " urls for word '" + c.getTermHashAsString() + "'");+ if (urlHashes.size() > 0) this.backend.remove(c.getTermHash(), urlHashes);+ }+ rc = containers;+ } else {+ // selection was from whole index, so we can just delete the whole container+ // but to avoid race conditions return the results from the deletes+ rc = new ArrayList<ReferenceContainer<WordReference>>(containers.size());+ for (ReferenceContainer<WordReference> c: containers) {+ container = this.backend.delete(c.getTermHash());+ if (this.log.isFine()) this.log.logFine("selected " + container.size() + " urls for word '" + c.getTermHashAsString() + "'");+ if (container.size() != 0) rc.add(container);}- if (this.log.isFine()) this.log.logFine("selected " + urlHashes.size() + " urls for word '" + c.getTermHashAsString() + "'");- if (urlHashes.size() > 0) this.backend.remove(c.getTermHash(), urlHashes);}// finished. The caller must take care of the containers and must put them back if not needed- return containers;+ return rc;}/**diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.javaindex 629edd04d..e45041799 100644--- a/source/de/anomic/yacy/dht/Transmission.java+++ b/source/de/anomic/yacy/dht/Transmission.java@@ -126,7 +126,11 @@ public class Transmission {ArrayList<String> notFound = new ArrayList<String>();while (i.hasNext()) {WordReference e = i.next();- if (references.containsKey(e.metadataHash()) || badReferences.contains(e.metadataHash())) continue;+ if (references.containsKey(e.metadataHash())) continue;+ if (badReferences.contains(e.metadataHash())) {+ notFound.add(e.metadataHash());+ continue;+ }URLMetadataRow r = repository.load(e.metadataHash(), null, 0);if (r == null) {notFound.add(e.metadataHash());