mirror of https://github.com/apache/lucene.git
fix AlcoholicMergePolicy to not excessively exaggerate segment sizes as it's getting drunk
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1337653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
42ebab7867
commit
7e511f80d1
|
@ -29,6 +29,7 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
@SuppressCodecs({ "SimpleText", "Memory" })
|
||||
public class TestSearchWithThreads extends LuceneTestCase {
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.util.GregorianCalendar;
|
|||
import java.util.Random;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Merge policy for testing, it is like an alcoholic.
|
||||
|
@ -45,6 +47,7 @@ public class AlcoholicMergePolicy extends LogMergePolicy {
|
|||
public AlcoholicMergePolicy(TimeZone tz, Random random) {
|
||||
this.calendar = new GregorianCalendar(tz);
|
||||
this.random = random;
|
||||
maxMergeSize = _TestUtil.nextInt(random, 1024*1024, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,11 +61,10 @@ public class AlcoholicMergePolicy extends LogMergePolicy {
|
|||
|
||||
Drink[] values = Drink.values();
|
||||
// pick a random drink during the day
|
||||
return values[random.nextInt(values.length)].drunkFactor * (1 + random.nextInt(Integer.MAX_VALUE / 2));
|
||||
|
||||
return values[random.nextInt(values.length)].drunkFactor * info.sizeInBytes();
|
||||
}
|
||||
return maxMergeSize == Long.MAX_VALUE ? maxMergeSize : maxMergeSize+1;
|
||||
|
||||
|
||||
return info.sizeInBytes();
|
||||
}
|
||||
|
||||
public static enum Drink {
|
||||
|
|
Loading…
Reference in New Issue