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


Java Window.into方法代码示例

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


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

示例1: testTopEmptyWithIncompatibleWindows

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Test
public void testTopEmptyWithIncompatibleWindows() {
  p.enableAbandonedNodeEnforcement(false);

  Window<String> windowingFn = Window.<String>into(FixedWindows.of(Duration.standardDays(10L)));
  PCollection<String> input = p.apply(Create.empty(StringUtf8Coder.of())).apply(windowingFn);

  expectedEx.expect(IllegalStateException.class);
  expectedEx.expectMessage("Top");
  expectedEx.expectMessage("GlobalWindows");
  expectedEx.expectMessage("withoutDefaults");
  expectedEx.expectMessage("asSingletonView");

  input.apply(Top.of(1, new OrderByLength()));
}
 
开发者ID:apache,项目名称:beam,代码行数:16,代码来源:TopTest.java

示例2: singleWindowFnSucceeds

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Test
public void singleWindowFnSucceeds() throws Exception {
  Duration windowDuration = Duration.standardDays(7);
  Window<Long> transform = Window.<Long>into(FixedWindows.of(windowDuration));
  PCollection<Long> windowed = input.apply(transform);

  CommittedBundle<Long> inputBundle = createInputBundle();

  UncommittedBundle<Long> outputBundle = createOutputBundle(windowed, inputBundle);

  BoundedWindow firstSecondWindow = new IntervalWindow(EPOCH, EPOCH.plus(windowDuration));
  BoundedWindow thirdWindow = new IntervalWindow(EPOCH.minus(windowDuration), EPOCH);

  TransformResult<Long> result = runEvaluator(windowed, inputBundle);

  assertThat(
      Iterables.getOnlyElement(result.getOutputBundles()),
      Matchers.<UncommittedBundle<?>>equalTo(outputBundle));
  CommittedBundle<Long> committed = outputBundle.commit(Instant.now());

  assertThat(
      committed.getElements(),
      containsInAnyOrder(
          // value in global window
          isSingleWindowedValue(3L, new Instant(2L), firstSecondWindow, NO_FIRING),

          // value in just interval window
          isSingleWindowedValue(2L, new Instant(-10L), thirdWindow, intervalWindowPane),

          // value in global window and two interval windows
          isSingleWindowedValue(
              1L, EPOCH.plus(Duration.standardDays(3)), firstSecondWindow, multiWindowPane),
          isSingleWindowedValue(
              1L, EPOCH.plus(Duration.standardDays(3)), firstSecondWindow, multiWindowPane),
          isSingleWindowedValue(
              1L, EPOCH.plus(Duration.standardDays(3)), firstSecondWindow, multiWindowPane)));
}
 
开发者ID:apache,项目名称:beam,代码行数:38,代码来源:WindowEvaluatorFactoryTest.java

示例3: window

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
private <T> PTransform<PCollection<T>, PCollection<T>> window() {
  return Window.into(new GlobalWindows());
}
 
开发者ID:apache,项目名称:beam,代码行数:4,代码来源:PAssert.java

示例4: windowDummy

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public <T> PTransform<PCollection<T>, PCollection<T>> windowDummy() {
  return Window.into(windowFn);
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:PAssert.java

示例5: windowActuals

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Override
public <T> PTransform<PCollection<T>, PCollection<T>> windowActuals() {
  return Window.into(windowFn.intoOnlyExisting());
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:PAssert.java

示例6: multipleWindowsWindowFnSucceeds

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Test
public void multipleWindowsWindowFnSucceeds() throws Exception {
  Duration windowDuration = Duration.standardDays(6);
  Duration slidingBy = Duration.standardDays(3);
  Window<Long> transform = Window.into(SlidingWindows.of(windowDuration).every(slidingBy));
  PCollection<Long> windowed = input.apply(transform);

  CommittedBundle<Long> inputBundle = createInputBundle();
  UncommittedBundle<Long> outputBundle = createOutputBundle(windowed, inputBundle);

  TransformResult<Long> result = runEvaluator(windowed, inputBundle);

  assertThat(
      Iterables.getOnlyElement(result.getOutputBundles()),
      Matchers.<UncommittedBundle<?>>equalTo(outputBundle));
  CommittedBundle<Long> committed = outputBundle.commit(Instant.now());

  BoundedWindow w1 = new IntervalWindow(EPOCH, EPOCH.plus(windowDuration));
  BoundedWindow w2 =
      new IntervalWindow(EPOCH.plus(slidingBy), EPOCH.plus(slidingBy).plus(windowDuration));
  BoundedWindow wMinus1 = new IntervalWindow(EPOCH.minus(windowDuration), EPOCH);
  BoundedWindow wMinusSlide =
      new IntervalWindow(EPOCH.minus(windowDuration).plus(slidingBy), EPOCH.plus(slidingBy));

  assertThat(
      committed.getElements(),
      containsInAnyOrder(
          // Value in global window mapped to one windowed value in multiple windows
          isWindowedValue(
              valueInGlobalWindow.getValue(),
              valueInGlobalWindow.getTimestamp(),
              ImmutableSet.of(w1, wMinusSlide),
              NO_FIRING),

          // Value in interval window mapped to one windowed value in multiple windows
          isWindowedValue(
              valueInIntervalWindow.getValue(),
              valueInIntervalWindow.getTimestamp(),
              ImmutableSet.of(wMinus1, wMinusSlide),
              valueInIntervalWindow.getPane()),

          // Value in three windows mapped to three windowed values in the same multiple windows
          isWindowedValue(
              valueInGlobalAndTwoIntervalWindows.getValue(),
              valueInGlobalAndTwoIntervalWindows.getTimestamp(),
              ImmutableSet.of(w1, w2),
              valueInGlobalAndTwoIntervalWindows.getPane()),
          isWindowedValue(
              valueInGlobalAndTwoIntervalWindows.getValue(),
              valueInGlobalAndTwoIntervalWindows.getTimestamp(),
              ImmutableSet.of(w1, w2),
              valueInGlobalAndTwoIntervalWindows.getPane()),
          isWindowedValue(
              valueInGlobalAndTwoIntervalWindows.getValue(),
              valueInGlobalAndTwoIntervalWindows.getTimestamp(),
              ImmutableSet.of(w1, w2),
              valueInGlobalAndTwoIntervalWindows.getPane())));
}
 
开发者ID:apache,项目名称:beam,代码行数:59,代码来源:WindowEvaluatorFactoryTest.java

示例7: referencesEarlierWindowsSucceeds

import org.apache.beam.sdk.transforms.windowing.Window; //导入方法依赖的package包/类
@Test
public void referencesEarlierWindowsSucceeds() throws Exception {
  Window<Long> transform = Window.into(new EvaluatorTestWindowFn());
  PCollection<Long> windowed = input.apply(transform);

  CommittedBundle<Long> inputBundle = createInputBundle();
  UncommittedBundle<Long> outputBundle = createOutputBundle(windowed, inputBundle);

  TransformResult<Long> result = runEvaluator(windowed, inputBundle);

  assertThat(
      Iterables.getOnlyElement(result.getOutputBundles()),
      Matchers.<UncommittedBundle<?>>equalTo(outputBundle));
  CommittedBundle<Long> committed = outputBundle.commit(Instant.now());

  assertThat(
      committed.getElements(),
      containsInAnyOrder(
          // Value in global window mapped to [timestamp, timestamp+1)
          isSingleWindowedValue(
              valueInGlobalWindow.getValue(),
              valueInGlobalWindow.getTimestamp(),
              new IntervalWindow(
                  valueInGlobalWindow.getTimestamp(),
                  valueInGlobalWindow.getTimestamp().plus(1L)),
              valueInGlobalWindow.getPane()),

          // Value in interval window mapped to the same window
          isWindowedValue(
              valueInIntervalWindow.getValue(),
              valueInIntervalWindow.getTimestamp(),
              valueInIntervalWindow.getWindows(),
              valueInIntervalWindow.getPane()),

          // Value in global window and two interval windows exploded and mapped in both ways
          isSingleWindowedValue(
              valueInGlobalAndTwoIntervalWindows.getValue(),
              valueInGlobalAndTwoIntervalWindows.getTimestamp(),
              new IntervalWindow(
                  valueInGlobalAndTwoIntervalWindows.getTimestamp(),
                  valueInGlobalAndTwoIntervalWindows.getTimestamp().plus(1L)),
              valueInGlobalAndTwoIntervalWindows.getPane()),
          isSingleWindowedValue(
              valueInGlobalAndTwoIntervalWindows.getValue(),
              valueInGlobalAndTwoIntervalWindows.getTimestamp(),
              intervalWindow1,
              valueInGlobalAndTwoIntervalWindows.getPane()),
          isSingleWindowedValue(
              valueInGlobalAndTwoIntervalWindows.getValue(),
              valueInGlobalAndTwoIntervalWindows.getTimestamp(),
              intervalWindow2,
              valueInGlobalAndTwoIntervalWindows.getPane())));
}
 
开发者ID:apache,项目名称:beam,代码行数:54,代码来源:WindowEvaluatorFactoryTest.java


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