diff --git a/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketch.java b/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketch.java index 189a8f7ecdb09..67938644d9f6c 100644 --- a/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketch.java +++ b/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketch.java @@ -120,11 +120,11 @@ public int getVersionNumber() { * Note that only Count-Min sketches with the same {@code depth}, {@code width}, and random seed * can be merged. * - * @exception CountMinSketchMergeException if the {@code other} {@link CountMinSketch} has + * @exception IncompatibleMergeException if the {@code other} {@link CountMinSketch} has * incompatible depth, width, relative-error, confidence, or random seed. */ public abstract CountMinSketch mergeInPlace(CountMinSketch other) - throws CountMinSketchMergeException; + throws IncompatibleMergeException; /** * Writes out this {@link CountMinSketch} to an output stream in binary format. diff --git a/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchImpl.java b/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchImpl.java index 2ea57ea59e3dd..8ea716df4a5cf 100644 --- a/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchImpl.java +++ b/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchImpl.java @@ -287,27 +287,29 @@ private long estimateCountForStringItem(String item) { } @Override - public CountMinSketch mergeInPlace(CountMinSketch other) throws CountMinSketchMergeException { + public CountMinSketch mergeInPlace(CountMinSketch other) throws IncompatibleMergeException { if (other == null) { - throw new CountMinSketchMergeException("Cannot merge null estimator"); + throw new IncompatibleMergeException("Cannot merge null estimator"); } if (!(other instanceof CountMinSketchImpl)) { - throw new CountMinSketchMergeException("Cannot merge estimator of class " + other.getClass().getName()); + throw new IncompatibleMergeException( + "Cannot merge estimator of class " + other.getClass().getName() + ); } CountMinSketchImpl that = (CountMinSketchImpl) other; if (this.depth != that.depth) { - throw new CountMinSketchMergeException("Cannot merge estimators of different depth"); + throw new IncompatibleMergeException("Cannot merge estimators of different depth"); } if (this.width != that.width) { - throw new CountMinSketchMergeException("Cannot merge estimators of different width"); + throw new IncompatibleMergeException("Cannot merge estimators of different width"); } if (!Arrays.equals(this.hashA, that.hashA)) { - throw new CountMinSketchMergeException("Cannot merge estimators of different seed"); + throw new IncompatibleMergeException("Cannot merge estimators of different seed"); } for (int i = 0; i < this.table.length; ++i) { diff --git a/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchMergeException.java b/common/sketch/src/main/java/org/apache/spark/util/sketch/IncompatibleMergeException.java similarity index 88% rename from common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchMergeException.java rename to common/sketch/src/main/java/org/apache/spark/util/sketch/IncompatibleMergeException.java index e751556421bb1..64b567caa57c1 100644 --- a/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchMergeException.java +++ b/common/sketch/src/main/java/org/apache/spark/util/sketch/IncompatibleMergeException.java @@ -17,8 +17,8 @@ package org.apache.spark.util.sketch; -public class CountMinSketchMergeException extends Exception { - public CountMinSketchMergeException(String message) { +public class IncompatibleMergeException extends Exception { + public IncompatibleMergeException(String message) { super(message); } } diff --git a/common/sketch/src/test/scala/org/apache/spark/util/sketch/CountMinSketchSuite.scala b/common/sketch/src/test/scala/org/apache/spark/util/sketch/CountMinSketchSuite.scala index 631f79b71e2c4..be4984e9cb304 100644 --- a/common/sketch/src/test/scala/org/apache/spark/util/sketch/CountMinSketchSuite.scala +++ b/common/sketch/src/test/scala/org/apache/spark/util/sketch/CountMinSketchSuite.scala @@ -134,17 +134,17 @@ class CountMinSketchSuite extends FunSuite { // scalastyle:ignore funsuite testItemType[String]("String") { r => r.nextString(r.nextInt(20)) } test("incompatible merge") { - intercept[CountMinSketchMergeException] { + intercept[IncompatibleMergeException] { CountMinSketch.create(10, 10, 1).mergeInPlace(null) } - intercept[CountMinSketchMergeException] { + intercept[IncompatibleMergeException] { val sketch1 = CountMinSketch.create(10, 20, 1) val sketch2 = CountMinSketch.create(10, 20, 2) sketch1.mergeInPlace(sketch2) } - intercept[CountMinSketchMergeException] { + intercept[IncompatibleMergeException] { val sketch1 = CountMinSketch.create(10, 10, 1) val sketch2 = CountMinSketch.create(10, 20, 2) sketch1.mergeInPlace(sketch2)