fixed new ordering for backup iterator TreeSet

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1899 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 399538b7de
commit 4239db0d1c

@ -47,15 +47,11 @@ package de.anomic.kelondro;
import de.anomic.kelondro.kelondroRecords.Node;
public abstract class kelondroAbstractOrder implements kelondroOrder, Cloneable {
public abstract class kelondroAbstractOrder implements kelondroOrder {
protected byte[] zero = null;
public Object clone() {
Object theClone = this.clone();
((kelondroOrder) theClone).rotate(this.zero);
return theClone;
}
public abstract Object clone();
public long partition(byte[] key, int forks) {
final long d = (Long.MAX_VALUE / forks) + ((Long.MAX_VALUE % forks) + 1) / forks;

@ -83,6 +83,12 @@ public class kelondroBase64Order extends kelondroAbstractOrder implements kelond
ahpla = (rfc1113compliant) ? ahpla_standard : ahpla_enhanced;
}
public Object clone() {
kelondroBase64Order o = new kelondroBase64Order(this.asc, this.rfc1113compliant);
o.rotate(this.zero);
return o;
}
public static kelondroOrder bySignature(String signature) {
if (signature.equals("Bd")) return new kelondroBase64Order(false, false);
if (signature.equals("bd")) return new kelondroBase64Order(false, true);

@ -47,7 +47,7 @@ package de.anomic.kelondro;
import java.util.Comparator;
public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelondroOrder, Comparator {
public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelondroOrder, Comparator, Cloneable {
boolean asc;
@ -55,6 +55,13 @@ public class kelondroNaturalOrder extends kelondroAbstractOrder implements kelon
public kelondroNaturalOrder(boolean ascending) {
this.asc = ascending;
this.zero = null;
}
public Object clone() {
kelondroNaturalOrder o = new kelondroNaturalOrder(this.asc);
o.rotate(this.zero);
return o;
}
public static kelondroOrder bySignature(String signature) {

@ -384,9 +384,9 @@ public final class plasmaWordIndex {
public static final int RL_WORDFILES = 3;
public synchronized TreeSet wordHashes(String startHash, int resourceLevel, boolean rot, int count) {
//kelondroOrder hashOrder = (kelondroOrder) indexOrder.clone();
//if (rot) hashOrder.rotate(startHash.getBytes()); else hashOrder.rotate(null);
TreeSet hashes = new TreeSet(/*hashOrder*/);
kelondroOrder hashOrder = (kelondroOrder) indexOrder.clone();
if (rot) hashOrder.rotate(startHash.getBytes()); else hashOrder.rotate(null);
TreeSet hashes = new TreeSet(hashOrder);
Iterator i = wordHashes(startHash, resourceLevel, rot);
String hash;
while ((hashes.size() < count) && (i.hasNext())) {

@ -61,8 +61,8 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
// environment constants
private static final String indexArrayFileName = "indexDump1.array";
public static final int wCacheReferenceLimit = 50;
public static final long wCacheMaxAge = 1000 * 60 * 60 * 2; // milliseconds; 2 hours
public static final long kCacheMaxAge = 1000 * 60 * 2; // milliseconds; 2 minutes
public static final long wCacheMaxAge = 1000 * 60 * 30; // milliseconds; 30 minutes
public static final long kCacheMaxAge = 1000 * 60 * 2; // milliseconds; 2 minutes
// class variables
private final File databaseRoot;
@ -393,35 +393,6 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
}
return count;
}
/*
public int tryRemoveURLs(String urlHash) {
// this tries to delete an index from the cache that has this
// urlHash assigned. This can only work if the entry is really fresh
// Such entries must be searched in the latest entries
int delCount = 0;
synchronized (wCache) {
Iterator i = hashDate.scores(false);
String wordHash;
long t;
plasmaWordIndexEntryContainer c;
while (i.hasNext()) {
wordHash = (String) i.next();
// check time
t = longEmit(hashDate.getScore(wordHash));
if (System.currentTimeMillis() - t > wCacheMinAge) return delCount;
// get container
c = (plasmaWordIndexEntryContainer) wCache.get(wordHash);
if (c.remove(urlHash) != null) {
wCache.put(wordHash, c);
hashScore.decScore(wordHash);
delCount++;
}
}
}
return delCount;
}
*/
public int tryRemoveURLs(String urlHash) {
// this tries to delete an index from the cache that has this

Loading…
Cancel
Save