You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by GitBox <gi...@apache.org> on 2020/11/05 16:47:16 UTC

[GitHub] [incubator-datasketches-java] davecromberge commented on a change in pull request #332: Relative error quantiles

davecromberge commented on a change in pull request #332:
URL: https://github.com/apache/incubator-datasketches-java/pull/332#discussion_r486891825



##########
File path: src/main/java/org/apache/datasketches/Util.java
##########
@@ -439,6 +465,72 @@ public static int ceilingPowerOf2(final int n) {
     return (n >= topPwrOf2) ? topPwrOf2 : Integer.highestOneBit((n - 1) << 1);
   }
 
+  /**
+   * Returns a double array of evenly spaced double values between min and max inclusive.
+   * @param min the lowest returned value
+   * @param max the highest returned value
+   * @param num the total number of values including min and max. Must be 2 or greater.
+   * @return a double array of evenly spaced values between min and max inclusive.
+   */
+  public static double[] evenlySpaced(final double min, final double max, final int num) {
+    if (num < 2) {
+      throw new SketchesArgumentException("num must be >= 2");
+    }
+    final double[] out = new double[num];
+    out[0] = min;
+    out[num - 1] = max;
+    if (num == 2) { return out; }
+
+    final double delta = (max - min) / (num - 1);
+
+    for (int i = 1; i < (num - 1); i++) { out[i] = i * delta; }
+    return out;
+  }
+
+  /**
+   * Returns a double array of evenly spaced float values between min and max inclusive.
+   * @param min the lowest returned value
+   * @param max the highest returned value
+   * @param num the total number of values including min and max. Must be 2 or greater.
+   * @return a double array of evenly spaced values between min and max inclusive.
+   */

Review comment:
       In the javadoc, the `double` array should be changed to `float` array.  

##########
File path: src/main/java/org/apache/datasketches/Criteria.java
##########
@@ -0,0 +1,420 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches;
+
+/**
+ * This supports the BinarySearch class.
+ *
+ * @author Lee Rhodes
+ */
+public enum Criteria {
+
+  /**
+   * Given an sorted array of increasing values and a value <i>V</i>, this criterion instucts the
+   * binary search algorithm to find the highest adjacent pair of values <i>{A,B}</i> such that
+   * <i>A &lt; V &le; B</i>.
+   * The returned value from the binary search algorithm will be the index of <i>A</i>
+   * or -1, if the value <i>V</i> &le; the the lowest value in the selected range of the array.

Review comment:
       Line 34 contains a redundancy: `the the lowest value in the selected range`

##########
File path: src/main/java/org/apache/datasketches/Util.java
##########
@@ -439,6 +465,72 @@ public static int ceilingPowerOf2(final int n) {
     return (n >= topPwrOf2) ? topPwrOf2 : Integer.highestOneBit((n - 1) << 1);
   }
 
+  /**
+   * Returns a double array of evenly spaced double values between min and max inclusive.
+   * @param min the lowest returned value
+   * @param max the highest returned value
+   * @param num the total number of values including min and max. Must be 2 or greater.
+   * @return a double array of evenly spaced values between min and max inclusive.
+   */
+  public static double[] evenlySpaced(final double min, final double max, final int num) {
+    if (num < 2) {
+      throw new SketchesArgumentException("num must be >= 2");
+    }
+    final double[] out = new double[num];
+    out[0] = min;
+    out[num - 1] = max;
+    if (num == 2) { return out; }
+
+    final double delta = (max - min) / (num - 1);
+
+    for (int i = 1; i < (num - 1); i++) { out[i] = i * delta; }
+    return out;
+  }

Review comment:
       If max == min, the output would likely contain zeroes.  Similarly, if max < min, the output would still be evenly spaced, but in an order that the caller may not expect.  If there is an assumption about the sort order, do you think that it is important to check that max > min?

##########
File path: src/main/java/org/apache/datasketches/req/FloatBuffer.java
##########
@@ -0,0 +1,418 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.req;
+
+import static org.apache.datasketches.Criteria.GE;
+import static org.apache.datasketches.Criteria.GT;
+import static org.apache.datasketches.Criteria.LE;
+import static org.apache.datasketches.Criteria.LT;
+import static org.apache.datasketches.req.ReqSketch.LS;
+
+import java.util.Arrays;
+
+import org.apache.datasketches.BinarySearch;
+import org.apache.datasketches.Criteria;
+import org.apache.datasketches.SketchesArgumentException;
+
+/**
+ * A special buffer of floats specifically designed to support the ReqCompactor class.
+ *
+ * @author Lee Rhodes
+ */
+class FloatBuffer {
+  private float[] arr_;
+  private int count_;
+  private int capacity_;
+  private int delta_;
+  private boolean sorted_;
+  private boolean spaceAtBottom_;
+
+  /**
+   * Constructs an empty FloatBuffer with an initial capacity specified by
+   * the <code>capacity</code> argument.
+   *
+   * @param capacity the initial capacity.
+   * @param delta add space in increments of this size
+   * @param spaceAtBottom if true, create any extra space at the bottom of the buffer,
+   * otherwise, create any extra space at the top of the buffer.
+   */
+  FloatBuffer(final int capacity, final int delta, final boolean spaceAtBottom) {
+    arr_ = new float[capacity];
+    count_ = 0;
+    capacity_ = capacity;
+    delta_ = delta;
+    sorted_ = true;
+    spaceAtBottom_ = spaceAtBottom;
+  }
+
+  /**
+   * Copy Constructor
+   * @param buf the FloatBuffer to be copied into this one
+   */
+  FloatBuffer(final FloatBuffer buf) {
+    arr_ = buf.arr_.clone();
+    count_ = buf.count_;
+    capacity_ = buf.capacity_;
+    delta_ = buf.delta_;
+    sorted_ = buf.sorted_;
+    spaceAtBottom_ = buf.spaceAtBottom_;
+  }
+
+  /**
+   * Private construction from elements
+   * @param arr the array to be used directly as the internal array
+   * @param count the number of active elements in the given array
+   * @param delta add space in increments of this size
+   * @param capacity the initial capacity
+   * @param sorted true if already sorted
+   * @param spaceAtBottom if true, create any extra space at the bottom of the buffer,
+   * otherwise, create any extra space at the top of the buffer.
+   */
+  private FloatBuffer(final float[] arr, final int count, final int delta, final int capacity,
+      final boolean sorted, final boolean spaceAtBottom) {
+    arr_ = arr;
+    count_ = count;
+    capacity_ = capacity;
+    delta_ = delta;
+    sorted_ = sorted;
+    spaceAtBottom_ = spaceAtBottom;
+  }

Review comment:
       What are the factors that should be taken into consideration when deciding whether to allocate space at the bottom or top?  For instance, does one incur less wasted space at the cost of repeated copying?

##########
File path: src/main/java/org/apache/datasketches/req/BaseReqSketch.java
##########
@@ -0,0 +1,281 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.req;
+
+/**
+ * This abstract class provides a single place to define and document the public API
+ * for the Relative Error Quantiles Sketch.
+ *
+ * @author Lee Rhodes
+ */
+abstract class BaseReqSketch {
+
+  /**
+   * Returns an approximation to the Cumulative Distribution Function (CDF), which is the
+   * cumulative analog of the PMF, of the input stream given a set of splitPoint (values).
+   *
+   * <p>The resulting approximations have a probabilistic guarantee that be obtained from the
+   * getNormalizedRankError(false) function.

Review comment:
       Could you explain what you mean by this?
   
   > The resulting approximations have a probabilistic guarantee that be obtained from the
   >   getNormalizedRankError(false) function.`
   
   Is the normalised rank error the probabilistic guarantee?  A similar question applies to the `getPMF` function.

##########
File path: src/main/java/org/apache/datasketches/Util.java
##########
@@ -380,6 +380,32 @@ public static boolean isMultipleOf8AndGT0(final long v) {
 
   //Powers of 2 related
 
+  /**
+   * Returns the number of one bits following the lowest-order ("rightmost") zero-bit in the
+   * two's complement binary representation of the specified long value, or 64 if the value is equal
+   * to minus one.
+   * @param v the value whose number of trailing ones is to be computed.
+   * @return the number of one bits following the lowest-order ("rightmost") zero-bit in the
+   * two's complement binary representation of the specified long value, or 64 if the value is equal
+   * to minus one.
+   */
+  public static int numberOfTrailingOnes(final long v) {
+    return Long.numberOfTrailingZeros(~v);
+  }
+
+  /**
+   * Returns the number of one bits preceding the highest-order ("leftmost") one-bit in the
+   * two's complement binary representation of the specified long value, or 64 if the value is equal
+   * to minus one.

Review comment:
       The documentation should refer to the highest-order ("leftmost") _zero-bit_

##########
File path: src/main/java/org/apache/datasketches/Criteria.java
##########
@@ -0,0 +1,458 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches;
+
+/**
+ * This supports the BinarySearch class by providing efficient, unique and unambiguous searching for
+ * comparison criteria for ordered arrays of values that may include duplicate values. These
+ * searching criteria include &lt;, &le;, ==, &ge;, &gt;. We also would like to be able to use the
+ * same search algorithm for all the criteria.
+ *
+ * <p>In order to make the searching unique and unambiguous, we modified the traditional binary
+ * search algorithm to search for adjacent pairs of values <i>{A, B}</i> in the values array
+ * instead of just a single value, where <i>A</i> and <i>B</i> are the array indicies of two
+ * adjacent values in the array. We then define the searching criteria,
+ * given an array of values <i>arr[]</i> and the search key value <i>v</i>, as follows:</p>
+ * <ul>
+ * <li><b>LT:</b> Find the highest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] < v <= arr[B]</i>. Normally we return the index <i>A</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * <li><b>LE:</b>  Find the highest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] <= v < arr[B]</i>. Normally we return the index <i>A</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * <li><b>EQ:</b>  Find the adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] <= v <= arr[B]</i>. We return the index <i>A</i> or <i>B</i> whichever
+ * equals <i>v</i>, otherwise we return -1.
+ * </li>
+ * <li><b>GE:</b>  Find the lowest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] < v <= arr[B]</i>. Normally we return the index <i>B</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * <li><b>GT:</b>  Find the lowest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] <= v <= arr[B]</i>. Normally we return the index <i>B</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.

Review comment:
       GT should read: `arr[A] <= V < arr[B]`

##########
File path: src/main/java/org/apache/datasketches/req/ReqDebug.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.req;
+
+//import org.apache.datasketches.req.ReqCompactor;

Review comment:
       This line can be removed.

##########
File path: src/main/java/org/apache/datasketches/InequalitySearch.java
##########
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches;
+
+import java.util.Comparator;
+
+/**
+ * This provides efficient, unique and unambiguous binary searching for inequalities
+ * for ordered arrays of values that may include duplicate values. These
+ * inequalities include &lt;, &le;, ==, &ge;, &gt;. The same search method can be used for all
+ * these inequalities.
+ *
+ * <p>In order to make the searching unique and unambiguous, we modified the traditional binary
+ * search algorithm to search for adjacent pairs of values <i>{A, B}</i> in the values array
+ * instead of just a single value, where <i>A</i> and <i>B</i> are the array indicies of two
+ * adjacent values in the array. We then define the searching criteria,
+ * given an array of values <i>arr[]</i> and the search key value <i>v</i>, as follows:</p>
+ * <ul>
+ * <li><b>LT:</b> Find the highest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] < v <= arr[B]</i>. Normally we return the index <i>A</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * <li><b>LE:</b>  Find the highest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] <= v < arr[B]</i>. Normally we return the index <i>A</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * <li><b>EQ:</b>  Find the adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] <= v <= arr[B]</i>. We return the index <i>A</i> or <i>B</i> whichever
+ * equals <i>v</i>, otherwise we return -1.
+ * </li>
+ * <li><b>GE:</b>  Find the lowest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] < v <= arr[B]</i>. Normally we return the index <i>B</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * <li><b>GT:</b>  Find the lowest ranked adjacent pair <i>{A, B}</i> such that:<br>
+ * <i>arr[A] <= v <= arr[B]</i>. Normally we return the index <i>B</i>. However if the
+ * search algorithm reaches the ends of the search range, the search algorithm calls the
+ * <i>resolve()</i> method to determine what to return to the caller.
+ * </li>
+ * </ul>
+ *
+ * @author Lee Rhodes
+ */
+public class InequalitySearch {
+
+  /**
+   * The enumerator of inequalities
+   */
+  public enum Inequality {
+
+    /**
+     * Less-Than
+     */
+    LT,
+
+    /**
+     * Less-Than Or Equals
+     */
+    LE,
+
+    /**
+     * Equals. Although not an inequality, it is included for completeness.
+     */
+    EQ,
+
+    /**
+     * Greater-Than Or Equals
+     */
+    GE,
+
+    /**
+     * Greater-Than
+     */
+    GT
+  }
+
+  /**
+   * Constructs this class
+   */
+  public InequalitySearch() { }
+
+  /**
+   * Binary Search for the index of the generic value in the given search range that satisfies
+   * the given inequality.
+   * If -1 is returned there are no values in the search range that satisfy the inequality.
+   *
+   * @param arr the given array that must be sorted.
+   * @param low the index of the lowest value in the search range
+   * @param high the index of the highest value in the search range
+   * @param v the value to search for.
+   * @param inequality one of LT, LE, EQ, GE, GT
+   * @param comparator for the type T
+   * @param <T> The generic type of value to be used in the search process.
+   * @return the index of the value in the given search range that satisfies the inequality.
+   */
+  public static <T> int find(final T[] arr, final int low, final int high, final T v,
+      final Inequality inequality, final Comparator<T> comparator) {
+    int lo = low;
+    int hi = high - 1;
+    int ret;
+    while (lo <= hi) {
+      final int midA = lo + (hi - lo) / 2;
+      ret = compare(arr, midA, midA + 1, v, inequality, comparator);
+      if (ret == -1 ) { hi = midA - 1; }
+      else if (ret == 1) { lo = midA + 1; }
+      else  { return getIndex(arr, midA, midA + 1, v, inequality, comparator); }
+    }
+    return resolve(lo, hi, low, high, inequality);
+  }

Review comment:
       The BinarySearch implementation uses primitive types, float and double, compared to a generic type T here.  Is the latter for performance reasons?

##########
File path: src/main/java/org/apache/datasketches/req/FloatBuffer.java
##########
@@ -0,0 +1,418 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.req;
+
+import static org.apache.datasketches.Criteria.GE;
+import static org.apache.datasketches.Criteria.GT;
+import static org.apache.datasketches.Criteria.LE;
+import static org.apache.datasketches.Criteria.LT;
+import static org.apache.datasketches.req.ReqSketch.LS;
+
+import java.util.Arrays;
+
+import org.apache.datasketches.BinarySearch;
+import org.apache.datasketches.Criteria;
+import org.apache.datasketches.SketchesArgumentException;
+
+/**
+ * A special buffer of floats specifically designed to support the ReqCompactor class.
+ *
+ * @author Lee Rhodes
+ */
+class FloatBuffer {
+  private float[] arr_;
+  private int count_;
+  private int capacity_;
+  private int delta_;
+  private boolean sorted_;
+  private boolean spaceAtBottom_;
+
+  /**
+   * Constructs an empty FloatBuffer with an initial capacity specified by
+   * the <code>capacity</code> argument.
+   *
+   * @param capacity the initial capacity.
+   * @param delta add space in increments of this size
+   * @param spaceAtBottom if true, create any extra space at the bottom of the buffer,
+   * otherwise, create any extra space at the top of the buffer.
+   */
+  FloatBuffer(final int capacity, final int delta, final boolean spaceAtBottom) {
+    arr_ = new float[capacity];
+    count_ = 0;
+    capacity_ = capacity;
+    delta_ = delta;
+    sorted_ = true;
+    spaceAtBottom_ = spaceAtBottom;
+  }
+
+  /**
+   * Copy Constructor
+   * @param buf the FloatBuffer to be copied into this one
+   */
+  FloatBuffer(final FloatBuffer buf) {
+    arr_ = buf.arr_.clone();
+    count_ = buf.count_;
+    capacity_ = buf.capacity_;
+    delta_ = buf.delta_;
+    sorted_ = buf.sorted_;
+    spaceAtBottom_ = buf.spaceAtBottom_;
+  }
+
+  /**
+   * Private construction from elements
+   * @param arr the array to be used directly as the internal array
+   * @param count the number of active elements in the given array
+   * @param delta add space in increments of this size
+   * @param capacity the initial capacity
+   * @param sorted true if already sorted
+   * @param spaceAtBottom if true, create any extra space at the bottom of the buffer,
+   * otherwise, create any extra space at the top of the buffer.
+   */
+  private FloatBuffer(final float[] arr, final int count, final int delta, final int capacity,
+      final boolean sorted, final boolean spaceAtBottom) {
+    arr_ = arr;
+    count_ = count;
+    capacity_ = capacity;
+    delta_ = delta;
+    sorted_ = sorted;
+    spaceAtBottom_ = spaceAtBottom;
+  }
+
+  /**
+   * Wraps the given array to use as the internal array; thus no copies. For internal use.
+   * @param arr the given array
+   * @param isSorted set true, if incomming array is already sorted.
+   * @param spaceAtBottom if true, create any extra space at the bottom of the buffer,
+   * otherwise, create any extra space at the top of the buffer.
+   * @return this, which will be sorted
+   */
+  static FloatBuffer wrap(final float[] arr, final boolean isSorted, final boolean spaceAtBottom) {
+    final FloatBuffer buf = new FloatBuffer(arr, arr.length, 0, arr.length, isSorted, spaceAtBottom);
+    buf.sort();
+    return buf;
+  }
+
+  /**
+   * Appends the given item to the active array and increments length().
+   * This will expand the array if necessary.
+   * @param item the given item
+   * @return this
+   */
+  FloatBuffer append(final float item) {
+    ensureSpace(1);
+    final int index = spaceAtBottom_ ? capacity_ - count_ - 1 : count_;
+    arr_[index] = item;
+    count_++;
+    sorted_ = false;
+    return this;
+  }
+
+  /**
+   * Ensures that the capacity of this FloatBuffer is at least newCapacity.
+   * If newCapacity &lt; capacity(), no action is taken.
+   * @param newCapacity the new desired capacity
+   * at the top.

Review comment:
       I am slightly confused by the `at the top` remark - does this refer to the location for where the capacity is allocated?

##########
File path: src/test/java/org/apache/datasketches/kll/RelativeErrorSketchTest.java
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.kll;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Lee Rhodes
+ */
+@SuppressWarnings("javadoc")
+public class RelativeErrorSketchTest {
+
+  @Test
+  public void check1() {
+
+  }
+
+
+  static void print(Object o) { System.out.print(o.toString()); }
+
+  static void println(Object o) { System.out.println(o.toString()); }
+}

Review comment:
       Is this test necessary?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org