use of com.yahoo.sketches.pig.theta.Estimate in project sketches-pig by DataSketches.
the class IntersectTest method checkAlgFinalFromPriorIntermed.
@Test
public void checkAlgFinalFromPriorIntermed() throws IOException {
EvalFunc<Tuple> interFuncIFinal = new Intersect.IntermediateFinal();
EvalFunc<Double> estFunc = new Estimate();
Tuple inputTuple = TupleFactory.getInstance().newTuple(1);
DataBag bag = BagFactory.getInstance().newDefaultBag();
// inputTuple.bag0:null
inputTuple.set(0, bag);
for (int i = 0; i < 4; i++) {
Tuple sketchTuple = TupleFactory.getInstance().newTuple(1);
sketchTuple.set(0, createDbaFromQssRange(256, i * 64, 256));
bag.add(sketchTuple);
// inputTuple.bag0:sketchTuple0.DBA0
// inputTuple.bag0:sketchTuple1.DBA1
// inputTuple.bag0:sketchTuple2.DBA2
// inputTuple.bag0:sketchTuple3.DBA3
}
Tuple resultTuple = interFuncIFinal.exec(inputTuple);
assertNotNull(resultTuple);
assertEquals(resultTuple.size(), 1);
DataByteArray bytes = (DataByteArray) resultTuple.get(0);
assertTrue(bytes.size() > 0);
Double est = estFunc.exec(resultTuple);
assertEquals(est, 64.0, 0.0);
}
use of com.yahoo.sketches.pig.theta.Estimate in project sketches-pig by DataSketches.
the class IntersectTest method checkAlgFinalInnerNotDBA.
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkAlgFinalInnerNotDBA() throws IOException {
EvalFunc<Tuple> interFuncFinal = new Intersect.IntermediateFinal();
EvalFunc<Double> estFunc = new Estimate();
Tuple inputTuple = TupleFactory.getInstance().newTuple(1);
Tuple resultTuple = interFuncFinal.exec(inputTuple);
assertEquals(estFunc.exec(resultTuple), 0.0, 0.0);
DataBag bag = BagFactory.getInstance().newDefaultBag();
// inputTuple.bag0:null
inputTuple.set(0, bag);
resultTuple = interFuncFinal.exec(inputTuple);
assertEquals(estFunc.exec(resultTuple), 0.0, 0.0);
Tuple innerTuple = TupleFactory.getInstance().newTuple(1);
bag.add(innerTuple);
// not a DBA
innerTuple.set(0, new Double(1.0));
resultTuple = interFuncFinal.exec(inputTuple);
assertEquals(estFunc.exec(resultTuple), 0.0, 0.0);
}
use of com.yahoo.sketches.pig.theta.Estimate in project sketches-pig by DataSketches.
the class IntersectTest method checkNullInput.
@Test
public void checkNullInput() throws IOException {
EvalFunc<Tuple> interFunc = new Intersect();
EvalFunc<Double> estFunc = new Estimate();
Tuple inputTuple = TupleFactory.getInstance().newTuple(1);
// null bag
Tuple resultTuple = interFunc.exec(inputTuple);
assertNotNull(resultTuple);
assertEquals(resultTuple.size(), 1);
Double est = estFunc.exec(resultTuple);
assertEquals(est, 0.0, 0.0);
}
use of com.yahoo.sketches.pig.theta.Estimate in project sketches-pig by DataSketches.
the class IntersectTest method checkAlgFinalOuterBagEmptyTuples.
@Test(expectedExceptions = SketchesStateException.class)
public void checkAlgFinalOuterBagEmptyTuples() throws IOException {
EvalFunc<Tuple> interFuncFinal = new Intersect.IntermediateFinal();
EvalFunc<Double> estFunc = new Estimate();
Tuple inputTuple = TupleFactory.getInstance().newTuple(1);
Tuple resultTuple = interFuncFinal.exec(inputTuple);
assertEquals(estFunc.exec(resultTuple), 0.0, 0.0);
DataBag bag = BagFactory.getInstance().newDefaultBag();
// inputTuple.bag0:null
inputTuple.set(0, bag);
resultTuple = interFuncFinal.exec(inputTuple);
assertEquals(estFunc.exec(resultTuple), 0.0, 0.0);
Tuple innerTuple = TupleFactory.getInstance().newTuple(1);
bag.add(innerTuple);
// Throws Illegal Result from HeapIntersection
resultTuple = interFuncFinal.exec(inputTuple);
// assertEquals(estFunc.exec(resultTuple), 0.0, 0.0);
}
use of com.yahoo.sketches.pig.theta.Estimate in project sketches-pig by DataSketches.
the class IntersectTest method checkAlgFinalFromPriorInitial.
@Test
public void checkAlgFinalFromPriorInitial() throws IOException {
EvalFunc<Tuple> interFuncFinal = new Intersect.IntermediateFinal();
EvalFunc<Double> estFunc = new Estimate();
Tuple inputTuple = TupleFactory.getInstance().newTuple(1);
DataBag bag = BagFactory.getInstance().newDefaultBag();
// inputTuple.bag0:null
inputTuple.set(0, bag);
Tuple innerTuple = TupleFactory.getInstance().newTuple(1);
DataBag innerBag = BagFactory.getInstance().newDefaultBag();
// innerTuple.innerBag0:null
innerTuple.set(0, innerBag);
// inputTuple.bag0.innerTuple0.innerBag0:null
bag.add(innerTuple);
for (int i = 0; i < 4; i++) {
Tuple sketchTuple = TupleFactory.getInstance().newTuple(1);
sketchTuple.set(0, createDbaFromQssRange(256, i * 64, 256));
innerBag.add(sketchTuple);
// inputTuple.bag0.innerTuple0.innerBag0.sketchTuple0.DBA0
// inputTuple.bag0.innerTuple0.innerBag0.sketchTuple1.DBA1
// inputTuple.bag0.innerTuple0.innerBag0.sketchTuple2.DBA2
// inputTuple.bag0.innerTuple0.innerBag0.sketchTuple3.DBA3
}
Tuple resultTuple = interFuncFinal.exec(inputTuple);
assertNotNull(resultTuple);
assertEquals(resultTuple.size(), 1);
DataByteArray bytes = (DataByteArray) resultTuple.get(0);
assertTrue(bytes.size() > 0);
Double est = estFunc.exec(resultTuple);
assertEquals(est, 64.0, 0.0);
}
Aggregations