You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2023/02/10 22:12:02 UTC

[datasketches-java] branch theta_compression updated (66375090 -> 3d7d5db1)

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

alsay pushed a change to branch theta_compression
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git


    from 66375090 theta compression
     new 75a44fa7 removed confusing comment
     new c50c5feb fixed theta extraction V4
     new 3d7d5db1 test compatibility with C++

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/datasketches/theta/PreambleUtil.java    |   2 +-
 .../org/apache/datasketches/theta/UnionImpl.java   |   2 +-
 .../datasketches/theta/CompactSketchTest.java      |  32 +++++++++++++++++++++
 src/test/resources/theta_estimation_mode_v4.sk     | Bin 0 -> 35955 bytes
 4 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 src/test/resources/theta_estimation_mode_v4.sk


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[datasketches-java] 01/03: removed confusing comment

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 75a44fa7c99d3d4f1d52812a9dfd8386ca136e54
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Feb 10 14:10:40 2023 -0800

    removed confusing comment
---
 src/main/java/org/apache/datasketches/theta/UnionImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/datasketches/theta/UnionImpl.java b/src/main/java/org/apache/datasketches/theta/UnionImpl.java
index 08cb3fe4..fd462fd2 100644
--- a/src/main/java/org/apache/datasketches/theta/UnionImpl.java
+++ b/src/main/java/org/apache/datasketches/theta/UnionImpl.java
@@ -297,7 +297,7 @@ final class UnionImpl extends Union {
   }
 
   @Override
-  public void union(final Sketch sketchIn) { //Only valid for theta Sketches using SerVer >= 3
+  public void union(final Sketch sketchIn) {
     //UNION Empty Rule: AND the empty states.
 
     if (sketchIn == null || sketchIn.isEmpty()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[datasketches-java] 03/03: test compatibility with C++

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3d7d5db16895de84769f25219a76a1110b722210
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Feb 10 14:11:54 2023 -0800

    test compatibility with C++
---
 .../datasketches/theta/CompactSketchTest.java      |  32 +++++++++++++++++++++
 src/test/resources/theta_estimation_mode_v4.sk     | Bin 0 -> 35955 bytes
 2 files changed, 32 insertions(+)

diff --git a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
index 6bedbf43..020e306b 100644
--- a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
@@ -25,8 +25,12 @@ import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
+import java.io.File;
+
 import org.apache.datasketches.common.Family;
 import org.apache.datasketches.common.SketchesArgumentException;
+import org.apache.datasketches.common.Util;
+import org.apache.datasketches.memory.MapHandle;
 import org.apache.datasketches.memory.Memory;
 import org.apache.datasketches.memory.WritableHandle;
 import org.apache.datasketches.memory.WritableMemory;
@@ -440,6 +444,34 @@ public class CompactSketchTest {
     }
   }
 
+  @Test
+  public void compatibilityWithCppEstimationModeV4() {
+    final File file = Util.getResourceFile("theta_estimation_mode_v4.sk");
+    try (MapHandle mh = Memory.map(file)) {
+      final Memory mem = mh.get();
+      CompactSketch cs1 = CompactSketch.heapify(mem);
+      
+      // construct sketch the same way
+      UpdateSketch sk = Sketches.updateSketchBuilder().build();
+      for (int i = 0; i < 10000; i++) {
+        sk.update(i);
+      }
+      CompactSketch cs2 = sk.compact();
+      assertEquals(cs1.isEmpty(), cs2.isEmpty());
+      assertEquals(cs1.isEstimationMode(), cs2.isEstimationMode());
+      assertEquals(cs1.getTheta(), cs2.getTheta());
+      assertEquals(cs1.getRetainedEntries(), cs2.getRetainedEntries());
+      HashIterator it1 = cs1.iterator();
+      HashIterator it2 = cs2.iterator();
+      while (it1.next()) {
+        assertTrue(it2.next());
+        assertEquals(it1.get(), it2.get());
+      }
+    } catch (final Exception e) {
+      e.printStackTrace();
+    }
+  }
+
   private static class State {
     String classType = null;
     int count = 0;
diff --git a/src/test/resources/theta_estimation_mode_v4.sk b/src/test/resources/theta_estimation_mode_v4.sk
new file mode 100644
index 00000000..33459ef5
Binary files /dev/null and b/src/test/resources/theta_estimation_mode_v4.sk differ


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[datasketches-java] 02/03: fixed theta extraction V4

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c50c5febafbc540208dff257e2f85ecd7e5c0d52
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Feb 10 14:11:14 2023 -0800

    fixed theta extraction V4
---
 src/main/java/org/apache/datasketches/theta/PreambleUtil.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/datasketches/theta/PreambleUtil.java b/src/main/java/org/apache/datasketches/theta/PreambleUtil.java
index 3c34b356..b2686142 100644
--- a/src/main/java/org/apache/datasketches/theta/PreambleUtil.java
+++ b/src/main/java/org/apache/datasketches/theta/PreambleUtil.java
@@ -411,7 +411,7 @@ final class PreambleUtil {
   }
 
   static long extractThetaLongV4(final Memory mem) {
-    return mem.getLong(THETA_LONG);
+    return mem.getLong(THETA_LONG_V4);
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org