mirror of https://github.com/apache/lucene.git
LUCENE-3879: fix more wrong shifts/invalid asserts for positions in 4.0 codecs
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1301541 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f4a88d2392
commit
70b95b5996
|
@ -475,7 +475,7 @@ public class PulsingPostingsReader extends PostingsReaderBase {
|
|||
payloadLength = postings.readVInt();
|
||||
//System.out.println("PR new payload len=" + payloadLength);
|
||||
}
|
||||
position += code >> 1;
|
||||
position += code >>> 1;
|
||||
payloadRetrieved = false;
|
||||
} else {
|
||||
position += postings.readVInt();
|
||||
|
|
|
@ -705,14 +705,14 @@ public class SepPostingsReader extends PostingsReaderBase {
|
|||
}
|
||||
|
||||
final int code = posReader.next();
|
||||
assert code >= 0;
|
||||
|
||||
if (storePayloads) {
|
||||
if ((code & 1) != 0) {
|
||||
// Payload length has changed
|
||||
payloadLength = posReader.next();
|
||||
assert payloadLength >= 0;
|
||||
}
|
||||
position += code >> 1;
|
||||
position += code >>> 1;
|
||||
pendingPayloadBytes += payloadLength;
|
||||
payloadPending = payloadLength > 0;
|
||||
} else {
|
||||
|
|
|
@ -1524,6 +1524,9 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||
Document doc = new Document();
|
||||
Token t1 = new Token("foo", 0, 3);
|
||||
t1.setPositionIncrement(Integer.MAX_VALUE-500);
|
||||
if (random.nextBoolean()) {
|
||||
t1.setPayload(new Payload(new byte[] { 0x1 } ));
|
||||
}
|
||||
TokenStream overflowingTokenStream = new CannedTokenStream(
|
||||
new Token[] { t1 }
|
||||
);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
|
||||
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
|
||||
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +33,7 @@ public final class CannedTokenStream extends TokenStream {
|
|||
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
|
||||
private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
|
||||
private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
|
||||
private final PayloadAttribute payloadAtt = addAttribute(PayloadAttribute.class);
|
||||
|
||||
public CannedTokenStream(Token[] tokens) {
|
||||
this.tokens = tokens;
|
||||
|
@ -48,6 +50,7 @@ public final class CannedTokenStream extends TokenStream {
|
|||
termAtt.append(token.toString());
|
||||
posIncrAtt.setPositionIncrement(token.getPositionIncrement());
|
||||
offsetAtt.setOffset(token.startOffset(), token.endOffset());
|
||||
payloadAtt.setPayload(token.getPayload());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -109,7 +109,6 @@ public class MockFixedIntBlockPostingsFormat extends PostingsFormat {
|
|||
@Override
|
||||
protected void flushBlock() throws IOException {
|
||||
for(int i=0;i<buffer.length;i++) {
|
||||
assert buffer[i] >= 0;
|
||||
out.writeVInt(buffer[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,6 @@ public class MockVariableIntBlockPostingsFormat extends PostingsFormat {
|
|||
|
||||
@Override
|
||||
protected int add(int value) throws IOException {
|
||||
assert value >= 0;
|
||||
buffer[pendingCount++] = value;
|
||||
// silly variable block length int encoder: if
|
||||
// first value <= 3, we write N vints at once;
|
||||
|
|
|
@ -53,7 +53,6 @@ public class MockSingleIntIndexOutput extends IntIndexOutput {
|
|||
/** Write an int to the primary file */
|
||||
@Override
|
||||
public void write(int v) throws IOException {
|
||||
assert v >= 0;
|
||||
out.writeVInt(v);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue