Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

* add custom comparator to ScoreCluster for byte[] * fixes http://forum.yacy-websuche.de/viewtopic.php?f=6&t=2010

f1ori76af84d732a3
diff --git a/source/de/anomic/kelondro/text/IndexBuffer.java b/source/de/anomic/kelondro/text/IndexBuffer.java
index 2dc753124..a9450f46f 100644
--- a/source/de/anomic/kelondro/text/IndexBuffer.java
+++ b/source/de/anomic/kelondro/text/IndexBuffer.java
@@ -33,6 +33,7 @@ import java.util.Iterator;
import java.util.Set;
import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.ByteOrder;
import de.anomic.kelondro.order.CloneableIterator;
import de.anomic.kelondro.text.referencePrototype.WordReferenceRow;
@@ -72,8 +73,8 @@ public final class IndexBuffer<ReferenceType extends Reference> extends Abstract
// creates a new index cache
// the cache has a back-end where indexes that do not fit in the cache are flushed
- this.hashScore = new ScoreCluster<byte[]>();
- this.hashDate = new ScoreCluster<byte[]>();
+ this.hashScore = new ScoreCluster<byte[]>(Base64Order.enhancedCoder);
+ this.hashDate = new ScoreCluster<byte[]>(Base64Order.enhancedCoder);
this.initTime = System.currentTimeMillis();
this.cacheEntityMaxCount = entityCacheMaxSize;
this.cacheReferenceCountLimit = wCacheReferenceCountLimitInit;
diff --git a/source/de/anomic/kelondro/util/ScoreCluster.java b/source/de/anomic/kelondro/util/ScoreCluster.java
index ed71556aa..a25cdff10 100644
--- a/source/de/anomic/kelondro/util/ScoreCluster.java
+++ b/source/de/anomic/kelondro/util/ScoreCluster.java
@@ -23,6 +23,7 @@ package de.anomic.kelondro.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
@@ -38,7 +39,15 @@ public final class ScoreCluster<E> {
private int encnt;
public ScoreCluster() {
- refkeyDB = new TreeMap<E, Long>();
+ this(null);
+ }
+
+ public ScoreCluster(Comparator<? super E> comparator) {
+ if(comparator != null) {
+ refkeyDB = new TreeMap<E, Long>(comparator);
+ } else {
+ refkeyDB = new TreeMap<E, Long>();
+ }
keyrefDB = new TreeMap<Long, E>();
gcount = 0;
encnt = 0;