You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/03/09 19:41:54 UTC
[1/2] lucene-solr git commit: add missing argument
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6_0 73f262c40 -> a3cf335b3
add missing argument
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a3cf335b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a3cf335b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a3cf335b
Branch: refs/heads/branch_6_0
Commit: a3cf335b372185a349e96d4421d8a31ac61e2471
Parents: 302c35c
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Mar 9 11:27:05 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Mar 9 13:42:33 2016 -0500
----------------------------------------------------------------------
.../test/org/apache/lucene/index/TestMaxPositionInOldIndex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a3cf335b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java
index 87625d2..3608b80 100644
--- a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java
+++ b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java
@@ -82,7 +82,7 @@ public class BuildMaxPositionIndex {
BaseDirectoryWrapper dir = newFSDirectory(path);
dir.setCheckIndexOnClose(false);
RuntimeException expected = expectThrows(RuntimeException.class, () -> {
- TestUtil.checkIndex(dir, false, true);
+ TestUtil.checkIndex(dir, false, true, null);
});
assertTrue(expected.getMessage().contains("pos 2147483647 > IndexWriter.MAX_POSITION=2147483519"));
[2/2] lucene-solr git commit: CheckIndex failed to say it was
checking points
Posted by mi...@apache.org.
CheckIndex failed to say it was checking points
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/302c35c3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/302c35c3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/302c35c3
Branch: refs/heads/branch_6_0
Commit: 302c35c3589367b5fda4e527e1dca46b639a068f
Parents: 73f262c
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Mar 9 11:03:19 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Mar 9 13:42:33 2016 -0500
----------------------------------------------------------------------
.../org/apache/lucene/index/CheckIndex.java | 7 +++++
.../index/TestAllFilesCheckIndexHeader.java | 3 +-
.../index/TestAllFilesDetectTruncation.java | 4 +--
.../apache/lucene/index/TestPointValues.java | 29 ++++++++++++++++++++
.../lucene/index/TestSwappedIndexFiles.java | 3 +-
.../lucene/store/MockDirectoryWrapper.java | 2 +-
.../java/org/apache/lucene/util/TestUtil.java | 14 ++++++----
7 files changed, 48 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
index 3c437c1..89b36ef 100644
--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
@@ -1683,9 +1683,14 @@ public final class CheckIndex implements Closeable {
* @lucene.experimental
*/
public static Status.PointsStatus testPoints(CodecReader reader, PrintStream infoStream, boolean failFast) throws IOException {
+ if (infoStream != null) {
+ infoStream.print(" test: points..............");
+ }
+ long startNS = System.nanoTime();
FieldInfos fieldInfos = reader.getFieldInfos();
Status.PointsStatus status = new Status.PointsStatus();
try {
+
if (fieldInfos.hasPointValues()) {
PointsReader values = reader.getPointsReader();
if (values == null) {
@@ -1840,6 +1845,8 @@ public final class CheckIndex implements Closeable {
}
}
}
+ msg(infoStream, String.format(Locale.ROOT, "OK [%d fields, %d points] [took %.3f sec]", status.totalValueFields, status.totalValuePoints, nsToSec(System.nanoTime()-startNS)));
+
} catch (Throwable e) {
if (failFast) {
IOUtils.reThrow(e);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java
index 68b7cc2..f6c1486 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java
@@ -28,7 +28,6 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
import org.apache.lucene.util.LuceneTestCase;
@@ -132,7 +131,7 @@ public class TestAllFilesCheckIndexHeader extends LuceneTestCase {
// CheckIndex should also fail:
try {
- TestUtil.checkIndex(dirCopy, true, true);
+ TestUtil.checkIndex(dirCopy, true, true, null);
fail("wrong bytes not detected after randomizing first " + wrongBytes + " bytes out of " + victimLength + " for file " + victim);
} catch (CorruptIndexException | EOFException | IndexFormatTooOldException e) {
// expected
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java
index 16caae3..c751417 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
import java.io.EOFException;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -28,7 +27,6 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
import org.apache.lucene.util.LuceneTestCase;
@@ -116,7 +114,7 @@ public class TestAllFilesDetectTruncation extends LuceneTestCase {
// CheckIndex should also fail:
try {
- TestUtil.checkIndex(dirCopy, true, true);
+ TestUtil.checkIndex(dirCopy, true, true, null);
fail("truncation not detected after removing " + lostBytes + " bytes out of " + victimLength + " for file " + victim);
} catch (CorruptIndexException | EOFException e) {
// expected
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java b/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java
index 55d4794..9b18f02 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java
@@ -17,6 +17,7 @@
package org.apache.lucene.index;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -40,6 +41,7 @@ import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
@@ -628,4 +630,31 @@ public class TestPointValues extends LuceneTestCase {
w.close();
dir.close();
}
+
+ public void testCheckIndexIncludesPoints() throws Exception {
+ Directory dir = new RAMDirectory();
+ IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(null));
+ Document doc = new Document();
+ doc.add(new IntPoint("int1", 17));
+ w.addDocument(doc);
+
+ doc = new Document();
+ doc.add(new IntPoint("int1", 44));
+ doc.add(new IntPoint("int2", -17));
+ w.addDocument(doc);
+ w.close();
+
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ CheckIndex.Status status = TestUtil.checkIndex(dir, false, true, output);
+ assertEquals(1, status.segmentInfos.size());
+ CheckIndex.Status.SegmentInfoStatus segStatus = status.segmentInfos.get(0);
+ // total 3 point values were index:
+ assertEquals(3, segStatus.pointsStatus.totalValuePoints);
+ // ... across 2 fields:
+ assertEquals(2, segStatus.pointsStatus.totalValueFields);
+
+ // Make sure CheckIndex in fact declares that it is testing points!
+ assertTrue(output.toString(IOUtils.UTF_8).contains("test: points..."));
+ dir.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java b/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java
index a284fdd..d220502 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java
@@ -28,7 +28,6 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.store.BaseDirectoryWrapper;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
-import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
import org.apache.lucene.util.LuceneTestCase;
@@ -118,7 +117,7 @@ public class TestSwappedIndexFiles extends LuceneTestCase {
// CheckIndex should also fail:
try {
- TestUtil.checkIndex(dirCopy, true, true);
+ TestUtil.checkIndex(dirCopy, true, true, null);
fail("wrong file " + victim + " not detected");
} catch (CorruptIndexException | EOFException | IndexFormatTooOldException e) {
// expected
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java b/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
index 7fe7c3b..c2544b4 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
@@ -850,7 +850,7 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
System.out.println("\nNOTE: MockDirectoryWrapper: now run CheckIndex");
}
- TestUtil.checkIndex(this, getCrossCheckTermVectorsOnClose(), true);
+ TestUtil.checkIndex(this, getCrossCheckTermVectorsOnClose(), true, null);
}
// TODO: factor this out / share w/ TestIW.assertNoUnreferencedFiles
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/302c35c3/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
index 5e328ba..d772ae3 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
@@ -279,28 +279,30 @@ public final class TestUtil {
}
public static CheckIndex.Status checkIndex(Directory dir, boolean crossCheckTermVectors) throws IOException {
- return checkIndex(dir, crossCheckTermVectors, false);
+ return checkIndex(dir, crossCheckTermVectors, false, null);
}
/** If failFast is true, then throw the first exception when index corruption is hit, instead of moving on to other fields/segments to
* look for any other corruption. */
- public static CheckIndex.Status checkIndex(Directory dir, boolean crossCheckTermVectors, boolean failFast) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
+ public static CheckIndex.Status checkIndex(Directory dir, boolean crossCheckTermVectors, boolean failFast, ByteArrayOutputStream output) throws IOException {
+ if (output == null) {
+ output = new ByteArrayOutputStream(1024);
+ }
// TODO: actually use the dir's locking, unless test uses a special method?
// some tests e.g. exception tests become much more complicated if they have to close the writer
try (CheckIndex checker = new CheckIndex(dir, NoLockFactory.INSTANCE.obtainLock(dir, "bogus"))) {
checker.setCrossCheckTermVectors(crossCheckTermVectors);
checker.setFailFast(failFast);
- checker.setInfoStream(new PrintStream(bos, false, IOUtils.UTF_8), false);
+ checker.setInfoStream(new PrintStream(output, false, IOUtils.UTF_8), false);
CheckIndex.Status indexStatus = checker.checkIndex(null);
if (indexStatus == null || indexStatus.clean == false) {
System.out.println("CheckIndex failed");
- System.out.println(bos.toString(IOUtils.UTF_8));
+ System.out.println(output.toString(IOUtils.UTF_8));
throw new RuntimeException("CheckIndex failed");
} else {
if (LuceneTestCase.INFOSTREAM) {
- System.out.println(bos.toString(IOUtils.UTF_8));
+ System.out.println(output.toString(IOUtils.UTF_8));
}
return indexStatus;
}