remove some dead code; make RIW/RIWC more hairy

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/preflexfixes@967224 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-07-23 19:40:31 +00:00
parent c8fd7fccc1
commit b797b021ee
4 changed files with 33 additions and 18 deletions

View File

@ -84,26 +84,16 @@ public final class SegmentTermEnum implements Cloneable {
format = firstInt;
// check that it is a format we can understand
if (format > FORMAT_MINIMUM)
throw new IndexFormatTooOldException(null, format, FORMAT_MINIMUM, FORMAT_CURRENT);
if (format < FORMAT_CURRENT)
throw new IndexFormatTooNewException(null, format, FORMAT_MINIMUM, FORMAT_CURRENT);
if (format > FORMAT_MINIMUM)
throw new IndexFormatTooOldException(null, format, FORMAT_MINIMUM, FORMAT_CURRENT);
if (format < FORMAT_CURRENT)
throw new IndexFormatTooNewException(null, format, FORMAT_MINIMUM, FORMAT_CURRENT);
size = input.readLong(); // read the size
if(format == -1){
if (!isIndex) {
indexInterval = input.readInt();
formatM1SkipInterval = input.readInt();
}
// switch off skipTo optimization for file format prior to 1.4rc2 in order to avoid a bug in
// skipTo implementation of these versions
skipInterval = Integer.MAX_VALUE;
} else {
indexInterval = input.readInt();
skipInterval = input.readInt();
maxSkipLevels = input.readInt();
}
indexInterval = input.readInt();
skipInterval = input.readInt();
maxSkipLevels = input.readInt();
assert indexInterval > 0: "indexInterval=" + indexInterval + " is negative; must be > 0";
assert skipInterval > 0: "skipInterval=" + skipInterval + " is negative; must be > 0";
}

View File

@ -43,6 +43,24 @@ public class RandomIndexWriter implements Closeable {
int docCount;
int flushAt;
// Randomly calls Thread.yield so we mixup thread scheduling
private static final class MockIndexWriter extends IndexWriter {
private final Random r;
public MockIndexWriter(Random r,Directory dir, IndexWriterConfig conf) throws IOException {
super(dir, conf);
this.r = r;
}
@Override
boolean testPoint(String name) {
if (r.nextInt(4) == 2)
Thread.yield();
return true;
}
}
/** create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT and MockAnalyzer */
public RandomIndexWriter(Random r, Directory dir) throws IOException {
this(r, dir, LuceneTestCaseJ4.newIndexWriterConfig(r, LuceneTestCaseJ4.TEST_VERSION_CURRENT, new MockAnalyzer()));
@ -61,7 +79,7 @@ public class RandomIndexWriter implements Closeable {
/** create a RandomIndexWriter with the provided config */
public RandomIndexWriter(Random r, Directory dir, IndexWriterConfig c) throws IOException {
this.r = r;
w = new IndexWriter(dir, c);
w = new MockIndexWriter(r, dir, c);
flushAt = _TestUtil.nextInt(r, 10, 1000);
}

View File

@ -428,6 +428,7 @@ public class LuceneTestCaseJ4 {
logmp.setUseCompoundDocStore(r.nextBoolean());
logmp.setUseCompoundFile(r.nextBoolean());
logmp.setCalibrateSizeByDeletes(r.nextBoolean());
logmp.setMergeFactor(_TestUtil.nextInt(r, 2, 20));
}
c.setReaderPooling(r.nextBoolean());

View File

@ -252,11 +252,17 @@ public class _TestUtil {
@Override
public Codec lookup(String name) {
// can't do this until we fix PreFlexRW to not
//impersonate PreFlex:
//return CodecProvider.getDefault().lookup(name);
return c;
}
};
}
/** Return a CodecProvider that can read any of the
* default codecs, but always writes in the specified
* codec. */
public static CodecProvider alwaysCodec(final String codec) {
return alwaysCodec(CodecProvider.getDefault().lookup(codec));
}