- fix for termination problem with uniq()

- addition to seed dna interpretation

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4208 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 0abf33ed03
commit 64b3b79e44

@ -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();
}
}

@ -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, ""); }

Loading…
Cancel
Save