github-advanced-security[bot] commented on code in PR #705:
URL: https://github.com/apache/datasketches-java/pull/705#discussion_r2641417737


##########
src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummary_Issue699.java:
##########
@@ -0,0 +1,69 @@
+package org.apache.datasketches.tuple.strings;
+
+import static org.apache.datasketches.common.Util.LS;
+
+import org.apache.datasketches.theta.UpdatableThetaSketch;
+import org.apache.datasketches.tuple.TupleSketchIterator;
+import org.apache.datasketches.tuple.TupleUnion;
+import org.testng.annotations.Test;
+
+public class ArrayOfStringsSummary_Issue699 {
+  UpdatableThetaSketch thetaSk = UpdatableThetaSketch.builder().build();
+  ArrayOfStringsTupleSketch tupleSk = new ArrayOfStringsTupleSketch();
+  TupleUnion<ArrayOfStringsSummary> union = new TupleUnion<>(new 
ArrayOfStringsSummarySetOperations());
+
+  @Test
+  void go() {
+    thetaSk.update("a");
+    thetaSk.update("b");
+    thetaSk.update("c");
+    
+    tupleSk.update("a", new String[] {"x", "y"});
+    tupleSk.update("b", new String[] {"z"});
+    tupleSk.update("e", new String[] {"x", "z"});
+    
+    println("Print Tuple Summary before union");
+    printSummaries(tupleSk.iterator());
+    
+    union.union(tupleSk);
+    union.union(thetaSk, new ArrayOfStringsSummary()); //enable this or the 
next
+    //union.union(thetaSk, new ArrayOfStringsSummary(new String[] {"u", 
"v"})); //optional association
+    
+    println("Print Tuple Summary after union");
+    printSummaries(union.getResult().iterator());
+  }
+  
+  @Test
+  void checkCopy() {
+    ArrayOfStringsSummary aoss = new ArrayOfStringsSummary();
+    ArrayOfStringsSummary aoss2 = aoss.copy();
+  }
+  
+  @Test
+  void checkToByteArray() {
+    ArrayOfStringsSummary aoss = new ArrayOfStringsSummary();
+    byte[] bytes = aoss.toByteArray();
+    println("byte[].length = " + bytes.length);
+  }
+  
+  
+  static void printSummaries(TupleSketchIterator<ArrayOfStringsSummary> it) {
+    while (it.next()) {
+      String[] strArr = it.getSummary().getValue();
+      if (strArr.length == 0) { print("-"); } //illustrates an empty string 
array
+      for (String s : strArr) {
+        print(s + ", ");
+      }
+      println("");
+    }
+    println("");
+  }
+  
+  private static void println(Object o) { 
+    print(o + LS);
+  }
+  
+  private static void print(Object o) {

Review Comment:
   ## Useless parameter
   
   The parameter 'o' is never used.
   
   [Show more 
details](https://github.com/apache/datasketches-java/security/code-scanning/957)



##########
src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSummary_Issue699.java:
##########
@@ -0,0 +1,69 @@
+package org.apache.datasketches.tuple.strings;
+
+import static org.apache.datasketches.common.Util.LS;
+
+import org.apache.datasketches.theta.UpdatableThetaSketch;
+import org.apache.datasketches.tuple.TupleSketchIterator;
+import org.apache.datasketches.tuple.TupleUnion;
+import org.testng.annotations.Test;
+
+public class ArrayOfStringsSummary_Issue699 {
+  UpdatableThetaSketch thetaSk = UpdatableThetaSketch.builder().build();
+  ArrayOfStringsTupleSketch tupleSk = new ArrayOfStringsTupleSketch();
+  TupleUnion<ArrayOfStringsSummary> union = new TupleUnion<>(new 
ArrayOfStringsSummarySetOperations());
+
+  @Test
+  void go() {
+    thetaSk.update("a");
+    thetaSk.update("b");
+    thetaSk.update("c");
+    
+    tupleSk.update("a", new String[] {"x", "y"});
+    tupleSk.update("b", new String[] {"z"});
+    tupleSk.update("e", new String[] {"x", "z"});
+    
+    println("Print Tuple Summary before union");
+    printSummaries(tupleSk.iterator());
+    
+    union.union(tupleSk);
+    union.union(thetaSk, new ArrayOfStringsSummary()); //enable this or the 
next
+    //union.union(thetaSk, new ArrayOfStringsSummary(new String[] {"u", 
"v"})); //optional association
+    
+    println("Print Tuple Summary after union");
+    printSummaries(union.getResult().iterator());
+  }
+  
+  @Test
+  void checkCopy() {
+    ArrayOfStringsSummary aoss = new ArrayOfStringsSummary();
+    ArrayOfStringsSummary aoss2 = aoss.copy();

Review Comment:
   ## Unread local variable
   
   Variable 'ArrayOfStringsSummary aoss2' is never read.
   
   [Show more 
details](https://github.com/apache/datasketches-java/security/code-scanning/958)



##########
src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java:
##########
@@ -49,40 +49,52 @@
     for (int i = 0; i < len; i++) {
       sketch1.update(strArrArr[i], strArrArr[i]);
     }
+    println("Sketch1");
+    printSummaries(sketch1.iterator());
+    
     sketch1.update(strArrArr[0], strArrArr[0]); //insert duplicate
+    println("Sketch1 updated with a duplicate");
     printSummaries(sketch1.iterator());
-    byte[] array = sketch1.toByteArray();
-    MemorySegment wseg = MemorySegment.ofArray(array);
+    
+    MemorySegment wseg = MemorySegment.ofArray(sketch1.toByteArray());

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [QuickSelectSketch.toByteArray](1) should be avoided because it has 
been deprecated.
   
   [Show more 
details](https://github.com/apache/datasketches-java/security/code-scanning/959)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to