lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject [33/37] lucene-solr:jira/solr-8542-v2: LUCENE-7528: Fix Lucene54's advanceExact impl in the sparse case.
Date Mon, 31 Oct 2016 14:06:26 GMT
LUCENE-7528: Fix Lucene54's advanceExact impl in the sparse case.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/66c90a96
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/66c90a96
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/66c90a96

Branch: refs/heads/jira/solr-8542-v2
Commit: 66c90a9683407eee52e85120cb1e80fd9dd905f5
Parents: 325b74e
Author: Adrien Grand <jpountz@gmail.com>
Authored: Mon Oct 31 10:36:26 2016 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Mon Oct 31 10:54:54 2016 +0100

----------------------------------------------------------------------
 .../lucene54/Lucene54DocValuesProducer.java     |  2 +-
 .../lucene54/TestLucene54DocValuesFormat.java   | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/66c90a96/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54DocValuesProducer.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54DocValuesProducer.java
b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54DocValuesProducer.java
index f1c169c..a35f503 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54DocValuesProducer.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54DocValuesProducer.java
@@ -715,7 +715,7 @@ final class Lucene54DocValuesProducer extends DocValuesProducer implements
Close
       }
       --index;
       doc = target;
-      return false;
+      return index >= 0 && docIds.get(index) == target;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/66c90a96/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene54/TestLucene54DocValuesFormat.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene54/TestLucene54DocValuesFormat.java
b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene54/TestLucene54DocValuesFormat.java
index b231716..a761dfc 100644
--- a/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene54/TestLucene54DocValuesFormat.java
+++ b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene54/TestLucene54DocValuesFormat.java
@@ -488,6 +488,33 @@ public class TestLucene54DocValuesFormat extends BaseCompressingDocValuesFormatT
         }
       }
 
+      // advanceExact
+      for (int i = 0; i < 2000; ++i) {
+        sparseValues.reset();
+        if (random().nextBoolean() && docIds.length > 0) {
+          sparseValues.advance(docIds[TestUtil.nextInt(random(), 0, docIds.length - 1)]);
+        }
+
+        final int target = TestUtil.nextInt(random(), Math.max(0, sparseValues.docID()),
maxDoc - 1);
+        final boolean exists = sparseValues.advanceExact(target);
+        
+        final int index = Arrays.binarySearch(docIds, target);
+        assertEquals(index >= 0, exists);
+        assertEquals(target, sparseValues.docID());
+
+        final boolean exists2 = sparseValues.advanceExact(target);
+        assertEquals(index >= 0, exists2);
+        assertEquals(target, sparseValues.docID());
+
+        final int nextIndex = index >= 0 ? index + 1 : -1 - index;
+        if (nextIndex >= docIds.length) {
+          assertEquals(DocIdSetIterator.NO_MORE_DOCS, sparseValues.nextDoc());
+        } else {
+          assertEquals(docIds[nextIndex], sparseValues.nextDoc());
+        }
+      }
+      
+
       final SparseNumericDocValuesRandomAccessWrapper raWrapper = new SparseNumericDocValuesRandomAccessWrapper(sparseValues,
missingValue);
 
       // random-access


Mime
View raw message