This is an automated email from the ASF dual-hosted git repository. leerho pushed a commit to branch fix_getMaxCompactSketchBytes in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit 271ad4029f13f079c7243a20592403557df33c3b Author: Lee Rhodes <[email protected]> AuthorDate: Fri May 10 10:36:46 2024 -0700 Added new method to compute absolute maximum number of storage bytes required for a CompactSketch given the configured number of nominal entries (power of 2). --- src/main/java/org/apache/datasketches/theta/Sketch.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/apache/datasketches/theta/Sketch.java b/src/main/java/org/apache/datasketches/theta/Sketch.java index 88811651..960878fc 100644 --- a/src/main/java/org/apache/datasketches/theta/Sketch.java +++ b/src/main/java/org/apache/datasketches/theta/Sketch.java @@ -304,6 +304,18 @@ public abstract class Sketch { return (numberOfEntries << 3) + 24; } + /** + * Returns the maximum number of storage bytes required for a CompactSketch given the configured + * number of nominal entries (power of 2). + * @param nomEntries <a href="{@docRoot}/resources/dictionary.html#nomEntries">Nominal Entries</a> + * @return the maximum number of storage bytes required for a CompactSketch with the given + * nomEntries. + */ + public static int getCompactSketchMaxBytes(final int nomEntries) { + final int nomEnt = ceilingPowerOf2(nomEntries); + return ((nomEnt << 4) * 15) / 16 + (Family.QUICKSELECT.getMaxPreLongs() << 3); + } + /** * Returns the maximum number of storage bytes required for an UpdateSketch with the given * number of nominal entries (power of 2). --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
