diff --git a/src/main/java/org/apache/datasketches/common/Util.java b/src/main/java/org/apache/datasketches/common/Util.java index 35f8a9be1..729b92f3f 100644 --- a/src/main/java/org/apache/datasketches/common/Util.java +++ b/src/main/java/org/apache/datasketches/common/Util.java @@ -290,67 +290,45 @@ public static boolean isMultipleOf8AndGT0(final long v) { //Powers of 2 or powers of base related /** - * Returns true if given int argument is exactly a positive power of 2 and greater than zero. + * Returns true if given long argument is exactly a positive power of 2. * - * @param powerOf2 The input argument. - * @return true if argument is exactly a positive power of 2 and greater than zero. - */ - public static boolean isIntPowerOf2(final int powerOf2) { - return powerOf2 > 0 && (powerOf2 & powerOf2 - 1) == 0; //or (v > 0) && ((v & -v) == v) - } - - /** - * Returns true if given long argument is exactly a positive power of 2 and greater than zero. - * - * @param powerOf2 The input argument. - * @return true if argument is exactly a positive power of 2 and greater than zero. - */ - public static boolean isLongPowerOf2(final long powerOf2) { - return powerOf2 > 0 && (powerOf2 & powerOf2 - 1L) == 0; //or (v > 0) && ((v & -v) == v) - } - - /** - * Checks the given int argument to make sure it is a positive power of 2 and greater than zero. - * If not it throws an exception with the user supplied local argument name. - * @param powerOf2 The input int argument must be a power of 2 and greater than zero. - * @param argName Used in the thrown exception. - * @throws SketchesArgumentException if not a power of 2 nor greater than zero. + * @param n The input argument. + * @return true if argument is exactly a positive power of 2. */ - public static void checkIfIntPowerOf2(final int powerOf2, final String argName) { - if (isIntPowerOf2(powerOf2)) { return; } - throw new SketchesArgumentException("The value of the int argument \"" + argName + "\"" - + " must be a positive integer-power of 2" + " and greater than 0: " + powerOf2); + public static boolean isPowerOf2(final long n) { + return (n > 0) && ((n & (n - 1L)) == 0); //or (n > 0) && ((n & -n) == n) } /** - * Checks the given long argument to make sure it is a positive power of 2 and greater than zero. - * If not, it throws an exception with the user supplied local argument name. - * @param powerOf2 The input long argument must be a power of 2 and greater than zero. - * @param argName Used in the thrown exception. - * @throws SketchesArgumentException if not a power of 2 nor greater than zero. + * Checks the given long argument if it is a positive integer power of 2. + * If not, it throws an exception with the user supplied local argument name, if not null. + * @param n The input long argument must be a positive integer power of 2. + * @param argName Used in the thrown exception. It may be null. + * @throws SketchesArgumentException if not a positive integer power of 2. */ - public static void checkIfLongPowerOf2(final long powerOf2, final String argName) { - if (isLongPowerOf2(powerOf2)) { return; } - throw new SketchesArgumentException("The value of the int argument \"" + argName + "\"" - + " must be a positive integer-power of 2" + " and greater than 0: " + powerOf2); + public static void checkIfPowerOf2(final long n, String argName) { + if (isPowerOf2(n)) { return; } + argName = (argName == null) ? "" : argName; + throw new SketchesArgumentException("The value of the argument \"" + argName + "\"" + + " must be a positive integer power of 2: " + n); } /** * Computes the int ceiling power of 2 within the range [1, 2^30]. This is the smallest positive power - * of 2 that is equal to or greater than the given n and a mathematical integer. + * of 2 that is equal to or greater than the given n and a positive integer. * *
For: *
For: *
For: *
For: *
The formula is: baseceiling(logbase(x))
@@ -622,7 +600,7 @@ public static int numberOfLeadingOnes(final long v) { * @throws SketchesArgumentException if not a power of 2 nor greater than zero. */ public static int exactLog2OfInt(final int powerOf2, final String argName) { - checkIfIntPowerOf2(powerOf2, argName); + checkIfPowerOf2(powerOf2, argName); return Integer.numberOfTrailingZeros(powerOf2); } @@ -635,7 +613,7 @@ public static int exactLog2OfInt(final int powerOf2, final String argName) { * @throws SketchesArgumentException if not a power of 2 nor greater than zero. */ public static int exactLog2OfLong(final long powerOf2, final String argName) { - checkIfLongPowerOf2(powerOf2, argName); + checkIfPowerOf2(powerOf2, argName); return Long.numberOfTrailingZeros(powerOf2); } @@ -646,7 +624,7 @@ public static int exactLog2OfLong(final long powerOf2, final String argName) { * @return the log2 of the given int value if it is an exact power of 2 and greater than zero. */ public static int exactLog2OfInt(final int powerOf2) { - if (!isIntPowerOf2(powerOf2)) { + if (!isPowerOf2(powerOf2)) { throw new SketchesArgumentException("Argument 'powerOf2' must be a positive power of 2."); } return Long.numberOfTrailingZeros(powerOf2); @@ -659,7 +637,7 @@ public static int exactLog2OfInt(final int powerOf2) { * @return the log2 of the given long value if it is an exact power of 2 and greater than zero. */ public static int exactLog2OfLong(final long powerOf2) { - if (!isLongPowerOf2(powerOf2)) { + if (!isPowerOf2(powerOf2)) { throw new SketchesArgumentException("Argument 'powerOf2' must be a positive power of 2."); } return Long.numberOfTrailingZeros(powerOf2); diff --git a/src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java b/src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java index 0205c252f..183dcee33 100644 --- a/src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java +++ b/src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java @@ -20,7 +20,7 @@ package org.apache.datasketches.cpc; import static org.apache.datasketches.common.Util.INVERSE_GOLDEN_U64; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.common.Util.log2; import static org.apache.datasketches.common.Util.powerSeriesNextDouble; import static org.apache.datasketches.cpc.CompressedState.importFromMemory; @@ -109,7 +109,7 @@ private void doRangeOfNAtLgK(final int lgK) { while (n <= maxN) { final double lgT = (slope * log2(n)) + lgMaxT; - final int totTrials = Math.max(ceilingIntPowerOf2((int) Math.pow(2.0, lgT)), (1 << lgMinT)); + final int totTrials = Math.max(ceilingPowerOf2((int) Math.pow(2.0, lgT)), (1 << lgMinT)); doTrialsAtLgKAtN(lgK, n, totTrials); n = Math.round(powerSeriesNextDouble(uPPO, n, true, 2.0)); } diff --git a/src/main/java/org/apache/datasketches/fdt/PostProcessor.java b/src/main/java/org/apache/datasketches/fdt/PostProcessor.java index e3d96e080..4d4df39a2 100644 --- a/src/main/java/org/apache/datasketches/fdt/PostProcessor.java +++ b/src/main/java/org/apache/datasketches/fdt/PostProcessor.java @@ -19,7 +19,7 @@ package org.apache.datasketches.fdt; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.thetacommon.HashOperations.hashSearchOrInsert; import static org.apache.datasketches.tuple.Util.stringHash; @@ -64,7 +64,7 @@ public PostProcessor(final FdtSketch sketch, final Group group, final char sep) this.sketch = sketch.copy(); this.sep = sep; final int numEntries = sketch.getRetainedEntries(); - mapArrSize = ceilingIntPowerOf2((int)(numEntries / 0.75)); + mapArrSize = ceilingPowerOf2((int)(numEntries / 0.75)); hashArr = new long[mapArrSize]; priKeyArr = new String[mapArrSize]; counterArr = new int[mapArrSize]; diff --git a/src/main/java/org/apache/datasketches/frequencies/ItemsSketch.java b/src/main/java/org/apache/datasketches/frequencies/ItemsSketch.java index a4cffa38b..7c5bc770d 100644 --- a/src/main/java/org/apache/datasketches/frequencies/ItemsSketch.java +++ b/src/main/java/org/apache/datasketches/frequencies/ItemsSketch.java @@ -22,7 +22,7 @@ import static org.apache.datasketches.common.Util.LS; import static org.apache.datasketches.common.Util.checkBounds; import static org.apache.datasketches.common.Util.exactLog2OfInt; -import static org.apache.datasketches.common.Util.isIntPowerOf2; +import static org.apache.datasketches.common.Util.isPowerOf2; import static org.apache.datasketches.frequencies.PreambleUtil.EMPTY_FLAG_MASK; import static org.apache.datasketches.frequencies.PreambleUtil.SER_VER; import static org.apache.datasketches.frequencies.PreambleUtil.extractActiveItems; @@ -321,7 +321,7 @@ public int getCurrentMapCapacity() { * @return epsilon used to compute a priori error. */ public static double getEpsilon(final int maxMapSize) { - if (!isIntPowerOf2(maxMapSize)) { + if (!isPowerOf2(maxMapSize)) { throw new SketchesArgumentException("maxMapSize is not a power of 2."); } return 3.5 / maxMapSize; diff --git a/src/main/java/org/apache/datasketches/frequencies/LongsSketch.java b/src/main/java/org/apache/datasketches/frequencies/LongsSketch.java index 6afc33ad4..30452a1b5 100644 --- a/src/main/java/org/apache/datasketches/frequencies/LongsSketch.java +++ b/src/main/java/org/apache/datasketches/frequencies/LongsSketch.java @@ -22,7 +22,7 @@ import static org.apache.datasketches.common.Util.LS; import static org.apache.datasketches.common.Util.checkBounds; import static org.apache.datasketches.common.Util.exactLog2OfInt; -import static org.apache.datasketches.common.Util.isIntPowerOf2; +import static org.apache.datasketches.common.Util.isPowerOf2; import static org.apache.datasketches.frequencies.PreambleUtil.EMPTY_FLAG_MASK; import static org.apache.datasketches.frequencies.PreambleUtil.SER_VER; import static org.apache.datasketches.frequencies.PreambleUtil.extractActiveItems; @@ -363,7 +363,7 @@ public int getCurrentMapCapacity() { * @return epsilon used to compute a priori error. */ public static double getEpsilon(final int maxMapSize) { - if (!isIntPowerOf2(maxMapSize)) { + if (!isPowerOf2(maxMapSize)) { throw new SketchesArgumentException("maxMapSize is not a power of 2."); } return 3.5 / maxMapSize; diff --git a/src/main/java/org/apache/datasketches/hash/MurmurHash3Adaptor.java b/src/main/java/org/apache/datasketches/hash/MurmurHash3Adaptor.java index 083301b47..feecdba97 100644 --- a/src/main/java/org/apache/datasketches/hash/MurmurHash3Adaptor.java +++ b/src/main/java/org/apache/datasketches/hash/MurmurHash3Adaptor.java @@ -20,7 +20,7 @@ package org.apache.datasketches.hash; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.hash.MurmurHash3.hash; import java.nio.ByteBuffer; @@ -368,7 +368,7 @@ private static int asInteger(final long[] data, final int n) { throw new SketchesStateException( "Internal Error: Failed to find integer < n within 10000 iterations."); } - final long mask = ceilingIntPowerOf2(n) - 1; + final long mask = ceilingPowerOf2(n) - 1; while (++cnt < 10000) { final long[] h = MurmurHash3.hash(data, seed); t = (int) (h[0] & mask); diff --git a/src/main/java/org/apache/datasketches/hll/PreambleUtil.java b/src/main/java/org/apache/datasketches/hll/PreambleUtil.java index 66334da3c..dfa1bfcb6 100644 --- a/src/main/java/org/apache/datasketches/hll/PreambleUtil.java +++ b/src/main/java/org/apache/datasketches/hll/PreambleUtil.java @@ -19,7 +19,7 @@ package org.apache.datasketches.hll; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.common.Util.exactLog2OfLong; import static org.apache.datasketches.common.Util.zeroPad; import static org.apache.datasketches.hll.HllUtil.LG_AUX_ARR_INTS; @@ -460,7 +460,7 @@ static int computeLgArr(final Memory mem, final int count, final int lgConfigK) //value is missing, recompute final CurMode curMode = extractCurMode(mem); if (curMode == CurMode.LIST) { return HllUtil.LG_INIT_LIST_SIZE; } - int ceilPwr2 = ceilingIntPowerOf2(count); + int ceilPwr2 = ceilingPowerOf2(count); if ((RESIZE_DENOM * count) > (RESIZE_NUMER * ceilPwr2)) { ceilPwr2 <<= 1; } if (curMode == CurMode.SET) { return Math.max(LG_INIT_SET_SIZE, exactLog2OfLong(ceilPwr2)); diff --git a/src/main/java/org/apache/datasketches/hllmap/CouponHashMap.java b/src/main/java/org/apache/datasketches/hllmap/CouponHashMap.java index 26e23e649..ecacc4d19 100644 --- a/src/main/java/org/apache/datasketches/hllmap/CouponHashMap.java +++ b/src/main/java/org/apache/datasketches/hllmap/CouponHashMap.java @@ -19,7 +19,7 @@ package org.apache.datasketches.hllmap; -import static org.apache.datasketches.common.Util.checkIfIntPowerOf2; +import static org.apache.datasketches.common.Util.checkIfPowerOf2; import static org.apache.datasketches.common.Util.invPow2; import java.util.Arrays; @@ -266,7 +266,7 @@ int getCapacityCouponsPerEntry() { } private static final void checkMaxCouponsPerKey(final int maxCouponsPerKey) { - checkIfIntPowerOf2(maxCouponsPerKey, "maxCouponsPerKey"); + checkIfPowerOf2(maxCouponsPerKey, "maxCouponsPerKey"); final int cpk = maxCouponsPerKey; if ((cpk < 16) || (cpk > 256)) { throw new SketchesArgumentException( diff --git a/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java b/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java index ebd431a0b..44c3179b7 100644 --- a/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java +++ b/src/main/java/org/apache/datasketches/quantiles/ClassicUtil.java @@ -27,8 +27,8 @@ import static java.lang.Math.min; import static java.lang.Math.pow; import static java.lang.Math.round; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; -import static org.apache.datasketches.common.Util.isIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; +import static org.apache.datasketches.common.Util.isPowerOf2; import static org.apache.datasketches.quantiles.PreambleUtil.COMPACT_FLAG_MASK; import static org.apache.datasketches.quantiles.PreambleUtil.EMPTY_FLAG_MASK; import static org.apache.datasketches.quantiles.PreambleUtil.ORDERED_FLAG_MASK; @@ -104,7 +104,7 @@ public static int getKFromEpsilon(final double epsilon, final boolean pmf) { * @param k must be greater than 1 and less than 65536 and a power of 2. */ static void checkK(final int k) { - if ((k < MIN_K) || (k > MAX_K) || !isIntPowerOf2(k)) { + if ((k < MIN_K) || (k > MAX_K) || !isPowerOf2(k)) { throw new SketchesArgumentException( "K must be >= " + MIN_K + " and <= " + MAX_K + " and a power of 2: " + k); } @@ -210,7 +210,7 @@ static int computeCombinedBufferItemCapacity(final int k, final long n) { final int totLevels = computeNumLevelsNeeded(k, n); if (totLevels == 0) { final int bbItems = computeBaseBufferItems(k, n); - return Math.max(2 * MIN_K, ceilingIntPowerOf2(bbItems)); + return Math.max(2 * MIN_K, ceilingPowerOf2(bbItems)); } return (2 + totLevels) * k; } diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java b/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java index 9e207fc0b..cc8f427c0 100644 --- a/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java +++ b/src/main/java/org/apache/datasketches/quantiles/DoublesMergeImpl.java @@ -19,7 +19,7 @@ package org.apache.datasketches.quantiles; -import static org.apache.datasketches.common.Util.checkIfIntPowerOf2; +import static org.apache.datasketches.common.Util.checkIfPowerOf2; import static org.apache.datasketches.quantiles.PreambleUtil.EMPTY_FLAG_MASK; import static org.apache.datasketches.quantiles.PreambleUtil.FLAGS_BYTE; @@ -151,7 +151,7 @@ static void downSamplingMergeInto(final DoublesSketch src, final UpdateDoublesSk } final int downFactor = sourceK / targetK; - checkIfIntPowerOf2(downFactor, "source.getK()/target.getK() ratio"); + checkIfPowerOf2(downFactor, "source.getK()/target.getK() ratio"); final int lgDownFactor = Integer.numberOfTrailingZeros(downFactor); if (src.isEmpty()) { return; } diff --git a/src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java b/src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java index bbcdf44f7..dc583fb7d 100644 --- a/src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java +++ b/src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java @@ -21,7 +21,7 @@ import static java.lang.Math.max; import static java.lang.Math.min; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.quantiles.ClassicUtil.MAX_PRELONGS; import static org.apache.datasketches.quantiles.ClassicUtil.MIN_K; import static org.apache.datasketches.quantiles.ClassicUtil.checkIsCompactMemory; @@ -456,7 +456,7 @@ public static int getUpdatableStorageBytes(final int k, final long n) { final int metaPre = MAX_PRELONGS + 2; //plus min, max final int totLevels = computeNumLevelsNeeded(k, n); if (n <= k) { - final int ceil = Math.max(ceilingIntPowerOf2((int)n), MIN_K * 2); + final int ceil = Math.max(ceilingPowerOf2((int)n), MIN_K * 2); return metaPre + ceil << 3; } return metaPre + (2 + totLevels) * k << 3; diff --git a/src/main/java/org/apache/datasketches/quantiles/ItemsMergeImpl.java b/src/main/java/org/apache/datasketches/quantiles/ItemsMergeImpl.java index c6af57d2e..2c1566988 100644 --- a/src/main/java/org/apache/datasketches/quantiles/ItemsMergeImpl.java +++ b/src/main/java/org/apache/datasketches/quantiles/ItemsMergeImpl.java @@ -20,7 +20,7 @@ package org.apache.datasketches.quantiles; import static java.lang.System.arraycopy; -import static org.apache.datasketches.common.Util.checkIfIntPowerOf2; +import static org.apache.datasketches.common.Util.checkIfPowerOf2; import java.util.Arrays; import java.util.Comparator; @@ -144,7 +144,7 @@ staticIf this.isCompact() == true this method returns this, - * otherwise, this method is equivalent to + * otherwise, this method is equivalent to * {@link #compact(boolean, WritableMemory) compact(true, null)}. * *
A CompactSketch is always immutable.
@@ -220,14 +220,14 @@ public CompactSketch compact() { * then rebuild() should be called on the UpdateSketch prior to calling this method. * *A CompactSketch is always immutable.
- * + * *A new CompactSketch object is created:
*Otherwise, this operation returns this.
* * @param dstOrdered assumed true if this sketch is empty or has only one value @@ -313,7 +313,7 @@ public static int getMaxCompactSketchBytes(final int numberOfEntries) { * nomEntries */ public static int getMaxUpdateSketchBytes(final int nomEntries) { - final int nomEnt = ceilingIntPowerOf2(nomEntries); + final int nomEnt = ceilingPowerOf2(nomEntries); return (nomEnt << 4) + (Family.QUICKSELECT.getMaxPreLongs() << 3); } diff --git a/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java b/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java index 2f6080916..eec91e881 100644 --- a/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java +++ b/src/main/java/org/apache/datasketches/theta/UpdateSketchBuilder.java @@ -21,7 +21,7 @@ import static org.apache.datasketches.common.Util.LS; import static org.apache.datasketches.common.Util.TAB; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import org.apache.datasketches.common.Family; import org.apache.datasketches.common.ResizeFactor; @@ -139,7 +139,7 @@ public int getLgNominalEntries() { * @return this UpdateSketchBuilder */ public UpdateSketchBuilder setLocalNominalEntries(final int nomEntries) { - bLocalLgNomLongs = Integer.numberOfTrailingZeros(ceilingIntPowerOf2(nomEntries)); + bLocalLgNomLongs = Integer.numberOfTrailingZeros(ceilingPowerOf2(nomEntries)); if ((bLocalLgNomLongs > ThetaUtil.MAX_LG_NOM_LONGS) || (bLocalLgNomLongs < ThetaUtil.MIN_LG_NOM_LONGS)) { throw new SketchesArgumentException( "Nominal Entries must be >= 16 and <= 67108864: " + nomEntries); diff --git a/src/main/java/org/apache/datasketches/thetacommon/HashOperations.java b/src/main/java/org/apache/datasketches/thetacommon/HashOperations.java index c4fad61ca..848bb47ed 100644 --- a/src/main/java/org/apache/datasketches/thetacommon/HashOperations.java +++ b/src/main/java/org/apache/datasketches/thetacommon/HashOperations.java @@ -20,7 +20,7 @@ package org.apache.datasketches.thetacommon; import static java.lang.Math.max; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import org.apache.datasketches.common.SketchesArgumentException; import org.apache.datasketches.common.SketchesStateException; @@ -351,7 +351,7 @@ public static long[] convertToHashTable( */ public static int minLgHashTableSize(final int count, final double rebuild_threshold) { final int upperCount = (int) Math.ceil(count / rebuild_threshold); - final int arrLongs = max(ceilingIntPowerOf2(upperCount), 1 << ThetaUtil.MIN_LG_ARR_LONGS); + final int arrLongs = max(ceilingPowerOf2(upperCount), 1 << ThetaUtil.MIN_LG_ARR_LONGS); final int newLgArrLongs = Integer.numberOfTrailingZeros(arrLongs); return newLgArrLongs; } diff --git a/src/main/java/org/apache/datasketches/thetacommon/ThetaUtil.java b/src/main/java/org/apache/datasketches/thetacommon/ThetaUtil.java index 23fa17129..be209ece1 100644 --- a/src/main/java/org/apache/datasketches/thetacommon/ThetaUtil.java +++ b/src/main/java/org/apache/datasketches/thetacommon/ThetaUtil.java @@ -140,7 +140,7 @@ public static int startingSubMultiple(final int lgTarget, final int lgRF, * @return The Log2 of the ceiling power of 2 of the given nomLongs. */ public static int checkNomLongs(final int nomLongs) { - final int lgNomLongs = Integer.numberOfTrailingZeros(Util.ceilingIntPowerOf2(nomLongs)); + final int lgNomLongs = Integer.numberOfTrailingZeros(Util.ceilingPowerOf2(nomLongs)); if (lgNomLongs > MAX_LG_NOM_LONGS || lgNomLongs < MIN_LG_NOM_LONGS) { throw new SketchesArgumentException("Nominal Entries must be >= 16 and <= 67108864: " + nomLongs); diff --git a/src/main/java/org/apache/datasketches/tuple/HashTables.java b/src/main/java/org/apache/datasketches/tuple/HashTables.java index eb672c9eb..bd42f4980 100644 --- a/src/main/java/org/apache/datasketches/tuple/HashTables.java +++ b/src/main/java/org/apache/datasketches/tuple/HashTables.java @@ -22,7 +22,7 @@ import static java.lang.Math.ceil; import static java.lang.Math.max; import static java.lang.Math.min; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.thetacommon.HashOperations.hashInsertOnly; import static org.apache.datasketches.thetacommon.HashOperations.hashSearch; @@ -162,7 +162,7 @@ void clear() { } static int getLgTableSize(final int count) { - final int tableSize = max(ceilingIntPowerOf2((int) ceil(count / 0.75)), 1 << ThetaUtil.MIN_LG_NOM_LONGS); + final int tableSize = max(ceilingPowerOf2((int) ceil(count / 0.75)), 1 << ThetaUtil.MIN_LG_NOM_LONGS); return Integer.numberOfTrailingZeros(tableSize); } diff --git a/src/main/java/org/apache/datasketches/tuple/Intersection.java b/src/main/java/org/apache/datasketches/tuple/Intersection.java index c9443acc5..b6f53249a 100644 --- a/src/main/java/org/apache/datasketches/tuple/Intersection.java +++ b/src/main/java/org/apache/datasketches/tuple/Intersection.java @@ -22,7 +22,7 @@ import static java.lang.Math.ceil; import static java.lang.Math.max; import static java.lang.Math.min; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import org.apache.datasketches.common.SketchesArgumentException; import org.apache.datasketches.common.SketchesStateException; @@ -247,7 +247,7 @@ private void resetToEmpty() { } static int getLgTableSize(final int count) { - final int tableSize = max(ceilingIntPowerOf2((int) ceil(count / 0.75)), 1 << ThetaUtil.MIN_LG_NOM_LONGS); + final int tableSize = max(ceilingPowerOf2((int) ceil(count / 0.75)), 1 << ThetaUtil.MIN_LG_NOM_LONGS); return Integer.numberOfTrailingZeros(tableSize); } diff --git a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java index 561773a8a..73c6c7fe0 100644 --- a/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java +++ b/src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java @@ -21,7 +21,7 @@ import static java.lang.Math.max; import static java.lang.Math.min; -import static org.apache.datasketches.common.Util.ceilingIntPowerOf2; +import static org.apache.datasketches.common.Util.ceilingPowerOf2; import static org.apache.datasketches.thetacommon.BoundsOnRatiosInTupleSketchedSets.getEstimateOfBoverA; import static org.apache.datasketches.thetacommon.BoundsOnRatiosInTupleSketchedSets.getLowerBoundForBoverA; import static org.apache.datasketches.thetacommon.BoundsOnRatiosInTupleSketchedSets.getUpperBoundForBoverA; @@ -74,7 +74,7 @@ public static