mirror of https://github.com/apache/lucene.git
LUCENE-1255: revert this change (allow pos=-1 again) since it's not backwards compatible
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@652116 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aecd167b05
commit
8f1feaa484
|
@ -104,7 +104,6 @@ public class CheckIndex {
|
||||||
|
|
||||||
String sFormat = "";
|
String sFormat = "";
|
||||||
boolean skip = false;
|
boolean skip = false;
|
||||||
boolean allowMinusOnePosition = true;
|
|
||||||
|
|
||||||
if (format == SegmentInfos.FORMAT)
|
if (format == SegmentInfos.FORMAT)
|
||||||
sFormat = "FORMAT [Lucene Pre-2.1]";
|
sFormat = "FORMAT [Lucene Pre-2.1]";
|
||||||
|
@ -118,7 +117,6 @@ public class CheckIndex {
|
||||||
// LUCENE-1255: All versions before 2.3.2/2.4 were
|
// LUCENE-1255: All versions before 2.3.2/2.4 were
|
||||||
// able to create position=-1 when the very first
|
// able to create position=-1 when the very first
|
||||||
// Token has positionIncrement 0
|
// Token has positionIncrement 0
|
||||||
allowMinusOnePosition = false;
|
|
||||||
if (format == SegmentInfos.FORMAT_CHECKSUM)
|
if (format == SegmentInfos.FORMAT_CHECKSUM)
|
||||||
sFormat = "FORMAT_CHECKSUM [Lucene 2.4]";
|
sFormat = "FORMAT_CHECKSUM [Lucene 2.4]";
|
||||||
else if (format == SegmentInfos.FORMAT_DEL_COUNT)
|
else if (format == SegmentInfos.FORMAT_DEL_COUNT)
|
||||||
|
@ -235,7 +233,7 @@ public class CheckIndex {
|
||||||
totPos += freq;
|
totPos += freq;
|
||||||
for(int j=0;j<freq;j++) {
|
for(int j=0;j<freq;j++) {
|
||||||
final int pos = termPositions.nextPosition();
|
final int pos = termPositions.nextPosition();
|
||||||
if (pos < -1 || (pos == -1 && !allowMinusOnePosition))
|
if (pos < -1)
|
||||||
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
|
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
|
||||||
if (pos < lastPos)
|
if (pos < lastPos)
|
||||||
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " < lastPos " + lastPos);
|
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " < lastPos " + lastPos);
|
||||||
|
|
|
@ -243,9 +243,6 @@ final class DocumentsWriterFieldData implements Comparable {
|
||||||
Token token = stream.next(localToken);
|
Token token = stream.next(localToken);
|
||||||
if (token == null) break;
|
if (token == null) break;
|
||||||
position += (token.getPositionIncrement() - 1);
|
position += (token.getPositionIncrement() - 1);
|
||||||
// LUCENE-1255: don't allow negative position
|
|
||||||
if (position < 0)
|
|
||||||
position = 0;
|
|
||||||
addPosition(token);
|
addPosition(token);
|
||||||
if (++length >= maxFieldLength) {
|
if (++length >= maxFieldLength) {
|
||||||
if (threadState.docWriter.infoStream != null)
|
if (threadState.docWriter.infoStream != null)
|
||||||
|
|
|
@ -3596,7 +3596,7 @@ public class TestIndexWriter extends LuceneTestCase
|
||||||
TermPositions tps = s.getIndexReader().termPositions(new Term("field", "a"));
|
TermPositions tps = s.getIndexReader().termPositions(new Term("field", "a"));
|
||||||
assertTrue(tps.next());
|
assertTrue(tps.next());
|
||||||
assertEquals(1, tps.freq());
|
assertEquals(1, tps.freq());
|
||||||
assertEquals(0, tps.nextPosition());
|
assertEquals(-1, tps.nextPosition());
|
||||||
w.close();
|
w.close();
|
||||||
|
|
||||||
assertTrue(_TestUtil.checkIndex(dir));
|
assertTrue(_TestUtil.checkIndex(dir));
|
||||||
|
|
Loading…
Reference in New Issue