Skip to content

Commit 7b229f3

Browse files
committed
fix: raise exception in floats
1 parent 7eff3a8 commit 7b229f3

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/main/java/org/apache/datasketches/quantilescommon/FloatsSketchSortedView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ public long[] getCumulativeWeights() {
7474

7575
@Override
7676
public float getMaxItem() {
77+
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
7778
final int top = quantiles.length - 1;
7879
return quantiles[top];
7980
}
8081

8182
@Override
8283
public float getMinItem() {
84+
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
8385
return quantiles[0];
8486
}
8587

src/main/java/org/apache/datasketches/quantilescommon/FloatsSortedView.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.apache.datasketches.quantilescommon;
2121

22+
import org.apache.datasketches.common.SketchesArgumentException;
23+
2224
/**
2325
* The Sorted View for quantiles of primitive type float.
2426
* @see SortedView
@@ -58,7 +60,7 @@ public interface FloatsSortedView extends SortedView {
5860
* </blockquote>
5961
* @param searchCrit the desired search criteria.
6062
* @return a discrete CDF array of m+1 double ranks (or cumulative probabilities) on the interval [0.0, 1.0].
61-
* @throws IllegalArgumentException if sketch is empty.
63+
* @throws SketchesArgumentException if sketch is empty.
6264
*/
6365
default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria searchCrit) {
6466
QuantilesUtil.checkFloatsSplitPointsOrder(splitPoints);
@@ -76,7 +78,7 @@ default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria
7678
* sketch algorithm.
7779
*
7880
* @return the maximum item of the stream
79-
* @throws IllegalArgumentException if sketch is empty.
81+
* @throws SketchesArgumentException if sketch is empty.
8082
*/
8183
float getMaxItem();
8284

@@ -85,7 +87,7 @@ default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria
8587
* sketch algorithm.
8688
*
8789
* @return the minimum item of the stream
88-
* @throws IllegalArgumentException if sketch is empty.
90+
* @throws SketchesArgumentException if sketch is empty.
8991
*/
9092
float getMinItem();
9193

@@ -127,7 +129,7 @@ default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria
127129
* </blockquote>
128130
* @param searchCrit the desired search criteria.
129131
* @return a PMF array of m+1 probability masses as doubles on the interval [0.0, 1.0].
130-
* @throws IllegalArgumentException if sketch is empty.
132+
* @throws SketchesArgumentException if sketch is empty.
131133
*/
132134
default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria searchCrit) {
133135
final double[] buckets = getCDF(splitPoints, searchCrit);
@@ -147,7 +149,7 @@ default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria
147149
* If EXCLUSIVE, he given rank includes all quantiles &lt;
148150
* the quantile directly corresponding to the given rank.
149151
* @return the approximate quantile given the normalized rank.
150-
* @throws IllegalArgumentException if sketch is empty.
152+
* @throws SketchesArgumentException if sketch is empty.
151153
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
152154
*/
153155
float getQuantile(double rank, QuantileSearchCriteria searchCrit);
@@ -164,7 +166,7 @@ default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria
164166
* @param quantile the given quantile
165167
* @param searchCrit if INCLUSIVE the given quantile is included into the rank.
166168
* @return the normalized rank corresponding to the given quantile.
167-
* @throws IllegalArgumentException if sketch is empty.
169+
* @throws SketchesArgumentException if sketch is empty.
168170
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
169171
*/
170172
double getRank(float quantile, QuantileSearchCriteria searchCrit);
@@ -173,4 +175,3 @@ default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria
173175
FloatsSortedViewIterator iterator();
174176

175177
}
176-

0 commit comments

Comments
 (0)