Search in sources :

Example 1 with LongDecimalWithOverflowState

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)));
}
Also used : LongDecimalWithOverflowStateFactory(io.prestosql.operator.aggregation.state.LongDecimalWithOverflowStateFactory) LongDecimalWithOverflowState(io.prestosql.operator.aggregation.state.LongDecimalWithOverflowState) Test(org.testng.annotations.Test)

Example 2 with LongDecimalWithOverflowState

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()));
}
Also used : LongDecimalWithOverflowStateFactory(io.prestosql.operator.aggregation.state.LongDecimalWithOverflowStateFactory) LongDecimalWithOverflowState(io.prestosql.operator.aggregation.state.LongDecimalWithOverflowState) Test(org.testng.annotations.Test)

Aggregations

LongDecimalWithOverflowState (io.prestosql.operator.aggregation.state.LongDecimalWithOverflowState)2 LongDecimalWithOverflowStateFactory (io.prestosql.operator.aggregation.state.LongDecimalWithOverflowStateFactory)2 Test (org.testng.annotations.Test)2