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);
}
Aggregations