You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2019/10/03 18:07:54 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #905: LUCENE-8990: Add estimateDocCount(visitor) method to PointValues

jpountz commented on a change in pull request #905: LUCENE-8990: Add estimateDocCount(visitor) method to PointValues
URL: https://github.com/apache/lucene-solr/pull/905#discussion_r331111490
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/index/PointValues.java
 ##########
 @@ -241,9 +241,28 @@ default void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOExcep
    * than {@link #intersect(IntersectVisitor)}.
    * @see DocIdSetIterator#cost */
   public long estimateDocCount(IntersectVisitor visitor) {
-    return (long) Math.ceil(estimatePointCount(visitor) / ((double) size() / getDocCount()));
+    long estimatedPointCount = estimatePointCount(visitor);
+    int docCount = getDocCount();
+    double size = size();
+    if (estimatedPointCount >= size) {
+      // math all docs
+      return docCount;
+    } else if (size == docCount || estimatedPointCount == 0L ) {
+      // if the point count estimate is 0 or we have only single values
+      // return this estimate
+      return  estimatedPointCount;
+    } else {
+      // in case of multi values estimate the number of docs using the solution provided in
+      // https://math.stackexchange.com/questions/1175295/urn-problem-probability-of-drawing-balls-of-k-unique-colors
+      // then approximate the solution for points per doc << size() which results in the expression
+      // D * (1 - ((N - n) / N)^(N/D))
 
 Review comment:
   maybe clarify what are D, N and n?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org