Search in sources :

Example 1 with NullableLongState

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

the class TestStateCompiler method testPrimitiveNullableLongSerialization.

@Test
public void testPrimitiveNullableLongSerialization() {
    AccumulatorStateFactory<NullableLongState> factory = StateCompiler.generateStateFactory(NullableLongState.class);
    AccumulatorStateSerializer<NullableLongState> serializer = StateCompiler.generateStateSerializer(NullableLongState.class);
    NullableLongState state = factory.createSingleState();
    NullableLongState deserializedState = factory.createSingleState();
    state.setLong(2);
    state.setNull(false);
    BlockBuilder builder = BIGINT.createBlockBuilder(null, 2);
    serializer.serialize(state, builder);
    state.setNull(true);
    serializer.serialize(state, builder);
    Block block = builder.build();
    assertEquals(block.isNull(0), false);
    assertEquals(BIGINT.getLong(block, 0), state.getLong());
    serializer.deserialize(block, 0, deserializedState);
    assertEquals(deserializedState.getLong(), state.getLong());
    assertEquals(block.isNull(1), true);
}
Also used : NullableLongState(com.facebook.presto.operator.aggregation.state.NullableLongState) BlockAssertions.createLongsBlock(com.facebook.presto.block.BlockAssertions.createLongsBlock) Block(com.facebook.presto.common.block.Block) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) Test(org.testng.annotations.Test)

Aggregations

BlockAssertions.createLongsBlock (com.facebook.presto.block.BlockAssertions.createLongsBlock)1 Block (com.facebook.presto.common.block.Block)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 NullableLongState (com.facebook.presto.operator.aggregation.state.NullableLongState)1 Test (org.testng.annotations.Test)1