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 2022/10/05 20:09:34 UTC
[GitHub] [datasketches-java] AlexanderSaydakov commented on a diff in pull request #412: Changes to classic quantiles
AlexanderSaydakov commented on code in PR #412:
URL: https://github.com/apache/datasketches-java/pull/412#discussion_r986069733
##########
src/main/java/org/apache/datasketches/quantiles/ItemsUnion.java:
##########
@@ -126,8 +137,8 @@ public void update(final ItemsSketch<T> sketchIn) {
* @param srcMem Memory image of sketch to be merged
* @param serDe an instance of ArrayOfItemsSerDe
*/
- public void update(final Memory srcMem, final ArrayOfItemsSerDe<T> serDe) {
- final ItemsSketch<T> that = ItemsSketch.getInstance(srcMem, comparator_, serDe);
+ public void union(final Memory srcMem, final ArrayOfItemsSerDe<T> serDe) { //TODO rename merge
Review Comment:
no objections. I just saw this comment and thought that the time for breaking changes is now.
##########
src/main/java/org/apache/datasketches/QuantilesDoublesAPI.java:
##########
@@ -0,0 +1,325 @@
+/*
+ * 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 static org.apache.datasketches.QuantileSearchCriteria.INCLUSIVE;
+
+public interface QuantilesDoublesAPI extends QuantilesAPI {
+
+ /**
+ * Same as {@link #getCDF(double[], QuantileSearchCriteria) getCDF(splitPoints, INCLUSIVE)}
+ * @param splitPoints an array of <i>m</i> unique, monotonically increasing quantiles
+ * @return a CDF array of m+1 double ranks (or probabilities) on the interval [0.0, 1.0).
+ */
+ default double[] getCDF(double[] splitPoints) {
+ return getCDF(splitPoints, INCLUSIVE);
+ }
+
+ /**
+ * Returns an approximation to the Cumulative Distribution Function (CDF) of the input stream
+ * as a monotonically increasing array of double ranks (or probabilities) on the interval [0.0, 1.0],
+ * given a set of splitPoints.
+ * The last rank in the returned array is always 1.0.
+ *
+ * <p>The resulting approximations have a probabilistic guarantee that can be obtained from the
+ * getNormalizedRankError(false) function.
+ *
+ * <p>If the sketch is empty this returns null.</p>
+ *
+ * @param splitPoints an array of <i>m</i> unique, monotonically increasing quantiles
+ * that divide the real number line into <i>m+1</i> consecutive non-overlapping intervals.
+ * It is not necessary to include either the minimum or maximum quantiles
+ * of the input stream in these split points.
+ *
+ * <p>If searchCrit is INCLUSIVE, the definition of an "interval" is
+ * exclusive of the left splitPoint and
+ * inclusive of the right splitPoint.</p>
+ *
+ * <p>If searchCrit is EXCLUSIVE, the definition of an "interval" is
+ * inclusive of the left splitPoint and
+ * exclusive of the right splitPoint.</p>
+ *
+ *<p>The left "splitPoint" for the lowest interval is the
+ * lowest quantile from the input stream retained by the sketch.
+ * The right "splitPoint" for the highest interval is the
+ * highest quantile from the input stream retained by the sketch.
+ * </p>
+ *
+ * @param searchCrit if INCLUSIVE, the weight of a given splitPoint quantile,
+ * if it also exists as retained quantile by the sketch,
+ * is included into the interval below.
+ * Otherwise, it is included into the interval above.
+ *
+ * @return an CDF array of m+1 double ranks (or probabilities) on the interval [0.0, 1.0).
+ */
+ double[] getCDF(double[] splitPoints, QuantileSearchCriteria searchCrit);
+
+ /**
+ * Returns the maximum quantile of the stream. This is provided for convenience, but is distinct from the largest
+ * quantile retained by the sketch algorithm.
+ *
+ * <p>If the sketch is empty this returns NaN.</p>
+ *
+ * @return the maximum quantile of the stream
+ */
+ double getMaxQuantile();
Review Comment:
I would say that "item" is fine generic term for input data of an arbitrary type. At least I find it less awkward than calling all input pieces of data "quantiles".
--
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.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
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