Search in sources :

Example 36 with UpdateSketch

use of org.apache.datasketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class CornerCaseTupleSetOperationsTest method emptyExact.

@Test
public void emptyExact() {
    IntegerSketch tupleA = getTupleSketch(SkType.EMPTY, 0, 0);
    IntegerSketch tupleB = getTupleSketch(SkType.EXACT, 0, GT_MIDP_V);
    UpdateSketch thetaB = getThetaSketch(SkType.EXACT, 0, GT_MIDP_V);
    final double expectedIntersectTheta = 1.0;
    final int expectedIntersectCount = 0;
    final boolean expectedIntersectEmpty = true;
    final double expectedAnotbTheta = 1.0;
    final int expectedAnotbCount = 0;
    final boolean expectedAnotbEmpty = true;
    final double expectedUnionTheta = 1.0;
    final int expectedUnionCount = 1;
    final boolean expectedUnionEmpty = false;
    checks(tupleA, tupleB, thetaB, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
}
Also used : UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 37 with UpdateSketch

use of org.apache.datasketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class CornerCaseTupleSetOperationsTest method estimationEmpty.

// =================================
@Test
public void estimationEmpty() {
    IntegerSketch tupleA = getTupleSketch(SkType.ESTIMATION, LOWP_FLT, LT_LOWP_V);
    IntegerSketch tupleB = getTupleSketch(SkType.EMPTY, 0, 0);
    UpdateSketch thetaB = getThetaSketch(SkType.EMPTY, 0, 0);
    final double expectedIntersectTheta = 1.0;
    final int expectedIntersectCount = 0;
    final boolean expectedIntersectEmpty = true;
    final double expectedAnotbTheta = LOWP_FLT;
    final int expectedAnotbCount = 1;
    final boolean expectedAnotbEmpty = false;
    final double expectedUnionTheta = LOWP_FLT;
    final int expectedUnionCount = 1;
    final boolean expectedUnionEmpty = false;
    checks(tupleA, tupleB, thetaB, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
}
Also used : UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 38 with UpdateSketch

use of org.apache.datasketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class CornerCaseTupleSetOperationsTest method degenerateDegenerate.

@Test
public void degenerateDegenerate() {
    // entries = 0
    IntegerSketch tupleA = getTupleSketch(SkType.DEGENERATE, MIDP_FLT, GT_MIDP_V);
    IntegerSketch tupleB = getTupleSketch(SkType.DEGENERATE, LOWP_FLT, GT_LOWP_V);
    UpdateSketch thetaB = getThetaSketch(SkType.DEGENERATE, LOWP_FLT, GT_LOWP_V);
    final double expectedIntersectTheta = LOWP_FLT;
    final int expectedIntersectCount = 0;
    final boolean expectedIntersectEmpty = false;
    final double expectedAnotbTheta = LOWP_FLT;
    final int expectedAnotbCount = 0;
    final boolean expectedAnotbEmpty = false;
    final double expectedUnionTheta = LOWP_FLT;
    final int expectedUnionCount = 0;
    final boolean expectedUnionEmpty = false;
    checks(tupleA, tupleB, thetaB, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
}
Also used : UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 39 with UpdateSketch

use of org.apache.datasketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class CornerCaseTupleSetOperationsTest method degenerateExact.

@Test
public void degenerateExact() {
    // entries = 0
    IntegerSketch tupleA = getTupleSketch(SkType.DEGENERATE, LOWP_FLT, GT_LOWP_V);
    IntegerSketch tupleB = getTupleSketch(SkType.EXACT, 0, LT_LOWP_V);
    UpdateSketch thetaB = getThetaSketch(SkType.EXACT, 0, LT_LOWP_V);
    final double expectedIntersectTheta = LOWP_FLT;
    final int expectedIntersectCount = 0;
    final boolean expectedIntersectEmpty = false;
    final double expectedAnotbTheta = LOWP_FLT;
    final int expectedAnotbCount = 0;
    final boolean expectedAnotbEmpty = false;
    final double expectedUnionTheta = LOWP_FLT;
    final int expectedUnionCount = 1;
    final boolean expectedUnionEmpty = false;
    checks(tupleA, tupleB, thetaB, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
}
Also used : UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Example 40 with UpdateSketch

use of org.apache.datasketches.theta.UpdateSketch in project sketches-core by DataSketches.

the class CornerCaseTupleSetOperationsTest method estimationEstimation.

@Test
public void estimationEstimation() {
    IntegerSketch tupleA = getTupleSketch(SkType.ESTIMATION, MIDP_FLT, LT_LOWP_V);
    IntegerSketch tupleB = getTupleSketch(SkType.ESTIMATION, LOWP_FLT, LT_LOWP_V);
    UpdateSketch thetaB = getThetaSketch(SkType.ESTIMATION, LOWP_FLT, LT_LOWP_V);
    final double expectedIntersectTheta = LOWP_FLT;
    final int expectedIntersectCount = 1;
    final boolean expectedIntersectEmpty = false;
    final double expectedAnotbTheta = LOWP_FLT;
    final int expectedAnotbCount = 0;
    final boolean expectedAnotbEmpty = false;
    final double expectedUnionTheta = LOWP_FLT;
    final int expectedUnionCount = 1;
    final boolean expectedUnionEmpty = false;
    checks(tupleA, tupleB, thetaB, expectedIntersectTheta, expectedIntersectCount, expectedIntersectEmpty, expectedAnotbTheta, expectedAnotbCount, expectedAnotbEmpty, expectedUnionTheta, expectedUnionCount, expectedUnionEmpty);
}
Also used : UpdateSketch(org.apache.datasketches.theta.UpdateSketch) Test(org.testng.annotations.Test)

Aggregations

UpdateSketch (org.apache.datasketches.theta.UpdateSketch)46 Test (org.testng.annotations.Test)42 DoubleSummary (org.apache.datasketches.tuple.adouble.DoubleSummary)12 AnotB (org.apache.datasketches.tuple.AnotB)6 JaccardSimilarity.dissimilarityTest (org.apache.datasketches.tuple.JaccardSimilarity.dissimilarityTest)6 JaccardSimilarity.similarityTest (org.apache.datasketches.tuple.JaccardSimilarity.similarityTest)6 UpdateSketchBuilder (org.apache.datasketches.theta.UpdateSketchBuilder)5 Intersection (org.apache.datasketches.tuple.Intersection)4 MapBasedRow (org.apache.druid.data.input.MapBasedRow)3 TestColumnSelectorFactory (org.apache.druid.query.groupby.epinephelinae.TestColumnSelectorFactory)3 Test (org.junit.Test)3 SketchesArgumentException (org.apache.datasketches.SketchesArgumentException)2 IntegerSummary (org.apache.datasketches.tuple.aninteger.IntegerSummary)2 GroupByQueryRunnerTest (org.apache.druid.query.groupby.GroupByQueryRunnerTest)2 SketchesStateException (org.apache.datasketches.SketchesStateException)1 CompactSketch (org.apache.datasketches.theta.CompactSketch)1 Intersection (org.apache.datasketches.theta.Intersection)1 Union (org.apache.datasketches.tuple.Union)1 SketchHolder (org.apache.druid.query.aggregation.datasketches.theta.SketchHolder)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1