當前位置: 首頁>>代碼示例>>Java>>正文


Java BoundedWindow類代碼示例

本文整理匯總了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));
      }
    }
  };
}
 
開發者ID:shakamunyi,項目名稱:spark-dataflow,代碼行數:21,代碼來源:TransformTranslator.java

示例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());
}
 
開發者ID:shakamunyi,項目名稱:spark-dataflow,代碼行數:9,代碼來源:SparkProcessContext.java

示例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


注:本文中的com.google.cloud.dataflow.sdk.transforms.windowing.BoundedWindow類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。