Skip to content

Commit

Permalink
Merge pull request #280 from apache/updateTests
Browse files Browse the repository at this point in the history
update Tests.
  • Loading branch information
leerho authored Sep 26, 2019
2 parents 13e5ef8 + add72cc commit 7fe5f18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void checkCompactFlagCorruption() {
println(""+csk1.getEstimate());
}

@Test
@Test //checks for bug introduced in 1.0.0-incubating.
public void checkDirectUnionSingleItem() {
int num = 2;
UpdateSketch[] skArr = new UpdateSketch[num];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class UpdatableSketchWithDoubleSummaryTest {
public void isEmpty() {
int lgK = 12;
DoubleSketch sketch = new DoubleSketch(lgK, mode);
// UpdatableSketch<Double, DoubleSummary> sketch =
// new UpdatableSketchBuilder<>(new DoubleSummaryFactory(mode)).build();
Assert.assertTrue(sketch.isEmpty());
Assert.assertFalse(sketch.isEstimationMode());
Assert.assertEquals(sketch.getEstimate(), 0.0);
Expand All @@ -60,19 +58,27 @@ public void isEmpty() {
Assert.assertFalse(it.next());
}

@Test
public void checkLowK() {
UpdatableSketchBuilder<Double, DoubleSummary> bldr = new UpdatableSketchBuilder<>(
new DoubleSummaryFactory(Mode.Sum));
bldr.setNominalEntries(16);
UpdatableSketch<Double,DoubleSummary> sk = bldr.build();
assertEquals(sk.getLgK(), 4);
}

@Test
public void serDeTest() {
int lgK = 12;
int K = 1 << lgK;
DoubleSummary.Mode a1Mode = DoubleSummary.Mode.AlwaysOne;
DoubleSketch a1Sk = new DoubleSketch(lgK, a1Mode);
DoubleSketch a1Sk = new DoubleSketch(lgK, Mode.AlwaysOne);
int m = 2 * K;
for (int key = 0; key < m; key++) {
a1Sk.update(key, 1.0);
}
double est1 = a1Sk.getEstimate();
Memory mem = Memory.wrap(a1Sk.toByteArray());
DoubleSketch a1Sk2 = new DoubleSketch(mem, a1Mode);
DoubleSketch a1Sk2 = new DoubleSketch(mem, Mode.AlwaysOne);
double est2 = a1Sk2.getEstimate();
assertEquals(est1, est2);
}
Expand All @@ -81,8 +87,7 @@ public void serDeTest() {
public void checkStringKey() {
int lgK = 12;
int K = 1 << lgK;
DoubleSummary.Mode a1Mode = DoubleSummary.Mode.AlwaysOne;
DoubleSketch a1Sk1 = new DoubleSketch(lgK, a1Mode);
DoubleSketch a1Sk1 = new DoubleSketch(lgK, Mode.AlwaysOne);
int m = K / 2;
for (int key = 0; key < m; key++) {
a1Sk1.update(Integer.toHexString(key), 1.0);
Expand Down

0 comments on commit 7fe5f18

Please sign in to comment.