Search in sources :

Example 1 with ValueWithTs

use of org.apache.flink.streaming.tests.verify.ValueWithTs in project flink by apache.

the class TtlVerifyUpdateFunction method initializeState.

@Override
public void initializeState(FunctionInitializationContext context) {
    states = TtlStateVerifier.VERIFIERS.stream().collect(Collectors.toMap(TtlStateVerifier::getId, v -> v.createState(context, ttlConfig)));
    prevUpdatesByVerifierId = TtlStateVerifier.VERIFIERS.stream().collect(Collectors.toMap(TtlStateVerifier::getId, v -> {
        checkNotNull(v);
        final TypeSerializer<ValueWithTs<?>> typeSerializer = new ValueWithTs.Serializer(v.getUpdateSerializer(), LongSerializer.INSTANCE);
        ListStateDescriptor<ValueWithTs<?>> stateDesc = new ListStateDescriptor<>("TtlPrevValueState_" + v.getId(), typeSerializer);
        KeyedStateStore store = context.getKeyedStateStore();
        return store.getListState(stateDesc);
    }));
}
Also used : KeyedStateStore(org.apache.flink.api.common.state.KeyedStateStore) TtlStateVerifier(org.apache.flink.streaming.tests.verify.TtlStateVerifier) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) ValueWithTs(org.apache.flink.streaming.tests.verify.ValueWithTs) LongSerializer(org.apache.flink.api.common.typeutils.base.LongSerializer) TypeSerializer(org.apache.flink.api.common.typeutils.TypeSerializer)

Aggregations

KeyedStateStore (org.apache.flink.api.common.state.KeyedStateStore)1 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)1 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)1 LongSerializer (org.apache.flink.api.common.typeutils.base.LongSerializer)1 TtlStateVerifier (org.apache.flink.streaming.tests.verify.TtlStateVerifier)1 ValueWithTs (org.apache.flink.streaming.tests.verify.ValueWithTs)1