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