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


Java PaneInfo.getIndex方法代码示例

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


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

示例1: updatePCollectionViewWindowValues

import org.apache.beam.sdk.transforms.windowing.PaneInfo; //导入方法依赖的package包/类
/**
 * Set the value of the {@link PCollectionView} in the {@link BoundedWindow} to be based on the
 * specified values, if the values are part of a later pane than currently exist within the
 * {@link PCollectionViewWindow}.
 */
private void updatePCollectionViewWindowValues(
    PCollectionView<?> view, BoundedWindow window, Collection<WindowedValue<?>> windowValues) {
  PCollectionViewWindow<?> windowedView = PCollectionViewWindow.of(view, window);
  AtomicReference<Iterable<? extends WindowedValue<?>>> contents =
      viewByWindows.getUnchecked(windowedView);
  if (contents.compareAndSet(null, windowValues)) {
    // the value had never been set, so we set it and are done.
    return;
  }
  PaneInfo newPane = windowValues.iterator().next().getPane();

  Iterable<? extends WindowedValue<?>> existingValues;
  long existingPane;
  do {
    existingValues = contents.get();
    existingPane =
        Iterables.isEmpty(existingValues)
            ? -1L
            : existingValues.iterator().next().getPane().getIndex();
  } while (newPane.getIndex() > existingPane
      && !contents.compareAndSet(existingValues, windowValues));
}
 
开发者ID:apache,项目名称:beam,代码行数:28,代码来源:SideInputContainer.java

示例2: outputFileFor

import org.apache.beam.sdk.transforms.windowing.PaneInfo; //导入方法依赖的package包/类
/** Construct an {@link OutputFile} for {@code pane} in {@code window} for {@code shard}. */
private OutputFile outputFileFor(BoundedWindow window, String shard, PaneInfo pane) {
  @Nullable String filename =
      outputPath == null
      ? null
      : String.format("%s/LOG-%s-%s-%03d-%s-%x",
          outputPath, window.maxTimestamp(), shard, pane.getIndex(),
          timingToString(pane.getTiming()),
          ThreadLocalRandom.current().nextLong());
  return new OutputFile(window.maxTimestamp(), shard, pane.getIndex(),
      pane.getTiming(), filename);
}
 
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:Query10.java

示例3: describePane

import org.apache.beam.sdk.transforms.windowing.PaneInfo; //导入方法依赖的package包/类
private <W> PaneInfo describePane(
    Object key, Instant windowMaxTimestamp, PaneInfo previousPane, boolean isFinal) {
  boolean isFirst = previousPane == null;
  Timing previousTiming = isFirst ? null : previousPane.getTiming();
  long index = isFirst ? 0 : previousPane.getIndex() + 1;
  long nonSpeculativeIndex = isFirst ? 0 : previousPane.getNonSpeculativeIndex() + 1;
  Instant outputWM = timerInternals.currentOutputWatermarkTime();
  Instant inputWM = timerInternals.currentInputWatermarkTime();

  // True if it is not possible to assign the element representing this pane a timestamp
  // which will make an ON_TIME pane for any following computation.
  // Ie true if the element's latest possible timestamp is before the current output watermark.
  boolean isLateForOutput = outputWM != null && windowMaxTimestamp.isBefore(outputWM);

  // True if all emitted panes (if any) were EARLY panes.
  // Once the ON_TIME pane has fired, all following panes must be considered LATE even
  // if the output watermark is behind the end of the window.
  boolean onlyEarlyPanesSoFar = previousTiming == null || previousTiming == Timing.EARLY;

  // True is the input watermark hasn't passed the window's max timestamp.
  boolean isEarlyForInput = !inputWM.isAfter(windowMaxTimestamp);

  Timing timing;
  if (isLateForOutput || !onlyEarlyPanesSoFar) {
    // The output watermark has already passed the end of this window, or we have already
    // emitted a non-EARLY pane. Irrespective of how this pane was triggered we must
    // consider this pane LATE.
    timing = Timing.LATE;
  } else if (isEarlyForInput) {
    // This is an EARLY firing.
    timing = Timing.EARLY;
    nonSpeculativeIndex = -1;
  } else {
    // This is the unique ON_TIME firing for the window.
    timing = Timing.ON_TIME;
  }

  WindowTracing.debug(
      "describePane: {} pane (prev was {}) for key:{}; windowMaxTimestamp:{}; "
      + "inputWatermark:{}; outputWatermark:{}; isLateForOutput:{}",
      timing, previousTiming, key, windowMaxTimestamp, inputWM, outputWM, isLateForOutput);

  if (previousPane != null) {
    // Timing transitions should follow EARLY* ON_TIME? LATE*
    switch (previousTiming) {
      case EARLY:
        checkState(
            timing == Timing.EARLY || timing == Timing.ON_TIME || timing == Timing.LATE,
            "EARLY cannot transition to %s", timing);
        break;
      case ON_TIME:
        checkState(
            timing == Timing.LATE, "ON_TIME cannot transition to %s", timing);
        break;
      case LATE:
        checkState(timing == Timing.LATE, "LATE cannot transtion to %s", timing);
        break;
      case UNKNOWN:
        break;
    }
    checkState(!previousPane.isLast(), "Last pane was not last after all.");
  }

  return PaneInfo.createPane(isFirst, isFinal, timing, index, nonSpeculativeIndex);
}
 
开发者ID:apache,项目名称:beam,代码行数:66,代码来源:PaneInfoTracker.java


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