You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by "AlexanderSaydakov (via GitHub)" <gi...@apache.org> on 2023/02/27 20:45:07 UTC

[GitHub] [datasketches-java] AlexanderSaydakov commented on a diff in pull request #430: HLL relative error

AlexanderSaydakov commented on code in PR #430:
URL: https://github.com/apache/datasketches-java/pull/430#discussion_r1119292064


##########
src/main/java/org/apache/datasketches/hll/BaseHllSketch.java:
##########
@@ -118,8 +120,14 @@ public static final int getSerializationVersion(final Memory mem) {
    * <a href="{@docRoot}/resources/dictionary.html#numStdDev">Number of Standard Deviations</a>
    * @return the current (approximate) RelativeError
    */
-  public double getRelErr(final boolean upperBound, final boolean unioned,
+  public static double getRelErr(final boolean upperBound, final boolean unioned,
       final int lgConfigK, final int numStdDev) {
+    HllUtil.checkLgK(lgConfigK);
+    if (lgConfigK > 12) {
+      final double rseFactor = unioned ? HLL_NON_HIP_RSE_FACTOR : HLL_HIP_RSE_FACTOR;
+      final int configK = 1 << lgConfigK;
+      return (upperBound ? -1.0 : 1.0) * (numStdDev * rseFactor) / Math.sqrt(configK);

Review Comment:
   this method did return negative values for UB before. It did not handle lgK > 12. I fixed that.
   I agree that returning negative is confusing, but changing that might break somebody's code. Perhaps it is fine now in Java since we are getting ready for a major release, but I am no sure how to approach this in C++, where we had a major release recently.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org