org.apache.beam.sdk.transforms.windowing.Window.getWindowFn()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.apache.beam.sdk.transforms.windowing.Window.getWindowFn()方法的一些代码示例,展示了Window.getWindowFn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getWindowFn()方法的具体详情如下:
包路径:org.apache.beam.sdk.transforms.windowing.Window
类名称:Window
方法名:getWindowFn

Window.getWindowFn介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-nemo

/**
 * @param ctx provides translation context
 * @param beamNode the beam node to be translated
 * @param transform transform which can be obtained from {@code beamNode}
 */
@PrimitiveTransformTranslator({Window.class, Window.Assign.class})
private static void windowTranslator(final PipelineTranslationContext ctx,
                   final TransformHierarchy.Node beamNode,
                   final PTransform<?, ?> transform) {
 final WindowFn windowFn;
 if (transform instanceof Window) {
  windowFn = ((Window) transform).getWindowFn();
 } else if (transform instanceof Window.Assign) {
  windowFn = ((Window.Assign) transform).getWindowFn();
 } else {
  throw new UnsupportedOperationException(String.format("%s is not supported", transform));
 }
 final IRVertex vertex = new OperatorVertex(
  new WindowFnTransform(windowFn, DisplayData.from(beamNode.getTransform())));
 ctx.addVertex(vertex);
 beamNode.getInputs().values().forEach(input -> ctx.addEdgeTo(vertex, input));
 beamNode.getOutputs().values().forEach(output -> ctx.registerMainOutputFrom(beamNode, vertex, output));
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-core

@Override
public PCollection<T> expand(PCollection<T> input) {
 applicableTo(input);
 WindowingStrategy<?, ?> outputStrategy =
   getOutputStrategyInternal(input.getWindowingStrategy());
 if (getWindowFn() == null) {
  // A new PCollection must be created in case input is reused in a different location as the
  // two PCollections will, in general, have a different windowing strategy.
  return PCollectionList.of(input)
    .apply(Flatten.pCollections())
    .setWindowingStrategyInternal(outputStrategy);
 } else {
  // This is the AssignWindows primitive
  return input.apply(new Assign<>(this, outputStrategy));
 }
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-core

/** Get the output strategy of this {@link Window Window PTransform}. For internal use only. */
public WindowingStrategy<?, ?> getOutputStrategyInternal(WindowingStrategy<?, ?> inputStrategy) {
 WindowingStrategy<?, ?> result = inputStrategy;
 if (getWindowFn() != null) {
  result = result.withWindowFn(getWindowFn());
 }
 if (getTrigger() != null) {
  result = result.withTrigger(getTrigger());
 }
 if (getAccumulationMode() != null) {
  result = result.withMode(getAccumulationMode());
 }
 if (getAllowedLateness() != null) {
  result =
    result.withAllowedLateness(
      Ordering.natural().max(getAllowedLateness(), inputStrategy.getAllowedLateness()));
 }
 if (getClosingBehavior() != null) {
  result = result.withClosingBehavior(getClosingBehavior());
 }
 if (getOnTimeBehavior() != null) {
  result = result.withOnTimeBehavior(getOnTimeBehavior());
 }
 if (getTimestampCombiner() != null) {
  result = result.withTimestampCombiner(getTimestampCombiner());
 }
 return result;
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-core

super.populateDisplayData(builder);
if (getWindowFn() != null) {
 builder
   .add(
     DisplayData.item("windowFn", getWindowFn().getClass())
       .withLabel("Windowing Function"))
   .include("windowFn", getWindowFn());

相关文章