Skip to content

Commit

Permalink
Merge pull request #508 from apache/ebpps_tostring
Browse files Browse the repository at this point in the history
More EBPPS cleanup
  • Loading branch information
leerho authored Feb 16, 2024
2 parents e89a10e + 80363ad commit ed1de41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.datasketches.sampling;

import static org.apache.datasketches.common.Util.LS;
import static org.apache.datasketches.sampling.PreambleUtil.EBPPS_SER_VER;
import static org.apache.datasketches.sampling.PreambleUtil.EMPTY_FLAG_MASK;
import static org.apache.datasketches.sampling.PreambleUtil.HAS_PARTIAL_ITEM_MASK;
Expand Down Expand Up @@ -365,7 +366,20 @@ private void internalMerge(final EbppsItemsSketch<T> other) {
*/
@Override
public String toString() {
return null;
final StringBuilder sb = new StringBuilder();

sb.append(LS);
final String thisSimpleName = this.getClass().getSimpleName();
sb.append("### ").append(thisSimpleName).append(" SUMMARY: ").append(LS);
sb.append(" k : ").append(k_).append(LS);
sb.append(" n : ").append(n_).append(LS);
sb.append(" Cum. weight : ").append(cumulativeWt_).append(LS);
sb.append(" wtMax : ").append(wtMax_).append(LS);
sb.append(" rho : ").append(rho_).append(LS);
sb.append(" C : ").append(sample_.getC()).append(LS);
sb.append("### END SKETCH SUMMARY").append(LS);

return sb.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import org.testng.annotations.Test;

public class EbppsSampleTest {
public class EbppsItemsSampleTest {
private static final double EPS = 1e-14;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

import java.util.ArrayList;
Expand All @@ -32,7 +33,7 @@
import org.apache.datasketches.memory.WritableMemory;
import org.testng.annotations.Test;

public class EbppsSketchTest {
public class EbppsItemsSketchTest {
private static final double EPS = 1e-13;

static EbppsItemsSketch<Integer> createUnweightedSketch(int k, long n) {
Expand Down Expand Up @@ -210,6 +211,8 @@ public void serializeDeserializeString() {
mem = Memory.wrap(bytes);
sk_heapify = EbppsItemsSketch.heapify(mem, new ArrayOfStringsSerDe());
checkIfEqual(sk, sk_heapify);

assertNotNull(sk.toString());
}

@Test(expectedExceptions = SketchesArgumentException.class)
Expand Down

0 comments on commit ed1de41

Please sign in to comment.