use of org.apache.datasketches.SketchesStateException in project sketches-core by DataSketches.
the class AdoubleIntersectionTest method checkExactIntersectionWithTheta.
@Test
public void checkExactIntersectionWithTheta() {
final UpdateSketch thSkNull = null;
final UpdateSketch thSkEmpty = new UpdateSketchBuilder().build();
final UpdateSketch thSk10 = new UpdateSketchBuilder().build();
final UpdateSketch thSk15 = new UpdateSketchBuilder().build();
for (int i = 0; i < 10; i++) {
thSk10.update(i);
}
// overlap = 5
for (int i = 0; i < 10; i++) {
thSk15.update(i + 5);
}
DoubleSummary dsum = new DoubleSummaryFactory(mode).newSummary();
final Intersection<DoubleSummary> intersection = new Intersection<>(new DoubleSummarySetOperations(mode, mode));
CompactSketch<DoubleSummary> result;
try {
intersection.getResult();
fail();
}// OK.
catch (final SketchesStateException e) {
}
try {
intersection.intersect(thSkNull, dsum);
fail();
}// OK
catch (final SketchesArgumentException e) {
}
intersection.intersect(thSkEmpty, dsum);
result = intersection.getResult();
// Empty after empty first call
Assert.assertTrue(result.isEmpty());
intersection.reset();
intersection.intersect(thSk10, dsum);
result = intersection.getResult();
// Returns valid first call
Assert.assertEquals(result.getEstimate(), 10.0);
intersection.reset();
// Valid first call
intersection.intersect(thSk10, dsum);
intersection.intersect(thSkEmpty, dsum);
result = intersection.getResult();
// Returns Empty after empty second call
Assert.assertTrue(result.isEmpty());
intersection.reset();
intersection.intersect(thSk10, dsum);
intersection.intersect(thSk15, dsum);
result = intersection.getResult();
// Returns intersection
Assert.assertEquals(result.getEstimate(), 5.0);
intersection.reset();
dsum = null;
try {
intersection.intersect(thSk10, dsum);
fail();
} catch (final SketchesArgumentException e) {
}
}
Aggregations