Search in sources :

Example 1 with LongDecimalWithOverflowState

use of com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowState in project presto by prestodb.

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(com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowStateFactory) LongDecimalWithOverflowState(com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowState) Test(org.testng.annotations.Test)

Example 2 with LongDecimalWithOverflowState

use of com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowState in project presto by prestodb.

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(com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowStateFactory) LongDecimalWithOverflowState(com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowState) Test(org.testng.annotations.Test)

Aggregations

LongDecimalWithOverflowState (com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowState)2 LongDecimalWithOverflowStateFactory (com.facebook.presto.operator.aggregation.state.LongDecimalWithOverflowStateFactory)2 Test (org.testng.annotations.Test)2