Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ under the License.
<!-- these are TestNG groups used for excluding / including groups of tests. See profiles section. -->
<testng.generate-java-files>generate_java_files</testng.generate-java-files>
<testng.check-cpp-files>check_cpp_files</testng.check-cpp-files>
<testng.check-go-files>check_go_files</testng.check-go-files>
<testng.check-cpp-historical-files>check_cpp_historical_files</testng.check-cpp-historical-files>

<!-- System-wide properties -->
Expand Down Expand Up @@ -623,7 +624,7 @@ under the License.
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>${testng.generate-java-files}</groups>
<excludedGroups>${testng.check-cpp-files},${testng.check-cpp-historical-files}</excludedGroups>
<excludedGroups>${testng.check-cpp-files},${testng.check-go-files},${testng.check-cpp-historical-files}</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand All @@ -642,7 +643,26 @@ under the License.
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>${testng.check-cpp-files}</groups>
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-historical-files}</excludedGroups>
<excludedGroups>${testng.generate-java-files},${testng.check-go-files},${testng.check-cpp-historical-files}</excludedGroups>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>

<profile>
<id>check-go-files</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- Apache Parent pom, pluginManagement-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>${testng.check-cpp-files}</groups>
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-files},${testng.check-cpp-historical-files}</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand All @@ -661,7 +681,7 @@ under the License.
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>${testng.check-cpp-historical-files}</groups>
<excludedGroups>${testng.generate-java-files},${testng.check-cpp-files}</excludedGroups>
<excludedGroups>${testng.generate-java-files},${testng.check-go-files},${testng.check-cpp-files}</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/datasketches/cpc/CpcSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ public String toString(final boolean detail) {
final double errConst = mergeFlag ? log(2) : sqrt(log(2) / 2.0);
final double rse = errConst / Math.sqrt(1 << lgK);
final StringBuilder sb = new StringBuilder();
sb.append("### CPD SKETCH - PREAMBLE:").append(LS);
sb.append("### CPC SKETCH - PREAMBLE:").append(LS);
sb.append(" Flavor : ").append(getFlavor()).append(LS);
sb.append(" LgK : ").append(lgK).append(LS);
sb.append(" Merge Flag : ").append(mergeFlag).append(LS);
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/apache/datasketches/common/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public final class TestUtil {
*/
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_CPP_HISTORICAL_FILES = "check_cpp_historical_files";

/**
Expand All @@ -59,6 +60,11 @@ public final class TestUtil {
*/
public static final Path cppPath = createPath("serialization_test_data/cpp_generated_files");

/**
* The full target 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
package org.apache.datasketches.cpc;

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.cppPath;
import static org.apache.datasketches.common.TestUtil.goPath;
import static org.apache.datasketches.common.TestUtil.javaPath;
import static org.testng.Assert.assertEquals;

Expand Down Expand Up @@ -78,4 +80,17 @@ public void allFlavors() throws IOException {
}
}

@Test(groups = {CHECK_GO_FILES})
public void checkAllFlavorsGo() throws IOException {
final int[] nArr = {0, 100, 200, 2000, 20000};
final Flavor[] flavorArr = {Flavor.EMPTY, Flavor.SPARSE, Flavor.HYBRID, Flavor.PINNED, Flavor.SLIDING};
int flavorIdx = 0;
for (int n: nArr) {
final byte[] bytes = Files.readAllBytes(goPath.resolve("cpc_n" + n + "_go.sk"));
final CpcSketch sketch = CpcSketch.heapify(Memory.wrap(bytes));
assertEquals(sketch.getFlavor(), flavorArr[flavorIdx++]);
assertEquals(sketch.getEstimate(), n, n * 0.02);
}
}

}