You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2022/01/29 23:22:13 UTC

[datasketches-java] 05/05: fix spelling, improved comments, etc.

This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch FixKllComments
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git

commit d465d283a4c8fd2e23b35a767544ce2b20a196a5
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sat Jan 29 15:19:10 2022 -0800

    fix spelling, improved comments, etc.
    
    No actual code changes.
---
 .../java/org/apache/datasketches/kll/KllFloatsSketch.java    | 12 ++++++++----
 src/main/java/org/apache/datasketches/kll/KllHelper.java     |  5 +++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java b/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java
index 6689510..69f7521 100644
--- a/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java
@@ -865,7 +865,7 @@ public class KllFloatsSketch {
         final int fromIndex = levels_[level];
         final int toIndex = levels_[level + 1]; // exclusive
         if (fromIndex < toIndex) {
-          sb.append(" level[").append(level).append("]: " + levels_[level] + " wt: " + (1 << level));
+          sb.append(" level[").append(level).append("]: offset: " + levels_[level] + " wt: " + (1 << level));
           sb.append(Util.LS);
         }
         for (int i = fromIndex; i < toIndex; i++) {
@@ -873,7 +873,7 @@ public class KllFloatsSketch {
         }
         level++;
       }
-      sb.append(" level[" + level + "]: " + levels_[level] + " (Exclusive)");
+      sb.append(" level[" + level + "]: offset: " + levels_[level] + " (Exclusive)");
       sb.append(Util.LS);
       sb.append("### End sketch data").append(Util.LS);
     }
@@ -1046,7 +1046,11 @@ public class KllFloatsSketch {
     }
   }
 
-  private int findLevelToCompact() {
+  /**
+   * Finds the first level starting with level 0 that exceeds its nominal capacity
+   * @return level to compact
+   */
+  private int findLevelToCompact() { //
     int level = 0;
     while (true) {
       assert level < numLevels_;
@@ -1063,7 +1067,7 @@ public class KllFloatsSketch {
     final int curTotalCap = levels_[numLevels_];
 
     // make sure that we are following a certain growth scheme
-    assert levels_[0] == 0;
+    assert levels_[0] == 0; //definition of full
     assert items_.length == curTotalCap;
 
     // note that merging MIGHT over-grow levels_, in which case we might not have to grow it here
diff --git a/src/main/java/org/apache/datasketches/kll/KllHelper.java b/src/main/java/org/apache/datasketches/kll/KllHelper.java
index c53e189..aedcf62 100644
--- a/src/main/java/org/apache/datasketches/kll/KllHelper.java
+++ b/src/main/java/org/apache/datasketches/kll/KllHelper.java
@@ -41,6 +41,7 @@ class KllHelper {
 
   /**
    * Copy the old array into a new larger array.
+   * The extra space is at the top.
    * @param oldArr the given old array with data
    * @param newLen the new length larger than the oldArr.length.
    * @return the new array
@@ -106,7 +107,7 @@ class KllHelper {
    * @return the actual capacity of a given level given its depth index.
    */
   private static long intCapAux(final int k, final int depth) {
-    if (depth <= 30) { return (int) intCapAuxAux(k, depth); }
+    if (depth <= 30) { return intCapAuxAux(k, depth); }
     final int half = depth / 2;
     final int rest = depth - half;
     final long tmp = intCapAuxAux(k, half);
@@ -122,7 +123,7 @@ class KllHelper {
   private static long intCapAuxAux(final long k, final int depth) {
     final long twok = k << 1; // for rounding pre-multiply by 2
     final long tmp = ((twok << depth) / powersOfThree[depth]);
-    final long result = ((tmp + 1) >> 1); // add 1 and divide by 2
+    final long result = ((tmp + 1L) >>> 1); // add 1 and divide by 2
     assert (result <= k);
     return result;
   }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org