You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2022/07/29 03:56:16 UTC
[datasketches-java] 04/08: incremental changes 1
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch More_changes_to_REQ
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git
commit 1ba33414bc628338cadb7880b84ddee8c4739c4f
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Mon Jul 25 14:38:00 2022 -0700
incremental changes 1
---
pom.xml | 1 +
.../apache/datasketches/kll/MiscFloatsTest.java | 42 +++++++++++++++++++---
2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 51095f4b..c626f47c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -682,6 +682,7 @@ under the License.
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
+ --add-opens java.base/sun.nio.ch=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
diff --git a/src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java b/src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java
index f0090486..3f827dfc 100644
--- a/src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java
+++ b/src/test/java/org/apache/datasketches/kll/MiscFloatsTest.java
@@ -147,9 +147,29 @@ public class MiscFloatsTest {
show(sk, 108);
}
+ @Test
+ public void viewCompactionAndSortedView() {
+ KllFloatsSketch sk = KllFloatsSketch.newHeapInstance(20);
+ boolean cumulative = false;
+ boolean inclusive = false;
+ show(sk, 20);
+ KllFloatsSketchSortedView sv = sk.getSortedView(cumulative, inclusive);
+ KllFloatsSketchSortedViewIterator itr = sv.iterator();
+ if (cumulative) {
+ printf("%12s%12s\n", "Value", "CumWeight");
+ } else {
+ printf("%12s%12s\n", "Value", "Weight");
+ }
+ while (itr.next()) {
+ float v = itr.getValue();
+ long wt = itr.getWeight();
+ printf("%12.1f%12d\n", v, wt);
+ }
+ }
+
private static void show(final KllFloatsSketch sk, int limit) {
int i = (int) sk.getN();
- for ( ; i < limit; i++) { sk.update(i + 1); } //incremental update
+ for ( ; i < limit; i++) { sk.update(i + 1); }
println(sk.toString(true, true));
}
@@ -521,14 +541,26 @@ public class MiscFloatsTest {
@Test
public void printlnTest() {
- println("PRINTING: " + this.getClass().getName());
+ println("PRINTING: println in " + this.getClass().getName());
+ String s = "PRINTING: printf in " + this.getClass().getName();
+ printf("%s\n", s);
+ }
+
+ private final static boolean enablePrinting = true;
+
+ /**
+ * @param format the format
+ * @param args the args
+ */
+ private static final void printf(final String format, final Object ...args) {
+ if (enablePrinting) { System.out.printf(format, args); }
}
/**
- * @param o value to print
+ * @param o the Object to println
*/
- static void println(final Object o) {
- System.out.println(o.toString()); //disable here
+ private static final void println(final Object o) {
+ if (enablePrinting) { System.out.println(o.toString()); }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org