LUCENE-3969: check that startOffset <= endOffset; comment out sops

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3969@1311406 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-04-09 20:04:55 +00:00
parent 3e098abaed
commit 9e98ec186c
1 changed files with 10 additions and 6 deletions

View File

@ -82,19 +82,23 @@ public final class ValidatingTokenFilter extends TokenFilter {
final int startOffset = offsetAtt.startOffset(); final int startOffset = offsetAtt.startOffset();
final int endOffset = offsetAtt.endOffset(); final int endOffset = offsetAtt.endOffset();
if (endOffset < startOffset) {
throw new IllegalStateException(name + ": startOffset=" + startOffset + " is > endOffset=" + endOffset + " pos=" + pos + "; token=" + termAtt);
}
final int posLen = posLenAtt == null ? 1 : posLenAtt.getPositionLength(); final int posLen = posLenAtt == null ? 1 : posLenAtt.getPositionLength();
if (!posToStartOffset.containsKey(pos)) { if (!posToStartOffset.containsKey(pos)) {
// First time we've seen a token leaving from this position: // First time we've seen a token leaving from this position:
posToStartOffset.put(pos, startOffset); posToStartOffset.put(pos, startOffset);
System.out.println(" + s " + pos + " -> " + startOffset); //System.out.println(" + s " + pos + " -> " + startOffset);
} else { } else {
// We've seen a token leaving from this position // We've seen a token leaving from this position
// before; verify the startOffset is the same: // before; verify the startOffset is the same:
System.out.println(" + vs " + pos + " -> " + startOffset); //System.out.println(" + vs " + pos + " -> " + startOffset);
final int oldStartOffset = posToStartOffset.get(pos); final int oldStartOffset = posToStartOffset.get(pos);
if (oldStartOffset != startOffset) { if (oldStartOffset != startOffset) {
throw new IllegalStateException(name + ": inconsistent startOffset as pos=" + pos + ": " + oldStartOffset + " vs " + startOffset + "; token=" + termAtt); throw new IllegalStateException(name + ": inconsistent startOffset at pos=" + pos + ": " + oldStartOffset + " vs " + startOffset + "; token=" + termAtt);
} }
} }
@ -103,14 +107,14 @@ public final class ValidatingTokenFilter extends TokenFilter {
if (!posToEndOffset.containsKey(endPos)) { if (!posToEndOffset.containsKey(endPos)) {
// First time we've seen a token arriving to this position: // First time we've seen a token arriving to this position:
posToEndOffset.put(endPos, endOffset); posToEndOffset.put(endPos, endOffset);
System.out.println(" + e " + endPos + " -> " + endOffset); //System.out.println(" + e " + endPos + " -> " + endOffset);
} else { } else {
// We've seen a token arriving to this position // We've seen a token arriving to this position
// before; verify the endOffset is the same: // before; verify the endOffset is the same:
System.out.println(" + ve " + endPos + " -> " + endOffset); //System.out.println(" + ve " + endPos + " -> " + endOffset);
final int oldEndOffset = posToEndOffset.get(endPos); final int oldEndOffset = posToEndOffset.get(endPos);
if (oldEndOffset != endOffset) { if (oldEndOffset != endOffset) {
throw new IllegalStateException(name + ": inconsistent endOffset as pos=" + endPos + ": " + oldEndOffset + " vs " + endOffset + "; token=" + termAtt); throw new IllegalStateException(name + ": inconsistent endOffset at pos=" + endPos + ": " + oldEndOffset + " vs " + endOffset + "; token=" + termAtt);
} }
} }
} }