Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0B1A1200AE8 for ; Tue, 3 May 2016 13:32:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 09F261609F4; Tue, 3 May 2016 13:32:18 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 534E41609F3 for ; Tue, 3 May 2016 13:32:17 +0200 (CEST) Received: (qmail 92928 invoked by uid 500); 3 May 2016 11:32:16 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 92919 invoked by uid 99); 3 May 2016 11:32:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 May 2016 11:32:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3C995DFB81; Tue, 3 May 2016 11:32:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mikemccand@apache.org To: commits@lucene.apache.org Message-Id: <48ca484fa7514e5a8c55fdd164a12705@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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, 3 May 2016 11:32:16 +0000 (UTC) archived-at: Tue, 03 May 2016 11:32:18 -0000 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 Authored: Tue May 3 07:31:11 2016 -0400 Committer: Mike McCandless 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);