You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2020/07/07 23:37:10 UTC

[incubator-datasketches-java] 07/10: Merge branch 'master' into Refactor_Theta_Tuple

This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch Refactor_Theta_Tuple
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-java.git

commit 46746a8133669c77f9db52e84ba3ce1f2a4e379c
Merge: 8736b03 eead07c
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Thu Jul 2 18:09:17 2020 -0700

    Merge branch 'master' into Refactor_Theta_Tuple

 src/main/java/org/apache/datasketches/theta/Sketch.java       |  1 +
 .../java/org/apache/datasketches/tuple/QuickSelectSketch.java |  2 +-
 .../tuple/arrayofdoubles/ArrayOfDoublesQuickSelectSketch.java |  4 ++--
 .../apache/datasketches/tuple/adouble/AdoubleAnotBTest.java   |  2 +-
 .../datasketches/tuple/aninteger/IntegerSketchTest.java       | 11 ++++++-----
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --cc src/main/java/org/apache/datasketches/theta/Sketch.java
index 251abc8,7e7be3a..d65c5cb
--- a/src/main/java/org/apache/datasketches/theta/Sketch.java
+++ b/src/main/java/org/apache/datasketches/theta/Sketch.java
@@@ -633,8 -589,61 +633,9 @@@ public abstract class Sketch 
      }
    }
  
 -  /*
 -   * The truth table for empty, curCount and theta when compacting is as follows:
 -   * <pre>
 -   * Num Theta CurCount Empty State    Comments
 -   *  0    1.0     0      T     OK     The Normal Empty State
 -   *  1    1.0     0      F   Internal This can result from an intersection of two exact, disjoint sets,
 -   *                                   or AnotB of two exact, identical sets. There is no probability
 -   *                                   distribution, so change to empty. Return {Th = 1.0, 0, T}.
 -   *                                   This is handled in SetOperation.createCompactSketch().
 -   *  2    1.0    !0      T   Error    Empty=T and curCount !0 should never co-exist.
 -   *                                   This is checked in all compacting operations.
 -   *  3    1.0    !0      F     OK     This corresponds to a sketch in exact mode
 -   *  4   <1.0     0      T   Internal This can be an initial UpdateSketch state if p < 1.0,
 -   *                                   so change theta to 1.0. Return {Th = 1.0, 0, T}.
 -   *                                   This is handled in UpdateSketch.compact() and toByteArray().
 -   *  5   <1.0     0      F     OK     This can result from set operations
 -   *  6   <1.0    !0      T   Error    Empty=T and curCount !0 should never co-exist.
 -   *                                   This is checked in all compacting operations.
 -   *  7   <1.0    !0      F     OK     This corresponds to a sketch in estimation mode
 -   * </pre>
 -   */
 -
 -  /**
 -   * This checks for the illegal condition where curCount > 0 and the state of
 -   * empty = true.  This check can be used anywhere a sketch is returned or a sketch is created
 -   * from complete arguments.
 -   * @param empty the given empty state
 -   * @param curCount the given current count
 -   */ //This handles #2 and #6 above
 -  static final void checkIllegalCurCountAndEmpty(final boolean empty, final int curCount) {
 -    if (empty && (curCount != 0)) { //this handles #2 and #6 above
 -      throw new SketchesStateException("Illegal State: Empty=true and Current Count != 0.");
 -    }
 -  }
 -
 -  /**
 -   * This corrects a temporary anomalous condition where compact() is called on an UpdateSketch
 -   * that was initialized with p < 1.0 and update() was never called.  In this case Theta < 1.0,
 -   * curCount = 0, and empty = true.  The correction is to change Theta to 1.0, which makes the
 -   * returning sketch empty. This should only be used in the compaction or serialization of an
 -   * UpdateSketch.
 -   * @param empty the given empty state
 -   * @param curCount the given curCount
 -   * @param thetaLong the given thetaLong
 -   * @return thetaLong
 -   */ //This handles #4 above
 -  static final long correctThetaOnCompact(final boolean empty, final int curCount,
 -      final long thetaLong) {
 -    return (empty && (curCount == 0) && (thetaLong < Long.MAX_VALUE)) ? Long.MAX_VALUE : thetaLong;
 -  }
 -
 -
+ 
    static final double estimate(final long thetaLong, final int curCount) {
 -    return curCount * (MAX_THETA_LONG_AS_DOUBLE / thetaLong);
 +    return curCount * (LONG_MAX_VALUE_AS_DOUBLE / thetaLong);
    }
  
    static final double lowerBound(final int curCount, final long thetaLong, final int numStdDev,


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