LUCENE-3037: fix skiplevel computation for some cases where skipInterval^N == df

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1095125 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-04-19 16:13:36 +00:00
parent a440c8c018
commit 8906ff3cc2
3 changed files with 5 additions and 3 deletions

View File

@ -186,7 +186,8 @@ public abstract class MultiLevelSkipListReader {
/** Loads the skip levels */
private void loadSkipLevels() throws IOException {
numberOfSkipLevels = docCount == 0 ? 0 : (int) Math.floor(Math.log(docCount) / Math.log(skipInterval[0]));
// TODO: would be preferable to use integer math here instead.
numberOfSkipLevels = docCount == 0 ? 0 : (int) Math.floor(StrictMath.log(docCount) / StrictMath.log(skipInterval[0]));
if (numberOfSkipLevels > maxNumberOfSkipLevels) {
numberOfSkipLevels = maxNumberOfSkipLevels;
}

View File

@ -61,7 +61,8 @@ public abstract class MultiLevelSkipListWriter {
this.skipInterval = skipInterval;
// calculate the maximum number of skip levels for this document frequency
numberOfSkipLevels = df == 0 ? 0 : (int) Math.floor(Math.log(df) / Math.log(skipInterval));
// TODO: would be preferable to use integer math here instead.
numberOfSkipLevels = df == 0 ? 0 : (int) Math.floor(StrictMath.log(df) / StrictMath.log(skipInterval));
// make sure it does not exceed maxSkipLevels
if (numberOfSkipLevels > maxSkipLevels) {

View File

@ -122,7 +122,7 @@ public class MockRandomCodec extends Codec {
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
// we pull this before the seed intentionally: because its not consumed at runtime
// (the skipInterval is written into postings header)
int skipInterval = _TestUtil.nextInt(seedRandom, 2, 64);
int skipInterval = _TestUtil.nextInt(seedRandom, 2, 10);
if (LuceneTestCase.VERBOSE) {
System.out.println("MockRandomCodec: skipInterval=" + skipInterval);