From 426eb333615abf507df1235eb424aa295a49a1b6 Mon Sep 17 00:00:00 2001 From: jmalkin <786705+jmalkin@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:36:36 -0800 Subject: [PATCH] Whitesource fixes --- .../org/apache/datasketches/sampling/EbppsItemsSample.java | 4 ++-- .../org/apache/datasketches/sampling/EbppsItemsSketch.java | 3 ++- .../org/apache/datasketches/sampling/EbppsSketchTest.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/datasketches/sampling/EbppsItemsSample.java b/src/main/java/org/apache/datasketches/sampling/EbppsItemsSample.java index 99e672f5b..38467ed32 100644 --- a/src/main/java/org/apache/datasketches/sampling/EbppsItemsSample.java +++ b/src/main/java/org/apache/datasketches/sampling/EbppsItemsSample.java @@ -97,8 +97,8 @@ public ArrayList getSample() { return null; ArrayList result = new ArrayList<>(resultSize); - for (T item : data_) - result.add(item); + if (data_ != null) + result.addAll(data_); if (includePartial) result.add(partialItem_); diff --git a/src/main/java/org/apache/datasketches/sampling/EbppsItemsSketch.java b/src/main/java/org/apache/datasketches/sampling/EbppsItemsSketch.java index e0d4f1f7d..4452644b6 100644 --- a/src/main/java/org/apache/datasketches/sampling/EbppsItemsSketch.java +++ b/src/main/java/org/apache/datasketches/sampling/EbppsItemsSketch.java @@ -335,7 +335,8 @@ private void internalMerge(EbppsItemsSketch other) { * Provides a human-readable summary of the sketch * @return a summary of information in the sketch */ - public String toString() { + @Override + public String toString() { return null; } diff --git a/src/test/java/org/apache/datasketches/sampling/EbppsSketchTest.java b/src/test/java/org/apache/datasketches/sampling/EbppsSketchTest.java index 4f725801e..dde0db669 100644 --- a/src/test/java/org/apache/datasketches/sampling/EbppsSketchTest.java +++ b/src/test/java/org/apache/datasketches/sampling/EbppsSketchTest.java @@ -60,6 +60,9 @@ static void checkIfEqual(EbppsItemsSketch sk1, EbppsItemsSketch sk2) { } // nothing to test if one is null and the other isn't } else { + // sk1.getC() >= 1.0 and sk2.getC() >= 1.0 (they're equal per above) + // so the samples shouldn't be null + assertTrue(sample1 != null && sample2 != null); final int len = Math.min(sample1.size(), sample2.size()); for (int i = 0; i < len; ++i) { assertEquals(sample1.get(i), sample2.get(i)); @@ -187,7 +190,6 @@ public void serializeDeserializeString() { Memory mem = Memory.wrap(bytes); EbppsItemsSketch sk_heapify = EbppsItemsSketch.heapify(mem, new ArrayOfStringsSerDe()); checkIfEqual(sk, sk_heapify); - // TODO: deserialize too few bytes // add uniform items for (int i = 0; i < k; ++i)