This commit is the result of the first round of reviews.
diff --git a/src/main/java/org/apache/datasketches/common/Util.java b/src/main/java/org/apache/datasketches/common/Util.java
index c9a749e..f713171 100644
--- a/src/main/java/org/apache/datasketches/common/Util.java
+++ b/src/main/java/org/apache/datasketches/common/Util.java
@@ -531,39 +531,39 @@
}
/**
- * Returns the ceiling of a given <i>n</i> given a <i>radix</i>, where the ceiling is an integral power of the radix.
- * This is the smallest positive power of <i>radix</i> that is equal to or greater than the given <i>n</i>
+ * Returns the ceiling of a given <i>n</i> given a <i>base</i>, where the ceiling is an integral power of the base.
+ * This is the smallest positive power of <i>base</i> that is equal to or greater than the given <i>n</i>
* and equal to a mathematical integer.
* The result of this function is consistent with {@link #ceilingIntPowerOf2(int)} for values
* less than one. I.e., if <i>n < 1,</i> the result is 1.
*
- * <p>The formula is: <i>radix<sup>ceiling(log<sub>radix</sub>(x))</sup></i></p>
+ * <p>The formula is: <i>base<sup>ceiling(log<sub>base</sub>(x))</sup></i></p>
*
- * @param radix The base of the number system.
+ * @param base The number in the expression ⌈base<sup>n</sup>⌉.
* @param n The input argument.
- * @return the ceiling power of <i>radix</i> as a double and equal to a mathematical integer.
+ * @return the ceiling power of <i>base</i> as a double and equal to a mathematical integer.
*/
- public static double ceilingPowerBaseOfDouble(final double radix, final double n) {
+ public static double ceilingPowerBaseOfDouble(final double base, final double n) {
final double x = n < 1.0 ? 1.0 : n;
- return Math.round(pow(radix, ceil(logBaseOfX(radix, x))));
+ return Math.round(pow(base, ceil(logBaseOfX(base, x))));
}
/**
- * Computes the floor of a given <i>n</i> given <i>radix</i>, where the floor is an integral power of the radix.
- * This is the largest positive power of <i>radix</i> that is equal to or less than the given <i>n</i>
+ * Computes the floor of a given <i>n</i> given <i>base</i>, where the floor is an integral power of the base.
+ * This is the largest positive power of <i>base</i> that is equal to or less than the given <i>n</i>
* and equal to a mathematical integer.
* The result of this function is consistent with {@link #floorPowerOf2(int)} for values
* less than one. I.e., if <i>n < 1,</i> the result is 1.
*
- * <p>The formula is: <i>radix<sup>floor(log<sub>radix</sub>(x))</sup></i></p>
+ * <p>The formula is: <i>base<sup>floor(log<sub>base</sub>(x))</sup></i></p>
*
- * @param radix The base of the number system.
+ * @param base The number in the expression ⌊base<sup>n</sup>⌋.
* @param n The input argument.
* @return the floor power of 2 and equal to a mathematical integer.
*/
- public static double floorPowerBaseOfDouble(final double radix, final double n) {
+ public static double floorPowerBaseOfDouble(final double base, final double n) {
final double x = n < 1.0 ? 1.0 : n;
- return Math.round(pow(radix, floor(logBaseOfX(radix, x))));
+ return Math.round(pow(base, floor(logBaseOfX(base, x))));
}
// Logarithm related
@@ -578,13 +578,13 @@
}
/**
- * Returns the log<sub>radix</sub>(x). Example: logB(2.0, x) = log(x) / log(2.0).
- * @param radix the base of the number system
+ * Returns the log<sub>base</sub>(x). Example, if base = 2.0: logB(2.0, x) = log(x) / log(2.0).
+ * @param base The number in the expression log(x) / log(base).
* @param x the given value
- * @return the log<sub>radix</sub>(x): Example: logB(2.0, x) = log(x) / log(2.0).
+ * @return the log<sub>base</sub>(x)
*/
- public static double logBaseOfX(final double radix, final double x) {
- return log(x) / log(radix);
+ public static double logBaseOfX(final double base, final double x) {
+ return log(x) / log(base);
}
/**
diff --git a/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java b/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
index 4b901f5..3f0baf0 100644
--- a/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
@@ -179,9 +179,9 @@
}
final GenericPartitionBoundaries<T> gpb = new GenericPartitionBoundaries<>(
this.totalN,
- evSpQuantiles.clone(),
- evSpNatRanks.clone(),
- evSpNormRanks.clone(),
+ evSpQuantiles,
+ evSpNatRanks,
+ evSpNormRanks,
getMaxItem(),
getMinItem(),
searchCrit);
diff --git a/src/main/java/org/apache/datasketches/partitions/Partitioner.java b/src/main/java/org/apache/datasketches/partitions/Partitioner.java
index fce0bec..b56356f 100644
--- a/src/main/java/org/apache/datasketches/partitions/Partitioner.java
+++ b/src/main/java/org/apache/datasketches/partitions/Partitioner.java
@@ -28,6 +28,7 @@
import static org.apache.datasketches.quantilescommon.QuantileSearchCriteria.INCLUSIVE;
import static org.apache.datasketches.quantilescommon.QuantilesAPI.EMPTY_MSG;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
@@ -36,7 +37,6 @@
import org.apache.datasketches.quantilescommon.PartitioningFeature;
import org.apache.datasketches.quantilescommon.QuantileSearchCriteria;
import org.apache.datasketches.quantilescommon.QuantilesGenericAPI;
-import org.apache.datasketches.quantilescommon.Stack;
/**
* A partitioning process that can partition very large data sets into thousands
@@ -44,14 +44,13 @@
* @param <T> the data type
* @param <S> the quantiles sketch that implements both QuantilesGenericAPI and PartitioningFeature.
*/
-//@SuppressWarnings("unused")
public class Partitioner<T, S extends QuantilesGenericAPI<T> & PartitioningFeature<T>> {
private static final QuantileSearchCriteria defaultCriteria = INCLUSIVE;
private final long tgtPartitionSize;
private final int maxPartsPerSk;
private final SketchFillRequest<T, S> fillReq;
private final QuantileSearchCriteria criteria;
- private final Stack<StackElement<T>> stack = new Stack<>();
+ private final ArrayDeque<StackElement<T>> stack = new ArrayDeque<>();
//computed once at the beginning
private int numLevels;
@@ -114,7 +113,7 @@
return finalPartitionList;
}
- private void partitionSearch(final Stack<StackElement<T>> stack) {
+ private void partitionSearch(final ArrayDeque<StackElement<T>> stack) {
if (stack.isEmpty()) {
return;
}
diff --git a/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java b/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java
index 869b680..23cd975 100644
--- a/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java
@@ -183,9 +183,9 @@
}
final GenericPartitionBoundaries<T> gpb = new GenericPartitionBoundaries<>(
this.totalN,
- evSpQuantiles.clone(),
- evSpNatRanks.clone(),
- evSpNormRanks.clone(),
+ evSpQuantiles,
+ evSpNatRanks,
+ evSpNormRanks,
getMaxItem(),
getMinItem(),
searchCrit);
diff --git a/src/main/java/org/apache/datasketches/quantilescommon/Stack.java b/src/main/java/org/apache/datasketches/quantilescommon/Stack.java
deleted file mode 100644
index 68d6378..0000000
--- a/src/main/java/org/apache/datasketches/quantilescommon/Stack.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.quantilescommon;
-
-import java.util.ArrayList;
-
-import org.apache.datasketches.common.SketchesStateException;
-
-/**
- * A classic LIFO stack based on ArrayList (as opposed to Vector).
- * All of the methods of ArrayList are available.
- */
-public class Stack<E> extends ArrayList<E> {
- private static final long serialVersionUID = 1L;
-
- /**
- * Creates an empty stack.
- */
- public Stack() { }
-
- /**
- * Pushes an item onto the stack
- * @param item the given item
- * @return the given element
- */
- public E push(final E item) {
- add(item);
- return item;
- }
-
- /**
- * Removes the item at the top of the stack.
- * @return the item at the top of the stack.
- */
- public E pop() {
- final E item = peek();
- remove(size() - 1);
- return item;
- }
-
- /**
- * Allows examination of the top item without removing it.
- * @return the top item without removing it
- */
- public E peek() {
- final int len = size();
- if (len == 0) { throw new SketchesStateException("Stack is empty"); }
- return get(len - 1);
- }
-
-}