leerho commented on code in PR #475:
URL: https://github.com/apache/datasketches-java/pull/475#discussion_r1410018322
##########
src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java:
##########
@@ -116,10 +132,66 @@ public long[] getCumulativeWeights() {
return cumWeights.clone();
}
- @Override //implemented here because it needs the comparator
+ @Override
+ public T getMaxItem() {
+ return maxItem;
+ }
+
+ @Override
+ public T getMinItem() {
+ return minItem;
+ }
+
+ @Override
+ public long getN() {
+ return totalN;
+ }
+
+ @Override
+ public double[] getNormalizedRanks() {
+ return normRanks.clone();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public GenericPartitionBoundaries<T> getPartitionBoundaries(final int
numEquallySized,
+ final QuantileSearchCriteria searchCrit) {
+ if (isEmpty()) { throw new
IllegalArgumentException(QuantilesAPI.EMPTY_MSG); }
+ final long totalN = this.totalN;
+ final int svLen = cumWeights.length;
+ //adjust ends of sortedView arrays
+ cumWeights[0] = 1L;
+ cumWeights[svLen - 1] = totalN;
+ normRanks[0] = 1.0 / totalN;
+ normRanks[svLen - 1] = 1.0;
+ quantiles[0] = this.getMinItem();
+ quantiles[svLen - 1] = this.getMaxItem();
+
+ final double[] evSpNormRanks = evenlySpacedDoubles(0, 1.0, numEquallySized
+ 1);
+ final int len = evSpNormRanks.length;
+ final T[] evSpQuantiles = (T[]) Array.newInstance(clazz, len);
+
+ final long[] evSpNatRanks = new long[len];
+ for (int i = 0; i < len; i++) {
+ final int index = getQuantileIndex(evSpNormRanks[i], searchCrit);
+ evSpQuantiles[i] = getQuantileFromIndex(index);
+ evSpNatRanks[i] = getCumWeightFromIndex(index);
+ }
+ final GenericPartitionBoundaries<T> gpb = new GenericPartitionBoundaries<>(
+ this.totalN,
+ evSpQuantiles.clone(),
Review Comment:
Done.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]