leerho commented on code in PR #546:
URL: https://github.com/apache/datasketches-java/pull/546#discussion_r1564177846
##########
src/main/java/org/apache/datasketches/quantilescommon/ItemsSketchSortedView.java:
##########
@@ -118,29 +114,35 @@ public int getNumRetained() {
}
@Override
- @SuppressWarnings("unchecked")
- public GenericPartitionBoundaries<T> getPartitionBoundaries(final int
numEquallySized,
+ public GenericPartitionBoundaries<T> getPartitionBoundariesFromPartSize(
+ final long nominalPartitionSize,
final QuantileSearchCriteria searchCrit) {
if (isEmpty()) { throw new
SketchesArgumentException(QuantilesAPI.EMPTY_MSG); }
- final long totalN = this.totalN;
- final int maxParts = (int) (totalN / Math.ceil(normRankErr *
PARTITIONING_ERROR_FACTOR) );
- final int svLen = cumWeights.length;
-
- if (numEquallySized > maxParts) {
+ final long partSizeItems = getMinPartitionSizeItems();
+ if (nominalPartitionSize < partSizeItems) {
throw new SketchesArgumentException(QuantilesAPI.UNSUPPORTED_MSG
- + "The requested number of partitions is too large for the 'k' of
this sketch "
- + "if it exceeds the maximum number of partitions allowed by the
error threshold for the 'k' of this sketch."
- + "Requested Partitions: " + numEquallySized + " > " + maxParts);
+ + " The requested nominal partition size is too small for this
sketch.");
}
- if (numEquallySized > svLen / 2.0) {
+ final long totalN = this.totalN;
+ final int numEquallySizedParts = (int) min(totalN / partSizeItems,
getMaxPartitions());
+ return getPartitionBoundariesFromNumParts(numEquallySizedParts);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public GenericPartitionBoundaries<T> getPartitionBoundariesFromNumParts(
+ final int numEquallySizedParts,
+ final QuantileSearchCriteria searchCrit) {
+ if (isEmpty()) { throw new
SketchesArgumentException(QuantilesAPI.EMPTY_MSG); }
+ final int maxParts = getMaxPartitions();
+ if (numEquallySizedParts > maxParts) {
throw new SketchesArgumentException(QuantilesAPI.UNSUPPORTED_MSG
- + "The requested number of partitions is too large for the number of
retained items "
- + "if it exceeds maximum number of retained items divided by 2."
- + "Requested Partitions: " + numEquallySized + " > "
- + "Retained Items / 2: " + (svLen / 2));
+ + " The requested number of partitions is too large for this
sketch.");
}
+ final long totalN = this.totalN;
Review Comment:
Turns out is was already a class member. I didn't need this line.
--
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]