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 2022/02/02 00:23:01 UTC

[datasketches-java] branch FixAoDIntersect created (now 0d46640)

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

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


      at 0d46640  Changed AoDIntersection check of matching numValues to an exception instead of an assert.

This branch includes the following new commits:

     new 0d46640  Changed AoDIntersection check of matching numValues to an exception instead of an assert.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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


[datasketches-java] 01/01: Changed AoDIntersection check of matching numValues to an exception instead of an assert.

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0d46640afc9c3b13b2c70edd950315a223a0e321
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Tue Feb 1 16:22:49 2022 -0800

    Changed AoDIntersection check of matching numValues to an exception
    instead of an assert.
    
    Added Javadoc comments relevant to this requirement to Union, AnotB and
    Intersection.
---
 .../datasketches/tuple/arrayofdoubles/ArrayOfDoublesAnotB.java   | 9 +++++----
 .../tuple/arrayofdoubles/ArrayOfDoublesIntersection.java         | 6 +++++-
 .../datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java   | 1 +
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesAnotB.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesAnotB.java
index 65a7c27..5fda000 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesAnotB.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesAnotB.java
@@ -32,11 +32,12 @@ public abstract class ArrayOfDoublesAnotB {
    * Perform A-and-not-B set operation on the two given sketches.
    * A null sketch is interpreted as an empty sketch.
    * This is not an accumulating update. Calling update() more than once
-   * without calling getResult() will discard the result of previous update()
-   * 
+   * without calling getResult() will discard the result of previous update().
+   * Both input sketches must have the same <i>numValues</i>.
+   *
    * @param a The incoming sketch for the first argument
    * @param b The incoming sketch for the second argument
-   */  
+   */
   public abstract void update(ArrayOfDoublesSketch a, ArrayOfDoublesSketch b);
 
   /**
@@ -48,7 +49,7 @@ public abstract class ArrayOfDoublesAnotB {
   /**
    * Gets the result of this operation in the form of a ArrayOfDoublesCompactSketch
    * @param mem memory for the result (can be null)
-   * @return compact sketch representing the result of the operation (off-heap if memory is 
+   * @return compact sketch representing the result of the operation (off-heap if memory is
    * provided)
    */
   public abstract ArrayOfDoublesCompactSketch getResult(WritableMemory mem);
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java
index 53b42fb..2ac468b 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesIntersection.java
@@ -58,13 +58,17 @@ public abstract class ArrayOfDoublesIntersection {
 
   /**
    * Performs a stateful intersection of the internal set with the given tupleSketch.
+   * The given tupleSketch and the internal state must have the same <i>numValues</i>.
    * @param tupleSketch Input sketch to intersect with the internal set.
    * @param combiner Method of combining two arrays of double values
    */
   public void intersect(final ArrayOfDoublesSketch tupleSketch, final ArrayOfDoublesCombiner combiner) {
     if (tupleSketch == null) { throw new SketchesArgumentException("Sketch must not be null"); }
     Util.checkSeedHashes(seedHash_, tupleSketch.getSeedHash());
-    assert tupleSketch.numValues_ == numValues_;
+    if (tupleSketch.numValues_ != numValues_) {
+      throw new SketchesArgumentException(
+          "Input tupleSketch cannot have different numValues from the internal numValues.");
+    }
 
     final boolean isFirstCall = firstCall_;
     firstCall_ = false;
diff --git a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java
index 965a54a..aaa5406 100644
--- a/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java
+++ b/src/main/java/org/apache/datasketches/tuple/arrayofdoubles/ArrayOfDoublesUnion.java
@@ -117,6 +117,7 @@ public abstract class ArrayOfDoublesUnion {
 
   /**
    * Updates the union by adding a set of entries from a given sketch, which can be on-heap or off-heap.
+   * Both the given tupleSketch and the internal state of the Union must have the same <i>numValues</i>.
    *
    * <p>Nulls and empty sketches are ignored.</p>
    *

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