Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ public long[] getCumulativeWeights() {

@Override
public double getMaxItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
final int top = quantiles.length - 1;
return quantiles[top];
}

@Override
public double getMinItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
return quantiles[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.apache.datasketches.quantilescommon;

import org.apache.datasketches.common.SketchesArgumentException;

/**
* The Sorted View for quantile sketches of primitive type double.
* @see SortedView
Expand Down Expand Up @@ -58,7 +60,7 @@ public interface DoublesSortedView extends SortedView {
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a discrete CDF array of m+1 double ranks (or cumulative probabilities) on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getCDF(final double[] splitPoints, final QuantileSearchCriteria searchCrit) {
QuantilesUtil.checkDoublesSplitPointsOrder(splitPoints);
Expand All @@ -76,7 +78,7 @@ default double[] getCDF(final double[] splitPoints, final QuantileSearchCriteria
* sketch algorithm.
*
* @return the maximum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
double getMaxItem();

Expand All @@ -85,7 +87,7 @@ default double[] getCDF(final double[] splitPoints, final QuantileSearchCriteria
* sketch algorithm.
*
* @return the minimum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
double getMinItem();

Expand Down Expand Up @@ -127,7 +129,7 @@ default double[] getCDF(final double[] splitPoints, final QuantileSearchCriteria
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a PMF array of m+1 probability masses as doubles on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getPMF(final double[] splitPoints, final QuantileSearchCriteria searchCrit) {
final double[] buckets = getCDF(splitPoints, searchCrit);
Expand All @@ -147,7 +149,7 @@ default double[] getPMF(final double[] splitPoints, final QuantileSearchCriteri
* If EXCLUSIVE, he given rank includes all quantiles &lt;
* the quantile directly corresponding to the given rank.
* @return the approximate quantile given the normalized rank.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see QuantileSearchCriteria
*/
double getQuantile(double rank, QuantileSearchCriteria searchCrit);
Expand All @@ -164,7 +166,7 @@ default double[] getPMF(final double[] splitPoints, final QuantileSearchCriteri
* @param quantile the given quantile
* @param searchCrit if INCLUSIVE the given quantile is included into the rank.
* @return the normalized rank corresponding to the given quantile.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see QuantileSearchCriteria
*/
double getRank(double quantile, QuantileSearchCriteria searchCrit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ public long[] getCumulativeWeights() {

@Override
public float getMaxItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
final int top = quantiles.length - 1;
return quantiles[top];
}

@Override
public float getMinItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
return quantiles[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.apache.datasketches.quantilescommon;

import org.apache.datasketches.common.SketchesArgumentException;

/**
* The Sorted View for quantiles of primitive type float.
* @see SortedView
Expand Down Expand Up @@ -58,7 +60,7 @@ public interface FloatsSortedView extends SortedView {
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a discrete CDF array of m+1 double ranks (or cumulative probabilities) on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria searchCrit) {
QuantilesUtil.checkFloatsSplitPointsOrder(splitPoints);
Expand All @@ -76,7 +78,7 @@ default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria
* sketch algorithm.
*
* @return the maximum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
float getMaxItem();

Expand All @@ -85,7 +87,7 @@ default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria
* sketch algorithm.
*
* @return the minimum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
float getMinItem();

Expand Down Expand Up @@ -127,7 +129,7 @@ default double[] getCDF(final float[] splitPoints, final QuantileSearchCriteria
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a PMF array of m+1 probability masses as doubles on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria searchCrit) {
final double[] buckets = getCDF(splitPoints, searchCrit);
Expand All @@ -147,7 +149,7 @@ default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria
* If EXCLUSIVE, he given rank includes all quantiles &lt;
* the quantile directly corresponding to the given rank.
* @return the approximate quantile given the normalized rank.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
float getQuantile(double rank, QuantileSearchCriteria searchCrit);
Expand All @@ -164,7 +166,7 @@ default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria
* @param quantile the given quantile
* @param searchCrit if INCLUSIVE the given quantile is included into the rank.
* @return the normalized rank corresponding to the given quantile.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
double getRank(float quantile, QuantileSearchCriteria searchCrit);
Expand All @@ -173,4 +175,3 @@ default double[] getPMF(final float[] splitPoints, final QuantileSearchCriteria
FloatsSortedViewIterator iterator();

}

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface GenericSortedView<T> extends PartitioningFeature<T>, SketchPar
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a discrete CDF array of m+1 double ranks (or cumulative probabilities) on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getCDF(final T[] splitPoints, final QuantileSearchCriteria searchCrit) {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
Expand All @@ -92,7 +92,7 @@ default double[] getCDF(final T[] splitPoints, final QuantileSearchCriteria sear
* sketch algorithm.
*
* @return the maximum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
T getMaxItem();

Expand All @@ -101,7 +101,7 @@ default double[] getCDF(final T[] splitPoints, final QuantileSearchCriteria sear
* sketch algorithm.
*
* @return the minimum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
T getMinItem();

Expand Down Expand Up @@ -143,7 +143,7 @@ default double[] getCDF(final T[] splitPoints, final QuantileSearchCriteria sear
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a PMF array of m+1 probability masses as doubles on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getPMF(final T[] splitPoints, final QuantileSearchCriteria searchCrit) {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
Expand All @@ -164,7 +164,7 @@ default double[] getPMF(final T[] splitPoints, final QuantileSearchCriteria sear
* If EXCLUSIVE, he given rank includes all quantiles &lt;
* the quantile directly corresponding to the given rank.
* @return the approximate quantile given the normalized rank.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
T getQuantile(double rank, QuantileSearchCriteria searchCrit);
Expand All @@ -181,7 +181,7 @@ default double[] getPMF(final T[] splitPoints, final QuantileSearchCriteria sear
* @param quantile the given quantile
* @param searchCrit if INCLUSIVE the given quantile is included into the rank.
* @return the normalized rank corresponding to the given quantile.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
double getRank(T quantile, QuantileSearchCriteria searchCrit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ public long[] getCumulativeWeights() {

@Override
public T getMaxItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
final int top = quantiles.length - 1;
return quantiles[top];
}

@Override
public T getMinItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
return quantiles[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ public long[] getCumulativeWeights() {

@Override
public long getMaxItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
final int top = quantiles.length - 1;
return quantiles[top];
}

@Override
public long getMinItem() {
if (isEmpty()) { throw new SketchesArgumentException(EMPTY_MSG); }
return quantiles[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.apache.datasketches.quantilescommon;

import org.apache.datasketches.common.SketchesArgumentException;

/**
* The Sorted View for quantile sketches of primitive type long.
* @see SortedView
Expand Down Expand Up @@ -58,7 +60,7 @@ public interface LongsSortedView extends SortedView {
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a discrete CDF array of m+1 double ranks (or cumulative probabilities) on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getCDF(final long[] splitPoints, final QuantileSearchCriteria searchCrit) {
QuantilesUtil.checkLongsSplitPointsOrder(splitPoints);
Expand All @@ -76,7 +78,7 @@ default double[] getCDF(final long[] splitPoints, final QuantileSearchCriteria s
* sketch algorithm.
*
* @return the maximum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
long getMaxItem();

Expand All @@ -85,7 +87,7 @@ default double[] getCDF(final long[] splitPoints, final QuantileSearchCriteria s
* sketch algorithm.
*
* @return the minimum item of the stream
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
long getMinItem();

Expand Down Expand Up @@ -127,7 +129,7 @@ default double[] getCDF(final long[] splitPoints, final QuantileSearchCriteria s
* </blockquote>
* @param searchCrit the desired search criteria.
* @return a PMF array of m+1 probability masses as doubles on the interval [0.0, 1.0].
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
*/
default double[] getPMF(final long[] splitPoints, final QuantileSearchCriteria searchCrit) {
final double[] buckets = getCDF(splitPoints, searchCrit);
Expand All @@ -147,7 +149,7 @@ default double[] getPMF(final long[] splitPoints, final QuantileSearchCriteria s
* If EXCLUSIVE, he given rank includes all quantiles &lt;
* the quantile directly corresponding to the given rank.
* @return the approximate quantile given the normalized rank.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see QuantileSearchCriteria
*/
long getQuantile(double rank, QuantileSearchCriteria searchCrit);
Expand All @@ -164,7 +166,7 @@ default double[] getPMF(final long[] splitPoints, final QuantileSearchCriteria s
* @param quantile the given quantile
* @param searchCrit if INCLUSIVE the given quantile is included into the rank.
* @return the normalized rank corresponding to the given quantile.
* @throws IllegalArgumentException if sketch is empty.
* @throws SketchesArgumentException if sketch is empty.
* @see QuantileSearchCriteria
*/
double getRank(long quantile, QuantileSearchCriteria searchCrit);
Expand Down
Loading
Loading