FlinkKeyGroupBagState(StateTag<BagState<T>> address, StateNamespace namespace, Coder<T> coder) { super( address.getId(), namespace.stringKey(), ListCoder.of(coder), new KeyGroupBagCombiner<>()); this.namespace = namespace; this.address = address; }
FlinkKeyGroupBagState( StateTag<BagState<T>> address, StateNamespace namespace, Coder<T> coder) { super(address.getId(), namespace.stringKey(), ListCoder.of(coder), new KeyGroupBagCombiner<T>()); this.namespace = namespace; this.address = address; }
FlinkKeyGroupBagState(StateTag<BagState<T>> address, StateNamespace namespace, Coder<T> coder) { super( address.getId(), namespace.stringKey(), ListCoder.of(coder), new KeyGroupBagCombiner<>()); this.namespace = namespace; this.address = address; }
@Override public void initializeState(StateInitializationContext context) throws Exception { if (getKeyedStateBackend() != null) { KeyGroupsList localKeyGroupRange = getKeyedStateBackend().getKeyGroupRange(); for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { DataInputViewStreamWrapper div = new DataInputViewStreamWrapper(streamProvider.getStream()); int keyGroupIdx = streamProvider.getKeyGroupId(); checkArgument(localKeyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); // if (this instanceof KeyGroupRestoringOperator) restoreKeyGroupState(keyGroupIdx, div); } } }
/** * Stream operators with state which can be restored need to override this hook method. * * @param context context that allows to register different states. */ public void initializeState(StateInitializationContext context) throws Exception { if (getKeyedStateBackend() != null) { KeyGroupsList localKeyGroupRange = getKeyedStateBackend().getKeyGroupRange(); // and then initialize the timer services for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { int keyGroupIdx = streamProvider.getKeyGroupId(); checkArgument(localKeyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); timeServiceManager.restoreStateForKeyGroup( new DataInputViewStreamWrapper(streamProvider.getStream()), keyGroupIdx, getUserCodeClassloader()); } } }
@Override public void initializeState(StateInitializationContext context) throws Exception { if (getKeyedStateBackend() != null) { int totalKeyGroups = getKeyedStateBackend().getNumberOfKeyGroups(); KeyGroupsList localKeyGroupRange = getKeyedStateBackend().getKeyGroupRange(); for (KeyGroupStatePartitionStreamProvider streamProvider : context.getRawKeyedStateInputs()) { DataInputViewStreamWrapper div = new DataInputViewStreamWrapper(streamProvider.getStream()); int keyGroupIdx = streamProvider.getKeyGroupId(); checkArgument(localKeyGroupRange.contains(keyGroupIdx), "Key Group " + keyGroupIdx + " does not belong to the local range."); // if (this instanceof KeyGroupRestoringOperator) restoreKeyGroupState(keyGroupIdx, div); // We just initialize our timerService if (keyCoder != null) { if (timerService == null) { timerService = new HeapInternalTimerService<>( totalKeyGroups, localKeyGroupRange, this, getRuntimeContext().getProcessingTimeService()); } timerService.restoreTimersForKeyGroup(div, keyGroupIdx, getUserCodeClassloader()); } } } }
timeServiceManager = new InternalTimeServiceManager<>( getKeyedStateBackend().getNumberOfKeyGroups(), getKeyedStateBackend().getKeyGroupRange(), this, getRuntimeContext().getProcessingTimeService());