c21 commented on a change in pull request #32907:
URL: https://github.com/apache/spark/pull/32907#discussion_r651446735



##########
File path: 
common/sketch/src/main/java/org/apache/spark/util/sketch/BloomFilterImpl.java
##########
@@ -193,14 +193,29 @@ public boolean isCompatible(BloomFilter other) {
 
   @Override
   public BloomFilter mergeInPlace(BloomFilter other) throws 
IncompatibleMergeException {
+    BloomFilterImpl otherImplInstance = checkCompatibilityForMerge(other);
+
+    this.bits.putAll(otherImplInstance.bits);
+    return this;
+  }
+
+  @Override
+  public BloomFilter intersectInPlace(BloomFilter other) throws 
IncompatibleMergeException {
+    BloomFilterImpl otherImplInstance = checkCompatibilityForMerge(other);
+
+    this.bits.and(otherImplInstance.bits);
+    return this;
+  }
+
+  private BloomFilterImpl checkCompatibilityForMerge(BloomFilter other) throws 
IncompatibleMergeException {
     // Duplicates the logic of `isCompatible` here to provide better error 
message.
     if (other == null) {
       throw new IncompatibleMergeException("Cannot merge null bloom filter");
     }
 
     if (!(other instanceof BloomFilterImpl)) {
       throw new IncompatibleMergeException(
-        "Cannot merge bloom filter of class " + other.getClass().getName()
+              "Cannot merge bloom filter of class " + 
other.getClass().getName()

Review comment:
       nit: seem to be unnecessary changed indentation.

##########
File path: 
common/sketch/src/main/java/org/apache/spark/util/sketch/BloomFilterImpl.java
##########
@@ -212,12 +227,10 @@ public BloomFilter mergeInPlace(BloomFilter other) throws 
IncompatibleMergeExcep
 
     if (this.numHashFunctions != that.numHashFunctions) {
       throw new IncompatibleMergeException(
-        "Cannot merge bloom filters with different number of hash functions"
+              "Cannot merge bloom filters with different number of hash 
functions"

Review comment:
       nit: seem to be unnecessary changed indentation.




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to