You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2016/10/31 15:15:01 UTC
[09/15] lucene-solr:jira/solr-8593: LUCENE-7529: Fix argument checks
of MultiDocValues' advanceExact impls.
LUCENE-7529: Fix argument checks of MultiDocValues' advanceExact impls.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/325b74e0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/325b74e0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/325b74e0
Branch: refs/heads/jira/solr-8593
Commit: 325b74e0e3e9c9ce265d8d7844f01209394b920a
Parents: 2ad2fca
Author: Adrien Grand <jp...@gmail.com>
Authored: Mon Oct 31 10:34:48 2016 +0100
Committer: Adrien Grand <jp...@gmail.com>
Committed: Mon Oct 31 10:54:54 2016 +0100
----------------------------------------------------------------------
.../org/apache/lucene/index/MultiDocValues.java | 10 +++++-----
.../apache/lucene/index/TestMultiDocValues.java | 19 +++++++++++++++++--
2 files changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/325b74e0/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
index 51d684d..3970e0a 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
@@ -140,7 +140,7 @@ public class MultiDocValues {
@Override
public boolean advanceExact(int targetDocID) throws IOException {
- if (targetDocID <= docID) {
+ if (targetDocID < docID) {
throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID);
}
int readerIndex = ReaderUtil.subIndex(targetDocID, leaves);
@@ -266,7 +266,7 @@ public class MultiDocValues {
@Override
public boolean advanceExact(int targetDocID) throws IOException {
- if (targetDocID <= docID) {
+ if (targetDocID < docID) {
throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID);
}
int readerIndex = ReaderUtil.subIndex(targetDocID, leaves);
@@ -390,7 +390,7 @@ public class MultiDocValues {
@Override
public boolean advanceExact(int targetDocID) throws IOException {
- if (targetDocID <= docID) {
+ if (targetDocID < docID) {
throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID);
}
int readerIndex = ReaderUtil.subIndex(targetDocID, leaves);
@@ -525,7 +525,7 @@ public class MultiDocValues {
@Override
public boolean advanceExact(int targetDocID) throws IOException {
- if (targetDocID <= docID) {
+ if (targetDocID < docID) {
throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID);
}
int readerIndex = ReaderUtil.subIndex(targetDocID, leaves);
@@ -1007,7 +1007,7 @@ public class MultiDocValues {
@Override
public boolean advanceExact(int targetDocID) throws IOException {
- if (targetDocID <= docID) {
+ if (targetDocID < docID) {
throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID);
}
int readerIndex = ReaderUtil.subIndex(targetDocID, docStarts);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/325b74e0/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java b/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java
index f6669d5..7d4d74f 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestMultiDocValues.java
@@ -71,7 +71,8 @@ public class TestMultiDocValues extends LuceneTestCase {
assertEquals(single.longValue(), multi.longValue());
}
testRandomAdvance(merged.getNumericDocValues("numbers"), MultiDocValues.getNumericValues(ir, "numbers"));
-
+ testRandomAdvanceExact(merged.getNumericDocValues("numbers"), MultiDocValues.getNumericValues(ir, "numbers"), merged.maxDoc());
+
ir.close();
ir2.close();
dir.close();
@@ -113,6 +114,7 @@ public class TestMultiDocValues extends LuceneTestCase {
assertEquals(expected, actual);
}
testRandomAdvance(merged.getBinaryDocValues("bytes"), MultiDocValues.getBinaryValues(ir, "bytes"));
+ testRandomAdvanceExact(merged.getBinaryDocValues("bytes"), MultiDocValues.getBinaryValues(ir, "bytes"), merged.maxDoc());
ir.close();
ir2.close();
@@ -164,6 +166,7 @@ public class TestMultiDocValues extends LuceneTestCase {
assertEquals(single.ordValue(), multi.ordValue());
}
testRandomAdvance(merged.getSortedDocValues("bytes"), MultiDocValues.getSortedValues(ir, "bytes"));
+ testRandomAdvanceExact(merged.getSortedDocValues("bytes"), MultiDocValues.getSortedValues(ir, "bytes"), merged.maxDoc());
ir.close();
ir2.close();
dir.close();
@@ -209,6 +212,7 @@ public class TestMultiDocValues extends LuceneTestCase {
assertEquals(expected, actual);
}
testRandomAdvance(merged.getSortedDocValues("bytes"), MultiDocValues.getSortedValues(ir, "bytes"));
+ testRandomAdvanceExact(merged.getSortedDocValues("bytes"), MultiDocValues.getSortedValues(ir, "bytes"), merged.maxDoc());
ir.close();
ir2.close();
@@ -275,6 +279,7 @@ public class TestMultiDocValues extends LuceneTestCase {
}
}
testRandomAdvance(merged.getSortedSetDocValues("bytes"), MultiDocValues.getSortedSetValues(ir, "bytes"));
+ testRandomAdvanceExact(merged.getSortedSetDocValues("bytes"), MultiDocValues.getSortedSetValues(ir, "bytes"), merged.maxDoc());
ir.close();
ir2.close();
@@ -341,7 +346,8 @@ public class TestMultiDocValues extends LuceneTestCase {
}
}
testRandomAdvance(merged.getSortedSetDocValues("bytes"), MultiDocValues.getSortedSetValues(ir, "bytes"));
-
+ testRandomAdvanceExact(merged.getSortedSetDocValues("bytes"), MultiDocValues.getSortedSetValues(ir, "bytes"), merged.maxDoc());
+
ir.close();
ir2.close();
dir.close();
@@ -391,6 +397,7 @@ public class TestMultiDocValues extends LuceneTestCase {
}
}
testRandomAdvance(merged.getSortedNumericDocValues("nums"), MultiDocValues.getSortedNumericValues(ir, "nums"));
+ testRandomAdvanceExact(merged.getSortedNumericDocValues("nums"), MultiDocValues.getSortedNumericValues(ir, "nums"), merged.maxDoc());
ir.close();
ir2.close();
@@ -410,4 +417,12 @@ public class TestMultiDocValues extends LuceneTestCase {
}
}
}
+
+ private void testRandomAdvanceExact(DocValuesIterator iter1, DocValuesIterator iter2, int maxDoc) throws IOException {
+ for (int target = random().nextInt(Math.min(maxDoc, 10)); target < maxDoc; target += random().nextInt(10)) {
+ final boolean exists1 = iter1.advanceExact(target);
+ final boolean exists2 = iter2.advanceExact(target);
+ assertEquals(exists1, exists2);
+ }
+ }
}