From 5f4a6892c11784c6a9ff9bbab6dff79980aa7baf Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 5 Mar 2014 23:28:19 +0100 Subject: [PATCH] enhanced RowSet re-sort limit for small sets --- source/net/yacy/kelondro/index/RowSet.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/net/yacy/kelondro/index/RowSet.java b/source/net/yacy/kelondro/index/RowSet.java index d43ef65f1..0beda9791 100644 --- a/source/net/yacy/kelondro/index/RowSet.java +++ b/source/net/yacy/kelondro/index/RowSet.java @@ -47,7 +47,6 @@ import net.yacy.kelondro.util.MemoryControl; public class RowSet extends RowCollection implements Index, Iterable, Serializable { private static final long serialVersionUID=-6036029762440788566L; - private static final int collectionReSortLimit = 3000; public RowSet(final RowSet rs) { super(rs); @@ -184,6 +183,10 @@ public class RowSet extends RowCollection implements Index, Iterable, } } + private final int collectionReSortLimit() { + return Math.min(3000, Math.max(100, this.chunkcount / 3)); + } + @Override public final Row.Entry replace(final Row.Entry entry) throws SpaceExceededException { assert (entry != null); @@ -195,7 +198,7 @@ public class RowSet extends RowCollection implements Index, Iterable, int index = -1; Row.Entry oldentry = null; // when reaching a specific amount of un-sorted entries, re-sort all - if ((this.chunkcount - this.sortBound) > collectionReSortLimit) { + if ((this.chunkcount - this.sortBound) > collectionReSortLimit()) { sort(); } index = find(key, 0); @@ -287,7 +290,7 @@ public class RowSet extends RowCollection implements Index, Iterable, if (this.rowdef.objectOrder == null) return iterativeSearch(a, astart, 0, this.chunkcount); - if ((this.chunkcount - this.sortBound) > collectionReSortLimit) { + if ((this.chunkcount - this.sortBound) > collectionReSortLimit()) { sort(); }