Search in sources :

Example 1 with LongDoubleAccumulator

use of com.hazelcast.jet.accumulator.LongDoubleAccumulator in project hazelcast by hazelcast.

the class AggregateOperationsTest method when_averagingDouble_noInput_then_NaN.

@Test
public void when_averagingDouble_noInput_then_NaN() {
    // Given
    AggregateOperation1<Double, LongDoubleAccumulator, Double> aggrOp = averagingDouble(Double::doubleValue);
    LongDoubleAccumulator acc = aggrOp.createFn().get();
    // When
    double result = aggrOp.finishFn().apply(acc);
    // Then
    assertEquals(Double.NaN, result, 0.0);
}
Also used : LongDoubleAccumulator(com.hazelcast.jet.accumulator.LongDoubleAccumulator) AggregateOperations.averagingDouble(com.hazelcast.jet.aggregate.AggregateOperations.averagingDouble) AggregateOperations.summingDouble(com.hazelcast.jet.aggregate.AggregateOperations.summingDouble) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with LongDoubleAccumulator

use of com.hazelcast.jet.accumulator.LongDoubleAccumulator in project hazelcast by hazelcast.

the class AggregateOperationsTest method when_averagingDouble_tooManyItems_then_exception.

@Test
public void when_averagingDouble_tooManyItems_then_exception() {
    // Given
    AggregateOperation1<Double, LongDoubleAccumulator, Double> aggrOp = averagingDouble(Double::doubleValue);
    LongDoubleAccumulator acc = new LongDoubleAccumulator(Long.MAX_VALUE, 0.0d);
    // Then
    exception.expect(ArithmeticException.class);
    // When
    aggrOp.accumulateFn().accept(acc, 0.0d);
}
Also used : LongDoubleAccumulator(com.hazelcast.jet.accumulator.LongDoubleAccumulator) AggregateOperations.averagingDouble(com.hazelcast.jet.aggregate.AggregateOperations.averagingDouble) AggregateOperations.summingDouble(com.hazelcast.jet.aggregate.AggregateOperations.summingDouble) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with LongDoubleAccumulator

use of com.hazelcast.jet.accumulator.LongDoubleAccumulator in project hazelcast-jet by hazelcast.

the class AggregateOperationsTest method when_averagingDoubleOverflow_thenException.

@Test
public void when_averagingDoubleOverflow_thenException() {
    // Given
    AggregateOperation1<Double, LongDoubleAccumulator, Double> aggrOp = averagingDouble(Double::doubleValue);
    LongDoubleAccumulator acc = new LongDoubleAccumulator(Long.MAX_VALUE, 0.0d);
    // When and Then
    exception.expect(ArithmeticException.class);
    aggrOp.accumulateFn().accept(acc, 0.0d);
}
Also used : LongDoubleAccumulator(com.hazelcast.jet.accumulator.LongDoubleAccumulator) AggregateOperations.averagingDouble(com.hazelcast.jet.aggregate.AggregateOperations.averagingDouble) AggregateOperations.summingDouble(com.hazelcast.jet.aggregate.AggregateOperations.summingDouble) Test(org.junit.Test)

Aggregations

LongDoubleAccumulator (com.hazelcast.jet.accumulator.LongDoubleAccumulator)3 AggregateOperations.averagingDouble (com.hazelcast.jet.aggregate.AggregateOperations.averagingDouble)3 AggregateOperations.summingDouble (com.hazelcast.jet.aggregate.AggregateOperations.summingDouble)3 Test (org.junit.Test)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2