Skip to content

Commit

Permalink
Merge a930c72 into 38f771c
Browse files Browse the repository at this point in the history
  • Loading branch information
leerho committed Jul 20, 2022
2 parents 38f771c + a930c72 commit c367889
Show file tree
Hide file tree
Showing 12 changed files with 683 additions and 337 deletions.
48 changes: 22 additions & 26 deletions src/main/java/org/apache/datasketches/InequalitySearch.java
Expand Up @@ -85,12 +85,11 @@ int getIndex(final long[] arr, final int a, final int b, final long v) {

@Override
int resolve(final int lo, final int hi, final int low, final int high) {
if (lo >= high) { return high; }
return -1;
return (lo >= high) ? high : -1;
}

@Override
String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
public String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
if (idx == -1) {
return "LT: " + v + " <= arr[" + low + "]=" + arr[low] + "; return -1";
}
Expand All @@ -104,7 +103,7 @@ String desc(final double[] arr, final int low, final int high, final double v, f
}

@Override
String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
public String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
if (idx == -1) {
return "LT: " + v + " <= arr[" + low + "]=" + arr[low] + "; return -1";
}
Expand All @@ -118,7 +117,7 @@ String desc(final float[] arr, final int low, final int high, final float v, fin
}

@Override
String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
public String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
if (idx == -1) {
return "LT: " + v + " <= arr[" + low + "]=" + arr[low] + "; return -1";
}
Expand Down Expand Up @@ -176,12 +175,11 @@ int getIndex(final long[] arr, final int a, final int b, final long v) {

@Override
int resolve(final int lo, final int hi, final int low, final int high) {
if (lo >= high) { return high; }
return -1;
return (lo >= high) ? high : -1;
}

@Override
String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
public String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
if (idx == -1) {
return "LE: " + v + " < arr[" + low + "]=" + arr[low] + "; return -1";
}
Expand All @@ -195,7 +193,7 @@ String desc(final double[] arr, final int low, final int high, final double v, f
}

@Override
String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
public String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
if (idx == -1) {
return "LE: " + v + " < arr[" + low + "]=" + arr[low] + "; return -1";
}
Expand All @@ -209,7 +207,7 @@ String desc(final float[] arr, final int low, final int high, final float v, fin
}

@Override
String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
public String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
if (idx == -1) {
return "LE: " + v + " < arr[" + low + "]=" + arr[low] + "; return -1";
}
Expand Down Expand Up @@ -267,7 +265,7 @@ int resolve(final int lo, final int hi, final int low, final int high) {
}

@Override
String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
public String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
if (idx == -1) {
if (v > arr[high]) {
return "EQ: " + v + " > arr[" + high + "]; return -1";
Expand All @@ -281,7 +279,7 @@ String desc(final double[] arr, final int low, final int high, final double v, f
}

@Override
String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
public String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
if (idx == -1) {
if (v > arr[high]) {
return "EQ: " + v + " > arr[" + high + "]; return -1";
Expand All @@ -295,7 +293,7 @@ String desc(final float[] arr, final int low, final int high, final float v, fin
}

@Override
String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
public String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
if (idx == -1) {
if (v > arr[high]) {
return "EQ: " + v + " > arr[" + high + "]; return -1";
Expand Down Expand Up @@ -353,12 +351,11 @@ int getIndex(final long[] arr, final int a, final int b, final long v) {

@Override
int resolve(final int lo, final int hi, final int low, final int high) {
if (hi <= low) { return low; }
return -1;
return (hi <= low) ? low : -1;
}

@Override
String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
public String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
if (idx == -1) {
return "GE: " + v + " > arr[" + high + "]=" + arr[high] + "; return -1";
}
Expand All @@ -372,7 +369,7 @@ String desc(final double[] arr, final int low, final int high, final double v, f
}

@Override
String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
public String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
if (idx == -1) {
return "GE: " + v + " > arr[" + high + "]=" + arr[high] + "; return -1";
}
Expand All @@ -386,7 +383,7 @@ String desc(final float[] arr, final int low, final int high, final float v, fin
}

@Override
String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
public String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
if (idx == -1) {
return "GE: " + v + " > arr[" + high + "]=" + arr[high] + "; return -1";
}
Expand Down Expand Up @@ -444,12 +441,11 @@ int getIndex(final long[] arr, final int a, final int b, final long v) {

@Override
int resolve(final int lo, final int hi, final int low, final int high) {
if (hi <= low) { return low; }
return -1;
return (hi <= low) ? low : -1;
}

@Override
String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
public String desc(final double[] arr, final int low, final int high, final double v, final int idx) {
if (idx == -1) {
return "GT: " + v + " >= arr[" + high + "]=" + arr[high] + "; return -1";
}
Expand All @@ -463,7 +459,7 @@ String desc(final double[] arr, final int low, final int high, final double v, f
}

@Override
String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
public String desc(final float[] arr, final int low, final int high, final float v, final int idx) {
if (idx == -1) {
return "GT: " + v + " >= arr[" + high + "]=" + arr[high] + "; return -1";
}
Expand All @@ -477,7 +473,7 @@ String desc(final float[] arr, final int low, final int high, final float v, fin
}

@Override
String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
public String desc(final long[] arr, final int low, final int high, final long v, final int idx) {
if (idx == -1) {
return "GT: " + v + " >= arr[" + high + "]=" + arr[high] + "; return -1";
}
Expand Down Expand Up @@ -580,7 +576,7 @@ String desc(final long[] arr, final int low, final int high, final long v, final
* @param idx the resolved index from the search
* @return the descriptive string.
*/
abstract String desc(double[] arr, int low, int high, double v, int idx);
public abstract String desc(double[] arr, int low, int high, double v, int idx);

/**
* Optional call that describes the details of the results of the search.
Expand All @@ -592,7 +588,7 @@ String desc(final long[] arr, final int low, final int high, final long v, final
* @param idx the resolved index from the search
* @return the descriptive string.
*/
abstract String desc(float[] arr, int low, int high, float v, int idx);
public abstract String desc(float[] arr, int low, int high, float v, int idx);

/**
* Optional call that describes the details of the results of the search.
Expand All @@ -604,7 +600,7 @@ String desc(final long[] arr, final int low, final int high, final long v, final
* @param idx the resolved index from the search
* @return the descriptive string.
*/
abstract String desc(long[] arr, int low, int high, long v, int idx);
public abstract String desc(long[] arr, int low, int high, long v, int idx);

/**
* Binary Search for the index of the double value in the given search range that satisfies
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/org/apache/datasketches/req/BaseReqSketch.java
Expand Up @@ -223,6 +223,12 @@ abstract class BaseReqSketch {
*/
public abstract int getSerializationBytes();

/**
* Gets the sorted view of the current state of this sketch
* @return the sorted view of the current state of this sketch
*/
public abstract ReqSketchSortedView getSortedView();

/**
* Returns true if this sketch is empty.
* @return empty flag
Expand All @@ -239,8 +245,10 @@ abstract class BaseReqSketch {
* Returns the current comparison criterion. If true the value comparison criterion is
* &le;, otherwise it will be the default, which is &lt;.
* @return the current comparison criterion
* @deprecated
* @deprecated in the future the ltEq comparison parameter will not be saved at the class level in preference to
* the comparison parameter being specified for each API call. This method will be removed.
*/
@Deprecated
public abstract boolean isLessThanOrEqual();

/**
Expand All @@ -266,14 +274,15 @@ abstract class BaseReqSketch {

/**
* Sets the chosen criterion for value comparison
* @deprecated
*
* @param ltEq (Less-than-or Equals) If true, the sketch will use the &le; criterion for comparing
* values. Otherwise, the criterion is strictly &lt;, the default.
* This can be set anytime prior to a <i>getRank(float)</i> or <i>getQuantile(double)</i> or
* equivalent query.
* @return this
* @deprecated in the future the ltEq comparison parameter will not be saved at the class level in preference to
* the comparison parameter being specified for each API call. This method will be removed.
*/
@Deprecated
public abstract ReqSketch setLessThanOrEqual(final boolean ltEq);

/**
Expand Down Expand Up @@ -301,7 +310,7 @@ abstract class BaseReqSketch {
* items of the compactor and the current nominal capacity of the compactor.
* @param fmt the format string for the data items; example: "%4.0f".
* @param allData all the retained items for the sketch will be output by
* compactory level. Otherwise, just a summary will be output.
* compactor level. Otherwise, just a summary will be output.
* @return a detailed view of the compactors and their data
*/
public abstract String viewCompactorDetail(String fmt, boolean allData);
Expand Down

0 comments on commit c367889

Please sign in to comment.