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 2026/09/13 19:21:44 UTC

(datasketches-java) branch improve_util_numdigits updated (fb2da3996 -> 1734af9ad)

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

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


    from fb2da3996 Improve the numDigits method
     new 386dfc271 Remove temp numDigits & test methods.
     add 509903ede Add CpcUnion.update(MemorySegment)
     add 325574e2a Merge pull request #759 from permutive-engineering/perf/cpc-union-memory-segment
     add 1a49f80b1 Choose the QuickSelect pivot by median of three
     add a5b488b56 Merge pull request #760 from permutive-engineering/fix/quickselect-sorted-input
     add 9a488f951 Make the deferred KxQ rebuild canonical, stop HIP drifting after a merge, set the compact flag for HLL_6/HLL_8
     add 041ddb57a Merge pull request #761 from apache/hll-parity
     add 63fcb766d Add UpdatableThetaSketch.compactTrimmed() to compact and reduce to k in one pass
     add 90319c208 Merge pull request #763 from apache/theta-compact-trim
     new c11f50afc Merge branch 'main' into improve_util_numdigits
     new 1734af9ad Revert to main

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/datasketches/common/QuickSelect.java    |  61 ++++---
 .../java/org/apache/datasketches/common/Util.java  |  66 +++----
 .../apache/datasketches/cpc/CpcCompression.java    |  15 +-
 .../java/org/apache/datasketches/cpc/CpcUnion.java |  72 ++++++++
 .../apache/datasketches/hll/AbstractHllArray.java  |   9 +-
 .../apache/datasketches/hll/DirectHllArray.java    |   7 +-
 .../java/org/apache/datasketches/hll/HllArray.java |   4 +-
 .../java/org/apache/datasketches/hll/HllUnion.java |  17 +-
 .../java/org/apache/datasketches/hll/HllUtil.java  |   6 +-
 .../datasketches/theta/UpdatableThetaSketch.java   |  95 ++++++++++
 .../org/apache/datasketches/common/UtilTest.java   |  16 --
 .../cpc/CpcUnionSegmentUpdateTest.java             | 167 ++++++++++++++++++
 .../apache/datasketches/hll/HllKxqRebuildTest.java | 147 ++++++++++++++++
 .../org/apache/datasketches/hll/HllSketchTest.java |  20 +--
 .../apache/datasketches/theta/CompactTrimTest.java | 194 +++++++++++++++++++++
 .../datasketches/thetacommon/QuickSelectTest.java  |  72 ++++++++
 16 files changed, 853 insertions(+), 115 deletions(-)
 create mode 100644 src/test/java/org/apache/datasketches/cpc/CpcUnionSegmentUpdateTest.java
 create mode 100644 src/test/java/org/apache/datasketches/hll/HllKxqRebuildTest.java
 create mode 100644 src/test/java/org/apache/datasketches/theta/CompactTrimTest.java


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


(datasketches-java) 03/03: Revert to main

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1734af9ad47b6f39d233adde31958d01d15aa35c
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sun Sep 13 12:21:38 2026 -0700

    Revert to main
---
 .../java/org/apache/datasketches/common/Util.java  | 48 +++++++++++-----------
 .../org/apache/datasketches/common/UtilTest.java   |  2 +
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/common/Util.java b/src/main/java/org/apache/datasketches/common/Util.java
index 8412fd24c..afb080501 100644
--- a/src/main/java/org/apache/datasketches/common/Util.java
+++ b/src/main/java/org/apache/datasketches/common/Util.java
@@ -620,7 +620,7 @@ public final class Util {
   }
 
   /** Logarithm related ************************/
-
+  
   /**
    * The log<sub>2</sub>(value)
    * @param value the given value
@@ -719,7 +719,7 @@ public final class Util {
   }
 
   /** Checks that throw ************************/
-
+  
   /**
    * Check the requested offset and length against the allocated size.
    * The invariants equation is: {@code 0 <= reqOff <= reqLen <= reqOff + reqLen <= allocSize}.
@@ -796,7 +796,7 @@ public final class Util {
   }
 
   /** Decimal Digits ***************************/
-
+  
   /**
    * Computes the number of decimal digits of the number n
    * @param n the given number
@@ -808,7 +808,7 @@ public final class Util {
   }
 
   /** Generic relational tests *****************/
-
+  
   /**
    * Finds the minimum of two generic items
    * @param <T> the type
@@ -971,7 +971,7 @@ public final class Util {
   }
 
   /** Seed Hashes ******************************/
-
+  
   /**
    * Computes and checks the 16-bit seed hash from the given long seed.
    * The seed hash may not be zero in order to maintain compatibility with older serialized
@@ -1004,25 +1004,25 @@ public final class Util {
     }
     return seedHashA;
   }
-
+  
   /** Files and File Bytes ******************************/
 
   /**
-   * Windows, POSIX, and JAR friendly, returns a byte array of the contents of the file defined by the given
+   * Windows, POSIX, and JAR friendly, returns a byte array of the contents of the file defined by the given 
    * resourceName.
    * If the resource is in a JAR it will be copied into the File System as a temporary file first.
-   *
+   * 
    * @param resourceName the short name or the full path name.
    * @return a byte array of the contents of the file defined by the given resourceName.
    */
   public static byte[] getResourceBytes(final String resourceName) {
     Objects.requireNonNull(resourceName, "Given resourceName must not be null");
-
+    
     String normalizedName = resourceName.replace('\\', '/');
     if (normalizedName.startsWith("/")) {
       normalizedName = normalizedName.substring(1);
     }
-
+  
     final ClassLoader loader = Util.class.getClassLoader();
     try (InputStream in = loader.getResourceAsStream(normalizedName)) {
       if (in == null) {
@@ -1037,10 +1037,10 @@ public final class Util {
   /**
    *   Windows, POSIX, and JAR friendly get Resource File.
    *   If the resource is in a JAR it will be copied into the File System as a temporary file first.
-   *
-   *   <p>While tempFile.deleteOnExit() works, keep in mind that JVMs running long processes won't delete those files
-   *   until the JVM completely terminates, which can lead to memory/disk leaks if this method is called frequently.
-   *   If you're using this for memory-mapped files, consider explicitly deleting the file once the memory-mapped buffer
+   *   
+   *   <p>While tempFile.deleteOnExit() works, keep in mind that JVMs running long processes won't delete those files 
+   *   until the JVM completely terminates, which can lead to memory/disk leaks if this method is called frequently. 
+   *   If you're using this for memory-mapped files, consider explicitly deleting the file once the memory-mapped buffer 
    *   is no longer in use, or registering a custom shutdown hook if deleteOnExit() is insufficient.</p>
    *   @param resourceName the simple file name or full path name.
    *   Any back-slashes will be converted to forward slashes and a leading forward slash will be removed.
@@ -1053,19 +1053,19 @@ public final class Util {
     // Normalize name: ClassLoaders MUST use forward slashes even on Windows
     String normalizedName = resourceName.replace('\\', '/');
     if (normalizedName.startsWith("/")) { normalizedName = normalizedName.substring(1); }
-
+  
     final ClassLoader loader = Util.class.getClassLoader();
     final URL url = loader.getResource(normalizedName);
     if (url == null) { throw new IllegalArgumentException("Resource not found: " + normalizedName); }
-
+  
     // If it's a real file, return it directly
     if ("file".equals(url.getProtocol())) {
-        try {
+        try { 
           final URI uri = url.toURI();
-          return new File(uri); }
+          return new File(uri); } 
         catch (final URISyntaxException e) { return new File(url.getPath()); }
     }
-
+  
     // If it's in a JAR, we must extract it for Memory.map() to work
     // We use a prefix that won't collide with Windows reserved names
     // We use NIO Files.createTempFile to ensure secure default permissions (0600)
@@ -1073,17 +1073,17 @@ public final class Util {
     try { tempFile = Files.createTempFile("datasketches-", ".bin").toFile(); }
     catch (final IOException e1) { throw new IllegalArgumentException(e1); }
     tempFile.deleteOnExit();
-
+  
     try (InputStream in = loader.getResourceAsStream(normalizedName)) {
         if (in == null) { throw new IllegalArgumentException("Could not open stream for " + normalizedName); }
-
+        
         // Use REPLACE_EXISTING to avoid "File Already Exists" errors on Windows retries
         Files.copy(in, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
     } catch (final IOException e) { throw new IllegalArgumentException(e); }
-
+  
     // Final Windows Fix: Ensure the file is actually writable if you need to setReadOnly later
-    //tempFile.setWritable(true);
-
+    //tempFile.setWritable(true); 
+    
     return tempFile;
   }
 
diff --git a/src/test/java/org/apache/datasketches/common/UtilTest.java b/src/test/java/org/apache/datasketches/common/UtilTest.java
index ca6445b3a..f9f0b09ae 100644
--- a/src/test/java/org/apache/datasketches/common/UtilTest.java
+++ b/src/test/java/org/apache/datasketches/common/UtilTest.java
@@ -433,6 +433,8 @@ public class UtilTest {
     assertEquals(v, v2);
   }
 
+
+
   @Test
   public void printlnTest() {
     println("PRINTING: " + this.getClass().getName());


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


(datasketches-java) 02/03: Merge branch 'main' into improve_util_numdigits

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c11f50afc72e6e64c7f600a741e24fb27ff5d823
Merge: 386dfc271 90319c208
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sun Sep 13 12:12:00 2026 -0700

    Merge branch 'main' into improve_util_numdigits

 .../apache/datasketches/common/QuickSelect.java    |  61 ++++---
 .../apache/datasketches/cpc/CpcCompression.java    |  15 +-
 .../java/org/apache/datasketches/cpc/CpcUnion.java |  72 ++++++++
 .../apache/datasketches/hll/AbstractHllArray.java  |   9 +-
 .../apache/datasketches/hll/DirectHllArray.java    |   7 +-
 .../java/org/apache/datasketches/hll/HllArray.java |   4 +-
 .../java/org/apache/datasketches/hll/HllUnion.java |  17 +-
 .../java/org/apache/datasketches/hll/HllUtil.java  |   6 +-
 .../datasketches/theta/UpdatableThetaSketch.java   |  95 ++++++++++
 .../cpc/CpcUnionSegmentUpdateTest.java             | 167 ++++++++++++++++++
 .../apache/datasketches/hll/HllKxqRebuildTest.java | 147 ++++++++++++++++
 .../org/apache/datasketches/hll/HllSketchTest.java |  20 +--
 .../apache/datasketches/theta/CompactTrimTest.java | 194 +++++++++++++++++++++
 .../datasketches/thetacommon/QuickSelectTest.java  |  72 ++++++++
 14 files changed, 829 insertions(+), 57 deletions(-)


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


(datasketches-java) 01/03: Remove temp numDigits & test methods.

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 386dfc271f3f742018304d6164c925074daaa809
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sun Sep 13 12:04:17 2026 -0700

    Remove temp numDigits & test methods.
---
 src/main/java/org/apache/datasketches/common/Util.java | 18 ------------------
 .../java/org/apache/datasketches/common/UtilTest.java  | 18 ------------------
 2 files changed, 36 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/common/Util.java b/src/main/java/org/apache/datasketches/common/Util.java
index 42f28b427..8412fd24c 100644
--- a/src/main/java/org/apache/datasketches/common/Util.java
+++ b/src/main/java/org/apache/datasketches/common/Util.java
@@ -807,24 +807,6 @@ public final class Util {
     return (int) ceil(log(n) / log(10));
   }
 
-  /**
-   * Computes the minimum number of characters required to print the number n as a decimal.
-   * Negative numbers add one for the minus sign character.
-   * No other non-digit characters are assumed.
-   * @param n the given number, which may be negative.
-   * @return the number of characters required to print the number n
-   */
-  public static int numDigits2(long n) {
-      if (n == 0) { return 1; }    // handles the zero special case
-      int count = (n < 0) ? 1 : 0; // handles the minus sign
-      while (n != 0) {
-          n /= 10;
-          count++;
-      }
-      return count;
-  }
-
-
   /** Generic relational tests *****************/
 
   /**
diff --git a/src/test/java/org/apache/datasketches/common/UtilTest.java b/src/test/java/org/apache/datasketches/common/UtilTest.java
index 22f20e274..ca6445b3a 100644
--- a/src/test/java/org/apache/datasketches/common/UtilTest.java
+++ b/src/test/java/org/apache/datasketches/common/UtilTest.java
@@ -46,7 +46,6 @@ import static org.apache.datasketches.common.Util.isPowerOf2;
 import static org.apache.datasketches.common.Util.longToBytes;
 import static org.apache.datasketches.common.Util.milliSecToString;
 import static org.apache.datasketches.common.Util.nanoSecToString;
-import static org.apache.datasketches.common.Util.numDigits2;
 import static org.apache.datasketches.common.Util.numberOfLeadingOnes;
 import static org.apache.datasketches.common.Util.numberOfTrailingOnes;
 import static org.apache.datasketches.common.Util.powerSeriesNextDouble;
@@ -434,23 +433,6 @@ public class UtilTest {
     assertEquals(v, v2);
   }
 
-  @Test
-  static void checkNumDigits() {
-    for (long n = 1; n < Long.MAX_VALUE && n > 0; n *= 10) {
-      checkN(n);
-      checkN(n - 1);
-      checkN(-n);
-      checkN(-n + 1);
-    }
-    checkN(Long.MAX_VALUE);
-    checkN(Long.MIN_VALUE);
-  }
-
-  private static void checkN(long n) {
-    //println(n);
-    assertEquals(numDigits2(n), String.valueOf(n).length());
-  }
-
   @Test
   public void printlnTest() {
     println("PRINTING: " + this.getClass().getName());


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