Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- fix for termination problem with uniq() - addition to seed dna interpretation
orbiter64b3b79e446e
diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex b468f9f5d..fbec5dd46 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -526,15 +526,28 @@ public class kelondroRowCollection {// this works only if the collection was ordered with sort before// if the collection is large and the number of deletions is also large,// then this method may run a long time with 100% CPU load which is caused- // by the large number of memory movements. Therefore it is possible- // to assign a runtime limitation+ // by the large number of memory movements.if (chunkcount < 2) return;int i = chunkcount - 2;- while (i >= 0) {- if (compare(i, i + 1) == 0) {- removeRow(i, true);+ long t = System.currentTimeMillis(); // for time-out+ int d = 0;+ boolean u = true;+ try {+ while (i >= 0) {+ if (compare(i, i + 1) == 0) {+ removeRow(i, false);+ d++;+ if (i < chunkcount - 2) u = false;+ }+ i--;+ if (System.currentTimeMillis() - t > 10000) {+ throw new RuntimeException("uniq() time-out at " + i + " (backwards) from " + chunkcount + " elements after " + (System.currentTimeMillis() - t) + " milliseconds; " + d + " deletions so far");+ }}- i--;+ } catch (RuntimeException e) {+ serverLog.logWarning("kelondroRowCollection", e.getMessage(), e);+ } finally {+ if (!u) this.sort();}}diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex b25164c08..60168114f 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -333,11 +333,15 @@ public class yacySeed {public final long getLong(String key, long dflt) {final Object o = this.dna.get(key);if (o == null) { return dflt; }- try {+ if (o instanceof String) try {return Long.parseLong((String) o);} catch (NumberFormatException e) {return dflt;- }+ } else if (o instanceof Long) {+ return ((Long) o).longValue();+ } else if (o instanceof Integer) {+ return (long) ((Integer) o).intValue();+ } else return dflt;}public final void setIP() { dna.put(yacySeed.IP, ""); }