Test the case where the combiner is not called - so initial is called and then final is called @throws Exception
()
| 553 | * @throws Exception |
| 554 | */ |
| 555 | @Test |
| 556 | public void testAggNoCombine() throws Exception { |
| 557 | |
| 558 | for (String[] aggGroup : aggs) { |
| 559 | String[] aggFinalTypes = null; // will contains AVGFinal, DoubleAvgFinal etc |
| 560 | String[] aggInitialTypes = null; // will contains AVGInitial, DoubleAvgInitial etc |
| 561 | |
| 562 | for (String stage: stages) { |
| 563 | String[] aggTypesArray = null; |
| 564 | if (stage.equals("Initial")) { |
| 565 | aggInitialTypes = new String[aggGroup.length]; |
| 566 | aggTypesArray = aggInitialTypes; |
| 567 | } else if (stage.equals("Final")) { |
| 568 | aggFinalTypes = new String[aggGroup.length]; |
| 569 | aggTypesArray = aggFinalTypes; |
| 570 | } else { // Intermediate |
| 571 | continue; |
| 572 | } |
| 573 | for (int i = 0; i < aggTypesArray.length; i++) { |
| 574 | aggTypesArray[i] = aggGroup[i] + stage; |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | for (int k = 0; k < aggFinalTypes.length; k++) { |
| 579 | EvalFunc<?> avgInitial = evalFuncMap.get(aggInitialTypes[k]); |
| 580 | Tuple tup = inputMap.get(getInputType(aggInitialTypes[k])); |
| 581 | |
| 582 | // To test this case, first AVGInitial is called for each input |
| 583 | // value and output of it is put into a bag. The bag containing |
| 584 | // all AVGInitial output is provided as input to AVGFinal |
| 585 | |
| 586 | // The tuple we got above has a bag with input |
| 587 | // values. Lets call AVGInitial with each value: |
| 588 | DataBag bg = (DataBag) tup.get(0); |
| 589 | DataBag finalInputBg = bagFactory.newDefaultBag(); |
| 590 | for (Tuple tuple : bg) { |
| 591 | DataBag initialInputBg = bagFactory.newDefaultBag(); |
| 592 | initialInputBg.add(tuple); |
| 593 | Tuple initialInputTuple = tupleFactory.newTuple(initialInputBg); |
| 594 | finalInputBg.add((Tuple)avgInitial.exec(initialInputTuple)); |
| 595 | } |
| 596 | |
| 597 | Tuple finalInputTuple = tupleFactory.newTuple(finalInputBg); |
| 598 | EvalFunc<?> aggFinal = evalFuncMap.get(aggFinalTypes[k]); |
| 599 | String msg = "[Testing " + aggGroup[k] + " on input type: " + getInputType(aggFinalTypes[k]); |
| 600 | System.err.println(msg + " for no combiner case]"); |
| 601 | Object output = aggFinal.exec(finalInputTuple); |
| 602 | msg += " ( (output) " + output + " == " + getExpected(aggFinalTypes[k]) + " (expected) )]"; |
| 603 | // for doubles, precisions can be a problem - so check |
| 604 | // if the type is double for expected result and check |
| 605 | // within some precision |
| 606 | if (getExpected(aggFinalTypes[k]) instanceof Double) { |
| 607 | assertEquals(msg, (Double)getExpected(aggFinalTypes[k]), (Double)output, 0.00001); |
| 608 | } else if (getExpected(aggFinalTypes[k]) instanceof BigDecimal) { |
| 609 | assertEquals(msg, ((BigDecimal)getExpected(aggFinalTypes[k])).toPlainString(), ((BigDecimal)output).toPlainString()); |
| 610 | } else if (getExpected(aggFinalTypes[k]) instanceof BigInteger) { |
| 611 | assertEquals(msg, ((BigInteger)getExpected(aggFinalTypes[k])).toString(), ((BigInteger)output).toString()); |
| 612 | // Compare millis so that we dont have to worry about TZ |
nothing calls this directly
no test coverage detected