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 2021/11/08 22:24:47 UTC

[datasketches-java] branch parameterLeakage created (now 3bedc0d)

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

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


      at 3bedc0d  Merge branch 'master' into parameterLeakage

This branch includes the following new commits:

     new 69ea482  Add one test
     new 3bedc0d  Merge branch 'master' into parameterLeakage

The 2 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.


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


[datasketches-java] 01/02: Add one test

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

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

commit 69ea4828dea4a88588aa5adc13a968e0071bf74f
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Mon Nov 8 14:16:29 2021 -0800

    Add one test
---
 .../tuple/aninteger/ParameterLeakageTest.java      | 178 +++++++++++++++++++++
 1 file changed, 178 insertions(+)

diff --git a/src/test/java/org/apache/datasketches/tuple/aninteger/ParameterLeakageTest.java b/src/test/java/org/apache/datasketches/tuple/aninteger/ParameterLeakageTest.java
new file mode 100644
index 0000000..8fee827
--- /dev/null
+++ b/src/test/java/org/apache/datasketches/tuple/aninteger/ParameterLeakageTest.java
@@ -0,0 +1,178 @@
+/*
+ * 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.tuple.aninteger;
+
+import static org.apache.datasketches.tuple.aninteger.IntegerSummary.Mode.Min;
+import static org.apache.datasketches.tuple.aninteger.IntegerSummary.Mode.Sum;
+
+import org.apache.datasketches.tuple.AnotB;
+import org.apache.datasketches.tuple.CompactSketch;
+import org.apache.datasketches.tuple.Intersection;
+//import org.apache.datasketches.tuple.UpdatableSketch;
+import org.apache.datasketches.tuple.Sketch;
+import org.apache.datasketches.tuple.SketchIterator;
+import org.apache.datasketches.tuple.Union;
+import org.testng.annotations.Test;
+
+/**
+ * These tests check to make sure that no summary objects, which are mutable, and created
+ * as needed internally within a tuple sketch never leak into the result sketch.
+ *
+ * @author Lee Rhodes
+ *
+ */
+public class ParameterLeakageTest {
+  IntegerSummarySetOperations setOps = new IntegerSummarySetOperations(Sum, Min);
+
+  @Test
+  public void checkUnion() {
+    IntegerSketch sk1 = new IntegerSketch(4, Sum);
+    sk1.update(1, 1);
+    IntegerSummary sk1sum = captureSummaries(sk1)[0];
+
+    IntegerSketch sk2 = new IntegerSketch(4, Sum);
+    sk2.update(2, 1);
+    IntegerSummary sk2sum = captureSummaries(sk2)[0];
+
+
+    Union<IntegerSummary> union = new Union<>(setOps);
+
+    CompactSketch<IntegerSummary> csk = union.union(sk1, sk2);
+    IntegerSummary[] summaries = captureSummaries(csk);
+    println("Union Count: " + summaries.length);
+
+    for (IntegerSummary isum : summaries) {
+      if ((isum == sk1sum) || (isum == sk2sum)) {
+        throw new IllegalArgumentException("Parameter Leakage");
+      }
+    }
+  }
+
+  @Test
+  public void checkIntersectStateless() {
+    IntegerSketch sk1 = new IntegerSketch(4, Sum);
+    sk1.update(1, 1);
+    IntegerSummary sk1sum = captureSummaries(sk1)[0];
+
+    IntegerSketch sk2 = new IntegerSketch(4, Sum);
+    sk2.update(1, 1);
+    IntegerSummary sk2sum = captureSummaries(sk2)[0];
+
+    Intersection<IntegerSummary> intersect = new Intersection<>(setOps);
+
+    CompactSketch<IntegerSummary> csk = intersect.intersect(sk1, sk2);
+    IntegerSummary[] summaries = captureSummaries(csk);
+    println("Intersect Stateless Count: " + summaries.length);
+
+    for (IntegerSummary isum : summaries) {
+      if ((isum == sk1sum) || (isum == sk2sum)) {
+        throw new IllegalArgumentException("Parameter Leakage");
+      }
+    }
+  }
+
+  @Test
+  public void checkIntersectStateful() {
+    IntegerSketch sk1 = new IntegerSketch(4, Sum);
+    sk1.update(1, 1);
+    IntegerSummary sk1sum = captureSummaries(sk1)[0];
+
+    IntegerSketch sk2 = new IntegerSketch(4, Sum);
+    sk2.update(1, 1);
+    IntegerSummary sk2sum = captureSummaries(sk2)[0];
+
+    Intersection<IntegerSummary> intersect = new Intersection<>(setOps);
+
+    intersect.intersect(sk1);
+    intersect.intersect(sk2);
+    CompactSketch<IntegerSummary> csk = intersect.getResult();
+
+    IntegerSummary[] summaries = captureSummaries(csk);
+    println("Intersect Stateful Count: " + summaries.length);
+
+    for (IntegerSummary isum : summaries) {
+      if ((isum == sk1sum) || (isum == sk2sum)) {
+        throw new IllegalArgumentException("Parameter Leakage");
+      }
+    }
+  }
+
+  @Test
+  public void checkAnotbStateless() {
+    IntegerSketch sk1 = new IntegerSketch(4, Sum);
+    sk1.update(1, 1);
+    IntegerSummary sk1sum = captureSummaries(sk1)[0];
+
+    IntegerSketch sk2 = new IntegerSketch(4, Sum);
+    sk2.update(2, 1);
+    IntegerSummary sk2sum = captureSummaries(sk2)[0];
+
+    CompactSketch<IntegerSummary> csk = AnotB.aNotB(sk1, sk2);
+    IntegerSummary[] summaries = captureSummaries(csk);
+    println("AnotB Stateless Count: " + summaries.length);
+
+    for (IntegerSummary isum : summaries) {
+      if ((isum == sk1sum) || (isum == sk2sum)) {
+        throw new IllegalArgumentException("Parameter Leakage");
+      }
+    }
+  }
+
+  @Test
+  public void checkAnotbStateful() {
+    IntegerSketch sk1 = new IntegerSketch(4, Sum);
+    sk1.update(1, 1);
+    IntegerSummary sk1sum = captureSummaries(sk1)[0];
+
+    IntegerSketch sk2 = new IntegerSketch(4, Sum);
+    sk2.update(2, 1);
+    IntegerSummary sk2sum = captureSummaries(sk2)[0];
+
+    AnotB<IntegerSummary> anotb = new AnotB<>();
+
+    anotb.setA(sk1);
+    anotb.notB(sk2);
+
+    CompactSketch<IntegerSummary> csk = anotb.getResult(true);
+    IntegerSummary[] summaries = captureSummaries(csk);
+    println("AnotB Stateful Count: " + summaries.length);
+
+    for (IntegerSummary isum : summaries) {
+      if ((isum == sk1sum) || (isum == sk2sum)) {
+        throw new IllegalArgumentException("Parameter Leakage");
+      }
+    }
+  }
+
+  private static IntegerSummary[] captureSummaries(Sketch<IntegerSummary> sk) {
+    int entries = sk.getRetainedEntries();
+    IntegerSummary[] intSumArr = new IntegerSummary[entries];
+    int cnt = 0;
+    SketchIterator<IntegerSummary> it = sk.iterator();
+    while (it.next()) {
+      intSumArr[cnt] = it.getSummary();
+      cnt++;
+    }
+    return intSumArr;
+  }
+
+
+  static void println(Object o) { System.out.println(o.toString()); }
+}

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


[datasketches-java] 02/02: Merge branch 'master' into parameterLeakage

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

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

commit 3bedc0d0e8dd2f7a1d4c5341667de41d03c1203f
Merge: 69ea482 2e51e5b
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Mon Nov 8 14:17:53 2021 -0800

    Merge branch 'master' into parameterLeakage


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