本文整理汇总了Java中com.google.cloud.dataflow.sdk.transforms.windowing.BoundedWindow类的典型用法代码示例。如果您正苦于以下问题:Java BoundedWindow类的具体用法?Java BoundedWindow怎么用?Java BoundedWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundedWindow类属于com.google.cloud.dataflow.sdk.transforms.windowing包,在下文中一共展示了BoundedWindow类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: window
import com.google.cloud.dataflow.sdk.transforms.windowing.BoundedWindow; //导入依赖的package包/类
private static <T, W extends BoundedWindow> TransformEvaluator<Window.Bound<T>> window() {
return new TransformEvaluator<Window.Bound<T>>() {
@Override
public void evaluate(Window.Bound<T> transform, EvaluationContext context) {
@SuppressWarnings("unchecked")
JavaRDDLike<WindowedValue<T>, ?> inRDD =
(JavaRDDLike<WindowedValue<T>, ?>) context.getInputRDD(transform);
WindowFn<? super T, W> windowFn = WINDOW_FG.get("windowFn", transform);
if (windowFn instanceof GlobalWindows) {
context.setOutputRDD(transform, inRDD);
} else {
@SuppressWarnings("unchecked")
DoFn<T, T> addWindowsDoFn = new AssignWindowsDoFn<>(windowFn);
DoFnFunction<T, T> dofn =
new DoFnFunction<>(addWindowsDoFn, context.getRuntimeContext(), null);
context.setOutputRDD(transform, inRDD.mapPartitions(dofn));
}
}
};
}
示例2: window
import com.google.cloud.dataflow.sdk.transforms.windowing.BoundedWindow; //导入依赖的package包/类
@Override
public BoundedWindow window() {
if (!(fn instanceof DoFn.RequiresWindowAccess)) {
throw new UnsupportedOperationException(
"window() is only available in the context of a DoFn marked as RequiresWindow.");
}
return Iterables.getOnlyElement(windowedValue.getWindows());
}
示例3: processElement
import com.google.cloud.dataflow.sdk.transforms.windowing.BoundedWindow; //导入依赖的package包/类
@Override
public void processElement(DoFn<List<String>, KV<String, TSProto>>.ProcessContext c)
throws Exception {
List<String> timeSeriesKey = c.element();
BoundedWindow window = c.window();
for (String s : timeSeriesKey) {
TSProto ts =
TSProto.newBuilder().setKey(s).setIsLive(false)
.setTime(window.maxTimestamp().getMillis()).build();
c.outputWithTimestamp(KV.of(s, ts), window.maxTimestamp());
LOG.debug(String.format("Generated value for missing tick details are key : %s time: %s" , ts.getKey(), new Instant(ts.getTime())));
}
}
开发者ID:GoogleCloudPlatform,项目名称:data-timeseries-java,代码行数:20,代码来源:CreateMissingTimeSeriesValuesDoFn.java