lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject lucene-solr:branch_6x: LUCENE-7269: also handle annoying schema ghost corner case where number of docs with points in a segment is 0
Date Tue, 03 May 2016 11:32:16 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 96cde1d41 -> 920051f05


LUCENE-7269: also handle annoying schema ghost corner case where number of docs with points
in a segment is 0


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

Branch: refs/heads/branch_6x
Commit: 920051f0504a3cc18bdc256e3e25a24cc9b4c69f
Parents: 96cde1d
Author: Mike McCandless <mikemccand@apache.org>
Authored: Tue May 3 07:31:11 2016 -0400
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Tue May 3 07:31:55 2016 -0400

----------------------------------------------------------------------
 .../org/apache/lucene/util/DocIdSetBuilder.java    | 17 ++++++++++-------
 .../apache/lucene/util/TestDocIdSetBuilder.java    |  6 ++++++
 2 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/920051f0/lucene/core/src/java/org/apache/lucene/util/DocIdSetBuilder.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/util/DocIdSetBuilder.java b/lucene/core/src/java/org/apache/lucene/util/DocIdSetBuilder.java
index a00fdca..0301ba8 100644
--- a/lucene/core/src/java/org/apache/lucene/util/DocIdSetBuilder.java
+++ b/lucene/core/src/java/org/apache/lucene/util/DocIdSetBuilder.java
@@ -101,13 +101,16 @@ public final class DocIdSetBuilder {
   DocIdSetBuilder(int maxDoc, int docCount, long valueCount) {
     this.maxDoc = maxDoc;
     this.multivalued = docCount < 0 || docCount != valueCount;
-    this.numValuesPerDoc = (docCount < 0 || valueCount < 0)
-        // assume one value per doc, this means the cost will be overestimated
-        // if the docs are actually multi-valued
-        ? 1
-        // otherwise compute from index stats
-        : (double) valueCount / docCount;
-    assert numValuesPerDoc >= 1;
+    if (docCount <= 0 || valueCount < 0) {
+      // assume one value per doc, this means the cost will be overestimated
+      // if the docs are actually multi-valued
+      this.numValuesPerDoc = 1;
+    } else {
+      // otherwise compute from index stats
+      this.numValuesPerDoc = (double) valueCount / docCount;
+    }
+
+    assert numValuesPerDoc >= 1: "valueCount=" + valueCount + " docCount=" + docCount;
 
     // For ridiculously small sets, we'll just use a sorted int[]
     // maxDoc >>> 7 is a good value if you want to save memory, lower values

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/920051f0/lucene/core/src/test/org/apache/lucene/util/TestDocIdSetBuilder.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/TestDocIdSetBuilder.java b/lucene/core/src/test/org/apache/lucene/util/TestDocIdSetBuilder.java
index 5dd8eb3..62e85fe 100644
--- a/lucene/core/src/test/org/apache/lucene/util/TestDocIdSetBuilder.java
+++ b/lucene/core/src/test/org/apache/lucene/util/TestDocIdSetBuilder.java
@@ -161,6 +161,12 @@ public class TestDocIdSetBuilder extends LuceneTestCase {
     assertEquals(new BitDocIdSet(expected), builder.build());
   }
 
+  public void testEmptyPoints() throws IOException {
+    PointValues values = new DummyPointValues(0, 0);
+    DocIdSetBuilder builder = new DocIdSetBuilder(1, values, "foo");
+    assertEquals(1d, builder.numValuesPerDoc, 0d);
+  }
+
   public void testLeverageStats() throws IOException {
     // single-valued points
     PointValues values = new DummyPointValues(42, 42);


Mime
View raw message