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

leerho pushed a commit to branch update_7.0.X
in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git


The following commit(s) were added to refs/heads/update_7.0.X by this push:
     new bbfa71fe Update 7.0.X move test-only utils from Util to TestUtil.
bbfa71fe is described below

commit bbfa71fe258ad9f38b799c894225b5c00838982a
Author: Lee Rhodes <[email protected]>
AuthorDate: Sat May 9 16:57:36 2026 -0700

    Update 7.0.X move test-only utils from Util to TestUtil.
---
 .../apache/datasketches/memory/internal/Util.java  | 258 ---------------------
 .../internal/AllocateDirectMapMemoryTest.java      |   3 +-
 .../AllocateDirectWritableMapMemoryTest.java       |   3 +-
 .../memory/internal/CommonMemoryTest.java          |  46 ----
 .../datasketches/memory/internal/TestUtil.java}    | 175 ++------------
 .../datasketches/memory/internal/ThreadTest.java   |   2 +-
 .../datasketches/memory/internal/UtilTest.java     |  17 +-
 7 files changed, 27 insertions(+), 477 deletions(-)

diff --git 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
 
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
index 5769fcab..d597cfd2 100644
--- 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
+++ 
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
@@ -21,19 +21,7 @@ package org.apache.datasketches.memory.internal;
 
 import static java.util.Arrays.fill;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
 import java.nio.ByteOrder;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
-import java.util.Objects;
-import java.util.Random;
-
-import org.apache.datasketches.memory.Memory;
 
 /**
  * @author Lee Rhodes
@@ -91,38 +79,6 @@ public final class Util {
     return ByteOrder.nativeOrder() == byteOrder;
   }
 
-  /**
-   * Searches a range of the specified array of longs for the specified value 
using the binary
-   * search algorithm. The range must be sorted method) prior to making this 
call.
-   * If it is not sorted, the results are undefined. If the range contains
-   * multiple elements with the specified value, there is no guarantee which 
one will be found.
-   * @param mem the Memory to be searched
-   * @param fromLongIndex the index of the first element (inclusive) to be 
searched
-   * @param toLongIndex the index of the last element (exclusive) to be 
searched
-   * @param key the value to be searched for
-   * @return index of the search key, if it is contained in the array within 
the specified range;
-   * otherwise, (-(insertion point) - 1). The insertion point is defined as 
the point at which
-   * the key would be inserted into the array: the index of the first element 
in the range greater
-   * than the key, or toIndex if all elements in the range are less than the 
specified key.
-   * Note that this guarantees that the return value will be &ge; 0 if and 
only if the key is found.
-   */
-  public static long binarySearchLongs(final Memory mem, final long 
fromLongIndex,
-      final long toLongIndex, final long key) {
-    ResourceImpl.checkBounds(fromLongIndex << 3, (toLongIndex - fromLongIndex) 
<< 3, mem.getCapacity());
-    long low = fromLongIndex;
-    long high = toLongIndex - 1L;
-
-    while (low <= high) {
-      final long mid = (low + high) >>> 1;
-      final long midVal = mem.getLong(mid << 3);
-
-      if (midVal < key)      { low = mid + 1;  }
-      else if (midVal > key) { high = mid - 1; }
-      else                   { return mid;     } // key found
-    }
-    return -(low + 1); // key not found.
-  }
-
   /**
    * Prepend the given string with zeros. If the given string is equal or 
greater than the given
    * field length, it will be returned without modification.
@@ -155,131 +111,6 @@ public final class Util {
     return s;
   }
 
-  /**
-   * Return true if all the masked bits of value are zero
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if all the masked bits of value are zero
-   */
-  public static final boolean isAllBitsClear(final long value, final long 
bitMask) {
-    return (~value & bitMask) == bitMask;
-  }
-
-  /**
-   * Return true if all the masked bits of value are one
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if all the masked bits of value are one
-   */
-  public static final boolean isAllBitsSet(final long value, final long 
bitMask) {
-    return (value & bitMask) == bitMask;
-  }
-
-  /**
-   * Return true if any the masked bits of value are zero
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if any the masked bits of value are zero
-   */
-  public static final boolean isAnyBitsClear(final long value, final long 
bitMask) {
-    return (~value & bitMask) != 0;
-  }
-
-  /**
-   * Return true if any the masked bits of value are one
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if any the masked bits of value are one
-   */
-  public static final boolean isAnyBitsSet(final long value, final long 
bitMask) {
-    return (value & bitMask) != 0;
-  }
-
-  /**
-   * Creates random valid Character Code Points (as integers). By definition, 
valid CodePoints
-   * are integers in the range 0 to Character.MAX_CODE_POINT, and exclude the 
surrogate values.
-   * This is used in unit testing and characterization testing of the UTF8 
class. Because the
-   * characterization tools are in a separate package, this must remain public.
-   *
-   * @author Lee Rhodes
-   */
-  public static class RandomCodePoints {
-    private Random rand; //
-    private static final int ALL_CP = Character.MAX_CODE_POINT + 1;
-    private static final int MIN_SUR = Character.MIN_SURROGATE;
-    private static final int MAX_SUR = Character.MAX_SURROGATE;
-
-    /**
-     * @param deterministic if true, configure java.util.Random with a fixed 
seed.
-     */
-    public RandomCodePoints(final boolean deterministic) {
-      rand = deterministic ? new Random(0) : new Random();
-    }
-
-    /**
-     * Fills the given array with random valid Code Points from 0, inclusive, 
to
-     * <i>Character.MAX_CODE_POINT</i>, inclusive.
-     * The surrogate range, which is from <i>Character.MIN_SURROGATE</i>, 
inclusive, to
-     * <i>Character.MAX_SURROGATE</i>, inclusive, is always <u>excluded</u>.
-     * @param cpArr the array to fill
-     */
-    public final void fillCodePointArray(final int[] cpArr) {
-      fillCodePointArray(cpArr, 0, ALL_CP);
-    }
-
-    /**
-     * Fills the given array with random valid Code Points from 
<i>startCP</i>, inclusive, to
-     * <i>endCP</i>, exclusive.
-     * The surrogate range, which is from <i>Character.MIN_SURROGATE</i>, 
inclusive, to
-     * <i>Character.MAX_SURROGATE</i>, inclusive, is always <u>excluded</u>.
-     * @param cpArr the array to fill
-     * @param startCP the starting Code Point, included.
-     * @param endCP the ending Code Point, excluded. This value cannot exceed 
0x110000.
-     */
-    public final void fillCodePointArray(final int[] cpArr, final int startCP, 
final int endCP) {
-      final int arrLen = cpArr.length;
-      final int numCP = Math.min(endCP, 0X110000) - Math.min(0, startCP);
-      int idx = 0;
-      while (idx < arrLen) {
-        final int cp = startCP + rand.nextInt(numCP);
-        if ((cp >= MIN_SUR) && (cp <= MAX_SUR)) {
-          continue;
-        }
-        cpArr[idx++] = cp;
-      }
-    }
-
-    /**
-     * Return a single valid random Code Point from 0, inclusive, to
-     * <i>Character.MAX_CODE_POINT</i>, inclusive.
-     * The surrogate range, which is from <i>Character.MIN_SURROGATE</i>, 
inclusive, to
-     * <i>Character.MAX_SURROGATE</i>, inclusive, is always <u>excluded</u>.
-     * @return a single valid random CodePoint.
-     */
-    public final int getCodePoint() {
-      return getCodePoint(0, ALL_CP);
-    }
-
-    /**
-     * Return a single valid random Code Point from <i>startCP</i>, inclusive, 
to
-     * <i>endCP</i>, exclusive.
-     * The surrogate range, which is from <i>Character.MIN_SURROGATE</i>, 
inclusive, to
-     * <i>Character.MAX_SURROGATE</i>, inclusive, is always <u>excluded</u>.
-     * @param startCP the starting Code Point, included.
-     * @param endCP the ending Code Point, excluded. This value cannot exceed 
0x110000.
-     * @return a single valid random CodePoint.
-     */
-    public final int getCodePoint(final int startCP, final int endCP) {
-      final int numCP = Math.min(endCP, 0X110000) - Math.min(0, startCP);
-      while (true) {
-        final int cp = startCP + rand.nextInt(numCP);
-        if ((cp < MIN_SUR) || (cp > MAX_SUR)) {
-          return cp;
-        }
-      }
-    }
-  } //End class RandomCodePoints
-
   /**
    * Checks if given value is &lt; zero.
    * @param value the given value
@@ -291,93 +122,4 @@ public final class Util {
       throw new IllegalArgumentException("The argument '" + arg + "' may not 
be negative.");
     }
   }
-
-  /**
-   * Windows, POSIX, and JAR friendly, returns a byte array of the contents of 
the file defined by the given 
-   * resourceName. This is only used in test.
-   * 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) {
-        throw new IllegalArgumentException("Resource not found: " + 
normalizedName);
-      }
-      return in.readAllBytes();
-    } catch (final IOException e) {
-      throw new IllegalArgumentException("Cannot read resource: " + 
normalizedName + LS + e);
-    }
-  }
-
-  /**
-   *   Windows, POSIX, and JAR friendly get Resource File. This is only used 
in test.
-   *   If the resource is in a JAR it will be copied into the File System as a 
temporary file first.
-   *   @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.
-   *   No other special characters allowed.
-   *   @return a File System File
-   */
-  public static File getResourceFile(final String resourceName) {
-    Objects.requireNonNull(resourceName, "Given resourceName must not be 
null");
-    if (resourceName.isEmpty()) { throw new IllegalArgumentException("Given 
resourceName must not be empty"); }
-    // 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 { 
-          final URI uri = url.toURI();
-          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
-    final File tempFile;
-    try { tempFile = File.createTempFile("datasketches-", ".bin"); }
-    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); 
-    
-    return tempFile;
-  }
-  
-  /**
-   * Windows, POSIX, and JAR friendly, checks if the given resourceName exists 
and sets it to Read-Only.  
-   * This is only used in test.
-   * If the resource is in a JAR it will be copied into the File System as a 
temporary file first.
-   * This will not work if the file is currently memory-mapped.  
-   * If it is memory-mapped, close the mapping first.
-   * @param resourceName the given resource.
-   * @return the read only file.
-   */
-  public static File setResourceReadOnly(final String resourceName) {
-      final File file = getResourceFile(resourceName);
-      file.setReadOnly();
-      return file;
-  }
 }
diff --git 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectMapMemoryTest.java
 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectMapMemoryTest.java
index 5ab35c0f..38617f05 100644
--- 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectMapMemoryTest.java
+++ 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectMapMemoryTest.java
@@ -19,7 +19,6 @@
 
 package org.apache.datasketches.memory.internal;
 
-import static org.apache.datasketches.memory.internal.Util.setResourceReadOnly;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
@@ -40,7 +39,7 @@ public class AllocateDirectMapMemoryTest {
   
   @BeforeClass
   public void setReadOnly() {
-    gettyFile = setResourceReadOnly("GettysburgAddress.txt");
+    gettyFile = TestUtil.setResourceReadOnly("GettysburgAddress.txt");
     gettySize = gettyFile.length();
   }
 
diff --git 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
index 6f6a31c0..4ce59464 100644
--- 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
+++ 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
@@ -20,7 +20,6 @@
 package org.apache.datasketches.memory.internal;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.datasketches.memory.internal.Util.setResourceReadOnly;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
@@ -44,7 +43,7 @@ public class AllocateDirectWritableMapMemoryTest {
   
   @BeforeClass
   public void setReadOnly() {
-    gettyFile = setResourceReadOnly("GettysburgAddress.txt");
+    gettyFile = TestUtil.setResourceReadOnly("GettysburgAddress.txt");
   }
 
   @Test
diff --git 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/CommonMemoryTest.java
 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/CommonMemoryTest.java
index a1d2e7fb..776289ff 100644
--- 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/CommonMemoryTest.java
+++ 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/CommonMemoryTest.java
@@ -19,13 +19,7 @@
 
 package org.apache.datasketches.memory.internal;
 
-import static org.apache.datasketches.memory.internal.Util.isAllBitsClear;
-import static org.apache.datasketches.memory.internal.Util.isAllBitsSet;
-import static org.apache.datasketches.memory.internal.Util.isAnyBitsClear;
-import static org.apache.datasketches.memory.internal.Util.isAnyBitsSet;
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
 
 import org.apache.datasketches.memory.WritableMemory;
 import org.testng.annotations.Test;
@@ -222,46 +216,6 @@ public class CommonMemoryTest {
     }
   }
 
-  @Test
-  public void checkSetClearIsBits() throws Exception {
-    int memCapacity = 8;
-    try (WritableMemory mem = WritableMemory.allocateDirect(memCapacity)) {
-      assertEquals(memCapacity, mem.getCapacity());
-      mem.clear();
-      setClearIsBitsTests(mem);
-    }
-  }
-
-  public static void setClearIsBitsTests(WritableMemory mem) {
-  //single bits
-    for (int i = 0; i < 8; i++) {
-      long bitMask = (1 << i);
-      long v = mem.getByte(0) & 0XFFL;
-      assertTrue(isAnyBitsClear(v, bitMask));
-      mem.setBits(0, (byte) bitMask);
-      v = mem.getByte(0) & 0XFFL;
-      assertTrue(isAnyBitsSet(v, bitMask));
-      mem.clearBits(0, (byte) bitMask);
-      v = mem.getByte(0) & 0XFFL;
-      assertTrue(isAnyBitsClear(v, bitMask));
-    }
-
-    //multiple bits
-    for (int i = 0; i < 7; i++) {
-      long bitMask1 = (1 << i);
-      long bitMask2 = (3 << i);
-      long v = mem.getByte(0) & 0XFFL;
-      assertTrue(isAnyBitsClear(v, bitMask1));
-      assertTrue(isAnyBitsClear(v, bitMask2));
-      mem.setBits(0, (byte) bitMask1); //set one bit
-      v = mem.getByte(0) & 0XFFL;
-      assertTrue(isAnyBitsSet(v, bitMask2));
-      assertTrue(isAnyBitsClear(v, bitMask2));
-      assertFalse(isAllBitsSet(v, bitMask2));
-      assertFalse(isAllBitsClear(v, bitMask2));
-    }
-  }
-
   @Test
   public void checkSetClearMemoryRegions() throws Exception {
     int memCapacity = 64; //must be 64
diff --git 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/TestUtil.java
similarity index 66%
copy from 
datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
copy to 
datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/TestUtil.java
index 5769fcab..002b7ea8 100644
--- 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/internal/Util.java
+++ 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/TestUtil.java
@@ -19,15 +19,12 @@
 
 package org.apache.datasketches.memory.internal;
 
-import static java.util.Arrays.fill;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.nio.ByteOrder;
 import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
 import java.util.Objects;
@@ -35,61 +32,7 @@ import java.util.Random;
 
 import org.apache.datasketches.memory.Memory;
 
-/**
- * @author Lee Rhodes
- */
-public final class Util {
-
-  private Util() { }
-
-  /**
-   * Java line separator that is platform independent.
-   */
-  public static final String LS = System.getProperty("line.separator");
-
-  /**
-   * The static final for <i>ByteOrder.nativeOrder()</i>.
-   */
-  public static final ByteOrder NATIVE_BYTE_ORDER = ByteOrder.nativeOrder();
-
-  /**
-   * The static final for NON <i>ByteOrder.nativeOrder()</i>.
-   */
-  public static final ByteOrder NON_NATIVE_BYTE_ORDER =
-      (NATIVE_BYTE_ORDER == ByteOrder.LITTLE_ENDIAN) ? ByteOrder.BIG_ENDIAN : 
ByteOrder.LITTLE_ENDIAN;
-  
-  /**
-   * Returns the opposite byte order from the given one.
-   * @param order the given byte order
-   * @return the opposite byte order from the given one
-   */
-  public static ByteOrder otherByteOrder(final ByteOrder order) {
-    return (order == NATIVE_BYTE_ORDER) ? NON_NATIVE_BYTE_ORDER : 
NATIVE_BYTE_ORDER;
-  }
-  
-  /**
-   * Don't use sun.misc.Unsafe#copyMemory to copy blocks of memory larger than 
this
-   * threshold, because internally it doesn't have safepoint polls, that may 
cause long
-   * "Time To Safe Point" pauses in the application. This has been fixed in 
JDK 9 (see
-   * https://bugs.openjdk.java.net/browse/JDK-8149596 and
-   * https://bugs.openjdk.java.net/browse/JDK-8141491), but not in JDK 8, so 
the Memory library
-   * should keep having this boilerplate as long as it supports Java 8.
-   *
-   * <p>A reference to this can be found in java.nio.Bits.</p>
-   */
-  public static final int UNSAFE_COPY_THRESHOLD_BYTES = 1024 * 1024;
-
-  /**
-   * Returns true if the given byteOrder is the same as the native byte order.
-   * @param byteOrder the given byte order
-   * @return true if the given byteOrder is the same as the native byte order.
-   */
-  public static boolean isNativeByteOrder(final ByteOrder byteOrder) {
-    if (byteOrder == null) {
-      throw new IllegalArgumentException("ByteOrder parameter cannot be 
null.");
-    }
-    return ByteOrder.nativeOrder() == byteOrder;
-  }
+public class TestUtil {
 
   /**
    * Searches a range of the specified array of longs for the specified value 
using the binary
@@ -111,90 +54,18 @@ public final class Util {
     ResourceImpl.checkBounds(fromLongIndex << 3, (toLongIndex - fromLongIndex) 
<< 3, mem.getCapacity());
     long low = fromLongIndex;
     long high = toLongIndex - 1L;
-
+  
     while (low <= high) {
       final long mid = (low + high) >>> 1;
       final long midVal = mem.getLong(mid << 3);
-
+  
       if (midVal < key)      { low = mid + 1;  }
       else if (midVal > key) { high = mid - 1; }
       else                   { return mid;     } // key found
     }
     return -(low + 1); // key not found.
   }
-
-  /**
-   * Prepend the given string with zeros. If the given string is equal or 
greater than the given
-   * field length, it will be returned without modification.
-   * @param s the given string
-   * @param fieldLength desired total field length including the given string
-   * @return the given string prepended with zeros.
-   */
-  public static final String zeroPad(final String s, final int fieldLength) {
-    return characterPad(s, fieldLength, '0', false);
-  }
-
-  /**
-   * Prepend or postpend the given string with the given character to fill the 
given field length.
-   * If the given string is equal or greater than the given field length, it 
will be returned
-   * without modification.
-   * @param s the given string
-   * @param fieldLength the desired field length
-   * @param padChar the desired pad character
-   * @param postpend if true append the pacCharacters to the end of the string.
-   * @return prepended or postpended given string with the given character to 
fill the given field length.
-   */
-  public static final String characterPad(final String s, final int 
fieldLength, final char padChar, final boolean postpend) {
-    final int sLen = s.length();
-    if (sLen < fieldLength) {
-      final char[] cArr = new char[fieldLength - sLen];
-      fill(cArr, padChar);
-      final String addstr = String.valueOf(cArr);
-      return (postpend) ? s.concat(addstr) : addstr.concat(s);
-    }
-    return s;
-  }
-
-  /**
-   * Return true if all the masked bits of value are zero
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if all the masked bits of value are zero
-   */
-  public static final boolean isAllBitsClear(final long value, final long 
bitMask) {
-    return (~value & bitMask) == bitMask;
-  }
-
-  /**
-   * Return true if all the masked bits of value are one
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if all the masked bits of value are one
-   */
-  public static final boolean isAllBitsSet(final long value, final long 
bitMask) {
-    return (value & bitMask) == bitMask;
-  }
-
-  /**
-   * Return true if any the masked bits of value are zero
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if any the masked bits of value are zero
-   */
-  public static final boolean isAnyBitsClear(final long value, final long 
bitMask) {
-    return (~value & bitMask) != 0;
-  }
-
-  /**
-   * Return true if any the masked bits of value are one
-   * @param value the value to be tested
-   * @param bitMask defines the bits of interest
-   * @return true if any the masked bits of value are one
-   */
-  public static final boolean isAnyBitsSet(final long value, final long 
bitMask) {
-    return (value & bitMask) != 0;
-  }
-
+  
   /**
    * Creates random valid Character Code Points (as integers). By definition, 
valid CodePoints
    * are integers in the range 0 to Character.MAX_CODE_POINT, and exclude the 
surrogate values.
@@ -208,14 +79,14 @@ public final class Util {
     private static final int ALL_CP = Character.MAX_CODE_POINT + 1;
     private static final int MIN_SUR = Character.MIN_SURROGATE;
     private static final int MAX_SUR = Character.MAX_SURROGATE;
-
+  
     /**
      * @param deterministic if true, configure java.util.Random with a fixed 
seed.
      */
     public RandomCodePoints(final boolean deterministic) {
       rand = deterministic ? new Random(0) : new Random();
     }
-
+  
     /**
      * Fills the given array with random valid Code Points from 0, inclusive, 
to
      * <i>Character.MAX_CODE_POINT</i>, inclusive.
@@ -226,7 +97,7 @@ public final class Util {
     public final void fillCodePointArray(final int[] cpArr) {
       fillCodePointArray(cpArr, 0, ALL_CP);
     }
-
+  
     /**
      * Fills the given array with random valid Code Points from 
<i>startCP</i>, inclusive, to
      * <i>endCP</i>, exclusive.
@@ -248,7 +119,7 @@ public final class Util {
         cpArr[idx++] = cp;
       }
     }
-
+  
     /**
      * Return a single valid random Code Point from 0, inclusive, to
      * <i>Character.MAX_CODE_POINT</i>, inclusive.
@@ -259,7 +130,7 @@ public final class Util {
     public final int getCodePoint() {
       return getCodePoint(0, ALL_CP);
     }
-
+  
     /**
      * Return a single valid random Code Point from <i>startCP</i>, inclusive, 
to
      * <i>endCP</i>, exclusive.
@@ -280,18 +151,6 @@ public final class Util {
     }
   } //End class RandomCodePoints
 
-  /**
-   * Checks if given value is &lt; zero.
-   * @param value the given value
-   * @param arg a meaningful name of the actual argument.
-   * @throws IllegalArgumentException if value is &lt; 0.
-   */
-  public static final void negativeCheck(final long value, final String arg) {
-    if (value < 0) {
-      throw new IllegalArgumentException("The argument '" + arg + "' may not 
be negative.");
-    }
-  }
-
   /**
    * Windows, POSIX, and JAR friendly, returns a byte array of the contents of 
the file defined by the given 
    * resourceName. This is only used in test.
@@ -307,7 +166,7 @@ public final class Util {
     if (normalizedName.startsWith("/")) {
       normalizedName = normalizedName.substring(1);
     }
-
+  
     final ClassLoader loader = Util.class.getClassLoader();
     try (InputStream in = loader.getResourceAsStream(normalizedName)) {
       if (in == null) {
@@ -315,7 +174,7 @@ public final class Util {
       }
       return in.readAllBytes();
     } catch (final IOException e) {
-      throw new IllegalArgumentException("Cannot read resource: " + 
normalizedName + LS + e);
+      throw new IllegalArgumentException("Cannot read resource: " + 
normalizedName + Util.LS + e);
     }
   }
 
@@ -333,11 +192,11 @@ 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 { 
@@ -345,27 +204,27 @@ public final class Util {
           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
     final File tempFile;
     try { tempFile = File.createTempFile("datasketches-", ".bin"); }
     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); 
     
     return tempFile;
   }
-  
+
   /**
    * Windows, POSIX, and JAR friendly, checks if the given resourceName exists 
and sets it to Read-Only.  
    * This is only used in test.
diff --git 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/ThreadTest.java
 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/ThreadTest.java
index 1d19bdd6..eb8b4573 100644
--- 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/ThreadTest.java
+++ 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/ThreadTest.java
@@ -39,7 +39,7 @@ public class ThreadTest {
 
   @BeforeClass
   public void prepareFileAndMemory() throws IOException {
-    gettyFile = Util.setResourceReadOnly("GettysburgAddress.txt");
+    gettyFile = TestUtil.setResourceReadOnly("GettysburgAddress.txt");
   }
 
   void initMap() throws IOException {
diff --git 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
index 61abb2af..8cdf2131 100644
--- 
a/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
+++ 
b/datasketches-memory-java11/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
@@ -20,9 +20,6 @@
 package org.apache.datasketches.memory.internal;
 
 import static org.apache.datasketches.memory.internal.Util.characterPad;
-import static org.apache.datasketches.memory.internal.Util.setResourceReadOnly;
-import static org.apache.datasketches.memory.internal.Util.getResourceBytes;
-import static org.apache.datasketches.memory.internal.Util.getResourceFile;
 import static org.apache.datasketches.memory.internal.Util.negativeCheck;
 import static org.apache.datasketches.memory.internal.Util.zeroPad;
 import static org.testng.Assert.assertEquals;
@@ -49,7 +46,7 @@ public class UtilTest {
   
   @BeforeClass
   public void setReadOnly() {
-    gettyFile = setResourceReadOnly("GettysburgAddress.txt");
+    gettyFile = TestUtil.setResourceReadOnly("GettysburgAddress.txt");
     gettySize = gettyFile.length();
   }
   
@@ -59,12 +56,12 @@ public class UtilTest {
     int k = 1024; //longs
     WritableMemory wMem = WritableMemory.allocate(k << 3); //1024 longs
     for (int i = 0; i < k; i++) { wMem.putLong(i << 3, i); }
-    long idx = Util.binarySearchLongs(wMem, 0, k - 1, k / 2);
+    long idx = TestUtil.binarySearchLongs(wMem, 0, k - 1, k / 2);
     long val = wMem.getLong(idx << 3);
     assertEquals(idx, k / 2);
     assertEquals(val, k / 2);
 
-    idx = Util.binarySearchLongs(wMem, 0, k - 1, k);
+    idx = TestUtil.binarySearchLongs(wMem, 0, k - 1, k);
     assertEquals(idx, -1024);
   }
 
@@ -98,7 +95,7 @@ public class UtilTest {
 
   @Test
   public void checkCodePointArr() {
-    final Util.RandomCodePoints rvcp = new Util.RandomCodePoints(true);
+    final TestUtil.RandomCodePoints rvcp = new TestUtil.RandomCodePoints(true);
     final int n = 1000;
     final int[] cpArr = new int[n];
     rvcp.fillCodePointArray(cpArr);
@@ -112,7 +109,7 @@ public class UtilTest {
 
   @Test
   public void checkCodePoint() {
-    final Util.RandomCodePoints rvcp = new Util.RandomCodePoints(true);
+    final TestUtil.RandomCodePoints rvcp = new TestUtil.RandomCodePoints(true);
     final int n = 1000;
     for (int i = 0; i < n; i++) {
       int cp = rvcp.getCodePoint();
@@ -147,7 +144,7 @@ public class UtilTest {
   @Test
   public void resourceFileNotFound() {
     final String shortFileName = "GettysburgAddress.txt";
-    try { getResourceFile(shortFileName + "123"); }
+    try { TestUtil.getResourceFile(shortFileName + "123"); }
     catch (IllegalArgumentException e) { //OK
     }
   }
@@ -160,7 +157,7 @@ public class UtilTest {
   @Test
   public void resourceBytesFileNotFound() {
     final String shortFileName = "GettysburgAddress.txt";
-    try { getResourceBytes(shortFileName + "123"); }
+    try { TestUtil.getResourceBytes(shortFileName + "123"); }
     catch (IllegalArgumentException e) { //OK
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to