use of io.prestosql.operator.aggregation.state.LongDecimalWithOverflowState in project hetu-core by openlookeng.
the class TestDecimalSumAggregation method testCombineOverflow.
@Test
public void testCombineOverflow() {
addToState(state, TWO.pow(125));
addToState(state, TWO.pow(126));
LongDecimalWithOverflowState otherState = new LongDecimalWithOverflowStateFactory().createSingleState();
addToState(otherState, TWO.pow(125));
addToState(otherState, TWO.pow(126));
DecimalSumAggregation.combine(state, otherState);
assertEquals(state.getOverflow(), 1);
assertEquals(state.getLongDecimal(), unscaledDecimal(TWO.pow(126)));
}
use of io.prestosql.operator.aggregation.state.LongDecimalWithOverflowState in project hetu-core by openlookeng.
the class TestDecimalSumAggregation method testCombineUnderflow.
@Test
public void testCombineUnderflow() {
addToState(state, TWO.pow(125).negate());
addToState(state, TWO.pow(126).negate());
LongDecimalWithOverflowState otherState = new LongDecimalWithOverflowStateFactory().createSingleState();
addToState(otherState, TWO.pow(125).negate());
addToState(otherState, TWO.pow(126).negate());
DecimalSumAggregation.combine(state, otherState);
assertEquals(state.getOverflow(), -1);
assertEquals(state.getLongDecimal(), unscaledDecimal(TWO.pow(126).negate()));
}
Aggregations