From e693cfae4780c54f7e31043c0adad7d74d07e8a3 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Tue, 17 Feb 2026 18:13:56 -0800 Subject: [PATCH 01/17] This replaces a bunch of methods attempting to read file bytes with one method. They were not robust, especially in a Windows OS environment. --- .../apache/datasketches/common/TestUtil.java | 224 +++--------------- .../datasketches/common/TestUtilTest.java | 66 ++++++ .../cpc/CpcSketchCrossLanguageTest.java | 5 +- .../BloomFilterCrossLanguageTest.java | 3 +- .../FrequentItemsSketchCrossLanguageTest.java | 9 +- .../hll/HllSketchCrossLanguageTest.java | 7 +- .../kll/KllCrossLanguageTest.java | 12 +- .../QuantilesSketchCrossLanguageTest.java | 8 +- .../req/ReqSketchCrossLanguageTest.java | 3 +- .../sampling/VarOptCrossLanguageTest.java | 9 +- .../tdigest/TDigestCrossLanguageTest.java | 9 +- .../tdigest/TDigestDoubleTest.java | 5 +- .../theta/ThetaSketchCrossLanguageTest.java | 13 +- .../tuple/TupleCrossLanguageTest.java | 12 +- .../AodSketchCrossLanguageTest.java | 7 +- src/test/resources/GettysburgAddress.txt | 7 + 16 files changed, 161 insertions(+), 238 deletions(-) create mode 100644 src/test/java/org/apache/datasketches/common/TestUtilTest.java create mode 100644 src/test/resources/GettysburgAddress.txt diff --git a/src/test/java/org/apache/datasketches/common/TestUtil.java b/src/test/java/org/apache/datasketches/common/TestUtil.java index 35180d003..e7017154a 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtil.java +++ b/src/test/java/org/apache/datasketches/common/TestUtil.java @@ -28,6 +28,8 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -51,216 +53,48 @@ public final class TestUtil { public static final String CHECK_CPP_HISTORICAL_FILES = "check_cpp_historical_files"; /** - * The full target Path for Java serialized sketches to be tested by other languages. + * The project relative Path for Java serialized sketches to be tested by other languages. */ - public static final Path javaPath = createPath("serialization_test_data/java_generated_files"); + public static final Path javaPath = Path.of(".", "serialization_test_data", "java_generated_files"); /** - * The full target Path for C++ serialized sketches to be tested by Java. + * The project relative Path for C++ serialized sketches to be tested by Java. */ - public static final Path cppPath = createPath("serialization_test_data/cpp_generated_files"); + public static final Path cppPath = Path.of(".", "serialization_test_data", "cpp_generated_files"); /** - * The full target Path for Go serialized sketches to be tested by Java. + * The project relative Path for Go serialized sketches to be tested by Java. */ - public static final Path goPath = createPath("serialization_test_data/go_generated_files"); - - private static Path createPath(final String projectLocalDir) { - try { - return Files.createDirectories(Paths.get(userDir, projectLocalDir)); - } catch (IOException e) { throw new SketchesArgumentException(e.getCause().toString()); } - } - - //Get Resources - - private static final int BUF_SIZE = 1 << 13; - - /** - * Gets 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. - */ - 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 = TestUtil.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 = TestUtil.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)); - } - if (!file.setReadable(false, true)) { - throw new IllegalStateException("Failed to set owner only 'Readable' on file"); - } - if (!file.setWritable(false, false)) { - throw new IllegalStateException("Failed to set everyone 'Not Writable' on file"); - } - return file; - } - - /** - * 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. - * @throws IllegalArgumentException if resource cannot be read. - */ - 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 = TestUtil.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 = TestUtil.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; - } - + public static final Path goPath = Path.of(".", "serialization_test_data", "go_generated_files"); + /** - * Note: This is only needed in Java 8 as it is part of Java 9+. - * Read all bytes from the given InputStream. - * 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 Integer.MAX_VALUE. - * @param in the Input Stream - * @return byte array + * The project relative Path for /src/test/resources */ - public static byte[] readAllBytesFromInputStream(final InputStream in) { - return readBytesFromInputStream(Integer.MAX_VALUE, in); - } + public static final Path resPath = Path.of(".","src","test","resources"); - /** - * Note: This is only needed in Java 8 as is part of Java 9+. - * Read numBytesToRead 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 Integer.MAX_VALUE. - * @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. - - */ - public static byte[] readBytesFromInputStream(final int numBytesToRead, final InputStream in) { - if (numBytesToRead < 0) { throw new IllegalArgumentException("numBytesToRead must be positive or zero."); } - - List 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; - } + //Get Resources - 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 final int BUF_SIZE = 1 << 13; - private static String getResourcePath(final URL url) { //must not be null - try { - 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() + Util.LS + e); + public static byte[] getFileBytes(Path basePath, String fileName) throws RuntimeException { + Objects.requireNonNull(basePath, "input parameter 'Path basePath' cannot be null."); + Objects.requireNonNull(fileName, "input parameter 'String fileName' cannot be null."); + Path path = Path.of(basePath.toString(), fileName); + Path absPath = path.toAbsolutePath(); //for debugging + byte[] bytes = new byte[0]; //or null + if (Files.notExists(path)) { + System.err.println("File disappeared or not found: " + absPath); + return bytes; //or null } - } - - /** - * 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 - */ - 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); + if (!Files.isRegularFile(path) || !Files.isReadable(path)) { + throw new RuntimeException("Path is not a regular file or not readable: " + absPath); } - final File file; try { - file = File.createTempFile("temp_" + name, suffix); - if (!file.setReadable(false, true)) { - throw new IllegalStateException("Failed to set only owner 'Readable' on file"); - } - if (!file.setWritable(false, true)) { - throw new IllegalStateException("Failed to set only owner 'Writable' on file"); + bytes = Files.readAllBytes(path); + return bytes; + } catch (IOException e) { + throw new RuntimeException("System Error reading file: " + absPath + " " + e); } - - } catch (final IOException e) { throw new RuntimeException(e); } - return file; - } - + } } diff --git a/src/test/java/org/apache/datasketches/common/TestUtilTest.java b/src/test/java/org/apache/datasketches/common/TestUtilTest.java new file mode 100644 index 000000000..d10b48a2f --- /dev/null +++ b/src/test/java/org/apache/datasketches/common/TestUtilTest.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.datasketches.common; + +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.resPath; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +//import static org.testng.internal.EclipseInterface.ASSERT_LEFT; // Ignore, standard imports +import static org.testng.Assert.assertNotNull; + +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import static java.nio.charset.StandardCharsets.UTF_8; + +public class TestUtilTest { + + @Test + public void testGetFileBytes_Success() throws IOException { + byte[] resultBytes = getFileBytes(resPath, "GettysburgAddress.txt"); + assertNotNull(resultBytes); + String resultString = new String(resultBytes, UTF_8); + assertTrue(resultString.startsWith("Abraham Lincoln's Gettysburg Address:")); + } + + @Test + public void testGetFileBytes_MissingFile() { + byte[] resultBytes = getFileBytes(resPath, "NonExistentFile"); + assertNotNull(resultBytes); + assertEquals(resultBytes.length, 0, "Should return empty array for missing file."); + } + + @Test + public void testGetFileBytes_NotRegular_NotReadable() throws IOException { + try { + byte[] resultBytes = getFileBytes(resPath, ""); + } catch (RuntimeException e) { + System.out.println(e.toString()); + } + } + +} diff --git a/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java index 912ed3a68..3389f99d3 100644 --- a/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java @@ -22,6 +22,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_GO_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.goPath; import static org.apache.datasketches.common.TestUtil.javaPath; @@ -75,7 +76,7 @@ public void allFlavors() throws IOException { final Flavor[] flavorArr = {Flavor.EMPTY, Flavor.SPARSE, Flavor.HYBRID, Flavor.PINNED, Flavor.SLIDING}; int flavorIdx = 0; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("cpc_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "cpc_n" + n + "_cpp.sk"); final CpcSketch sketch = CpcSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getFlavor(), flavorArr[flavorIdx++]); assertEquals(sketch.getEstimate(), n, n * 0.02); @@ -88,7 +89,7 @@ public void checkAllFlavorsGo() throws IOException { final Flavor[] flavorArr = {Flavor.EMPTY, Flavor.SPARSE, Flavor.HYBRID, Flavor.PINNED, Flavor.SLIDING}; int flavorIdx = 0; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(goPath.resolve("cpc_n" + n + "_go.sk")); + final byte[] bytes = getFileBytes(goPath, "cpc_n" + n + "_go.sk"); final CpcSketch sketch = CpcSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getFlavor(), flavorArr[flavorIdx++]); assertEquals(sketch.getEstimate(), n, n * 0.02); diff --git a/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java b/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java index 0ecc060b8..bb2e9ccd1 100644 --- a/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -65,7 +66,7 @@ public void readBloomFilterBinariesForCompatibilityTesting() throws IOException final short[] hArr = {3, 5}; for (final int n : nArr) { for (final short numHashes : hArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("bf_n" + n + "_h" + numHashes + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath,"bf_n" + n + "_h" + numHashes + "_cpp.sk"); final BloomFilter bf = BloomFilter.heapify(MemorySegment.ofArray(bytes)); assertEquals(bf.isEmpty(), n == 0); assertTrue(bf.isEmpty() || (bf.getBitsUsed() > (n / 10))); diff --git a/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java index 109d468be..74f417c38 100644 --- a/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -102,7 +103,7 @@ public void generateBinariesForCompatibilityTestingStringsSketchUtf8() throws IO public void longs() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("frequent_long_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "frequent_long_n" + n + "_cpp.sk"); final FrequentLongsSketch sketch = FrequentLongsSketch.getInstance(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); if (n > 10) { @@ -118,7 +119,7 @@ public void longs() throws IOException { public void strings() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("frequent_string_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "frequent_string_n" + n + "_cpp.sk"); final FrequentItemsSketch sketch = FrequentItemsSketch.getInstance(MemorySegment.ofArray(bytes), new ArrayOfStringsSerDe()); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); if (n > 10) { @@ -132,7 +133,7 @@ public void strings() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void stringsAscii() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("frequent_string_ascii_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "frequent_string_ascii_cpp.sk"); final FrequentItemsSketch sketch = FrequentItemsSketch.getInstance(MemorySegment.ofArray(bytes), new ArrayOfStringsSerDe()); assertFalse(sketch.isEmpty()); assertEquals(sketch.getMaximumError(), 0); @@ -145,7 +146,7 @@ public void stringsAscii() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void stringsUtf8() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("frequent_string_utf8_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "frequent_string_utf8_cpp.sk"); final FrequentItemsSketch sketch = FrequentItemsSketch.getInstance(MemorySegment.ofArray(bytes), new ArrayOfStringsSerDe()); assertFalse(sketch.isEmpty()); assertEquals(sketch.getMaximumError(), 0); diff --git a/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java index e69d01621..51966007b 100644 --- a/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.apache.datasketches.hll.TgtHllType.HLL_4; @@ -68,7 +69,7 @@ public void generateBinariesForCompatibilityTesting() throws IOException { public void hll4() throws IOException { final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("hll4_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "hll4_n" + n + "_cpp.sk"); final HllSketch sketch = HllSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getLgConfigK(), 12); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); @@ -80,7 +81,7 @@ public void hll4() throws IOException { public void hll6() throws IOException { final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("hll6_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "hll6_n" + n + "_cpp.sk"); final HllSketch sketch = HllSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getLgConfigK(), 12); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); @@ -92,7 +93,7 @@ public void hll6() throws IOException { public void hll8() throws IOException { final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("hll8_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "hll8_n" + n + "_cpp.sk"); final HllSketch sketch = HllSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getLgConfigK(), 12); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); diff --git a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java index 45fb4d8c9..392e667c9 100644 --- a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java @@ -22,8 +22,10 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_CPP_HISTORICAL_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.resPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; @@ -95,7 +97,7 @@ public void generateKllItemsSketchBinaries() throws IOException { @Test(groups = {CHECK_CPP_HISTORICAL_FILES}) public void checkCppKllDoublesSketchOneItemVersion1() { - final byte[] byteArr = TestUtil.getResourceBytes("kll_sketch_double_one_item_v1.sk"); + final byte[] byteArr = TestUtil.getFileBytes(resPath, "kll_sketch_double_one_item_v1.sk"); final KllDoublesSketch sk = KllDoublesSketch.heapify(MemorySegment.ofArray(byteArr)); assertFalse(sk.isEmpty()); assertFalse(sk.isEstimationMode()); @@ -107,7 +109,7 @@ public void checkCppKllDoublesSketchOneItemVersion1() { @Test(groups = {CHECK_CPP_HISTORICAL_FILES}) public void checkCppKllFloatsSketchOneItemVersion1() { - final byte[] byteArr = TestUtil.getResourceBytes("kll_sketch_float_one_item_v1.sk"); + final byte[] byteArr = TestUtil.getFileBytes(resPath, "kll_sketch_float_one_item_v1.sk"); final KllFloatsSketch sk = KllFloatsSketch.heapify(MemorySegment.ofArray(byteArr)); assertFalse(sk.isEmpty()); assertFalse(sk.isEstimationMode()); @@ -121,7 +123,7 @@ public void checkCppKllFloatsSketchOneItemVersion1() { public void kllFloat() throws IOException { final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("kll_float_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "kll_float_n" + n + "_cpp.sk"); final KllFloatsSketch sketch = KllFloatsSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getK(), 200); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); @@ -146,7 +148,7 @@ public void kllFloat() throws IOException { public void kllDouble() throws IOException { final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("kll_double_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "kll_double_n" + n + "_cpp.sk"); final KllDoublesSketch sketch = KllDoublesSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getK(), 200); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); @@ -184,7 +186,7 @@ public int compare(final String s1, final String s2) { }; final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("kll_string_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "kll_string_n" + n + "_cpp.sk"); final KllHeapItemsSketch sketch = new KllHeapItemsSketch<>( MemorySegment.ofArray(bytes), numericOrder, diff --git a/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java index bb0b1bfde..0ef9c83d3 100644 --- a/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java @@ -22,8 +22,10 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_CPP_HISTORICAL_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.resPath; import static org.apache.datasketches.quantilescommon.QuantileSearchCriteria.EXCLUSIVE; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -91,7 +93,7 @@ public int compare(final String s1, final String s2) { public void checkDoublesSketch() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] byteArr = Files.readAllBytes(cppPath.resolve("quantiles_double_n" + n + "_cpp.sk")); + final byte[] byteArr = getFileBytes(cppPath, "quantiles_double_n" + n + "_cpp.sk"); final QuantilesDoublesSketch sk = QuantilesDoublesSketch.wrap(MemorySegment.ofArray(byteArr)); assertTrue(n == 0 ? sk.isEmpty() : !sk.isEmpty()); assertTrue(n > 128 ? sk.isEstimationMode() : !sk.isEstimationMode()); @@ -128,7 +130,7 @@ public int compare(final String s1, final String s2) { }; final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] byteArr = Files.readAllBytes(cppPath.resolve("quantiles_string_n" + n + "_cpp.sk")); + final byte[] byteArr = getFileBytes(cppPath, "quantiles_string_n" + n + "_cpp.sk"); final QuantilesItemsSketch sk = QuantilesItemsSketch.heapify( String.class, MemorySegment.ofArray(byteArr), @@ -242,7 +244,7 @@ private static void getAndCheck(final String ver, final int n, final double quan println("fullName: "+ fileName); println("Old Median: " + quantile); //Read File bytes - final byte[] byteArr = TestUtil.getResourceBytes(fileName); + final byte[] byteArr = TestUtil.getFileBytes(resPath, fileName); final MemorySegment srcSeg = MemorySegment.ofArray(byteArr); // heapify as update sketch diff --git a/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java index e126f9b46..198dffe36 100644 --- a/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -56,7 +57,7 @@ public void generateBinariesForCompatibilityTesting() throws IOException { public void deserializeFromCpp() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("req_float_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "req_float_n" + n + "_cpp.sk"); final ReqSketch sk = ReqSketch.heapify(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? sk.isEmpty() : !sk.isEmpty()); assertTrue(n > 10 ? sk.isEstimationMode() : !sk.isEstimationMode()); diff --git a/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java b/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java index dd759b05d..265f3ca90 100644 --- a/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -114,7 +115,7 @@ public void generateUnionDoubleSampling() throws IOException { public void deserializeFromCppSketchLongs() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("varopt_sketch_long_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "varopt_sketch_long_n" + n + "_cpp.sk"); final VarOptItemsSketch sk = VarOptItemsSketch.heapify(MemorySegment.ofArray(bytes), new ArrayOfLongsSerDe()); assertEquals(sk.getK(), 32); assertEquals(sk.getN(), n); @@ -124,7 +125,7 @@ public void deserializeFromCppSketchLongs() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void deserializeFromCppSketchStringsExact() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("varopt_sketch_string_exact_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "varopt_sketch_string_exact_cpp.sk"); final VarOptItemsSketch sk = VarOptItemsSketch.heapify(MemorySegment.ofArray(bytes), new ArrayOfStringsSerDe()); assertEquals(sk.getK(), 1024); assertEquals(sk.getN(), 200); @@ -139,7 +140,7 @@ public void deserializeFromCppSketchStringsExact() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void deserializeFromCppSketchLongsSampling() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("varopt_sketch_long_sampling_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "varopt_sketch_long_sampling_cpp.sk"); final VarOptItemsSketch sk = VarOptItemsSketch.heapify(MemorySegment.ofArray(bytes), new ArrayOfLongsSerDe()); assertEquals(sk.getK(), 1024); assertEquals(sk.getN(), 2003); @@ -156,7 +157,7 @@ public void deserializeFromCppSketchLongsSampling() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void deserializeFromCppUnionDoubleSampling() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("varopt_union_double_sampling_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "varopt_union_double_sampling_cpp.sk"); final VarOptItemsUnion u = VarOptItemsUnion.heapify(MemorySegment.ofArray(bytes), new ArrayOfDoublesSerDe()); // must reduce k in the process diff --git a/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java index 1ce3f7555..a46c06515 100644 --- a/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -40,9 +41,9 @@ public void deserializeFromCppDouble() throws IOException { for (final int n : nArr) { final byte[] bytes; if (buffered) { - bytes = Files.readAllBytes(cppPath.resolve("tdigest_double_buf_n" + n + "_cpp.sk")); + bytes = getFileBytes(cppPath, "tdigest_double_buf_n" + n + "_cpp.sk"); } else { - bytes = Files.readAllBytes(cppPath.resolve("tdigest_double_n" + n + "_cpp.sk")); + bytes = getFileBytes(cppPath, "tdigest_double_n" + n + "_cpp.sk"); } final TDigestDouble td = TDigestDouble.heapify(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? td.isEmpty() : !td.isEmpty()); @@ -70,9 +71,9 @@ public void deserializeFromCppFloat() throws IOException { for (final int n : nArr) { final byte[] bytes; if (buffered) { - bytes = Files.readAllBytes(cppPath.resolve("tdigest_float_buf_n" + n + "_cpp.sk")); + bytes = getFileBytes(cppPath, "tdigest_float_buf_n" + n + "_cpp.sk"); } else { - bytes = Files.readAllBytes(cppPath.resolve("tdigest_float_n" + n + "_cpp.sk")); + bytes = getFileBytes(cppPath, "tdigest_float_n" + n + "_cpp.sk"); } final TDigestDouble td = TDigestDouble.heapify(MemorySegment.ofArray(bytes), true); assertTrue(n == 0 ? td.isEmpty() : !td.isEmpty()); diff --git a/src/test/java/org/apache/datasketches/tdigest/TDigestDoubleTest.java b/src/test/java/org/apache/datasketches/tdigest/TDigestDoubleTest.java index b7a414d27..c940648be 100644 --- a/src/test/java/org/apache/datasketches/tdigest/TDigestDoubleTest.java +++ b/src/test/java/org/apache/datasketches/tdigest/TDigestDoubleTest.java @@ -19,6 +19,7 @@ package org.apache.datasketches.tdigest; +import static org.apache.datasketches.common.TestUtil.resPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertThrows; @@ -152,7 +153,7 @@ public void serializeDeserializeNonEmpty() { @Test public void deserializeFromReferenceImplementationDouble() { - final byte[] bytes = TestUtil.getResourceBytes("tdigest_ref_k100_n10000_double.sk"); + final byte[] bytes = TestUtil.getFileBytes(resPath, "tdigest_ref_k100_n10000_double.sk"); final TDigestDouble td = TDigestDouble.heapify(MemorySegment.ofArray(bytes)); final int n = 10000; assertEquals(td.getK(), 100); @@ -168,7 +169,7 @@ public void deserializeFromReferenceImplementationDouble() { @Test public void deserializeFromReferenceImplementationFloat() { - final byte[] bytes = TestUtil.getResourceBytes("tdigest_ref_k100_n10000_float.sk"); + final byte[] bytes = TestUtil.getFileBytes(resPath, "tdigest_ref_k100_n10000_float.sk"); final TDigestDouble td = TDigestDouble.heapify(MemorySegment.ofArray(bytes)); final int n = 10000; assertEquals(td.getK(), 100); diff --git a/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java index 3bfa8bc2c..1c27b56e6 100644 --- a/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -79,7 +80,7 @@ public void generateBinariesForCompatibilityTestingNonEmptyNoEntries() throws IO public void deserializeFromCppSegment() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("theta_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "theta_n" + n + "_cpp.sk"); final CompactThetaSketch sketch = CompactThetaSketch.wrap(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); assertEquals(sketch.getEstimate(), n, n * 0.03); @@ -98,7 +99,7 @@ public void deserializeFromCppSegment() throws IOException { public void deserializeFromCppBytes() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("theta_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "theta_n" + n + "_cpp.sk"); final CompactThetaSketch sketch = CompactThetaSketch.wrap(bytes); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); assertEquals(sketch.getEstimate(), n, n * 0.03); @@ -117,7 +118,7 @@ public void deserializeFromCppBytes() throws IOException { public void deserializeFromCppCompressedSegment() throws IOException { final int[] nArr = {10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("theta_compressed_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "theta_compressed_n" + n + "_cpp.sk"); final CompactThetaSketch sketch = CompactThetaSketch.wrap(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); assertEquals(sketch.getEstimate(), n, n * 0.03); @@ -136,7 +137,7 @@ public void deserializeFromCppCompressedSegment() throws IOException { public void deserializeFromCppCompressedBytes() throws IOException { final int[] nArr = {10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("theta_compressed_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "theta_compressed_n" + n + "_cpp.sk"); final CompactThetaSketch sketch = CompactThetaSketch.wrap(bytes); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); assertEquals(sketch.getEstimate(), n, n * 0.03); @@ -153,7 +154,7 @@ public void deserializeFromCppCompressedBytes() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void deserializeFromCppNonEmptyNoEntriesSegment() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("theta_non_empty_no_entries_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "theta_non_empty_no_entries_cpp.sk"); final CompactThetaSketch sketch = CompactThetaSketch.wrap(MemorySegment.ofArray(bytes)); assertFalse(sketch.isEmpty()); assertEquals(sketch.getRetainedEntries(), 0); @@ -161,7 +162,7 @@ public void deserializeFromCppNonEmptyNoEntriesSegment() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void deserializeFromCppNonEmptyNoEntriesBytes() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("theta_non_empty_no_entries_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "theta_non_empty_no_entries_cpp.sk"); final CompactThetaSketch sketch = CompactThetaSketch.wrap(bytes); assertFalse(sketch.isEmpty()); assertEquals(sketch.getRetainedEntries(), 0); diff --git a/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java index b2f70b7bb..b58905b2b 100644 --- a/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java @@ -22,8 +22,10 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_CPP_HISTORICAL_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.resPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -47,7 +49,7 @@ public class TupleCrossLanguageTest { @Test(groups = {CHECK_CPP_HISTORICAL_FILES}) public void serialVersion1Compatibility() { - final byte[] byteArr = TestUtil.getResourceBytes("CompactSketchWithDoubleSummary4K_serialVersion1.sk"); + final byte[] byteArr = TestUtil.getFileBytes(resPath, "CompactSketchWithDoubleSummary4K_serialVersion1.sk"); TupleSketch sketch = TupleSketch.heapifySketch(MemorySegment.ofArray(byteArr), new DoubleSummaryDeserializer()); Assert.assertTrue(sketch.isEstimationMode()); Assert.assertEquals(sketch.getEstimate(), 8192, 8192 * 0.99); @@ -63,7 +65,7 @@ public void serialVersion1Compatibility() { @Test(groups = {CHECK_CPP_HISTORICAL_FILES}) public void version2Compatibility() { - final byte[] byteArr = TestUtil.getResourceBytes("TupleWithTestIntegerSummary4kTrimmedSerVer2.sk"); + final byte[] byteArr = TestUtil.getFileBytes(resPath, "TupleWithTestIntegerSummary4kTrimmedSerVer2.sk"); TupleSketch sketch1 = TupleSketch.heapifySketch(MemorySegment.ofArray(byteArr), new IntegerSummaryDeserializer()); // construct the same way @@ -88,7 +90,7 @@ public void version2Compatibility() { public void deserializeFromCppIntegerSummary() throws IOException { 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 byte[] bytes = getFileBytes(cppPath, "tuple_int_n" + n + "_cpp.sk"); final TupleSketch sketch = TupleSketch.heapifySketch(MemorySegment.ofArray(bytes), new IntegerSummaryDeserializer()); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); @@ -117,13 +119,13 @@ public void generateForCppIntegerSummary() throws IOException { @Test(expectedExceptions = SketchesArgumentException.class, groups = {CHECK_CPP_HISTORICAL_FILES}) public void noSupportHeapifyV0_9_1() throws Exception { - final byte[] byteArr = TestUtil.getResourceBytes("ArrayOfDoublesUnion_v0.9.1.sk"); + final byte[] byteArr = TestUtil.getFileBytes(resPath, "ArrayOfDoublesUnion_v0.9.1.sk"); ArrayOfDoublesUnion.heapify(MemorySegment.ofArray(byteArr)); } @Test(expectedExceptions = SketchesArgumentException.class, groups = {CHECK_CPP_HISTORICAL_FILES}) public void noSupportWrapV0_9_1() throws Exception { - final byte[] byteArr = TestUtil.getResourceBytes("ArrayOfDoublesUnion_v0.9.1.sk"); + final byte[] byteArr = TestUtil.getFileBytes(resPath, "ArrayOfDoublesUnion_v0.9.1.sk"); ArrayOfDoublesUnion.wrap(MemorySegment.ofArray(byteArr)); } diff --git a/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java index faca658d8..bc751200f 100644 --- a/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java @@ -21,6 +21,7 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; import static org.apache.datasketches.common.TestUtil.javaPath; import static org.testng.Assert.assertEquals; @@ -81,7 +82,7 @@ public void generateBinariesForCompatibilityTestingNonEmptyNoEntries() throws IO public void deserializeFromCppOneValue() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("aod_1_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "aod_1_n" + n + "_cpp.sk"); final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketch.wrap(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); assertEquals(sketch.getEstimate(), n, n * 0.03); @@ -97,7 +98,7 @@ public void deserializeFromCppOneValue() throws IOException { public void deserializeFromCppThreeValues() throws IOException { final int[] nArr = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("aod_3_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "aod_3_n" + n + "_cpp.sk"); final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketch.wrap(MemorySegment.ofArray(bytes)); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty()); assertEquals(sketch.getEstimate(), n, n * 0.03); @@ -113,7 +114,7 @@ public void deserializeFromCppThreeValues() throws IOException { @Test(groups = {CHECK_CPP_FILES}) public void deserializeFromCppOneValueNonEmptyNoEntries() throws IOException { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("aod_1_non_empty_no_entries_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath, "aod_1_non_empty_no_entries_cpp.sk"); final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketch.wrap(MemorySegment.ofArray(bytes)); assertFalse(sketch.isEmpty()); assertEquals(sketch.getRetainedEntries(), 0); diff --git a/src/test/resources/GettysburgAddress.txt b/src/test/resources/GettysburgAddress.txt new file mode 100644 index 000000000..3969d1766 --- /dev/null +++ b/src/test/resources/GettysburgAddress.txt @@ -0,0 +1,7 @@ +Abraham Lincoln's Gettysburg Address: + + Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. + + Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. + + But, in a larger sense, we can not dedicate —- we can not consecrate —- we can not hallow —- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -— that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -— that we here highly resolve that these dead shall not have died in vain -— that this nation, under God, shall have a new birth of freedom -— and that government of the people, by the people, for the people, shall not perish from the earth. From 31e5942212f59e2179407292cb334d681af7c50f Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Tue, 17 Feb 2026 18:33:05 -0800 Subject: [PATCH 02/17] Fix unread var. --- src/test/java/org/apache/datasketches/common/TestUtilTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/datasketches/common/TestUtilTest.java b/src/test/java/org/apache/datasketches/common/TestUtilTest.java index d10b48a2f..3770e998c 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtilTest.java +++ b/src/test/java/org/apache/datasketches/common/TestUtilTest.java @@ -57,7 +57,7 @@ public void testGetFileBytes_MissingFile() { @Test public void testGetFileBytes_NotRegular_NotReadable() throws IOException { try { - byte[] resultBytes = getFileBytes(resPath, ""); + getFileBytes(resPath, ""); } catch (RuntimeException e) { System.out.println(e.toString()); } From d6a9d042dd9bea628f7a37b481c2dc49f5eec169 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Wed, 18 Feb 2026 11:51:14 -0800 Subject: [PATCH 03/17] Add putBytesToFile methods --- .../apache/datasketches/common/TestUtil.java | 71 ++++++++++++++----- .../datasketches/common/TestUtilTest.java | 5 +- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/test/java/org/apache/datasketches/common/TestUtil.java b/src/test/java/org/apache/datasketches/common/TestUtil.java index e7017154a..3306790e8 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtil.java +++ b/src/test/java/org/apache/datasketches/common/TestUtil.java @@ -42,14 +42,13 @@ */ public final class TestUtil { - private static final String userDir = System.getProperty("user.dir"); - /** * TestNG group constants */ public static final String GENERATE_JAVA_FILES = "generate_java_files"; public static final String CHECK_CPP_FILES = "check_cpp_files"; public static final String CHECK_GO_FILES = "check_go_files"; + public static final String CHECK_RUST_FILES = "check_rust_files"; public static final String CHECK_CPP_HISTORICAL_FILES = "check_cpp_historical_files"; /** @@ -67,34 +66,74 @@ public final class TestUtil { */ public static final Path goPath = Path.of(".", "serialization_test_data", "go_generated_files"); + /** + * The project relative Path for Rust serialized sketches to be tested by Java. + */ + public static final Path rustPath = Path.of(".", "serialization_test_data", "rust_generated_files"); + /** * The project relative Path for /src/test/resources */ public static final Path resPath = Path.of(".","src","test","resources"); - //Get Resources - - private static final int BUF_SIZE = 1 << 13; - - public static byte[] getFileBytes(Path basePath, String fileName) throws RuntimeException { + /** + * Gets all the bytes of a file as a byte array. + * If the file is missing, this writes a warning message to the console. + * @param basePath the base directory path where the file is located + * @param fileName the simple file name of the file + * @return a byte array + * @throws RuntimeException for IO errors, or if resolved path is not a file or not readable. + */ + public static byte[] getFileBytes(final Path basePath, final String fileName) throws RuntimeException { Objects.requireNonNull(basePath, "input parameter 'Path basePath' cannot be null."); Objects.requireNonNull(fileName, "input parameter 'String fileName' cannot be null."); Path path = Path.of(basePath.toString(), fileName); - Path absPath = path.toAbsolutePath(); //for debugging + Path absPath = path.toAbsolutePath(); //for error output byte[] bytes = new byte[0]; //or null - if (Files.notExists(path)) { + if (Files.notExists(path)) { //In this specific case, just issue warning. System.err.println("File disappeared or not found: " + absPath); - return bytes; //or null + return bytes; //empty } if (!Files.isRegularFile(path) || !Files.isReadable(path)) { throw new RuntimeException("Path is not a regular file or not readable: " + absPath); } try { - bytes = Files.readAllBytes(path); - return bytes; - } catch (IOException e) { - throw new RuntimeException("System Error reading file: " + absPath + " " + e); - } - } + bytes = Files.readAllBytes(path); + return bytes; + } catch (IOException e) { + throw new RuntimeException("System IO Error reading file: " + absPath + " " + e); + } + } + + /** + * Puts all the bytes of the given byte array to a file with the given fileName. + * This assumes that the base directory path is {@link #javaPath javaPath}. + * @param fileName the name of the target file + * @param bytes the given byte array + */ + public static void putBytesToJavaPathFile(final String fileName, final byte[] bytes) { + putBytesToFile(javaPath, fileName, bytes); + } + + /** + * Puts all the bytes of the given byte array to a basePath file with the given fileName. + * @param basePath the directory path for the given fileName + * @param fileName the name of the target file + * @param bytes the given byte array + * @throws RuntimeException for IO errors, + */ + public static void putBytesToFile(final Path basePath, final String fileName, final byte[] bytes) { + Objects.requireNonNull(basePath, "input parameter 'Path basePath' cannot be null."); + Objects.requireNonNull(fileName, "input parameter 'String fileName' cannot be null."); + Objects.requireNonNull(bytes, "input parameter 'byte[] bytes' cannot be null."); + Path filePath = null; + try { + Files.createDirectories(basePath); //create the directory if it doesn't exist. + filePath = basePath.resolve(fileName); + Files.write(filePath, bytes); + } catch (IOException e) { + throw new RuntimeException("System IO Error writing file: " + filePath.toString() + " " + e); + } + } } diff --git a/src/test/java/org/apache/datasketches/common/TestUtilTest.java b/src/test/java/org/apache/datasketches/common/TestUtilTest.java index 3770e998c..420b05c12 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtilTest.java +++ b/src/test/java/org/apache/datasketches/common/TestUtilTest.java @@ -44,7 +44,7 @@ public void testGetFileBytes_Success() throws IOException { byte[] resultBytes = getFileBytes(resPath, "GettysburgAddress.txt"); assertNotNull(resultBytes); String resultString = new String(resultBytes, UTF_8); - assertTrue(resultString.startsWith("Abraham Lincoln's Gettysburg Address:")); + assertTrue(resultString.startsWith("Abraham Lincoln's Gettysburg Address:")); } @Test @@ -63,4 +63,7 @@ public void testGetFileBytes_NotRegular_NotReadable() throws IOException { } } + + + } From 3f8eb8e6bbc798bea7023bd593ea788c753bf273 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Sat, 21 Feb 2026 10:47:17 -0800 Subject: [PATCH 04/17] Fix get_file_bytes and put_file_bytes. --- pom.xml | 488 ++++++++++-------- .../datasketches/common/A_BeforeSuite.java | 33 ++ .../apache/datasketches/common/TestUtil.java | 56 +- .../datasketches/common/TestUtilTest.java | 33 +- src/test/resources/testng.xml | 28 + 5 files changed, 388 insertions(+), 250 deletions(-) create mode 100644 src/test/java/org/apache/datasketches/common/A_BeforeSuite.java create mode 100644 src/test/resources/testng.xml diff --git a/pom.xml b/pom.xml index a5ab62239..2b9be8bb7 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. org.apache apache - 35 + 37 org.apache.datasketches @@ -82,7 +82,7 @@ under the License. - 7.11.0 + 7.12.0 generate_java_files check_cpp_files @@ -90,30 +90,37 @@ under the License. check_cpp_historical_files - 3.9.11 + 3.9.12 25 - - -Xmx4g + ${java.version} + -Xmx4g + -Duser.language=en + -Duser.country=US + -Dfile.encoding=UTF-8 + ${jvm.mem} ${jvm.locale.language} ${jvm.locale.country} ${jvm.locale.encoding} UTF-8 ${charset.encoding} ${charset.encoding} ${charset.encoding} yyyy-MM-dd'T'HH-mm-ss'Z' - + + + 3.15.0 3.12.0 + + 0.17 + + 3.2.0 - - 4.9.10 - - 0.17 + + 9.0.2 + - 4.3.0 + 5.0.0 0.8.14 - - 2.19.1 1.0.0 @@ -129,22 +136,261 @@ under the License. - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - ${testng.generate-java-files},${testng.check-cpp-files},${testng.check-go-files},${testng.check-cpp-historical-files} - - - - + + + org.apache.maven.plugins + maven-assembly-plugin + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + true + ${java.version} + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + enforce-banned-dependencies + + enforce + + + + + + [${maven.version},4.0.0) + + + + + com.google.code.findbugs:annotations + + + + true + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + default-jar + package + + jar + + + + default-test-jar + package + + test-jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + org.apache.datasketches.memory/internal + true + public + all,-missing + + ${jvm.mem} + ${jvm.locale.language} + ${jvm.locale.country} + ${jvm.locale.encoding} + + + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-release-plugin + + + + + org.apache.maven.plugins + maven-source-plugin + + + + attach-sources + package + + jar-no-fork + + + + attach-test-sources + package + + test-jar-no-fork + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + @{jvm.args} + + ${java.version} + + false + false + false + ${project.build.directory}/test-output + + src/test/resources/testng.xml + + false + ${testng.generate-java-files},${testng.check-cpp-files},${testng.check-go-files},${testng.check-cpp-historical-files} + + + + + org.apache.maven.plugins + maven-toolchains-plugin + ${maven-toolchains-plugin.version} + + + + toolchain + + + + + + + ${java.version} + + + + + + + org.apache.rat + apache-rat-plugin + ${apache-rat-plugin.version} + + + verify + + check + + + + + ${project.basedir}/rat + true + true + + + StandardCollection + **/*.yaml + **/*.yml + **/.* + **/test/resources/**/*.txt + **/git.properties + **/doc/** + **/*.sk + LICENSE + NOTICE + **/*.code-workspace + + + + + + + com.github.hazendaz.maven + coveralls-maven-plugin + ${coveralls-maven-plugin.version} + + ${coveralls-repo-token} + + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + default-prepare-agent + + prepare-agent + + + + default-report + test + + report + + + + + + + io.github.git-commit-id + git-commit-id-maven-plugin + ${git-commit-id-maven-plugin.version} + + + + + + + org.apache.maven.plugins maven-assembly-plugin @@ -153,23 +399,9 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - - true - ${java.version} - - -J${jvm.options} - - - org.apache.maven.plugins - maven-dependency-plugin - - - - - org.apache.maven.plugins maven-deploy-plugin @@ -177,78 +409,16 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - - - enforce-banned-dependencies - - enforce - - - - - [25,) - - - [${maven.version},) - - - - - - com.google.code.findbugs:annotations - - - - true - - - org.apache.maven.plugins maven-jar-plugin - - - default-jar - package - - jar - - - - default-test-jar - package - - test-jar - - - org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - ${project.reporting.outputDirectory} - ${project.reporting.outputDirectory} - true - public - all,-missing - ${java.version} - - -J${jvm.options} - - - - - attach-javadocs - - jar - - - @@ -259,132 +429,36 @@ under the License. org.apache.maven.plugins maven-source-plugin - - - attach-sources - package - - jar-no-fork - - - - attach-test-sources - package - - test-jar-no-fork - - - org.apache.maven.plugins maven-surefire-plugin - - 1 - true - ${argLine} ${jvm.options} - false - false - true - ${project.build.directory}/test-output/${maven.build.timestamp} - org.apache.maven.plugins maven-toolchains-plugin - ${maven-toolchains-plugin.version} - - - - toolchain - - - - - - - ${java.version} - - - org.apache.rat apache-rat-plugin - ${apache-rat-plugin.version} - - - verify - - check - - - - - ${project.basedir}/rat - true - - - StandardCollection - **/*.yaml - **/*.yml - **/.* - **/test/resources/**/*.txt - **/git.properties - **/doc/** - **/*.sk - LICENSE - NOTICE - **/*.code-workspace - - - - - - org.codehaus.mojo - versions-maven-plugin - ${versions-maven-plugin.version} - - org.eluder.coveralls - coveralls-maven-plugin - ${coveralls-maven-plugin.version} - - ${coveralls-repo-token} - + com.github.hazendaz.maven + coveralls-maven-plugin - org.jacoco jacoco-maven-plugin - ${jacoco-maven-plugin.version} - - - default-prepare-agent - - prepare-agent - - - - default-report - test - - report - - - - pl.project13.maven - git-commit-id-plugin - ${git-commit-id-plugin.version} + io.github.git-commit-id + git-commit-id-maven-plugin @@ -408,8 +482,8 @@ under the License. pl.project13.maven - git-commit-id-plugin - ${git-commit-id-plugin.version} + git-commit-id-maven-plugin + ${git-commit-id-maven-plugin.version} @@ -433,7 +507,7 @@ under the License. git.branch git.commit.id.full - + git.commit.time git.commit.user.email git.tags @@ -452,7 +526,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - ${maven-jar-plugin.version} + default-jar diff --git a/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java b/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java new file mode 100644 index 000000000..a90004652 --- /dev/null +++ b/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.datasketches.common; + +import org.testng.annotations.BeforeSuite; + +public class A_BeforeSuite { + + @BeforeSuite + public void printTestEnvironment() { + System.out.println("===================================================="); + System.out.println("TEST JDK: " + System.getProperty("java.version")); + System.out.println("TEST JDK HOME: " + System.getProperty("java.home")); + System.out.println("====================================================="); + } +} diff --git a/src/test/java/org/apache/datasketches/common/TestUtil.java b/src/test/java/org/apache/datasketches/common/TestUtil.java index 3306790e8..e668eadec 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtil.java +++ b/src/test/java/org/apache/datasketches/common/TestUtil.java @@ -19,22 +19,9 @@ package org.apache.datasketches.common; -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.LinkOption; -import java.nio.file.NoSuchFileException; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.Objects; /** @@ -65,47 +52,59 @@ public final class TestUtil { * The project relative Path for Go serialized sketches to be tested by Java. */ public static final Path goPath = Path.of(".", "serialization_test_data", "go_generated_files"); - + /** * The project relative Path for Rust serialized sketches to be tested by Java. */ public static final Path rustPath = Path.of(".", "serialization_test_data", "rust_generated_files"); - + /** * The project relative Path for /src/test/resources */ public static final Path resPath = Path.of(".","src","test","resources"); + public enum Existence { MUST_EXIST, WARNING } /** * Gets all the bytes of a file as a byte array. - * If the file is missing, this writes a warning message to the console. + * If the file is missing, this either throws an exception or writes a warning message to the console + * based on the state of {@link #Existence Existence}. * @param basePath the base directory path where the file is located * @param fileName the simple file name of the file - * @return a byte array - * @throws RuntimeException for IO errors, or if resolved path is not a file or not readable. + * @param option an optional parameter. If option == Existence.MUST_EXIST and the file does not exist an exception will be thrown. + * If option == Existence.WARNING, or not given, and the file does not exist, it writes a warning message + * to {@link System.err.out System.err.out}. + * If option has more than one argument an exception will be thrown. + * @return a byte array. It may be empty. + * @throws RuntimeException for IO errors, or if resolved path is not a file or not readable or optionally not found. */ - public static byte[] getFileBytes(final Path basePath, final String fileName) throws RuntimeException { + public static byte[] getFileBytes(final Path basePath, final String fileName, Existence... option) { Objects.requireNonNull(basePath, "input parameter 'Path basePath' cannot be null."); Objects.requireNonNull(fileName, "input parameter 'String fileName' cannot be null."); + if (option.length > 1) { throw new IllegalArgumentException("Existence option has a maximum of one argument"); } + Existence status = (option.length == 1) ? option[0] : Existence.WARNING; + Path path = Path.of(basePath.toString(), fileName); Path absPath = path.toAbsolutePath(); //for error output - byte[] bytes = new byte[0]; //or null - if (Files.notExists(path)) { //In this specific case, just issue warning. - System.err.println("File disappeared or not found: " + absPath); - return bytes; //empty + if (Files.notExists(path)) { + if (status == Existence.MUST_EXIST) { + throw new RuntimeException("File disappeared or not found: " + absPath); + } else { + System.err.println("WARNING: File disappeared or not found: " + absPath); + return new byte[0]; + } } if (!Files.isRegularFile(path) || !Files.isReadable(path)) { throw new RuntimeException("Path is not a regular file or not readable: " + absPath); } try { - bytes = Files.readAllBytes(path); + byte[] bytes = Files.readAllBytes(path); return bytes; } catch (IOException e) { throw new RuntimeException("System IO Error reading file: " + absPath + " " + e); } } - + /** * Puts all the bytes of the given byte array to a file with the given fileName. * This assumes that the base directory path is {@link #javaPath javaPath}. @@ -113,17 +112,18 @@ public static byte[] getFileBytes(final Path basePath, final String fileName) th * @param bytes the given byte array */ public static void putBytesToJavaPathFile(final String fileName, final byte[] bytes) { - putBytesToFile(javaPath, fileName, bytes); + putFileBytes(javaPath, fileName, bytes); } - + /** * Puts all the bytes of the given byte array to a basePath file with the given fileName. + * If the file exists it will be overwritten. * @param basePath the directory path for the given fileName * @param fileName the name of the target file * @param bytes the given byte array * @throws RuntimeException for IO errors, */ - public static void putBytesToFile(final Path basePath, final String fileName, final byte[] bytes) { + public static void putFileBytes(final Path basePath, final String fileName, final byte[] bytes) { Objects.requireNonNull(basePath, "input parameter 'Path basePath' cannot be null."); Objects.requireNonNull(fileName, "input parameter 'String fileName' cannot be null."); Objects.requireNonNull(bytes, "input parameter 'byte[] bytes' cannot be null."); diff --git a/src/test/java/org/apache/datasketches/common/TestUtilTest.java b/src/test/java/org/apache/datasketches/common/TestUtilTest.java index 420b05c12..60668c1fe 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtilTest.java +++ b/src/test/java/org/apache/datasketches/common/TestUtilTest.java @@ -19,23 +19,19 @@ package org.apache.datasketches.common; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putFileBytes; import static org.apache.datasketches.common.TestUtil.resPath; - import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; //import static org.testng.internal.EclipseInterface.ASSERT_LEFT; // Ignore, standard imports import static org.testng.Assert.assertNotNull; - -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import static org.testng.Assert.assertTrue; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; -import static java.nio.charset.StandardCharsets.UTF_8; + +import org.testng.annotations.Test; public class TestUtilTest { @@ -49,7 +45,7 @@ public void testGetFileBytes_Success() throws IOException { @Test public void testGetFileBytes_MissingFile() { - byte[] resultBytes = getFileBytes(resPath, "NonExistentFile"); + byte[] resultBytes = getFileBytes(resPath, "Test_NonExistentFile_OK"); assertNotNull(resultBytes); assertEquals(resultBytes.length, 0, "Should return empty array for missing file."); } @@ -59,11 +55,18 @@ public void testGetFileBytes_NotRegular_NotReadable() throws IOException { try { getFileBytes(resPath, ""); } catch (RuntimeException e) { - System.out.println(e.toString()); + System.out.println("Test: Not regular file or not readable: OK\n" + " " + e.toString()); } } - - - - + + private static final Path testPath = Path.of(".", "target", "testDir"); + + @Test + public void testPutBytesToFile() { + byte[] gettysBytes = getFileBytes(resPath, "GettysburgAddress.txt"); + putFileBytes(testPath, "GettysburgAddressCopy.txt", gettysBytes); + byte[] gettysBytes2 = getFileBytes(testPath, "GettysburgAddressCopy.txt"); + assertEquals(gettysBytes, gettysBytes2); + } + } diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml new file mode 100644 index 000000000..d42c27eb6 --- /dev/null +++ b/src/test/resources/testng.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + From f054e51e089939c018b42f5843119bd38cdea000 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Sat, 21 Feb 2026 11:35:45 -0800 Subject: [PATCH 05/17] Update pom. --- pom.xml | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 2b9be8bb7..2fb4d6af0 100644 --- a/pom.xml +++ b/pom.xml @@ -107,20 +107,23 @@ under the License. 3.15.0 - 3.12.0 - + + 0.17 3.2.0 - - 9.0.2 - + 5.0.0 + + + 9.0.2 + 0.8.14 + 1.0.0 @@ -358,7 +361,13 @@ under the License. - + + io.github.git-commit-id + git-commit-id-maven-plugin + ${git-commit-id-maven-plugin.version} + + + org.jacoco jacoco-maven-plugin @@ -380,12 +389,6 @@ under the License. - - io.github.git-commit-id - git-commit-id-maven-plugin - ${git-commit-id-maven-plugin.version} - - @@ -447,18 +450,18 @@ under the License. - com.github.hazendaz.maven - coveralls-maven-plugin + com.github.hazendaz.maven + coveralls-maven-plugin - org.jacoco - jacoco-maven-plugin + io.github.git-commit-id + git-commit-id-maven-plugin - io.github.git-commit-id - git-commit-id-maven-plugin + org.jacoco + jacoco-maven-plugin @@ -481,11 +484,12 @@ under the License. - pl.project13.maven + io.github.git-commit-id git-commit-id-maven-plugin ${git-commit-id-maven-plugin.version} + get-the-git-infos revision @@ -546,14 +550,13 @@ under the License. false false - false + true + true - ${java.version} (${java.vendor} ${java.vm.version}) - ${os.name} ${os.arch} ${os.version} The Apache Software Foundation ${project.groupId}:${project.artifactId} - + ${git.branch} @@ -573,6 +576,7 @@ under the License. org.apache.maven.plugins maven-gpg-plugin + sign-artifacts @@ -595,8 +599,8 @@ under the License. - pl.project13.maven - git-commit-id-plugin + io.github.git-commit-id + git-commit-id-maven-plugin org.apache.maven.plugins From 1e1bd369b06b932378cc0d02ac13b6f035987f40 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Sat, 21 Feb 2026 11:44:10 -0800 Subject: [PATCH 06/17] update testng.xml --- src/test/resources/testng.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index d42c27eb6..24df3053e 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -20,7 +20,7 @@ under the License. --> - + From 008109e061fef4e8938ccbc915b7449b0aa3d243 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Sat, 21 Feb 2026 13:32:11 -0800 Subject: [PATCH 07/17] update pom. --- pom.xml | 59 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 2fb4d6af0..099de78c1 100644 --- a/pom.xml +++ b/pom.xml @@ -25,12 +25,6 @@ under the License. 4.0.0 - - org.apache - apache - 37 - - org.apache.datasketches datasketches-java 9.0.1-SNAPSHOT @@ -106,7 +100,16 @@ under the License. + 3.8.0 3.15.0 + 3.1.4 + 3.6.2 + 3.2.8 + 3.5.0 + 3.12.0 + 3.3.1 + 3.4.0 + 3.5.4 0.17 @@ -145,16 +148,15 @@ under the License. org.apache.maven.plugins maven-assembly-plugin - + ${maven-assembly-plugin.version} org.apache.maven.plugins maven-compiler-plugin - + ${maven-compiler-plugin.version} true - ${java.version} @@ -162,13 +164,13 @@ under the License. org.apache.maven.plugins maven-deploy-plugin - + ${maven-deploy-plugin.version} org.apache.maven.plugins maven-enforcer-plugin - + ${maven-enforcer-plugin.version} enforce-banned-dependencies @@ -204,7 +206,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - + ${maven-jar-plugin.version} default-jar @@ -226,7 +228,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - + ${maven-javadoc-plugin.version} org.apache.datasketches.memory/internal true @@ -252,13 +254,13 @@ under the License. org.apache.maven.plugins maven-release-plugin - + ${maven-release-plugin.version} org.apache.maven.plugins maven-source-plugin - + ${maven-source-plugin.version} attach-sources @@ -280,7 +282,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - + ${maven-surefire-failsafe-plugins.version} @{jvm.args} @@ -530,7 +532,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - + ${maven-jar-plugin.version} default-jar @@ -576,7 +578,7 @@ under the License. org.apache.maven.plugins maven-gpg-plugin - + ${maven-gpg-plugin.version} sign-artifacts @@ -614,6 +616,26 @@ under the License. + + + apache-release + + + + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + source-release-assembly + none + + + + + + + generate-java-files @@ -692,4 +714,5 @@ under the License. + From 896d02a59c556100423e962f4cc5610c5df5d3f8 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Sat, 21 Feb 2026 18:06:56 -0800 Subject: [PATCH 08/17] try to fix pom.xml --- pom.xml | 27 +++++++++++++++------------ src/test/resources/testng.xml | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 099de78c1..1cea755de 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,7 @@ under the License. @@ -335,8 +335,7 @@ under the License. ${project.basedir}/rat true - true - + StandardCollection **/*.yaml @@ -349,7 +348,7 @@ under the License. LICENSE NOTICE **/*.code-workspace - + @@ -367,6 +366,10 @@ under the License. io.github.git-commit-id git-commit-id-maven-plugin ${git-commit-id-maven-plugin.version} + + ${m2e.version} + ${project.basedir}/.git + @@ -455,12 +458,12 @@ under the License. com.github.hazendaz.maven coveralls-maven-plugin - + org.jacoco jacoco-maven-plugin diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 24df3053e..477867204 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -22,7 +22,7 @@ under the License. - + From 3fae60d43f3a8829839d0bb643f506453f58656d Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Mon, 23 Feb 2026 10:52:43 -0800 Subject: [PATCH 09/17] update pom --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1cea755de..070eafc60 100644 --- a/pom.xml +++ b/pom.xml @@ -458,12 +458,12 @@ under the License. com.github.hazendaz.maven coveralls-maven-plugin - + org.jacoco jacoco-maven-plugin From fdb778078a75ef0d8147aaa13bd206c0fb1abecf Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Mon, 23 Feb 2026 13:24:59 -0800 Subject: [PATCH 10/17] Update pom and @BeforeSuite test. --- pom.xml | 7 +------ .../java/org/apache/datasketches/common/A_BeforeSuite.java | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 070eafc60..433eab4d1 100644 --- a/pom.xml +++ b/pom.xml @@ -295,8 +295,7 @@ under the License. src/test/resources/testng.xml false - + ${testng.generate-java-files},${testng.check-cpp-files},${testng.check-go-files},${testng.check-cpp-historical-files} @@ -366,10 +365,6 @@ under the License. io.github.git-commit-id git-commit-id-maven-plugin ${git-commit-id-maven-plugin.version} - - ${m2e.version} - ${project.basedir}/.git - diff --git a/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java b/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java index a90004652..97fe267ff 100644 --- a/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java +++ b/src/test/java/org/apache/datasketches/common/A_BeforeSuite.java @@ -23,7 +23,7 @@ public class A_BeforeSuite { - @BeforeSuite + @BeforeSuite(alwaysRun = true) public void printTestEnvironment() { System.out.println("===================================================="); System.out.println("TEST JDK: " + System.getProperty("java.version")); From 676b8c7d067423f6ed5380cf424b79805dea79d4 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Mon, 23 Feb 2026 15:08:16 -0800 Subject: [PATCH 11/17] Update getFileBytes tests. --- .../apache/datasketches/common/TestUtil.java | 2 +- .../datasketches/common/TestUtilTest.java | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/apache/datasketches/common/TestUtil.java b/src/test/java/org/apache/datasketches/common/TestUtil.java index e668eadec..c166d72c7 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtil.java +++ b/src/test/java/org/apache/datasketches/common/TestUtil.java @@ -68,7 +68,7 @@ public enum Existence { MUST_EXIST, WARNING } /** * Gets all the bytes of a file as a byte array. * If the file is missing, this either throws an exception or writes a warning message to the console - * based on the state of {@link #Existence Existence}. + * based on the state of the optional {@link #Existence Existence}. * @param basePath the base directory path where the file is located * @param fileName the simple file name of the file * @param option an optional parameter. If option == Existence.MUST_EXIST and the file does not exist an exception will be thrown. diff --git a/src/test/java/org/apache/datasketches/common/TestUtilTest.java b/src/test/java/org/apache/datasketches/common/TestUtilTest.java index 60668c1fe..22838a557 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtilTest.java +++ b/src/test/java/org/apache/datasketches/common/TestUtilTest.java @@ -23,8 +23,9 @@ import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.putFileBytes; import static org.apache.datasketches.common.TestUtil.resPath; +import static org.apache.datasketches.common.TestUtil.Existence.MUST_EXIST; +import static org.apache.datasketches.common.TestUtil.Existence.WARNING; import static org.testng.Assert.assertEquals; -//import static org.testng.internal.EclipseInterface.ASSERT_LEFT; // Ignore, standard imports import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -36,7 +37,7 @@ public class TestUtilTest { @Test - public void testGetFileBytes_Success() throws IOException { + public void testGetFileBytes_Success() {// throws IOException { byte[] resultBytes = getFileBytes(resPath, "GettysburgAddress.txt"); assertNotNull(resultBytes); String resultString = new String(resultBytes, UTF_8); @@ -44,19 +45,20 @@ public void testGetFileBytes_Success() throws IOException { } @Test - public void testGetFileBytes_MissingFile() { - byte[] resultBytes = getFileBytes(resPath, "Test_NonExistentFile_OK"); + public void testGetFileBytes_MissingFile_Warning() { + byte[] resultBytes = getFileBytes(resPath, "Test_NonExistentFile_OK", WARNING); //WARNING is the default assertNotNull(resultBytes); assertEquals(resultBytes.length, 0, "Should return empty array for missing file."); } - @Test + @Test(expectedExceptions = RuntimeException.class) + public void testGetFileBytes_MissingFile_MustExist() { + getFileBytes(resPath, "Test_NonExistentFile_OK", MUST_EXIST); + } + + @Test(expectedExceptions = RuntimeException.class) public void testGetFileBytes_NotRegular_NotReadable() throws IOException { - try { - getFileBytes(resPath, ""); - } catch (RuntimeException e) { - System.out.println("Test: Not regular file or not readable: OK\n" + " " + e.toString()); - } + getFileBytes(resPath, ""); } private static final Path testPath = Path.of(".", "target", "testDir"); From 3697a9ca37cc56cf0ac04adc03e45ba6f21a75ed Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Mon, 23 Feb 2026 18:12:01 -0800 Subject: [PATCH 12/17] Updated all write bytes to file in /test/. --- .../apache/datasketches/common/TestUtil.java | 6 +- .../datasketches/common/TestUtilTest.java | 4 +- .../cpc/CpcSketchCrossLanguageTest.java | 11 +-- .../BloomFilterCrossLanguageTest.java | 13 +-- .../FrequentItemsSketchCrossLanguageTest.java | 20 ++-- .../hll/HllSketchCrossLanguageTest.java | 14 ++- .../kll/KllCrossLanguageTest.java | 20 ++-- .../QuantilesSketchCrossLanguageTest.java | 10 +- .../req/ReqSketchCrossLanguageTest.java | 10 +- .../sampling/ReservoirCrossLanguageTest.java | 91 ++++++++----------- .../sampling/VarOptCrossLanguageTest.java | 20 ++-- .../tdigest/TDigestCrossLanguageTest.java | 9 +- .../theta/ThetaSketchCrossLanguageTest.java | 14 +-- .../tuple/TupleCrossLanguageTest.java | 13 +-- .../AodSketchCrossLanguageTest.java | 17 ++-- .../strings/AosSketchCrossLanguageTest.java | 15 ++- 16 files changed, 112 insertions(+), 175 deletions(-) diff --git a/src/test/java/org/apache/datasketches/common/TestUtil.java b/src/test/java/org/apache/datasketches/common/TestUtil.java index c166d72c7..f3fa89a49 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtil.java +++ b/src/test/java/org/apache/datasketches/common/TestUtil.java @@ -111,8 +111,8 @@ public static byte[] getFileBytes(final Path basePath, final String fileName, E * @param fileName the name of the target file * @param bytes the given byte array */ - public static void putBytesToJavaPathFile(final String fileName, final byte[] bytes) { - putFileBytes(javaPath, fileName, bytes); + public static void putBytesToJavaPath(final String fileName, final byte[] bytes) { + putBytesToFile(javaPath, fileName, bytes); } /** @@ -123,7 +123,7 @@ public static void putBytesToJavaPathFile(final String fileName, final byte[] by * @param bytes the given byte array * @throws RuntimeException for IO errors, */ - public static void putFileBytes(final Path basePath, final String fileName, final byte[] bytes) { + public static void putBytesToFile(final Path basePath, final String fileName, final byte[] bytes) { Objects.requireNonNull(basePath, "input parameter 'Path basePath' cannot be null."); Objects.requireNonNull(fileName, "input parameter 'String fileName' cannot be null."); Objects.requireNonNull(bytes, "input parameter 'byte[] bytes' cannot be null."); diff --git a/src/test/java/org/apache/datasketches/common/TestUtilTest.java b/src/test/java/org/apache/datasketches/common/TestUtilTest.java index 22838a557..e8051fe88 100644 --- a/src/test/java/org/apache/datasketches/common/TestUtilTest.java +++ b/src/test/java/org/apache/datasketches/common/TestUtilTest.java @@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.datasketches.common.TestUtil.getFileBytes; -import static org.apache.datasketches.common.TestUtil.putFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToFile; import static org.apache.datasketches.common.TestUtil.resPath; import static org.apache.datasketches.common.TestUtil.Existence.MUST_EXIST; import static org.apache.datasketches.common.TestUtil.Existence.WARNING; @@ -66,7 +66,7 @@ public void testGetFileBytes_NotRegular_NotReadable() throws IOException { @Test public void testPutBytesToFile() { byte[] gettysBytes = getFileBytes(resPath, "GettysburgAddress.txt"); - putFileBytes(testPath, "GettysburgAddressCopy.txt", gettysBytes); + putBytesToFile(testPath, "GettysburgAddressCopy.txt", gettysBytes); byte[] gettysBytes2 = getFileBytes(testPath, "GettysburgAddressCopy.txt"); assertEquals(gettysBytes, gettysBytes2); } diff --git a/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java index 3389f99d3..b0f3ef77f 100644 --- a/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/cpc/CpcSketchCrossLanguageTest.java @@ -22,15 +22,14 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_GO_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.goPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; import org.testng.annotations.Test; @@ -51,7 +50,7 @@ public void generateBinariesForCompatibilityTesting() throws IOException { sk.update(i); } assertEquals(sk.getFlavor(), flavorArr[flavorIdx++]); - Files.newOutputStream(javaPath.resolve("cpc_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("cpc_n" + n + "_java.sk", sk.toByteArray()); } } @@ -67,7 +66,7 @@ void negativeIntEquivalence() throws Exception { final long v4 = -1; sk.update(v4); assertEquals(sk.getEstimate(), 1, 0.01); - Files.newOutputStream(javaPath.resolve("cpc_negative_one_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("cpc_negative_one_java.sk", sk.toByteArray()); } @Test(groups = {CHECK_CPP_FILES}) diff --git a/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java b/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java index bb2e9ccd1..4decdb91c 100644 --- a/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/filters/bloomfilter/BloomFilterCrossLanguageTest.java @@ -21,18 +21,15 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; -import org.apache.datasketches.filters.bloomfilter.BloomFilter; -import org.apache.datasketches.filters.bloomfilter.BloomFilterBuilder; import org.testng.annotations.Test; /** @@ -42,7 +39,7 @@ public class BloomFilterCrossLanguageTest { @Test(groups = {GENERATE_JAVA_FILES}) - public void generatBloomFilterBinariesForCompatibilityTesting() throws IOException { + public void generateBloomFilterBinariesForCompatibilityTesting() throws IOException { final int[] nArr = {0, 10_000, 2_000_000, 300_000_00}; final short[] hArr = {3, 5}; for (final int n : nArr) { @@ -55,7 +52,7 @@ public void generatBloomFilterBinariesForCompatibilityTesting() throws IOExcepti if (n > 0) { bf.update(Float.NaN); } assertEquals(bf.isEmpty(), n == 0); assertTrue(bf.isEmpty() || (bf.getBitsUsed() > (n / 10))); - Files.newOutputStream(javaPath.resolve("bf_n" + n + "_h" + numHashes + "_java.sk")).write(bf.toByteArray()); + putBytesToJavaPath("bf_n" + n + "_h" + numHashes + "_java.sk", bf.toByteArray()); } } } diff --git a/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java index 74f417c38..49a735df7 100644 --- a/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/frequencies/FrequentItemsSketchCrossLanguageTest.java @@ -21,20 +21,17 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; import org.apache.datasketches.common.ArrayOfStringsSerDe; -import org.apache.datasketches.frequencies.FrequentItemsSketch; -import org.apache.datasketches.frequencies.FrequentLongsSketch; import org.testng.annotations.Test; /** @@ -54,7 +51,7 @@ public void generateBinariesForCompatibilityTestingLongsSketch() throws IOExcept assertTrue(n == 0 ? sk.isEmpty() : !sk.isEmpty()); if (n > 10) { assertTrue(sk.getMaximumError() > 0); } else { assertEquals(sk.getMaximumError(), 0); } - Files.newOutputStream(javaPath.resolve("frequent_long_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("frequent_long_n" + n + "_java.sk", sk.toByteArray()); } } @@ -69,8 +66,7 @@ public void generateBinariesForCompatibilityTestingStringsSketch() throws IOExce assertTrue(n == 0 ? sk.isEmpty() : !sk.isEmpty()); if (n > 10) { assertTrue(sk.getMaximumError() > 0); } else { assertEquals(sk.getMaximumError(), 0); } - Files.newOutputStream(javaPath.resolve("frequent_string_n" + n + "_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("frequent_string_n" + n + "_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } } @@ -81,8 +77,7 @@ public void generateBinariesForCompatibilityTestingStringsSketchAscii() throws I sk.update("bbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 2); sk.update("ccccccccccccccccccccccccccccc", 3); sk.update("ddddddddddddddddddddddddddddd", 4); - Files.newOutputStream(javaPath.resolve("frequent_string_ascii_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("frequent_string_ascii_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -95,8 +90,7 @@ public void generateBinariesForCompatibilityTestingStringsSketchUtf8() throws IO sk.update("уфхцч", 5); sk.update("шщъыь", 6); sk.update("эюя", 7); - Files.newOutputStream(javaPath.resolve("frequent_string_utf8_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("frequent_string_utf8_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } @Test(groups = {CHECK_CPP_FILES}) diff --git a/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java index 51966007b..51932d554 100644 --- a/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/hll/HllSketchCrossLanguageTest.java @@ -21,20 +21,18 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.apache.datasketches.hll.TgtHllType.HLL_4; import static org.apache.datasketches.hll.TgtHllType.HLL_6; import static org.apache.datasketches.hll.TgtHllType.HLL_8; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; -import org.apache.datasketches.hll.HllSketch; import org.testng.annotations.Test; /** @@ -59,9 +57,9 @@ public void generateBinariesForCompatibilityTesting() throws IOException { for (int i = 0; i < n; i++) { hll8.update(i); } - Files.newOutputStream(javaPath.resolve("hll4_n" + n + "_java.sk")).write(hll4.toCompactByteArray()); - Files.newOutputStream(javaPath.resolve("hll6_n" + n + "_java.sk")).write(hll6.toCompactByteArray()); - Files.newOutputStream(javaPath.resolve("hll8_n" + n + "_java.sk")).write(hll8.toCompactByteArray()); + putBytesToJavaPath("hll4_n" + n + "_java.sk", hll4.toCompactByteArray()); + putBytesToJavaPath("hll6_n" + n + "_java.sk", hll6.toCompactByteArray()); + putBytesToJavaPath("hll8_n" + n + "_java.sk", hll8.toCompactByteArray()); } } diff --git a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java index 392e667c9..9473dd546 100644 --- a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java @@ -22,27 +22,21 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_CPP_HISTORICAL_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.apache.datasketches.common.TestUtil.resPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; import java.util.Comparator; import org.apache.datasketches.common.ArrayOfStringsSerDe; import org.apache.datasketches.common.TestUtil; import org.apache.datasketches.common.Util; -import org.apache.datasketches.kll.KllDoublesSketch; -import org.apache.datasketches.kll.KllFloatsSketch; -import org.apache.datasketches.kll.KllHeapItemsSketch; -import org.apache.datasketches.kll.KllItemsSketch; -import org.apache.datasketches.kll.KllLongsSketch; import org.apache.datasketches.quantilescommon.QuantilesDoublesSketchIteratorAPI; import org.apache.datasketches.quantilescommon.QuantilesFloatsSketchIterator; import org.apache.datasketches.quantilescommon.QuantilesGenericSketchIteratorAPI; @@ -60,7 +54,7 @@ public void generateKllDoublesSketchBinaries() throws IOException { for (final int n: nArr) { final KllDoublesSketch sk = KllDoublesSketch.newHeapInstance(); for (int i = 1; i <= n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("kll_double_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("kll_double_n" + n + "_java.sk", sk.toByteArray()); } } @@ -70,7 +64,7 @@ public void generateKllFloatsSketchBinaries() throws IOException { for (final int n: nArr) { final KllFloatsSketch sk = KllFloatsSketch.newHeapInstance(); for (int i = 1; i <= n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("kll_float_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("kll_float_n" + n + "_java.sk", sk.toByteArray()); } } @@ -80,7 +74,7 @@ public void generateKllLongsSketchBinaries() throws IOException { for (final int n: nArr) { final KllLongsSketch sk = KllLongsSketch.newHeapInstance(); for (int i = 1; i <= n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("kll_long_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("kll_long_n" + n + "_java.sk", sk.toByteArray()); } } @@ -91,7 +85,7 @@ public void generateKllItemsSketchBinaries() throws IOException { final int digits = Util.numDigits(n); final KllItemsSketch sk = KllItemsSketch.newHeapInstance(Comparator.naturalOrder(), serDe); for (int i = 1; i <= n; i++) { sk.update(Util.longToFixedLengthString(i, digits)); } - Files.newOutputStream(javaPath.resolve("kll_string_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("kll_string_n" + n + "_java.sk", sk.toByteArray()); } } diff --git a/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java index 0ef9c83d3..53746c260 100644 --- a/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/quantiles/QuantilesSketchCrossLanguageTest.java @@ -22,9 +22,9 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_CPP_HISTORICAL_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.apache.datasketches.common.TestUtil.resPath; import static org.apache.datasketches.quantilescommon.QuantileSearchCriteria.EXCLUSIVE; import static org.testng.Assert.assertEquals; @@ -32,7 +32,6 @@ import java.io.IOException; import java.lang.foreign.MemorySegment; -import java.nio.file.Files; import java.util.Comparator; import org.apache.datasketches.common.ArrayOfStringsSerDe; @@ -57,7 +56,7 @@ public void generateDoublesSketch() throws IOException { for (int i = 1; i <= n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("quantiles_double_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("quantiles_double_n" + n + "_java.sk", sk.toByteArray()); } } @@ -84,8 +83,7 @@ public int compare(final String s1, final String s2) { assertEquals(sk.getMinItem(), "1"); assertEquals(sk.getMaxItem(), Integer.toString(n)); } - Files.newOutputStream(javaPath.resolve("quantiles_string_n" + n + "_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("quantiles_string_n" + n + "_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } } diff --git a/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java index 198dffe36..0e7fbee59 100644 --- a/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/req/ReqSketchCrossLanguageTest.java @@ -21,18 +21,16 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; import org.apache.datasketches.quantilescommon.QuantilesFloatsSketchIterator; -import org.apache.datasketches.req.ReqSketch; import org.testng.annotations.Test; /** @@ -49,7 +47,7 @@ public void generateBinariesForCompatibilityTesting() throws IOException { for (int i = 1; i <= n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("req_float_n" + n + "_java.sk")).write(sk.toByteArray()); + putBytesToJavaPath("req_float_n" + n + "_java.sk", sk.toByteArray()); } } diff --git a/src/test/java/org/apache/datasketches/sampling/ReservoirCrossLanguageTest.java b/src/test/java/org/apache/datasketches/sampling/ReservoirCrossLanguageTest.java index 781fbebca..564f3b53b 100644 --- a/src/test/java/org/apache/datasketches/sampling/ReservoirCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/sampling/ReservoirCrossLanguageTest.java @@ -19,19 +19,18 @@ package org.apache.datasketches.sampling; +import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; + +import java.io.IOException; +import java.util.ArrayList; + import org.apache.datasketches.common.ArrayOfDoublesSerDe; import org.apache.datasketches.common.ArrayOfLongsSerDe; import org.apache.datasketches.common.ArrayOfStringsSerDe; import org.apache.datasketches.common.ResizeFactor; import org.testng.annotations.Test; -import java.io.IOException; -import java.nio.file.Files; -import java.util.ArrayList; - -import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.javaPath; - /** * Serialize binary sketches to be tested by other language code. * Test deserialization of binary sketches serialized by other language code. @@ -43,8 +42,7 @@ public void generateReservoirLongsSketchEmpty() throws IOException { final int k = 128; final ReservoirLongsSketch sk = ReservoirLongsSketch.newInstance(k); - Files.newOutputStream(javaPath.resolve("reservoir_longs_empty_k" + k + "_java.sk")) - .write(sk.toByteArray()); + putBytesToJavaPath("reservoir_longs_empty_k" + k + "_java.sk", sk.toByteArray()); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -57,8 +55,7 @@ public void generateReservoirLongsSketchExact() throws IOException { for (int i = 0; i < n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("reservoir_longs_exact_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray()); + putBytesToJavaPath("reservoir_longs_exact_n" + n + "_k" + k + "_java.sk", sk.toByteArray()); } } @@ -80,8 +77,7 @@ public void generateReservoirLongsSketchSampling() throws IOException { k ); - Files.newOutputStream(javaPath.resolve("reservoir_longs_sampling_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray()); + putBytesToJavaPath("reservoir_longs_sampling_n" + n + "_k" + k + "_java.sk", sk.toByteArray()); } } @@ -90,8 +86,7 @@ public void generateReservoirLongsUnionEmpty() throws IOException { int maxK = 128; ReservoirLongsUnion union = ReservoirLongsUnion.newInstance(maxK); - Files.newOutputStream(javaPath.resolve("reservoir_longs_union_empty_maxk" + maxK + "_java.sk")) - .write(union.toByteArray()); + putBytesToJavaPath("reservoir_longs_union_empty_maxk" + maxK + "_java.sk", union.toByteArray()); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -104,8 +99,7 @@ public void generateReservoirLongsUnionExact() throws IOException { for (int i = 0; i < n; i++) { union.update(i); } - Files.newOutputStream(javaPath.resolve("reservoir_longs_union_exact_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray()); + putBytesToJavaPath("reservoir_longs_union_exact_n" + n + "_maxk" + maxK + "_java.sk", union.toByteArray()); } } @@ -130,8 +124,7 @@ public void generateReservoirLongsUnionSampling() throws IOException { ReservoirLongsUnion union = ReservoirLongsUnion.newInstance(maxK); union.update(sk); - Files.newOutputStream(javaPath.resolve("reservoir_longs_union_sampling_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray()); + putBytesToJavaPath("reservoir_longs_union_sampling_n" + n + "_maxk" + maxK + "_java.sk", union.toByteArray()); } } @@ -140,8 +133,7 @@ public void generateReservoirItemsSketchLongEmpty() throws IOException { final int k = 128; final ReservoirItemsSketch sk = ReservoirItemsSketch.newInstance(k); - Files.newOutputStream(javaPath.resolve("reservoir_items_long_empty_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("reservoir_items_long_empty_k" + k + "_java.sk", sk.toByteArray(new ArrayOfLongsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -154,8 +146,7 @@ public void generateReservoirItemsSketchLongExact() throws IOException { for (int i = 0; i < n; i++) { sk.update((long) i); } - Files.newOutputStream(javaPath.resolve("reservoir_items_long_exact_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("reservoir_items_long_exact_n" + n + "_k" + k + "_java.sk", sk.toByteArray(new ArrayOfLongsSerDe())); } } @@ -177,8 +168,7 @@ public void generateReservoirItemsSketchLongSampling() throws IOException { k ); - Files.newOutputStream(javaPath.resolve("reservoir_items_long_sampling_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("reservoir_items_long_sampling_n" + n + "_k" + k + "_java.sk", sk.toByteArray(new ArrayOfLongsSerDe())); } } @@ -187,8 +177,7 @@ public void generateReservoirItemsSketchDoubleEmpty() throws IOException { final int k = 128; final ReservoirItemsSketch sk = ReservoirItemsSketch.newInstance(k); - Files.newOutputStream(javaPath.resolve("reservoir_items_double_empty_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("reservoir_items_double_empty_k" + k + "_java.sk", sk.toByteArray(new ArrayOfDoublesSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -201,8 +190,7 @@ public void generateReservoirItemsSketchDoubleExact() throws IOException { for (int i = 0; i < n; i++) { sk.update((double) i); } - Files.newOutputStream(javaPath.resolve("reservoir_items_double_exact_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("reservoir_items_double_exact_n" + n + "_k" + k + "_java.sk", sk.toByteArray(new ArrayOfDoublesSerDe())); } } @@ -224,8 +212,7 @@ public void generateReservoirItemsSketchDoubleSampling() throws IOException { k ); - Files.newOutputStream(javaPath.resolve("reservoir_items_double_sampling_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("reservoir_items_double_sampling_n" + n + "_k" + k + "_java.sk", sk.toByteArray(new ArrayOfDoublesSerDe())); } } @@ -234,8 +221,7 @@ public void generateReservoirItemsSketchStringEmpty() throws IOException { final int k = 128; final ReservoirItemsSketch sk = ReservoirItemsSketch.newInstance(k); - Files.newOutputStream(javaPath.resolve("reservoir_items_string_empty_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("reservoir_items_string_empty_k" + k + "_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -248,8 +234,7 @@ public void generateReservoirItemsSketchStringExact() throws IOException { for (int i = 0; i < n; i++) { sk.update("item" + i); } - Files.newOutputStream(javaPath.resolve("reservoir_items_string_exact_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("reservoir_items_string_exact_n" + n + "_k" + k + "_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } } @@ -271,8 +256,7 @@ public void generateReservoirItemsSketchStringSampling() throws IOException { k ); - Files.newOutputStream(javaPath.resolve("reservoir_items_string_sampling_n" + n + "_k" + k + "_java.sk")) - .write(sk.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("reservoir_items_string_sampling_n" + n + "_k" + k + "_java.sk", sk.toByteArray(new ArrayOfStringsSerDe())); } } @@ -281,8 +265,7 @@ public void generateReservoirItemsUnionLongEmpty() throws IOException { int maxK = 128; ReservoirItemsUnion union = ReservoirItemsUnion.newInstance(maxK); - Files.newOutputStream(javaPath.resolve("reservoir_items_union_long_empty_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("reservoir_items_union_long_empty_maxk" + maxK + "_java.sk", union.toByteArray(new ArrayOfLongsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -295,8 +278,8 @@ public void generateReservoirItemsUnionLongExact() throws IOException { for (int i = 0; i < n; i++) { union.update((long) i); } - Files.newOutputStream(javaPath.resolve("reservoir_items_union_long_exact_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("reservoir_items_union_long_exact_n" + n + "_maxk" + maxK + "_java.sk", + union.toByteArray(new ArrayOfLongsSerDe())); } } @@ -321,8 +304,8 @@ public void generateReservoirItemsUnionLongSampling() throws IOException { ReservoirItemsUnion union = ReservoirItemsUnion.newInstance(maxK); union.update(sk); - Files.newOutputStream(javaPath.resolve("reservoir_items_union_long_sampling_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("reservoir_items_union_long_sampling_n" + n + "_maxk" + maxK + "_java.sk", + union.toByteArray(new ArrayOfLongsSerDe())); } } @@ -331,8 +314,7 @@ public void generateReservoirItemsUnionDoubleEmpty() throws IOException { int maxK = 128; ReservoirItemsUnion union = ReservoirItemsUnion.newInstance(maxK); - Files.newOutputStream(javaPath.resolve("reservoir_items_union_double_empty_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("reservoir_items_union_double_empty_maxk" + maxK + "_java.sk", union.toByteArray(new ArrayOfDoublesSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -345,8 +327,8 @@ public void generateReservoirItemsUnionDoubleExact() throws IOException { for (int i = 0; i < n; i++) { union.update((double) i); } - Files.newOutputStream(javaPath.resolve("reservoir_items_union_double_exact_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("reservoir_items_union_double_exact_n" + n + "_maxk" + maxK + "_java.sk", + union.toByteArray(new ArrayOfDoublesSerDe())); } } @@ -371,8 +353,8 @@ public void generateReservoirItemsUnionDoubleSampling() throws IOException { ReservoirItemsUnion union = ReservoirItemsUnion.newInstance(maxK); union.update(sk); - Files.newOutputStream(javaPath.resolve("reservoir_items_union_double_sampling_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("reservoir_items_union_double_sampling_n" + n + "_maxk" + maxK + "_java.sk", + union.toByteArray(new ArrayOfDoublesSerDe())); } } @@ -381,8 +363,7 @@ public void generateReservoirItemsUnionStringEmpty() throws IOException { int maxK = 128; ReservoirItemsUnion union = ReservoirItemsUnion.newInstance(maxK); - Files.newOutputStream(javaPath.resolve("reservoir_items_union_string_empty_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("reservoir_items_union_string_empty_maxk" + maxK + "_java.sk", union.toByteArray(new ArrayOfStringsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -395,8 +376,8 @@ public void generateReservoirItemsUnionStringExact() throws IOException { for (int i = 0; i < n; i++) { union.update("item" + i); } - Files.newOutputStream(javaPath.resolve("reservoir_items_union_string_exact_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("reservoir_items_union_string_exact_n" + n + "_maxk" + maxK + "_java.sk", + union.toByteArray(new ArrayOfStringsSerDe())); } } @@ -421,8 +402,8 @@ public void generateReservoirItemsUnionStringSampling() throws IOException { ReservoirItemsUnion union = ReservoirItemsUnion.newInstance(maxK); union.update(sk); - Files.newOutputStream(javaPath.resolve("reservoir_items_union_string_sampling_n" + n + "_maxk" + maxK + "_java.sk")) - .write(union.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("reservoir_items_union_string_sampling_n" + n + "_maxk" + maxK + "_java.sk", + union.toByteArray(new ArrayOfStringsSerDe())); } } } diff --git a/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java b/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java index 265f3ca90..c8db54da8 100644 --- a/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/sampling/VarOptCrossLanguageTest.java @@ -21,22 +21,18 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.io.IOException; import java.lang.foreign.MemorySegment; -import java.nio.file.Files; import org.apache.datasketches.common.ArrayOfDoublesSerDe; import org.apache.datasketches.common.ArrayOfLongsSerDe; import org.apache.datasketches.common.ArrayOfStringsSerDe; -import org.apache.datasketches.sampling.SampleSubsetSummary; -import org.apache.datasketches.sampling.VarOptItemsSketch; -import org.apache.datasketches.sampling.VarOptItemsUnion; import org.testng.annotations.Test; /** @@ -54,8 +50,7 @@ public void generateSketchesLong() throws IOException { for (int i = 1; i <= n; i++) { sk.update(Long.valueOf(i), 1.0); } - Files.newOutputStream(javaPath.resolve("varopt_sketch_long_n" + n + "_java.sk")) - .write(sk.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("varopt_sketch_long_n" + n + "_java.sk", sk.toByteArray(new ArrayOfLongsSerDe())); } } @@ -65,8 +60,7 @@ public void generateSketchStringExact() throws IOException { for (int i = 1; i <= 200; ++i) { sketch.update(Integer.toString(i), 1000.0 / i); } - Files.newOutputStream(javaPath.resolve("varopt_sketch_string_exact_java.sk")) - .write(sketch.toByteArray(new ArrayOfStringsSerDe())); + putBytesToJavaPath("varopt_sketch_string_exact_java.sk", sketch.toByteArray(new ArrayOfStringsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -79,8 +73,7 @@ public void generateSketchLongSampling() throws IOException { sketch.update(-1L, 100000.0); sketch.update(-2L, 110000.0); sketch.update(-3L, 120000.0); - Files.newOutputStream(javaPath.resolve("varopt_sketch_long_sampling_java.sk")) - .write(sketch.toByteArray(new ArrayOfLongsSerDe())); + putBytesToJavaPath("varopt_sketch_long_sampling_java.sk", sketch.toByteArray(new ArrayOfLongsSerDe())); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -107,8 +100,7 @@ public void generateUnionDoubleSampling() throws IOException { sketch.update(1.0 * i, 1.0); } union.update(sketch); - Files.newOutputStream(javaPath.resolve("varopt_union_double_sampling_java.sk")) - .write(union.toByteArray(new ArrayOfDoublesSerDe())); + putBytesToJavaPath("varopt_union_double_sampling_java.sk", union.toByteArray(new ArrayOfDoublesSerDe())); } @Test(groups = {CHECK_CPP_FILES}) diff --git a/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java index a46c06515..99d88b429 100644 --- a/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java @@ -21,14 +21,15 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; + import java.io.IOException; import java.lang.foreign.MemorySegment; -import java.nio.file.Files; + import org.testng.annotations.Test; public class TDigestCrossLanguageTest { @@ -101,7 +102,7 @@ public void generateForCppDouble() throws IOException { for (int i = 1; i <= n; i++) { td.update(i); } - Files.newOutputStream(javaPath.resolve("tdigest_double_n" + n + "_java.sk")).write(td.toByteArray()); + putBytesToJavaPath("tdigest_double_n" + n + "_java.sk", td.toByteArray()); } } diff --git a/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java index 1c27b56e6..c9cf0361b 100644 --- a/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/theta/ThetaSketchCrossLanguageTest.java @@ -21,20 +21,16 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.io.IOException; import java.lang.foreign.MemorySegment; -import java.nio.file.Files; -import org.apache.datasketches.theta.CompactThetaSketch; -import org.apache.datasketches.theta.HashIterator; -import org.apache.datasketches.theta.UpdatableThetaSketch; import org.testng.annotations.Test; /** @@ -51,7 +47,7 @@ public void generateBinariesForCompatibilityTesting() throws IOException { for (int i = 0; i < n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("theta_n" + n + "_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("theta_n" + n + "_java.sk", sk.compact().toByteArray()); } } @@ -63,7 +59,7 @@ public void generateBinariesForCompatibilityTestingCompressed() throws IOExcepti for (int i = 0; i < n; i++) { sk.update(i); } - Files.newOutputStream(javaPath.resolve("theta_compressed_n" + n + "_java.sk")).write(sk.compact().toByteArrayCompressed()); + putBytesToJavaPath("theta_compressed_n" + n + "_java.sk", sk.compact().toByteArrayCompressed()); } } @@ -73,7 +69,7 @@ public void generateBinariesForCompatibilityTestingNonEmptyNoEntries() throws IO sk.update(1); assertFalse(sk.isEmpty()); assertEquals(sk.getRetainedEntries(), 0); - Files.newOutputStream(javaPath.resolve("theta_non_empty_no_entries_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("theta_non_empty_no_entries_java.sk", sk.compact().toByteArray()); } @Test(groups = {CHECK_CPP_FILES}) diff --git a/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java index b58905b2b..6c182baa2 100644 --- a/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tuple/TupleCrossLanguageTest.java @@ -22,23 +22,18 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.CHECK_CPP_HISTORICAL_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.apache.datasketches.common.TestUtil.resPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; import org.apache.datasketches.common.SketchesArgumentException; import org.apache.datasketches.common.TestUtil; -import org.apache.datasketches.tuple.TupleSketch; -import org.apache.datasketches.tuple.TupleSketchIterator; -import org.apache.datasketches.tuple.UpdatableTupleSketch; -import org.apache.datasketches.tuple.UpdatableTupleSketchBuilder; import org.apache.datasketches.tuple.adouble.DoubleSummary; import org.apache.datasketches.tuple.adouble.DoubleSummaryDeserializer; import org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesUnion; @@ -113,7 +108,7 @@ public void generateForCppIntegerSummary() throws IOException { 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()); + putBytesToJavaPath("tuple_int_n" + n + "_java.sk", sk.compact().toByteArray()); } } diff --git a/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java index bc751200f..121b8f52d 100644 --- a/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tuple/arrayofdoubles/AodSketchCrossLanguageTest.java @@ -21,21 +21,16 @@ import static org.apache.datasketches.common.TestUtil.CHECK_CPP_FILES; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.getFileBytes; import static org.apache.datasketches.common.TestUtil.cppPath; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.getFileBytes; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import java.lang.foreign.MemorySegment; import java.io.IOException; -import java.nio.file.Files; +import java.lang.foreign.MemorySegment; -import org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketch; -import org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketchIterator; -import org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesUpdatableSketch; -import org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesUpdatableSketchBuilder; import org.testng.annotations.Test; /** @@ -52,7 +47,7 @@ public void generateBinariesForCompatibilityTestingOneValue() throws IOException for (int i = 0; i < n; i++) { sk.update(i, new double[] {i}); } - Files.newOutputStream(javaPath.resolve("aod_1_n" + n + "_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aod_1_n" + n + "_java.sk", sk.compact().toByteArray()); } } @@ -64,7 +59,7 @@ public void generateBinariesForCompatibilityTestingThreeValues() throws IOExcept for (int i = 0; i < n; i++) { sk.update(i, new double[] {i, i, i}); } - Files.newOutputStream(javaPath.resolve("aod_3_n" + n + "_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aod_3_n" + n + "_java.sk", sk.compact().toByteArray()); } } @@ -75,7 +70,7 @@ public void generateBinariesForCompatibilityTestingNonEmptyNoEntries() throws IO sk.update(1, new double[] {1}); assertFalse(sk.isEmpty()); assertEquals(sk.getRetainedEntries(), 0); - Files.newOutputStream(javaPath.resolve("aod_1_non_empty_no_entries_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aod_1_non_empty_no_entries_java.sk", sk.compact().toByteArray()); } @Test(groups = {CHECK_CPP_FILES}) diff --git a/src/test/java/org/apache/datasketches/tuple/strings/AosSketchCrossLanguageTest.java b/src/test/java/org/apache/datasketches/tuple/strings/AosSketchCrossLanguageTest.java index dd425abfa..973f4bf80 100644 --- a/src/test/java/org/apache/datasketches/tuple/strings/AosSketchCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/tuple/strings/AosSketchCrossLanguageTest.java @@ -20,12 +20,11 @@ package org.apache.datasketches.tuple.strings; import static org.apache.datasketches.common.TestUtil.GENERATE_JAVA_FILES; -import static org.apache.datasketches.common.TestUtil.javaPath; +import static org.apache.datasketches.common.TestUtil.putBytesToJavaPath; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import java.io.IOException; -import java.nio.file.Files; import org.apache.datasketches.common.ResizeFactor; import org.testng.annotations.Test; @@ -44,7 +43,7 @@ public void generateBinariesForCompatibilityTestingOneString() throws IOExceptio for (int i = 0; i < n; i++) { sk.update(new String[] {String.valueOf(i)}, new String[] {"value" + i}); } - Files.newOutputStream(javaPath.resolve("aos_1_n" + n + "_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aos_1_n" + n + "_java.sk", sk.compact().toByteArray()); } } @@ -56,7 +55,7 @@ public void generateBinariesForCompatibilityTestingThreeStrings() throws IOExcep for (int i = 0; i < n; i++) { sk.update(new String[] {String.valueOf(i)}, new String[] {"a" + i, "b" + i, "c" + i}); } - Files.newOutputStream(javaPath.resolve("aos_3_n" + n + "_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aos_3_n" + n + "_java.sk", sk.compact().toByteArray()); } } @@ -67,7 +66,7 @@ public void generateBinariesForCompatibilityTestingNonEmptyNoEntries() throws IO sk.update(new String[] {"key1"}, new String[] {"value1"}); assertFalse(sk.isEmpty()); assertEquals(sk.getRetainedEntries(), 0); - Files.newOutputStream(javaPath.resolve("aos_1_non_empty_no_entries_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aos_1_non_empty_no_entries_java.sk", sk.compact().toByteArray()); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -78,7 +77,7 @@ public void generateBinariesForCompatibilityTestingMultiKeyStrings() throws IOEx for (int i = 0; i < n; i++) { sk.update(new String[] {"key" + i, "subkey" + (i % 10)}, new String[] {"value" + i}); } - Files.newOutputStream(javaPath.resolve("aos_multikey_n" + n + "_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aos_multikey_n" + n + "_java.sk", sk.compact().toByteArray()); } } @@ -93,7 +92,7 @@ public void generateBinariesForCompatibilityTestingUnicodeStrings() throws IOExc assertFalse(sk.isEmpty()); assertEquals(sk.getRetainedEntries(), 3); - Files.newOutputStream(javaPath.resolve("aos_unicode_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aos_unicode_java.sk", sk.compact().toByteArray()); } @Test(groups = {GENERATE_JAVA_FILES}) @@ -107,6 +106,6 @@ public void generateBinariesForCompatibilityTestingEmptyStrings() throws IOExcep assertFalse(sk.isEmpty()); assertEquals(sk.getRetainedEntries(), 3); - Files.newOutputStream(javaPath.resolve("aos_empty_strings_java.sk")).write(sk.compact().toByteArray()); + putBytesToJavaPath("aos_empty_strings_java.sk", sk.compact().toByteArray()); } } From 50cc9e41d3096d8033a7a9b800c3e12f557c6e9d Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Mon, 23 Feb 2026 18:31:28 -0800 Subject: [PATCH 13/17] Fix pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 433eab4d1..4c039c483 100644 --- a/pom.xml +++ b/pom.xml @@ -283,7 +283,7 @@ under the License. maven-surefire-plugin ${maven-surefire-failsafe-plugins.version} - @{jvm.args} + @{argLine} @{jvm.args} ${java.version} From 293d721966ad04ab5fa449a9405a786eecbc8877 Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Tue, 24 Feb 2026 10:12:39 -0800 Subject: [PATCH 14/17] Update pom. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c039c483..f70224b77 100644 --- a/pom.xml +++ b/pom.xml @@ -283,7 +283,7 @@ under the License. maven-surefire-plugin ${maven-surefire-failsafe-plugins.version} - @{argLine} @{jvm.args} + @{argLine} @{jvm.args} ${java.version} From 359f4d386482f306149dd1460412c927880999fb Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Tue, 24 Feb 2026 16:07:25 -0800 Subject: [PATCH 15/17] Removed DOCTYPE link as unnecessary --- src/test/resources/testng.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 477867204..a78e300f5 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,4 +1,4 @@ - + @@ -53,14 +50,14 @@ under the License. - + - + - + @@ -68,16 +65,16 @@ under the License. - + - + - + @@ -88,7 +85,7 @@ under the License. - + @@ -101,44 +98,44 @@ under the License. - + - + - + - - + + - + - + - + @@ -146,51 +143,51 @@ under the License. - + - + - + - + - + - + - + - + - + - + - + @@ -198,11 +195,11 @@ under the License. - + - + - + @@ -211,21 +208,21 @@ under the License. - + - + - + @@ -233,19 +230,19 @@ under the License. - + - + - + - + @@ -259,12 +256,12 @@ under the License. - + - + @@ -275,27 +272,27 @@ under the License. - + - + - + - + - + @@ -369,13 +366,13 @@ under the License. - + - + @@ -386,26 +383,26 @@ under the License. - + - + - + - + - + - + diff --git a/tools/testng.xml b/tools/testng.xml deleted file mode 100644 index 6571f092c..000000000 --- a/tools/testng.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 73719536643a20a4b0aa1195ba588b3533344e5f Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Wed, 25 Feb 2026 14:11:39 -0800 Subject: [PATCH 17/17] Update Fix_get_file_bytes from main. --- .../java/org/apache/datasketches/kll/KllCrossLanguageTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java index 9ca2d25fc..3ce30ec1e 100644 --- a/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java +++ b/src/test/java/org/apache/datasketches/kll/KllCrossLanguageTest.java @@ -210,7 +210,7 @@ public int compare(final String s1, final String s2) { public void kllLong() throws IOException { final int[] nArr = {0, 10, 100, 1000, 10000, 100000, 1000000}; for (final int n: nArr) { - final byte[] bytes = Files.readAllBytes(cppPath.resolve("kll_long_n" + n + "_cpp.sk")); + final byte[] bytes = getFileBytes(cppPath,"kll_long_n" + n + "_cpp.sk"); final KllLongsSketch sketch = KllLongsSketch.heapify(MemorySegment.ofArray(bytes)); assertEquals(sketch.getK(), 200); assertTrue(n == 0 ? sketch.isEmpty() : !sketch.isEmpty());