You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2008/04/23 20:32:44 UTC
svn commit: r650992 -
/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java
Author: mikemccand
Date: Wed Apr 23 11:32:40 2008
New Revision: 650992
URL: http://svn.apache.org/viewvc?rev=650992&view=rev
Log:
LUCENE-1255: in CheckIndex, accept pos=-1 if index is < 2.4; added NOTE to remind user to turn on assertions for more thorough checking
Modified:
lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java
Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java?rev=650992&r1=650991&r2=650992&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/CheckIndex.java Wed Apr 23 11:32:40 2008
@@ -201,7 +201,7 @@
totPos += freq;
for(int j=0;j<freq;j++) {
final int pos = termPositions.nextPosition();
- if (pos < 0)
+ if (pos < -1)
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
if (pos < lastPos)
throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " < lastPos " + lastPos);
@@ -318,6 +318,13 @@
return false;
}
+ static boolean assertsOn;
+
+ private static boolean testAsserts() {
+ assertsOn = true;
+ return true;
+ }
+
public static void main(String[] args) throws Throwable {
boolean doFix = false;
@@ -347,6 +354,10 @@
"corruption, else 0.\n");
System.exit(1);
}
+
+ assert testAsserts();
+ if (!assertsOn)
+ out.println("\nNOTE: testing will be more thorough if you run java with '-ea:org.apache.lucene', so assertions are enabled");
final String dirName = args[0];
out.println("\nOpening index @ " + dirName + "\n");