Search in sources :

Example 1 with AnotB

use of org.apache.datasketches.tuple.AnotB in project sketches-core by DataSketches.

the class AdoubleAnotBTest method aNotBNullEmptyCombinations.

/**
 **************************************
 */
@Test
public void aNotBNullEmptyCombinations() {
    final AnotB<DoubleSummary> aNotB = new AnotB<>();
    // calling getResult() before calling update() should yield an empty set
    final CompactSketch<DoubleSummary> result = aNotB.getResult(true);
    results.set(0, true, 0.0, 0.0, 0.0).check(result);
    final UpdatableSketch<Double, DoubleSummary> sketch = buildUpdatableTuple();
    final UpdateSketch skTheta = buildUpdateTheta();
    threeMethodsWithTheta(aNotB, null, null, null, results);
    threeMethodsWithTheta(aNotB, sketch, null, null, results);
    threeMethodsWithTheta(aNotB, null, sketch, null, results);
    threeMethodsWithTheta(aNotB, sketch, sketch, null, results);
    threeMethodsWithTheta(aNotB, null, null, skTheta, results);
    threeMethodsWithTheta(aNotB, sketch, null, skTheta, results);
    threeMethodsWithTheta(aNotB, null, sketch, skTheta, results);
    threeMethodsWithTheta(aNotB, sketch, sketch, skTheta, results);
}
Also used : AnotB(org.apache.datasketches.tuple.AnotB) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 2 with AnotB

use of org.apache.datasketches.tuple.AnotB in project sketches-core by DataSketches.

the class AdoubleAnotBTest method aNotBExactOverlap.

@Test
public void aNotBExactOverlap() {
    final UpdatableSketch<Double, DoubleSummary> sketchA = buildUpdatableTuple();
    sketchA.update(1, 1.0);
    sketchA.update(1, 1.0);
    sketchA.update(2, 1.0);
    sketchA.update(2, 1.0);
    final UpdatableSketch<Double, DoubleSummary> sketchB = buildUpdatableTuple();
    sketchB.update(2, 1.0);
    sketchB.update(2, 1.0);
    sketchB.update(3, 1.0);
    sketchB.update(3, 1.0);
    final UpdateSketch skThetaB = buildUpdateTheta();
    skThetaB.update(2);
    skThetaB.update(3);
    final AnotB<DoubleSummary> aNotB = new AnotB<>();
    results.set(1, false, 1.0, 0.0, 2.0);
    threeMethodsWithTheta(aNotB, sketchA, sketchB, skThetaB, results);
}
Also used : AnotB(org.apache.datasketches.tuple.AnotB) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 3 with AnotB

use of org.apache.datasketches.tuple.AnotB in project sketches-core by DataSketches.

the class AdoubleAnotBTest method aNotBEmptyExact.

@Test
public void aNotBEmptyExact() {
    final UpdatableSketch<Double, DoubleSummary> sketchA = buildUpdatableTuple();
    final UpdatableSketch<Double, DoubleSummary> sketchB = buildUpdatableTuple();
    sketchB.update(1, 1.0);
    sketchB.update(2, 1.0);
    final UpdateSketch skThetaB = buildUpdateTheta();
    skThetaB.update(1);
    skThetaB.update(2);
    final AnotB<DoubleSummary> aNotB = new AnotB<>();
    results.set(0, true, 0.0, 0.0, 0.0);
    threeMethodsWithTheta(aNotB, sketchA, sketchB, skThetaB, results);
}
Also used : AnotB(org.apache.datasketches.tuple.AnotB) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 4 with AnotB

use of org.apache.datasketches.tuple.AnotB in project sketches-core by DataSketches.

the class AdoubleAnotBTest method aNotBEstimationOverlapLargeB.

@Test
public void aNotBEstimationOverlapLargeB() {
    final UpdatableSketch<Double, DoubleSummary> sketchA = buildUpdatableTuple();
    for (int i = 0; i < 10_000; i++) {
        sketchA.update(i, 1.0);
    }
    final UpdatableSketch<Double, DoubleSummary> sketchB = buildUpdatableTuple();
    for (int i = 0; i < 100_000; i++) {
        sketchB.update(i + 8000, 1.0);
    }
    final UpdateSketch skThetaB = buildUpdateTheta();
    for (int i = 0; i < 100_000; i++) {
        skThetaB.update(i + 8000);
    }
    final int expected = 8_000;
    final AnotB<DoubleSummary> aNotB = new AnotB<>();
    results.set(376, false, expected, 0.1, 1.0);
    threeMethodsWithTheta(aNotB, sketchA, sketchB, skThetaB, results);
    // same thing, but compact sketches
    threeMethodsWithTheta(aNotB, sketchA.compact(), sketchB.compact(), skThetaB.compact(), results);
}
Also used : AnotB(org.apache.datasketches.tuple.AnotB) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 5 with AnotB

use of org.apache.datasketches.tuple.AnotB in project sketches-core by DataSketches.

the class AdoubleAnotBTest method aNotBEstimationOverlap.

@Test
public void aNotBEstimationOverlap() {
    final UpdatableSketch<Double, DoubleSummary> sketchA = buildUpdatableTuple();
    for (int i = 0; i < 8192; i++) {
        sketchA.update(i, 1.0);
    }
    final UpdatableSketch<Double, DoubleSummary> sketchB = buildUpdatableTuple();
    for (int i = 0; i < 4096; i++) {
        sketchB.update(i, 1.0);
    }
    final UpdateSketch skThetaB = buildUpdateTheta();
    for (int i = 0; i < 4096; i++) {
        skThetaB.update(i);
    }
    final AnotB<DoubleSummary> aNotB = new AnotB<>();
    results.set(2123, false, 4096.0, 0.03, 1.0);
    threeMethodsWithTheta(aNotB, sketchA, sketchB, skThetaB, results);
    // same thing, but compact sketches
    threeMethodsWithTheta(aNotB, sketchA.compact(), sketchB.compact(), skThetaB.compact(), results);
}
Also used : AnotB(org.apache.datasketches.tuple.AnotB) UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Aggregations

AnotB (org.apache.datasketches.tuple.AnotB)7 Test (org.testng.annotations.Test)7 UpdateSketch (org.apache.datasketches.theta.UpdateSketch)6 WritableMemory (org.apache.datasketches.memory.WritableMemory)1 Intersection (org.apache.datasketches.tuple.Intersection)1 Union (org.apache.datasketches.tuple.Union)1