当前位置: 首页>>代码示例>>Java>>正文


Java StateInitializationContext.getRawKeyedStateInputs方法代码示例

本文整理汇总了Java中org.apache.flink.runtime.state.StateInitializationContext.getRawKeyedStateInputs方法的典型用法代码示例。如果您正苦于以下问题:Java StateInitializationContext.getRawKeyedStateInputs方法的具体用法?Java StateInitializationContext.getRawKeyedStateInputs怎么用?Java StateInitializationContext.getRawKeyedStateInputs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.runtime.state.StateInitializationContext的用法示例。


在下文中一共展示了StateInitializationContext.getRawKeyedStateInputs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeState

import org.apache.flink.runtime.state.StateInitializationContext; //导入方法依赖的package包/类
@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);

    }
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:DedupingOperator.java

示例2: initializeState

import org.apache.flink.runtime.state.StateInitializationContext; //导入方法依赖的package包/类
/**
 * 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());
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:AbstractStreamOperator.java

示例3: initializeState

import org.apache.flink.runtime.state.StateInitializationContext; //导入方法依赖的package包/类
@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());
      }
    }
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:31,代码来源:DoFnOperator.java


注:本文中的org.apache.flink.runtime.state.StateInitializationContext.getRawKeyedStateInputs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。