Search in sources :

Example 1 with NullableLongState

use of io.prestosql.operator.aggregation.state.NullableLongState in project hetu-core by openlookeng.

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(io.prestosql.operator.aggregation.state.NullableLongState) Block(io.prestosql.spi.block.Block) BlockAssertions.createLongsBlock(io.prestosql.block.BlockAssertions.createLongsBlock) BlockBuilder(io.prestosql.spi.block.BlockBuilder) Test(org.testng.annotations.Test)

Aggregations

BlockAssertions.createLongsBlock (io.prestosql.block.BlockAssertions.createLongsBlock)1 NullableLongState (io.prestosql.operator.aggregation.state.NullableLongState)1 Block (io.prestosql.spi.block.Block)1 BlockBuilder (io.prestosql.spi.block.BlockBuilder)1 Test (org.testng.annotations.Test)1