Skip to content
Permalink
Browse files
Merge pull request #385 from apache/FixAoDIntersect
Changed AoDIntersection check of matching numValues to an exception
  • Loading branch information
leerho committed Feb 2, 2022
2 parents 1e14bf1 + 0d46640 commit 3ef667872d196e500cf2a4dd5c064071aafaef83
Showing 3 changed files with 11 additions and 5 deletions.
@@ -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);
@@ -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;
@@ -117,6 +117,7 @@ public static ArrayOfDoublesUnion wrap(final WritableMemory srcMem, final long s

/**
* 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>
*

0 comments on commit 3ef6678

Please sign in to comment.