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

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


The following commit(s) were added to 
refs/heads/Revert_to_classLoader_getResource by this push:
     new 2cd2befe This commit/PR does 2 things:
2cd2befe is described below

commit 2cd2befeba4e1be104ab658283dc997e028d4758
Author: Lee Rhodes <[email protected]>
AuthorDate: Tue Oct 24 12:38:43 2023 -0700

    This commit/PR does 2 things:
    
    1. In the prior release I thought I didn't need the Java
    Class.getResource() methods for obtaining resources.  Well, I was wrong.
    So this reinstalls these important methods with a major improvement:
    These methods will now work from JAR files of classes as well as from
    within a file system.
    
    2. I increased my detection of all kinds of minor code quality issues.
    So this commit fixes all that I could find. Examples: redundant casts,
    redundant declaration of generic parameters, methods that could be
    declared static, variable name hiding, etc.
---
 pom.xml                                            |   2 +-
 .../java/org/apache/datasketches/common/Util.java  | 206 +++++++++++++++++----
 .../org/apache/datasketches/cpc/PreambleUtil.java  |   4 +-
 .../kll/KllDirectCompactItemsSketch.java           |   2 +-
 .../datasketches/kll/KllHeapItemsSketch.java       |  12 +-
 .../org/apache/datasketches/kll/KllHelper.java     |   2 +-
 .../apache/datasketches/kll/KllItemsSketch.java    |  14 +-
 .../datasketches/kll/KllItemsSketchSortedView.java |   2 +-
 .../datasketches/quantiles/DoublesUnionImpl.java   |   2 +-
 .../apache/datasketches/quantiles/ItemsSketch.java |   4 +-
 .../quantiles/ItemsSketchSortedView.java           |   2 +-
 .../apache/datasketches/quantiles/ItemsUnion.java  |   4 +-
 .../theta/ConcurrentPropagationService.java        |   4 +-
 .../datasketches/tuple/QuickSelectSketch.java      |   2 +-
 .../org/apache/datasketches/tuple/Sketches.java    |   8 +-
 .../apache/datasketches/tuple/UpdatableSketch.java |   2 +-
 .../datasketches/kll/KllCrossLanguageTest.java     |   4 +-
 .../kll/KllDirectCompactItemsSketchTest.java       |  16 +-
 .../datasketches/kll/KllDoublesSketchTest.java     |   2 +-
 .../apache/datasketches/kll/KllMiscItemsTest.java  |   2 +-
 .../QuantilesSketchCrossLanguageTest.java          |   2 +-
 .../quantilescommon/CrossCheckQuantilesTest.java   |  16 +-
 .../quantilescommon/InequalitySearchTest.java      |   6 +-
 .../quantilescommon/ReflectUtilityTest.java        |   2 +-
 .../datasketches/req/ReqSketchSortedViewTest.java  |   4 +-
 .../datasketches/tuple/TupleCrossLanguageTest.java |  10 +-
 26 files changed, 239 insertions(+), 97 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4158b016..93788f83 100644
--- a/pom.xml
+++ b/pom.xml
@@ -287,7 +287,7 @@ under the License.
             <useManifestOnlyJar>false</useManifestOnlyJar>
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
             
<reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
-            
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-files}</excludedGroups>
 -->
+            
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-files}</excludedGroups>
           </configuration>
         </plugin>
 
diff --git a/src/main/java/org/apache/datasketches/common/Util.java 
b/src/main/java/org/apache/datasketches/common/Util.java
index a90528fb..9e0a6f52 100644
--- a/src/main/java/org/apache/datasketches/common/Util.java
+++ b/src/main/java/org/apache/datasketches/common/Util.java
@@ -26,13 +26,19 @@ import static java.lang.Math.pow;
 import static java.lang.Math.round;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Comparator;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -830,53 +836,187 @@ public final class Util {
   //Get Resources
 
   /**
-   * Gets the absolute path of the given resource file's shortName.
-   *
-   * <p>Note that the ClassLoader.getResource(shortName) returns a URL,
-   * which can have special characters, e.g., "%20" for spaces. This method
-   * obtains the URL, converts it to a URI, then does a uri.getPath(), which
-   * decodes any special characters in the URI path. This is required to make
-   * obtaining resources operating-system independent.</p>
-   *
+   * Gets the file defined by the given resource file's shortFileName.
    * @param shortFileName the last name in the pathname's name sequence.
-   * @return the absolute path of the given resource file's shortName.
+   * @return the file defined by the given resource file's shortFileName.
+   * @throws URISyntaxException error
+   * @throws MalformedURLException error
+   * @throws IOException if an IO error occurs
    */
-  public static String getResourcePath(final String shortFileName) {
-    Objects.requireNonNull(shortFileName, "input parameter " + shortFileName + 
" cannot be null.");
-    try {
-      final URL url = Util.class.getClassLoader().getResource(shortFileName);
-      Objects.requireNonNull(url, "resource " + shortFileName + " could not be 
acquired.");
-      final URI uri = url.toURI();
-      //decodes any special characters
-      final String path = uri.isAbsolute() ? 
Paths.get(uri).toAbsolutePath().toString() : uri.getPath();
-      return path;
-    } catch (final URISyntaxException e) {
-      throw new SketchesArgumentException("Cannot find resource: " + 
shortFileName + LS + e);
+  public static File getResourceFile(final String shortFileName) {
+    Objects.requireNonNull(shortFileName, "input parameter 'String 
shortFileName' cannot be null.");
+    final String slashName = (shortFileName.charAt(0) == '/') ? shortFileName 
: '/' + shortFileName;
+    final URL url = Util.class.getResource(slashName);
+    Objects.requireNonNull(url, "resource " + slashName + " returns null 
URL.");
+    File file;
+    file = createTempFile(slashName);
+    if (url.getProtocol().equals("jar")) { //definitely a jar
+      try (final InputStream input = Util.class.getResourceAsStream(slashName);
+        final OutputStream out = new FileOutputStream(file)) {
+        Objects.requireNonNull(input, "InputStream  is null.");
+        int numRead = 0;
+        final byte[] buf = new byte[1024];
+        while ((numRead = input.read(buf)) != -1) { out.write(buf, 0, 
numRead); }
+      } catch (final IOException e ) { throw new RuntimeException(e); }
+    } else { //protocol says resource is not a jar, must be a file
+      file = new File(getResourcePath(url));
     }
+    file.setReadOnly();
+    return file;
   }
 
   /**
-   * Gets the file defined by the given resource file's shortFileName.
+   * Returns a byte array of the contents of the file defined by the given 
resource file's shortFileName.
    * @param shortFileName the last name in the pathname's name sequence.
-   * @return the file defined by the given resource file's shortFileName.
+   * @return a byte array of the contents of the file defined by the given 
resource file's shortFileName.
+   * @throws IllegalArgumentException if resource cannot be read.
+   * @throws IOException if an IO error occurs
    */
-  public static File getResourceFile(final String shortFileName) {
-    return new File(getResourcePath(shortFileName));
+  public static byte[] getResourceBytes(final String shortFileName) {
+    Objects.requireNonNull(shortFileName, "input parameter 'String 
shortFileName' cannot be null.");
+    final String slashName = (shortFileName.charAt(0) == '/') ? shortFileName 
: '/' + shortFileName;
+    final URL url = Util.class.getResource(slashName);
+    Objects.requireNonNull(url, "resource " + slashName + " returns null 
URL.");
+    final byte[] out;
+    if (url.getProtocol().equals("jar")) { //definitely a jar
+      try (final InputStream input = 
Util.class.getResourceAsStream(slashName)) {
+        out = readAllBytesFromInputStream(input);
+      } catch (final IOException e) { throw new RuntimeException(e); }
+    } else { //protocol says resource is not a jar, must be a file
+      try {
+        out = Files.readAllBytes(Paths.get(getResourcePath(url)));
+      } catch (final IOException e) { throw new RuntimeException(e); }
+    }
+    return out;
   }
 
   /**
-   * Returns a byte array of the contents of the file defined by the given 
resource file's
-   * shortFileName.
-   * @param shortFileName the last name in the pathname's name sequence.
-   * @return a byte array of the contents of the file defined by the given 
resource file's
-   * shortFileName.
+   * Note: This is only needed in Java 8 as it is part of Java 9+.
+   * Read all bytes from the given <i>InputStream</i>.
+   * This is limited to streams that are no longer than the maximum 
allocatable byte array determined by the VM.
+   * This may be a little smaller than <i>Integer.MAX_VALUE</i>.
+   * @param in the Input Stream
+   * @return byte array
+   * @throws IOException if an IO error occurs
    */
-  public static byte[] getResourceBytes(final String shortFileName) {
+  public static byte[] readAllBytesFromInputStream(final InputStream in) {
+    return readBytesFromInputStream(Integer.MAX_VALUE, in);
+  }
+
+  private static final int BUF_SIZE = 1 << 13;
+
+  /**
+   * Note: This is only needed in Java 8 as is part of Java 9+.
+   * Read <i>numBytesToRead</i> bytes from an input stream into a single byte 
array.
+   * This is limited to streams that are no longer than the maximum 
allocatable byte array determined by the VM.
+   * This may be a little smaller than <i>Integer.MAX_VALUE</i>.
+   * @param numBytesToRead number of bytes to read
+   * @param in the InputStream
+   * @return the filled byte array from the input stream
+   * @throws IllegalArgumentException if array size grows larger than what can 
be safely allocated by some VMs.
+   * @throws IOException if an IO error occurs
+   */
+  public static byte[] readBytesFromInputStream(final int numBytesToRead, 
final InputStream in) {
+    if (numBytesToRead < 0) { throw new 
IllegalArgumentException("numBytesToRead must be positive or zero."); }
+
+    List<byte[]> buffers = null;
+    byte[] result = null;
+    int totalBytesRead = 0;
+    int remaining = numBytesToRead;
+    int chunkCnt;
+    do {
+        final byte[] partialBuffer = new byte[Math.min(remaining, BUF_SIZE)];
+        int numRead = 0;
+
+        try {
+          // reads input stream in chunks of partial buffers, stops at EOF or 
when remaining is zero.
+          while ((chunkCnt =
+                in.read(partialBuffer, numRead, Math.min(partialBuffer.length 
- numRead, remaining))) > 0) {
+              numRead += chunkCnt;
+              remaining -= chunkCnt;
+          }
+        } catch (final IOException e) { throw new RuntimeException(e); }
+
+        if (numRead > 0) {
+            if (Integer.MAX_VALUE - Long.BYTES - totalBytesRead < numRead) {
+              throw new IllegalArgumentException(
+                  "Input stream is larger than what can be safely allocated as 
a byte[] in some VMs."); }
+            totalBytesRead += numRead;
+            if (result == null) {
+                result = partialBuffer;
+            } else {
+                if (buffers == null) {
+                    buffers = new ArrayList<>();
+                    buffers.add(result);
+                }
+                buffers.add(partialBuffer);
+            }
+        }
+    } while (chunkCnt >= 0 && remaining > 0);
+
+    final byte[] out;
+    if (buffers == null) {
+        if (result == null) {
+          out = new byte[0];
+        } else {
+          out = result.length == totalBytesRead ? result : 
Arrays.copyOf(result, totalBytesRead);
+        }
+        return out;
+    }
+
+    result = new byte[totalBytesRead];
+    int offset = 0;
+    remaining = totalBytesRead;
+    for (byte[] b : buffers) {
+        final int count = Math.min(b.length, remaining);
+        System.arraycopy(b, 0, result, offset, count);
+        offset += count;
+        remaining -= count;
+    }
+    return result;
+  }
+
+  private static String getResourcePath(final URL url) { //must not be null
     try {
-      return Files.readAllBytes(Paths.get(getResourcePath(shortFileName)));
-    } catch (final IOException e) {
-      throw new SketchesArgumentException("Cannot read resource: " + 
shortFileName + LS + e);
+      final URI uri = url.toURI();
+      //decodes any special characters
+      final String path = uri.isAbsolute() ? 
Paths.get(uri).toAbsolutePath().toString() : uri.getPath();
+      return path;
+    } catch (final URISyntaxException e) {
+      throw new IllegalArgumentException("Cannot find resource: " + 
url.toString() + LS + e);
     }
   }
 
+  /**
+   * Create an empty temporary file.
+   * On a Mac these files are stored at the system variable $TMPDIR.  They 
should be cleared on a reboot.
+   * @param shortFileName the name before prefixes and suffixes are added here 
and by the OS.
+   * The final extension will be the current extension. The prefix "temp_" is 
added here.
+   * @return a temp file,which will be eventually deleted by the OS
+   * @throws IOException if an IO error occurs
+   */
+  private static File createTempFile(final String shortFileName) {
+    //remove any leading slash
+    final String resName = (shortFileName.charAt(0) == '/') ? 
shortFileName.substring(1) : shortFileName;
+    final String suffix;
+    final String name;
+    final int  lastIdx = resName.length() - 1;
+    final int lastIdxOfDot = resName.lastIndexOf('.');
+    if (lastIdxOfDot == -1) {
+      suffix = ".tmp";
+      name = resName;
+    } else if (lastIdxOfDot == lastIdx) {
+      suffix = ".tmp";
+      name = resName.substring(0, lastIdxOfDot);
+    } else { //has a real suffix
+      suffix = resName.substring(lastIdxOfDot);
+      name = resName.substring(0, lastIdxOfDot);
+    }
+    final File file;
+    try {
+      file = File.createTempFile("temp_" + name, suffix);
+    } catch (final IOException e) { throw new RuntimeException(e); }
+    return file;
+  }
+
 }
diff --git a/src/main/java/org/apache/datasketches/cpc/PreambleUtil.java 
b/src/main/java/org/apache/datasketches/cpc/PreambleUtil.java
index e3379f58..e10b71e9 100644
--- a/src/main/java/org/apache/datasketches/cpc/PreambleUtil.java
+++ b/src/main/java/org/apache/datasketches/cpc/PreambleUtil.java
@@ -812,8 +812,8 @@ final class PreambleUtil {
     Objects.requireNonNull(mem, "Source Memory must not be null");
     checkBounds(0, 8, mem.getCapacity()); //need min 8 bytes
     rtAssertEquals(getSerVer(mem), SER_VER & 0XFF);
-    final Format fmt = getFormat(mem);
-    final int preIntsDef = getDefinedPreInts(fmt) & 0XFF;
+    final Format fmat = getFormat(mem);
+    final int preIntsDef = getDefinedPreInts(fmat) & 0XFF;
     rtAssertEquals(getPreInts(mem), preIntsDef);
     final Family fam = getFamily(mem);
     rtAssert(fam == Family.CPC);
diff --git 
a/src/main/java/org/apache/datasketches/kll/KllDirectCompactItemsSketch.java 
b/src/main/java/org/apache/datasketches/kll/KllDirectCompactItemsSketch.java
index 7663eecf..b8d91fef 100644
--- a/src/main/java/org/apache/datasketches/kll/KllDirectCompactItemsSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllDirectCompactItemsSketch.java
@@ -168,7 +168,7 @@ final class KllDirectCompactItemsSketch<T> extends 
KllItemsSketch<T> {
   T getSingleItem() {
     if (getN() != 1) { throw new 
SketchesArgumentException(NOT_SINGLE_ITEM_MSG); }
     final int offset = getCompactDataOffset(); //both single & full
-    return (T) (serDe.deserializeFromMemory(mem, offset, 1)[0]);
+    return (serDe.deserializeFromMemory(mem, offset, 1)[0]);
   }
 
   @Override
diff --git a/src/main/java/org/apache/datasketches/kll/KllHeapItemsSketch.java 
b/src/main/java/org/apache/datasketches/kll/KllHeapItemsSketch.java
index 576af1af..4b3c6c7c 100644
--- a/src/main/java/org/apache/datasketches/kll/KllHeapItemsSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllHeapItemsSketch.java
@@ -106,9 +106,9 @@ final class KllHeapItemsSketch<T> extends KllItemsSketch<T> 
{
     } else if (memStruct == COMPACT_FULL) {
       int offset = DATA_START_ADR + memVal.numLevels * Integer.BYTES;
       this.minItem = serDe.deserializeFromMemory(srcMem, offset, 1)[0];
-      offset += serDe.sizeOf((T) minItem);
+      offset += serDe.sizeOf(minItem);
       this.maxItem = serDe.deserializeFromMemory(srcMem, offset, 1)[0];
-      offset += serDe.sizeOf((T) maxItem);
+      offset += serDe.sizeOf(maxItem);
       final int numRetained = levelsArr[memVal.numLevels] - levelsArr[0];
       final Object[] retItems = serDe.deserializeFromMemory(srcMem, offset, 
numRetained);
       System.arraycopy(retItems, 0, itemsArr, levelsArr[0], numRetained);
@@ -153,8 +153,8 @@ final class KllHeapItemsSketch<T> extends KllItemsSketch<T> 
{
 
   @Override
   byte[] getMinMaxByteArr() {
-    final byte[] minBytes = serDe.serializeToByteArray((T)minItem);
-    final byte[] maxBytes = serDe.serializeToByteArray((T)maxItem);
+    final byte[] minBytes = serDe.serializeToByteArray(minItem);
+    final byte[] maxBytes = serDe.serializeToByteArray(maxItem);
     final byte[] minMaxBytes = new byte[minBytes.length + maxBytes.length];
     copyBytes(minBytes, 0, minMaxBytes, 0, minBytes.length);
     copyBytes(maxBytes, 0, minMaxBytes, minBytes.length, maxBytes.length);
@@ -163,8 +163,8 @@ final class KllHeapItemsSketch<T> extends KllItemsSketch<T> 
{
 
   @Override
   int getMinMaxSizeBytes() {
-    final int minBytes = serDe.sizeOf((T)minItem);
-    final int maxBytes = serDe.sizeOf((T)maxItem);
+    final int minBytes = serDe.sizeOf(minItem);
+    final int maxBytes = serDe.sizeOf(maxItem);
     return minBytes + maxBytes;
   }
 
diff --git a/src/main/java/org/apache/datasketches/kll/KllHelper.java 
b/src/main/java/org/apache/datasketches/kll/KllHelper.java
index 21a0aba8..6956ccb6 100644
--- a/src/main/java/org/apache/datasketches/kll/KllHelper.java
+++ b/src/main/java/org/apache/datasketches/kll/KllHelper.java
@@ -622,7 +622,7 @@ final class KllHelper {
       }
       else { //sketchType == KllItemsSketch
         final KllItemsSketch<T> itmSk = (KllItemsSketch<T>) sketch;
-        final T[] myItemsArr = (T[]) itmSk.getTotalItemsArray();
+        final T[] myItemsArr = itmSk.getTotalItemsArray();
         sb.append(outputItemsData(numLevels, fullLevelsArr, myItemsArr, 
serDe));
       }
     }
diff --git a/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java 
b/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java
index 97bbc519..68c9a6df 100644
--- a/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java
+++ b/src/main/java/org/apache/datasketches/kll/KllItemsSketch.java
@@ -77,7 +77,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
       final Comparator<? super T> comparator,
       final ArrayOfItemsSerDe<T> serDe) {
       final KllItemsSketch<T> itmSk =
-          new KllHeapItemsSketch<T>(DEFAULT_K, DEFAULT_M, comparator, serDe);
+          new KllHeapItemsSketch<>(DEFAULT_K, DEFAULT_M, comparator, serDe);
     return itmSk;
   }
 
@@ -96,7 +96,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
       final int k,
       final Comparator<? super T> comparator,
       final ArrayOfItemsSerDe<T> serDe) {
-    return new KllHeapItemsSketch<T>(k, DEFAULT_M, comparator, serDe);
+    return new KllHeapItemsSketch<>(k, DEFAULT_M, comparator, serDe);
   }
 
   // Factory to create an heap instance from a Memory image
@@ -114,7 +114,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
       final Memory srcMem,
       final Comparator<? super T> comparator,
       final ArrayOfItemsSerDe<T> serDe) {
-    return new KllHeapItemsSketch<T>(srcMem, comparator, serDe);
+    return new KllHeapItemsSketch<>(srcMem, comparator, serDe);
   }
 
   //Factory to wrap a Read-Only Memory
@@ -137,7 +137,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
       final Comparator<? super T> comparator,
       final ArrayOfItemsSerDe<T> serDe) {
     final KllMemoryValidate memVal = new KllMemoryValidate(srcMem, 
SketchType.ITEMS_SKETCH, serDe);
-    return new KllDirectCompactItemsSketch<T>(memVal, comparator, serDe);
+    return new KllDirectCompactItemsSketch<>(memVal, comparator, serDe);
   }
 
   //END of Constructors
@@ -157,7 +157,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
     final Object[] boundaries = getQuantiles(ranks, searchCrit);
     boundaries[0] = getMinItem();
     boundaries[boundaries.length - 1] = getMaxItem();
-    final GenericPartitionBoundaries<T> gpb = new 
GenericPartitionBoundaries<T>();
+    final GenericPartitionBoundaries<T> gpb = new 
GenericPartitionBoundaries<>();
     gpb.N = this.getN();
     gpb.ranks = ranks;
     gpb.boundaries = (T[])boundaries;
@@ -248,7 +248,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
 
   @Override
   public QuantilesGenericSketchIterator<T> iterator() {
-    return new KllItemsSketchIterator<T>(
+    return new KllItemsSketchIterator<>(
         getTotalItemsArray(), getLevelsArray(SketchStructure.UPDATABLE), 
getNumLevels());
   }
 
@@ -303,7 +303,7 @@ public abstract class KllItemsSketch<T> extends KllSketch 
implements QuantilesGe
 
   private final KllItemsSketchSortedView<T> refreshSortedView() {
     final KllItemsSketchSortedView<T> sv = (kllItemsSV == null)
-        ? kllItemsSV = new KllItemsSketchSortedView<T>(this)
+        ? kllItemsSV = new KllItemsSketchSortedView<>(this)
         : kllItemsSV;
     return sv;
   }
diff --git 
a/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java 
b/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
index 1b04a4d3..c3fb8bab 100644
--- a/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java
@@ -169,7 +169,7 @@ public class KllItemsSketchSortedView<T> implements 
GenericSortedView<T> {
 
   @Override
   public KllItemsSketchSortedViewIterator<T> iterator() {
-    return new KllItemsSketchSortedViewIterator<T>((T[])quantiles, cumWeights);
+    return new KllItemsSketchSortedViewIterator<>((T[])quantiles, cumWeights);
   }
 
   //restricted methods
diff --git 
a/src/main/java/org/apache/datasketches/quantiles/DoublesUnionImpl.java 
b/src/main/java/org/apache/datasketches/quantiles/DoublesUnionImpl.java
index e45f813b..b55f0b53 100644
--- a/src/main/java/org/apache/datasketches/quantiles/DoublesUnionImpl.java
+++ b/src/main/java/org/apache/datasketches/quantiles/DoublesUnionImpl.java
@@ -177,7 +177,7 @@ final class DoublesUnionImpl extends DoublesUnionImplR {
     UpdateDoublesSketch ret = null;
 
     switch (outCase) {
-      case 0: ret = null; break; //return null
+      case 0: break; //return null
       case 1: ret = myQS; break; //no-op
       case 2: { //myQS = null,  other = valid; stream or downsample to myMaxK
         assert other != null;
diff --git a/src/main/java/org/apache/datasketches/quantiles/ItemsSketch.java 
b/src/main/java/org/apache/datasketches/quantiles/ItemsSketch.java
index caa73c6e..cdb21ae9 100644
--- a/src/main/java/org/apache/datasketches/quantiles/ItemsSketch.java
+++ b/src/main/java/org/apache/datasketches/quantiles/ItemsSketch.java
@@ -302,7 +302,7 @@ public final class ItemsSketch<T> implements 
QuantilesGenericAPI<T> {
     final T[] boundaries = getQuantiles(ranks, searchCrit);
     boundaries[0] = getMinItem();
     boundaries[boundaries.length - 1] = getMaxItem();
-    final GenericPartitionBoundaries<T> gpb = new 
GenericPartitionBoundaries<T>();
+    final GenericPartitionBoundaries<T> gpb = new 
GenericPartitionBoundaries<>();
     gpb.N = this.getN();
     gpb.ranks = ranks;
     gpb.boundaries = boundaries;
@@ -608,7 +608,7 @@ public final class ItemsSketch<T> implements 
QuantilesGenericAPI<T> {
 
   private final ItemsSketchSortedView<T> refreshSortedView() {
     final ItemsSketchSortedView<T> sv = (classicQisSV == null)
-        ? classicQisSV = new ItemsSketchSortedView<T>(this)
+        ? classicQisSV = new ItemsSketchSortedView<>(this)
         : classicQisSV;
     return sv;
   }
diff --git 
a/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java 
b/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java
index 4d6d3031..d2ccf9fd 100644
--- a/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java
+++ b/src/main/java/org/apache/datasketches/quantiles/ItemsSketchSortedView.java
@@ -164,7 +164,7 @@ public class ItemsSketchSortedView<T> implements 
GenericSortedView<T> {
 
   @Override
   public ItemsSketchSortedViewIterator<T> iterator() {
-    return new ItemsSketchSortedViewIterator<T>(quantiles, cumWeights);
+    return new ItemsSketchSortedViewIterator<>(quantiles, cumWeights);
   }
 
   //restricted methods
diff --git a/src/main/java/org/apache/datasketches/quantiles/ItemsUnion.java 
b/src/main/java/org/apache/datasketches/quantiles/ItemsUnion.java
index 22b59065..b6a08bf1 100644
--- a/src/main/java/org/apache/datasketches/quantiles/ItemsUnion.java
+++ b/src/main/java/org/apache/datasketches/quantiles/ItemsUnion.java
@@ -61,7 +61,7 @@ public final class ItemsUnion<T> {
    */
   public static <T> ItemsUnion<T> getInstance(final Class<T> clazz, final 
Comparator<? super T> comparator) {
     final ItemsSketch<T> emptySk = ItemsSketch.getInstance(clazz, comparator);
-    return new ItemsUnion<T>(PreambleUtil.DEFAULT_K, comparator, emptySk);
+    return new ItemsUnion<>(PreambleUtil.DEFAULT_K, comparator, emptySk);
   }
 
   /**
@@ -288,7 +288,7 @@ public final class ItemsUnion<T> {
     ItemsSketch<T> ret = null;
 
     switch (outCase) {
-      case 0: ret = null; break;
+      case 0: break;
       case 1: ret = myQS; break;
       case 2: { //myQS = null,  other = valid; stream or downsample to myMaxK
         assert other != null;
diff --git 
a/src/main/java/org/apache/datasketches/theta/ConcurrentPropagationService.java 
b/src/main/java/org/apache/datasketches/theta/ConcurrentPropagationService.java
index ee6551c5..d6d08dd0 100644
--- 
a/src/main/java/org/apache/datasketches/theta/ConcurrentPropagationService.java
+++ 
b/src/main/java/org/apache/datasketches/theta/ConcurrentPropagationService.java
@@ -54,7 +54,7 @@ final class ConcurrentPropagationService {
   }
 
   public static ExecutorService getExecutorService(final long id) {
-    return getInstance().initExecutorService((int) id % NUM_POOL_THREADS);
+    return initExecutorService((int) id % NUM_POOL_THREADS);
   }
 
   @SuppressWarnings("static-access")
@@ -62,7 +62,7 @@ final class ConcurrentPropagationService {
     return getInstance().propagationExecutorService[(int) id % 
NUM_POOL_THREADS] = null;
   }
 
-  private ExecutorService initExecutorService(final int i) {
+  private static ExecutorService initExecutorService(final int i) {
     if (propagationExecutorService[i] == null) {
       propagationExecutorService[i] = Executors.newSingleThreadExecutor();
     }
diff --git a/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java 
b/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java
index 6146174a..2efe5212 100644
--- a/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/QuickSelectSketch.java
@@ -232,7 +232,7 @@ class QuickSelectSketch<S extends Summary> extends 
Sketch<S> {
    * @return a deep copy of this sketch
    */
   QuickSelectSketch<S> copy() {
-    return new QuickSelectSketch<S>(this);
+    return new QuickSelectSketch<>(this);
   }
 
   long[] getHashTable() {
diff --git a/src/main/java/org/apache/datasketches/tuple/Sketches.java 
b/src/main/java/org/apache/datasketches/tuple/Sketches.java
index 7a573518..ab9cfb3c 100644
--- a/src/main/java/org/apache/datasketches/tuple/Sketches.java
+++ b/src/main/java/org/apache/datasketches/tuple/Sketches.java
@@ -31,7 +31,7 @@ public final class Sketches {
    * @return an empty instance of Sketch
    */
   public static <S extends Summary> Sketch<S> createEmptySketch() {
-    return new CompactSketch<S>(null, null, Long.MAX_VALUE, true);
+    return new CompactSketch<>(null, null, Long.MAX_VALUE, true);
   }
 
   /**
@@ -51,9 +51,9 @@ public final class Sketches {
       final SummaryDeserializer<S> deserializer) {
     final SerializerDeserializer.SketchType sketchType = 
SerializerDeserializer.getSketchType(mem);
     if (sketchType == SerializerDeserializer.SketchType.QuickSelectSketch) {
-      return new QuickSelectSketch<S>(mem, deserializer, null);
+      return new QuickSelectSketch<>(mem, deserializer, null);
     }
-    return new CompactSketch<S>(mem, deserializer);
+    return new CompactSketch<>(mem, deserializer);
   }
 
   /**
@@ -73,7 +73,7 @@ public final class Sketches {
       final Memory mem,
       final SummaryDeserializer<S> deserializer,
       final SummaryFactory<S> summaryFactory) {
-    return new UpdatableSketch<U, S>(mem, deserializer, summaryFactory);
+    return new UpdatableSketch<>(mem, deserializer, summaryFactory);
   }
 
 }
diff --git a/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java 
b/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java
index 208dc604..f4987278 100644
--- a/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/UpdatableSketch.java
@@ -87,7 +87,7 @@ public class UpdatableSketch<U, S extends 
UpdatableSummary<U>> extends QuickSele
    */
   @Override
   public UpdatableSketch<U,S> copy() {
-    return new UpdatableSketch<U,S>(this);
+    return new UpdatableSketch<>(this);
   }
 
   /**
diff --git 
a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java 
b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java
index ceb3bc6d..09d3ee88 100644
--- a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java
@@ -79,7 +79,7 @@ public class KllCrossLanguageTest {
   }
 
   @Test(groups = {CHECK_CPP_HISTORICAL_FILES})
-  public void checkCppKllDoublesSketchOneItemVersion1() throws IOException {
+  public void checkCppKllDoublesSketchOneItemVersion1() {
     final byte[] byteArr = 
getResourceBytes("kll_sketch_double_one_item_v1.sk");
     final KllDoublesSketch sk = KllDoublesSketch.heapify(Memory.wrap(byteArr));
     assertFalse(sk.isEmpty());
@@ -91,7 +91,7 @@ public class KllCrossLanguageTest {
   }
 
   @Test(groups = {CHECK_CPP_HISTORICAL_FILES})
-  public void checkCppKllFloatsSketchOneItemVersion1() throws IOException {
+  public void checkCppKllFloatsSketchOneItemVersion1() {
     final byte[] byteArr = getResourceBytes("kll_sketch_float_one_item_v1.sk");
     final KllFloatsSketch sk = KllFloatsSketch.heapify(Memory.wrap(byteArr));
     assertFalse(sk.isEmpty());
diff --git 
a/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchTest.java
 
b/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchTest.java
index 3f786e67..008e1527 100644
--- 
a/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchTest.java
+++ 
b/src/test/java/org/apache/datasketches/kll/KllDirectCompactItemsSketchTest.java
@@ -64,7 +64,7 @@ public class KllDirectCompactItemsSketchTest {
     assertTrue(sk2 instanceof KllDirectCompactItemsSketch);
     //println(sk2.toString(true, false));
     assertTrue(sk2.isReadOnly());
-    assertEquals((String)sk2.getSingleItem(), "1");
+    assertEquals(sk2.getSingleItem(), "1");
 
     sk.update("2");
     sk2 = KllItemsSketch.wrap(Memory.wrap(sk.toByteArray()), 
Comparator.naturalOrder(), serDe);
@@ -80,16 +80,16 @@ public class KllDirectCompactItemsSketchTest {
     int k = 20;
     KllItemsSketch<String> sk = KllItemsSketch.newHeapInstance(k, 
Comparator.naturalOrder(), serDe);
 
-    String[] itemsArr = (String[]) sk.getTotalItemsArray();
+    String[] itemsArr = sk.getTotalItemsArray();
     for (int j = 0; j < k; j++) { assertNull(itemsArr[j]); }
 
     sk.update(" 1"); //single
-    itemsArr = (String[]) sk.getTotalItemsArray();
+    itemsArr = sk.getTotalItemsArray();
     for (int j = 0; j < k - 1; j++) { assertNull(itemsArr[j]); }
     assertEquals(itemsArr[k - 1], " 1");
 
     sk.update(" 2"); //multiple
-    itemsArr = (String[]) sk.getTotalItemsArray();
+    itemsArr = sk.getTotalItemsArray();
     for (int j = 0; j < k - 2; j++) { assertNull(itemsArr[j]); }
     assertEquals(itemsArr[k - 1], " 1");
     assertEquals(itemsArr[k - 2], " 2");
@@ -101,18 +101,18 @@ public class KllDirectCompactItemsSketchTest {
     KllItemsSketch<String> sk = KllItemsSketch.newHeapInstance(k, 
Comparator.naturalOrder(), serDe);
 
     KllItemsSketch<String> sk2 = 
KllItemsSketch.wrap(Memory.wrap(sk.toByteArray()), Comparator.naturalOrder(), 
serDe);
-    String[] itemsArr = (String[]) sk2.getTotalItemsArray(); //empty
+    String[] itemsArr = sk2.getTotalItemsArray(); //empty
     for (int j = 0; j < k; j++) { assertNull(itemsArr[j]); }
 
     sk.update(" 1"); //single
     sk2 = KllItemsSketch.wrap(Memory.wrap(sk.toByteArray()), 
Comparator.naturalOrder(), serDe);
-    itemsArr = (String[]) sk2.getTotalItemsArray();
+    itemsArr = sk2.getTotalItemsArray();
     for (int j = 0; j < k - 1; j++) { assertNull(itemsArr[j]); }
     assertEquals(itemsArr[k - 1], " 1");
 
     sk.update(" 2"); //multi
     sk2 = KllItemsSketch.wrap(Memory.wrap(sk.toByteArray()), 
Comparator.naturalOrder(), serDe);
-    itemsArr = (String[]) sk2.getTotalItemsArray();
+    itemsArr = sk2.getTotalItemsArray();
     for (int j = 0; j < k - 2; j++) { assertNull(itemsArr[j]); }
     assertEquals(itemsArr[k - 1], " 1");
     assertEquals(itemsArr[k - 2], " 2");
@@ -123,7 +123,7 @@ public class KllDirectCompactItemsSketchTest {
     int k = 20;
 
     KllItemsSketch<String> sk = KllItemsSketch.newHeapInstance(k, 
Comparator.naturalOrder(), serDe);
-    String[] retArr = (String[]) sk.getRetainedItemsArray();
+    String[] retArr = sk.getRetainedItemsArray();
     assertEquals(retArr.length, sk.getNumRetained());
     assertEquals(retArr.length, 0);
 
diff --git 
a/src/test/java/org/apache/datasketches/kll/KllDoublesSketchTest.java 
b/src/test/java/org/apache/datasketches/kll/KllDoublesSketchTest.java
index 95986d53..ba63e8be 100644
--- a/src/test/java/org/apache/datasketches/kll/KllDoublesSketchTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllDoublesSketchTest.java
@@ -119,7 +119,7 @@ public class KllDoublesSketchTest {
       double rank = i/10.0;
       double q = rank == 1.0 ? i : i + 1;
       assertEquals(sketch.getQuantile(rank, EXCLUSIVE), q);
-      q = (double)(rank == 0 ? i + 1.0 : i);
+      q = rank == 0 ? i + 1.0 : i;
       assertEquals(sketch.getQuantile(rank, INCLUSIVE), q);
     }
 
diff --git a/src/test/java/org/apache/datasketches/kll/KllMiscItemsTest.java 
b/src/test/java/org/apache/datasketches/kll/KllMiscItemsTest.java
index 64fa70de..35d73fce 100644
--- a/src/test/java/org/apache/datasketches/kll/KllMiscItemsTest.java
+++ b/src/test/java/org/apache/datasketches/kll/KllMiscItemsTest.java
@@ -136,7 +136,7 @@ public class KllMiscItemsTest {
     }
     println(sk.toString(true, true));
     sk.toByteArray();
-    final String[] items = (String[]) sk.getTotalItemsArray();
+    final String[] items = sk.getTotalItemsArray();
     assertEquals(items.length, 33);
     final int[] levels = sk.getLevelsArray(sk.sketchStructure);
     assertEquals(levels.length, 3);
diff --git 
a/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java
 
b/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java
index bc127e95..3e1bc130 100644
--- 
a/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java
+++ 
b/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java
@@ -229,7 +229,7 @@ public class QuantilesSketchCrossLanguageTest {
     getAndCheck(ver, n, expected);
   }
 
-  private static void getAndCheck(String ver, int n, double quantile)  {
+  private static void getAndCheck(String ver, int n, double quantile) {
     DoublesSketch.rand.setSeed(131); //make deterministic
     //create fileName
     int k = 128;
diff --git 
a/src/test/java/org/apache/datasketches/quantilescommon/CrossCheckQuantilesTest.java
 
b/src/test/java/org/apache/datasketches/quantilescommon/CrossCheckQuantilesTest.java
index eb9a0a59..5f4c4c75 100644
--- 
a/src/test/java/org/apache/datasketches/quantilescommon/CrossCheckQuantilesTest.java
+++ 
b/src/test/java/org/apache/datasketches/quantilescommon/CrossCheckQuantilesTest.java
@@ -337,22 +337,22 @@ public class CrossCheckQuantilesTest {
     itemsSV = new ItemsSketchSortedViewString(svIValues[set], 
svCumWeights[set], totalN[set], comparator);
   }
 
-  private final ReqSketchSortedView getRawReqSV(
+  private final static ReqSketchSortedView getRawReqSV(
       final float[] values, final long[] cumWeights, final long totalN) throws 
Exception {
     return (ReqSketchSortedView) REQ_SV_CTOR.newInstance(values, cumWeights, 
totalN);
   }
 
-  private final KllFloatsSketchSortedView getRawKllFloatsSV(
+  private final static KllFloatsSketchSortedView getRawKllFloatsSV(
       final float[] values, final long[] cumWeights, final long totalN) throws 
Exception {
     return (KllFloatsSketchSortedView) KLL_FLOATS_SV_CTOR.newInstance(values, 
cumWeights, totalN);
   }
 
-  private final KllDoublesSketchSortedView getRawKllDoublesSV(
+  private final static KllDoublesSketchSortedView getRawKllDoublesSV(
       final double[] values, final long[] cumWeights, final long totalN) 
throws Exception {
     return (KllDoublesSketchSortedView) 
KLL_DOUBLES_SV_CTOR.newInstance(values, cumWeights, totalN);
   }
 
-  private final DoublesSketchSortedView getRawClassicDoublesSV(
+  private final static DoublesSketchSortedView getRawClassicDoublesSV(
       final double[] values, final long[] cumWeights, final long totalN) 
throws Exception {
     return (DoublesSketchSortedView) 
CLASSIC_DOUBLES_SV_CTOR.newInstance(values, cumWeights, totalN);
   }
@@ -378,7 +378,7 @@ public class CrossCheckQuantilesTest {
     println("");
   }
 
-  private float[] convertToFloatStream(
+  private static float[] convertToFloatStream(
       final float[] svFValueArr,
       final long[] svWeightsArr,
       final int totalCount) {
@@ -395,7 +395,7 @@ public class CrossCheckQuantilesTest {
     return out;
   }
 
-  private double[] convertToDoubleStream(
+  private static double[] convertToDoubleStream(
       final double[] svDValueArr,
       final long[] svWeightsArr,
       final int totalCount) {
@@ -412,7 +412,7 @@ public class CrossCheckQuantilesTest {
     return out;
   }
 
-  private String[] convertToItemStream(
+  private static String[] convertToItemStream(
       final String[] svIValueArr,
       final long[] svWeightsArr,
       final int totalCount) {
@@ -429,7 +429,7 @@ public class CrossCheckQuantilesTest {
     return out;
   }
 
-  private long[] convertToCumWeights(final long[] weights) {
+  private static long[] convertToCumWeights(final long[] weights) {
     final int len = weights.length;
     final long[] out = new long[len];
     out[0] = weights[0];
diff --git 
a/src/test/java/org/apache/datasketches/quantilescommon/InequalitySearchTest.java
 
b/src/test/java/org/apache/datasketches/quantilescommon/InequalitySearchTest.java
index 3a74d228..640d7d59 100644
--- 
a/src/test/java/org/apache/datasketches/quantilescommon/InequalitySearchTest.java
+++ 
b/src/test/java/org/apache/datasketches/quantilescommon/InequalitySearchTest.java
@@ -403,7 +403,7 @@ public class InequalitySearchTest {
     exerciseDoubles(arr);
   }
 
-  private void exerciseDoubles(final double[] arr) {
+  private static void exerciseDoubles(final double[] arr) {
     checkFindDouble(arr, LT);
     checkFindDouble(arr, LE);
     checkFindDouble(arr, EQ);
@@ -439,7 +439,7 @@ public class InequalitySearchTest {
     exerciseFloats(arr);
   }
 
-  private void exerciseFloats(final float[] arr) {
+  private static void exerciseFloats(final float[] arr) {
     checkFindFloat(arr, LT);
     checkFindFloat(arr, LE);
     checkFindFloat(arr, EQ);
@@ -475,7 +475,7 @@ public class InequalitySearchTest {
     exerciseLongs(arr);
   }
 
-  private void exerciseLongs(final long[] arr) {
+  private static void exerciseLongs(final long[] arr) {
     checkFindLong(arr, LT);
     checkFindLong(arr, LE);
     checkFindLong(arr, EQ);
diff --git 
a/src/test/java/org/apache/datasketches/quantilescommon/ReflectUtilityTest.java 
b/src/test/java/org/apache/datasketches/quantilescommon/ReflectUtilityTest.java
index 2d037917..b756c5da 100644
--- 
a/src/test/java/org/apache/datasketches/quantilescommon/ReflectUtilityTest.java
+++ 
b/src/test/java/org/apache/datasketches/quantilescommon/ReflectUtilityTest.java
@@ -57,7 +57,7 @@ public final class ReflectUtilityTest {
   }
 
   @Test //Example
-  public void checkCtr() throws Exception {
+  public static void checkCtr() throws Exception {
     float[] farr = { 10, 20, 30 };
     long[] larr = { 1, 2, 3 };
     long n = 3;
diff --git 
a/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java 
b/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java
index 58ac3dfb..eb75790e 100644
--- a/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java
+++ b/src/test/java/org/apache/datasketches/req/ReqSketchSortedViewTest.java
@@ -95,14 +95,14 @@ public class ReqSketchSortedViewTest {
     return sketch;
   }
 
-  private void checkIterator(final ReqSketch sketch) {
+  private static void checkIterator(final ReqSketch sketch) {
     println("\nNot Deduped:");
     FloatsSortedView sv = sketch.getSortedView();
     FloatsSortedViewIterator itr = sv.iterator();
     printIterator(itr);
   }
 
-  private void printIterator(final FloatsSortedViewIterator itr) {
+  private static void printIterator(final FloatsSortedViewIterator itr) {
     println("");
     String[] header = {"Value", "Wt", "CumWtNotInc", "NormRankNotInc", 
"CumWtInc", "NormRankInc"};
     String hfmt = "%8s%6s%16s%16s%16s%16s\n";
diff --git 
a/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java 
b/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java
index ad6485d2..57098444 100644
--- a/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java
+++ b/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java
@@ -43,7 +43,7 @@ import org.testng.annotations.Test;
 public class TupleCrossLanguageTest {
 
   @Test(groups = {CHECK_CPP_HISTORICAL_FILES})
-  public void serialVersion1Compatibility() throws IOException {
+  public void serialVersion1Compatibility() {
     final byte[] byteArr = 
getResourceBytes("CompactSketchWithDoubleSummary4K_serialVersion1.sk");
     Sketch<DoubleSummary> sketch = 
Sketches.heapifySketch(Memory.wrap(byteArr), new DoubleSummaryDeserializer());
     Assert.assertTrue(sketch.isEstimationMode());
@@ -59,7 +59,7 @@ public class TupleCrossLanguageTest {
   }
 
   @Test(groups = {CHECK_CPP_HISTORICAL_FILES})
-  public void version2Compatibility() throws IOException {
+  public void version2Compatibility() {
     final byte[] byteArr = 
getResourceBytes("TupleWithTestIntegerSummary4kTrimmedSerVer2.sk");
     Sketch<IntegerSummary> sketch1 = 
Sketches.heapifySketch(Memory.wrap(byteArr), new IntegerSummaryDeserializer());
 
@@ -86,7 +86,8 @@ public class TupleCrossLanguageTest {
     final int[] nArr = {0, 1, 10, 100, 1000, 10_000, 100_000, 1_000_000};
     for (int n: nArr) {
       final byte[] bytes = Files.readAllBytes(cppPath.resolve("tuple_int_n" + 
n + "_cpp.sk"));
-      final Sketch<IntegerSummary> sketch = 
Sketches.heapifySketch(Memory.wrap(bytes), new IntegerSummaryDeserializer());
+      final Sketch<IntegerSummary> sketch =
+          Sketches.heapifySketch(Memory.wrap(bytes), new 
IntegerSummaryDeserializer());
       assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty());
       assertTrue(n > 1000 ? sketch.isEstimationMode() : 
!sketch.isEstimationMode());
       assertEquals(sketch.getEstimate(), n, n * 0.03);
@@ -102,7 +103,8 @@ public class TupleCrossLanguageTest {
   public void generateForCppIntegerSummary() throws IOException {
     final int[] nArr = {0, 1, 10, 100, 1000, 10_000, 100_000, 1_000_000};
     for (int n: nArr) {
-      final UpdatableSketch<Integer, IntegerSummary> sk = new 
UpdatableSketchBuilder<>(new IntegerSummaryFactory()).build();
+      final UpdatableSketch<Integer, IntegerSummary> sk =
+          new UpdatableSketchBuilder<>(new IntegerSummaryFactory()).build();
       for (int i = 0; i < n; i++) sk.update(i, i);
       Files.newOutputStream(javaPath.resolve("tuple_int_n" + n + 
"_java.sk")).write(sk.compact().toByteArray());
     }


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


Reply via email to