mirror of https://github.com/apache/lucene.git
LUCENE-3851: fix test bug; add asserts
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1297518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ebf04948b
commit
4c4aff6400
|
@ -69,6 +69,7 @@ class Direct16 extends PackedInts.ReaderImpl
|
|||
}
|
||||
|
||||
public long get(final int index) {
|
||||
assert index >= 0 && index < size();
|
||||
return 0xFFFFL & values[index];
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ class Direct32 extends PackedInts.ReaderImpl
|
|||
}
|
||||
|
||||
public long get(final int index) {
|
||||
assert index >= 0 && index < size();
|
||||
return 0xFFFFFFFFL & values[index];
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ class Direct64 extends PackedInts.ReaderImpl
|
|||
}
|
||||
|
||||
public long get(final int index) {
|
||||
assert index >= 0 && index < size();
|
||||
return values[index];
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ class Direct8 extends PackedInts.ReaderImpl
|
|||
}
|
||||
|
||||
public long get(final int index) {
|
||||
assert index >= 0 && index < size();
|
||||
return 0xFFL & values[index];
|
||||
}
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ class Packed32 extends PackedInts.ReaderImpl implements PackedInts.Mutable {
|
|||
* @return the value at the given index.
|
||||
*/
|
||||
public long get(final int index) {
|
||||
assert index >= 0 && index < size();
|
||||
final long majorBitPos = (long)index * bitsPerValue;
|
||||
final int elementPos = (int)(majorBitPos >>> BLOCK_BITS); // / BLOCK_SIZE
|
||||
final int bitPos = (int)(majorBitPos & MOD_MASK); // % BLOCK_SIZE);
|
||||
|
|
|
@ -176,6 +176,7 @@ class Packed64 extends PackedInts.ReaderImpl implements PackedInts.Mutable {
|
|||
* @return the value at the given index.
|
||||
*/
|
||||
public long get(final int index) {
|
||||
assert index >= 0 && index < size();
|
||||
final long majorBitPos = (long)index * bitsPerValue;
|
||||
final int elementPos = (int)(majorBitPos >>> BLOCK_BITS); // / BLOCK_SIZE
|
||||
final int bitPos = (int)(majorBitPos & MOD_MASK); // % BLOCK_SIZE);
|
||||
|
|
|
@ -25,12 +25,7 @@ import java.util.Random;
|
|||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.analysis.MockTokenizer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.codecs.FieldInfosReader;
|
||||
import org.apache.lucene.codecs.lucene3x.Lucene3xPostingsFormat;
|
||||
import org.apache.lucene.codecs.lucene3x.PreFlexRWCodec;
|
||||
import org.apache.lucene.codecs.lucene3x.SegmentTermEnum;
|
||||
import org.apache.lucene.codecs.lucene3x.TermInfosReaderIndex;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.index.CorruptIndexException;
|
||||
|
@ -86,8 +81,8 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {
|
|||
directory = newDirectory();
|
||||
|
||||
config.setCodec(new PreFlexRWCodec());
|
||||
// turn off compound file, this test will open some index files directly.
|
||||
LogMergePolicy mp = newLogMergePolicy();
|
||||
// turn off compound file, this test will open some index files directly.
|
||||
mp.setUseCompoundFile(false);
|
||||
config.setMergePolicy(mp);
|
||||
|
||||
|
@ -182,9 +177,16 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {
|
|||
int termPosition = index * termIndexInterval * indexDivisor;
|
||||
for (int i = 0; i < termPosition; i++) {
|
||||
// TODO: this test just uses random terms, so this is always possible
|
||||
assumeTrue("ran out of terms.", termEnum.next());
|
||||
assumeTrue("ran out of terms", termEnum.next());
|
||||
}
|
||||
return termEnum.term();
|
||||
final Term term = termEnum.term();
|
||||
// An indexed term is only written when the term after
|
||||
// it exists, so, if the number of terms is 0 mod
|
||||
// termIndexInterval, the last index term will not be
|
||||
// written; so we require a term after this term
|
||||
// as well:
|
||||
assumeTrue("ran out of terms", termEnum.next());
|
||||
return term;
|
||||
}
|
||||
|
||||
private static void populate(Directory directory, IndexWriterConfig config) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
|
|
|
@ -210,9 +210,9 @@ final class TermInfosWriter implements Closeable {
|
|||
assert ti.freqPointer >= lastTi.freqPointer: "freqPointer out of order (" + ti.freqPointer + " < " + lastTi.freqPointer + ")";
|
||||
assert ti.proxPointer >= lastTi.proxPointer: "proxPointer out of order (" + ti.proxPointer + " < " + lastTi.proxPointer + ")";
|
||||
|
||||
if (!isIndex && size % indexInterval == 0)
|
||||
if (!isIndex && size % indexInterval == 0) {
|
||||
other.add(lastFieldNumber, lastTerm, lastTi); // add an index term
|
||||
|
||||
}
|
||||
writeTerm(fieldNumber, term); // write term
|
||||
|
||||
output.writeVInt(ti.docFreq); // write doc freq
|
||||
|
|
Loading…
Reference in New Issue