Search in sources :

Example 1 with KeyedStateStore

use of org.apache.flink.api.common.state.KeyedStateStore in project flink by apache.

the class StreamingRuntimeContext method getAggregatingState.

@Override
public <IN, ACC, OUT> AggregatingState<IN, OUT> getAggregatingState(AggregatingStateDescriptor<IN, ACC, OUT> stateProperties) {
    KeyedStateStore keyedStateStore = checkPreconditionsAndGetKeyedStateStore(stateProperties);
    stateProperties.initializeSerializerUnlessSet(getExecutionConfig());
    return keyedStateStore.getAggregatingState(stateProperties);
}
Also used : KeyedStateStore(org.apache.flink.api.common.state.KeyedStateStore)

Example 2 with KeyedStateStore

use of org.apache.flink.api.common.state.KeyedStateStore in project flink by apache.

the class StreamingRuntimeContext method getState.

// ------------------------------------------------------------------------
// key/value state
// ------------------------------------------------------------------------
@Override
public <T> ValueState<T> getState(ValueStateDescriptor<T> stateProperties) {
    KeyedStateStore keyedStateStore = checkPreconditionsAndGetKeyedStateStore(stateProperties);
    stateProperties.initializeSerializerUnlessSet(getExecutionConfig());
    return keyedStateStore.getState(stateProperties);
}
Also used : KeyedStateStore(org.apache.flink.api.common.state.KeyedStateStore)

Example 3 with KeyedStateStore

use of org.apache.flink.api.common.state.KeyedStateStore in project flink by apache.

the class StreamingRuntimeContext method getFoldingState.

@Override
public <T, ACC> FoldingState<T, ACC> getFoldingState(FoldingStateDescriptor<T, ACC> stateProperties) {
    KeyedStateStore keyedStateStore = checkPreconditionsAndGetKeyedStateStore(stateProperties);
    stateProperties.initializeSerializerUnlessSet(getExecutionConfig());
    return keyedStateStore.getFoldingState(stateProperties);
}
Also used : KeyedStateStore(org.apache.flink.api.common.state.KeyedStateStore)

Example 4 with KeyedStateStore

use of org.apache.flink.api.common.state.KeyedStateStore in project flink by apache.

the class StreamingRuntimeContext method checkPreconditionsAndGetKeyedStateStore.

private KeyedStateStore checkPreconditionsAndGetKeyedStateStore(StateDescriptor<?, ?> stateDescriptor) {
    Preconditions.checkNotNull(stateDescriptor, "The state properties must not be null");
    KeyedStateStore keyedStateStore = operator.getKeyedStateStore();
    Preconditions.checkNotNull(keyedStateStore, "Keyed state can only be used on a 'keyed stream', i.e., after a 'keyBy()' operation.");
    return keyedStateStore;
}
Also used : KeyedStateStore(org.apache.flink.api.common.state.KeyedStateStore)

Example 5 with KeyedStateStore

use of org.apache.flink.api.common.state.KeyedStateStore 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)9 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 AggregateFunction (org.apache.flink.api.common.functions.AggregateFunction)1 AggregatingStateDescriptor (org.apache.flink.api.common.state.AggregatingStateDescriptor)1 MapStateDescriptor (org.apache.flink.api.common.state.MapStateDescriptor)1 ReducingStateDescriptor (org.apache.flink.api.common.state.ReducingStateDescriptor)1 ValueStateDescriptor (org.apache.flink.api.common.state.ValueStateDescriptor)1 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)1 LongSerializer (org.apache.flink.api.common.typeutils.base.LongSerializer)1 StringSerializer (org.apache.flink.api.common.typeutils.base.StringSerializer)1 OperatorSubtaskState (org.apache.flink.runtime.checkpoint.OperatorSubtaskState)1 Watermark (org.apache.flink.streaming.api.watermark.Watermark)1 MergingWindowAssigner (org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner)1