Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fixed "Too many open files" - bug
orbiterf8f8dd05dba0
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.javaindex 8057d53b3..e6f118f03 100644--- a/source/de/anomic/kelondro/kelondroRecords.java+++ b/source/de/anomic/kelondro/kelondroRecords.java@@ -742,6 +742,12 @@ public class kelondroRecords {this.entryFile = null;}+ public void finalize() {+ try {+ close();+ } catch (IOException e) {}+ }+protected static String[] line2args(String line) {// parse the command lineif ((line == null) || (line.length() == 0)) return null;diff --git a/source/de/anomic/plasma/plasmaSearch.java b/source/de/anomic/plasma/plasmaSearch.javaindex 123f6598a..2ce2928e1 100644--- a/source/de/anomic/plasma/plasmaSearch.java+++ b/source/de/anomic/plasma/plasmaSearch.java@@ -165,14 +165,21 @@ public final class plasmaSearch {// the map now holds the search results in order of number of hits per word// we now must pairwise build up a conjunction of these setsString k = (String) map.firstKey(); // the smallest, which means, the one with the least entries- plasmaWordIndexEntity searchResult = (plasmaWordIndexEntity) map.remove(k);+ plasmaWordIndexEntity searchA, searchB, searchResult = (plasmaWordIndexEntity) map.remove(k);while ((map.size() > 0) && (searchResult.size() > 0) && (time > 0)) {// take the first element of map which is a result and combine it with resultk = (String) map.firstKey(); // the next smallest...time -= (System.currentTimeMillis() - stamp); stamp = System.currentTimeMillis();- searchResult = joinConstructive(searchResult, (plasmaWordIndexEntity) map.remove(k), 2 * time / (map.size() + 1));+ searchA = searchResult;+ searchB = (plasmaWordIndexEntity) map.remove(k);+ searchResult = joinConstructive(searchA, searchB, 2 * time / (map.size() + 1));+ // close the input files/structures+ if (searchA != searchResult) searchA.close();+ if (searchB != searchResult) searchB.close();}-+ searchA = null; // free resources+ searchB = null; // free resources+// in 'searchResult' is now the combined search resultif (searchResult.size() == 0) return new plasmaWordIndexEntity(null);return searchResult;diff --git a/source/de/anomic/plasma/plasmaWordIndexEntity.java b/source/de/anomic/plasma/plasmaWordIndexEntity.javaindex 4c9388e33..0ff1e80a1 100644--- a/source/de/anomic/plasma/plasmaWordIndexEntity.java+++ b/source/de/anomic/plasma/plasmaWordIndexEntity.java@@ -141,11 +141,17 @@ public class plasmaWordIndexEntity {public void close() throws IOException {if (theTmpMap == null) {- theIndex.close();+ if (theIndex != null) theIndex.close();theIndex = null;} else theTmpMap = null;}+ public void finalize() {+ try {+ close();+ } catch (IOException e) {}+ }+public boolean contains(String urlhash) throws IOException {if (theTmpMap == null) return (theIndex.get(urlhash.getBytes()) != null); else return (theTmpMap.containsKey(urlhash));}