LUCENE-3210: let app control how aggressive TMP is in targetting segments with deletions; default it to more aggressive than today

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1137060 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-06-17 22:39:38 +00:00
parent 74aac32eb3
commit f32a6aa455
3 changed files with 24 additions and 1 deletions

View File

@ -545,6 +545,10 @@ New Features
* LUCENE-3179: Added OpenBitSet.prevSetBit (Paul Elschot via Mike McCandless)
* LUCENE-3210: Made TieredMergePolicy more aggressive in reclaiming
segments with deletions; added new methods
set/getReclaimDeletesWeight to control this. (Mike McCandless)
Build
* LUCENE-1344: Create OSGi bundle using dev-tools/maven.

View File

@ -82,6 +82,7 @@ public class TieredMergePolicy extends MergePolicy {
private double expungeDeletesPctAllowed = 10.0;
private boolean useCompoundFile = true;
private double noCFSRatio = 0.1;
private double reclaimDeletesWeight = 2.0;
/** Maximum number of segments to be merged at a time
* during "normal" merging. For explicit merging (eg,
@ -133,6 +134,23 @@ public class TieredMergePolicy extends MergePolicy {
return maxMergedSegmentBytes/1024/1024.;
}
/** Controls how aggressively merges that reclaim more
* deletions are favored. Higher values favor selecting
* merges that reclaim deletions. A value of 0.0 means
* deletions don't impact merge selection. */
public TieredMergePolicy setReclaimDeletesWeight(double v) {
if (v < 0.0) {
throw new IllegalArgumentException("reclaimDeletesWeight must be >= 0.0 (got " + v + ")");
}
reclaimDeletesWeight = v;
return this;
}
/** See {@link #setReclaimDeletesWeight}. */
public double getReclaimDeletesWeight() {
return reclaimDeletesWeight;
}
/** Segments smaller than this are "rounded up" to this
* size, ie treated as equal (floor) size for merge
* selection. This is to prevent frequent flushing of
@ -435,7 +453,7 @@ public class TieredMergePolicy extends MergePolicy {
// Strongly favor merges that reclaim deletes:
final double nonDelRatio = ((double) totAfterMergeBytes)/totBeforeMergeBytes;
mergeScore *= nonDelRatio;
mergeScore *= Math.pow(nonDelRatio, reclaimDeletesWeight);
final double finalMergeScore = mergeScore;

View File

@ -947,6 +947,7 @@ public abstract class LuceneTestCase extends Assert {
tmp.setSegmentsPerTier(_TestUtil.nextInt(r, 2, 20));
tmp.setUseCompoundFile(r.nextBoolean());
tmp.setNoCFSRatio(0.1 + r.nextDouble()*0.8);
tmp.setReclaimDeletesWeight(r.nextDouble()*4);
return tmp;
}