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


Java Window.Assign方法代码示例

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


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

示例1: translate

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public void translate(Window.Assign<T> transform, TranslationContext context) {
  PCollection<T> output = context.getOutput();
  PCollection<T> input = context.getInput();

 if (transform.getWindowFn() == null) {
   // no work to do
   context.addAlias(output, input);
 } else {
    @SuppressWarnings("unchecked")
    WindowFn<T, BoundedWindow> windowFn = (WindowFn<T, BoundedWindow>) transform.getWindowFn();
    ApexProcessFnOperator<T> operator = ApexProcessFnOperator.assignWindows(windowFn,
        context.getPipelineOptions());
    context.addOperator(operator, operator.outputPort);
    context.addStream(context.getInput(), operator.inputPort);
 }

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

示例2: window

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
private static <T, W extends BoundedWindow> TransformEvaluator<Window.Assign<T>> window() {
  return new TransformEvaluator<Window.Assign<T>>() {
    @Override
    public void evaluate(Window.Assign<T> transform, EvaluationContext context) {
      @SuppressWarnings("unchecked")
      JavaRDD<WindowedValue<T>> inRDD =
          ((BoundedDataset<T>) context.borrowDataset(transform)).getRDD();

      if (TranslationUtils.skipAssignWindows(transform, context)) {
        context.putDataset(transform, new BoundedDataset<>(inRDD));
      } else {
        context.putDataset(transform, new BoundedDataset<>(
            inRDD.map(new SparkAssignWindowFn<>(transform.getWindowFn()))));
      }
    }

    @Override
    public String toNativeString() {
      return "map(new <windowFn>())";
    }
  };
}
 
开发者ID:apache,项目名称:beam,代码行数:23,代码来源:TransformTranslator.java

示例3: translate

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public FunctionSpec translate(
    AppliedPTransform<?, ?, Window.Assign<?>> transform, SdkComponents components) {
  return FunctionSpec.newBuilder()
      .setUrn("urn:beam:transform:window:v1")
      .setPayload(
          WindowIntoTranslation.toProto(transform.getTransform(), components).toByteString())
      .build();
}
 
开发者ID:apache,项目名称:beam,代码行数:10,代码来源:WindowIntoTranslation.java

示例4: window

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
private static <T, W extends BoundedWindow> TransformEvaluator<Window.Assign<T>> window() {
  return new TransformEvaluator<Window.Assign<T>>() {
    @Override
    public void evaluate(final Window.Assign<T> transform, EvaluationContext context) {
      @SuppressWarnings("unchecked")
      UnboundedDataset<T> unboundedDataset =
          ((UnboundedDataset<T>) context.borrowDataset(transform));
      JavaDStream<WindowedValue<T>> dStream = unboundedDataset.getDStream();
      JavaDStream<WindowedValue<T>> outputStream;
      if (TranslationUtils.skipAssignWindows(transform, context)) {
        // do nothing.
        outputStream = dStream;
      } else {
        outputStream = dStream.transform(
            new Function<JavaRDD<WindowedValue<T>>, JavaRDD<WindowedValue<T>>>() {
          @Override
          public JavaRDD<WindowedValue<T>> call(JavaRDD<WindowedValue<T>> rdd) throws Exception {
            return rdd.map(new SparkAssignWindowFn<>(transform.getWindowFn()));
          }
        });
      }
      context.putDataset(transform,
          new UnboundedDataset<>(outputStream, unboundedDataset.getStreamSources()));
    }

    @Override
    public String toNativeString() {
      return "map(new <windowFn>())";
    }
  };
}
 
开发者ID:apache,项目名称:beam,代码行数:32,代码来源:StreamingTransformTranslator.java

示例5: translateNode

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public void translateNode(
    Window.Assign<T> transform,
    FlinkStreamingTranslationContext context) {

  @SuppressWarnings("unchecked")
  WindowingStrategy<T, BoundedWindow> windowingStrategy =
      (WindowingStrategy<T, BoundedWindow>)
          context.getOutput(transform).getWindowingStrategy();

  TypeInformation<WindowedValue<T>> typeInfo =
      context.getTypeInfo(context.getOutput(transform));

  DataStream<WindowedValue<T>> inputDataStream =
      context.getInputDataStream(context.getInput(transform));

  WindowFn<T, ? extends BoundedWindow> windowFn = windowingStrategy.getWindowFn();

  FlinkAssignWindows<T, ? extends BoundedWindow> assignWindowsFunction =
      new FlinkAssignWindows<>(windowFn);

  SingleOutputStreamOperator<WindowedValue<T>> outputDataStream = inputDataStream
      .flatMap(assignWindowsFunction)
      .name(context.getOutput(transform).getName())
      .returns(typeInfo);

  context.setOutputDataStream(context.getOutput(transform), outputDataStream);
}
 
开发者ID:apache,项目名称:beam,代码行数:29,代码来源:FlinkStreamingTransformTranslators.java

示例6: translateHelper

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
private <T> void translateHelper(Window.Assign<T> transform, TranslationContext context) {
  StepTranslationContext stepContext = context.addStep(transform, "Bucket");
  PCollection<T> input = context.getInput(transform);
  stepContext.addInput(PropertyNames.PARALLEL_INPUT, input);
  stepContext.addOutput(context.getOutput(transform));

  WindowingStrategy<?, ?> strategy = context.getOutput(transform).getWindowingStrategy();
  byte[] serializedBytes = serializeWindowingStrategy(strategy);
  String serializedJson = byteArrayToJsonString(serializedBytes);
  stepContext.addInput(PropertyNames.SERIALIZED_FN, serializedJson);
}
 
开发者ID:apache,项目名称:beam,代码行数:12,代码来源:DataflowPipelineTranslator.java

示例7: translate

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public void translate(Window.Assign<T> transform, TranslationContext context) {
  PCollection<T> input = (PCollection<T>) context.getInput();
  PCollection<T> output = (PCollection<T>) context.getOutput();
  JavaStream<WindowedValue<T>> inputStream = context.getInputStream(input);
  WindowingStrategy<?, ?> outputStrategy = output.getWindowingStrategy();
  WindowFn<T, BoundedWindow> windowFn = (WindowFn<T, BoundedWindow>) outputStrategy.getWindowFn();
  JavaStream<WindowedValue<T>> outputStream =
      inputStream
          .flatMap(new AssignWindows(windowFn), "assign_windows");

  context.setOutputStream(output, outputStream);
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:WindowAssignTranslator.java

示例8: createTransformEvaluator

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
private <InputT> TransformEvaluator<InputT> createTransformEvaluator(
    AppliedPTransform<PCollection<InputT>, PCollection<InputT>, Window.Assign<InputT>>
        transform) {

  WindowFn<? super InputT, ?> fn = (WindowFn) WindowIntoTranslation.getWindowFn(transform);

  UncommittedBundle<InputT> outputBundle =
      evaluationContext.createBundle(
          (PCollection<InputT>) Iterables.getOnlyElement(transform.getOutputs().values()));
  if (fn == null) {
    return PassthroughTransformEvaluator.create(transform, outputBundle);
  }
  return new WindowIntoEvaluator<>(transform, fn, outputBundle);
}
 
开发者ID:apache,项目名称:beam,代码行数:15,代码来源:WindowEvaluatorFactory.java

示例9: WindowIntoEvaluator

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public WindowIntoEvaluator(
    AppliedPTransform<PCollection<InputT>, PCollection<InputT>, Window.Assign<InputT>>
        transform,
    WindowFn<? super InputT, ?> windowFn,
    UncommittedBundle<InputT> outputBundle) {
  this.outputBundle = outputBundle;
  this.transform = transform;
  // Safe contravariant cast
  this.windowFn = (WindowFn<InputT, ?>) windowFn;
}
 
开发者ID:apache,项目名称:beam,代码行数:12,代码来源:WindowEvaluatorFactory.java

示例10: toProto

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
public static WindowIntoPayload toProto(Window.Assign<?> transform, SdkComponents components) {
  return WindowIntoPayload.newBuilder()
      .setWindowFn(WindowingStrategyTranslation.toProto(transform.getWindowFn(), components))
      .build();
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:WindowIntoTranslation.java

示例11: getUrn

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public String getUrn(Window.Assign<?> transform) {
  return PTransformTranslation.WINDOW_TRANSFORM_URN;
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:WindowIntoTranslation.java

示例12: translate

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public void translate(Window.Assign transform, TranslationContext context) {
  translateHelper(transform, context);
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:DataflowPipelineTranslator.java

示例13: skipAssignWindows

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
/**
 * Checks if the window transformation should be applied or skipped.
 *
 * <p>Avoid running assign windows if both source and destination are global window or if the user
 * has not specified the WindowFn (meaning they are just messing with triggering or allowed
 * lateness).
 *
 * @param transform The {@link Window.Assign} transformation.
 * @param context The {@link EvaluationContext}.
 * @param <T> PCollection type.
 * @param <W> {@link BoundedWindow} type.
 * @return if to apply the transformation.
 */
public static <T, W extends BoundedWindow> boolean skipAssignWindows(
    Window.Assign<T> transform, EvaluationContext context) {
  @SuppressWarnings("unchecked")
  WindowFn<? super T, W> windowFn = (WindowFn<? super T, W>) transform.getWindowFn();
  return windowFn == null
      || (context.getInput(transform).getWindowingStrategy().getWindowFn()
              instanceof GlobalWindows
          && windowFn instanceof GlobalWindows);
}
 
开发者ID:apache,项目名称:beam,代码行数:23,代码来源:TranslationUtils.java


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