Java Code Examples for org.apache.beam.sdk.transforms.windowing.PaneInfo#NO_FIRING

The following examples show how to use org.apache.beam.sdk.transforms.windowing.PaneInfo#NO_FIRING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowedValue.java    From beam with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a {@code WindowedValue} with the given value and timestamp, {@code GlobalWindow} and
 * default pane.
 */
public static <T> WindowedValue<T> timestampedValueInGlobalWindow(T value, Instant timestamp) {
  if (BoundedWindow.TIMESTAMP_MIN_VALUE.equals(timestamp)) {
    return valueInGlobalWindow(value);
  } else {
    return new TimestampedValueInGlobalWindow<>(value, timestamp, PaneInfo.NO_FIRING);
  }
}
 
Example 2
Source File: TransformTranslatorTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void testSplitBySameKey() {
  VarIntCoder coder = VarIntCoder.of();
  WindowedValue.WindowedValueCoder<Integer> wvCoder =
      WindowedValue.FullWindowedValueCoder.of(coder, GlobalWindow.Coder.INSTANCE);
  Instant now = Instant.now();
  List<GlobalWindow> window = Arrays.asList(GlobalWindow.INSTANCE);
  PaneInfo paneInfo = PaneInfo.NO_FIRING;
  List<Tuple2<ByteArray, byte[]>> firstKey =
      Arrays.asList(
          new Tuple2(
              new ByteArray(CoderHelpers.toByteArrayWithTs(1, coder, now)),
              CoderHelpers.toByteArray(WindowedValue.of(1, now, window, paneInfo), wvCoder)),
          new Tuple2(
              new ByteArray(CoderHelpers.toByteArrayWithTs(1, coder, now.plus(1))),
              CoderHelpers.toByteArray(
                  WindowedValue.of(2, now.plus(1), window, paneInfo), wvCoder)));

  List<Tuple2<ByteArray, byte[]>> secondKey =
      Arrays.asList(
          new Tuple2(
              new ByteArray(CoderHelpers.toByteArrayWithTs(2, coder, now)),
              CoderHelpers.toByteArray(WindowedValue.of(3, now, window, paneInfo), wvCoder)),
          new Tuple2(
              new ByteArray(CoderHelpers.toByteArrayWithTs(2, coder, now.plus(2))),
              CoderHelpers.toByteArray(
                  WindowedValue.of(4, now.plus(2), window, paneInfo), wvCoder)));

  Iterable<Tuple2<ByteArray, byte[]>> concat = Iterables.concat(firstKey, secondKey);
  Iterator<Iterator<WindowedValue<KV<Integer, Integer>>>> keySplit;
  keySplit = TransformTranslator.splitBySameKey(concat.iterator(), coder, wvCoder);

  for (int i = 0; i < 2; i++) {
    Iterator<WindowedValue<KV<Integer, Integer>>> iter = keySplit.next();
    List<WindowedValue<KV<Integer, Integer>>> list = new ArrayList<>();
    Iterators.addAll(list, iter);
    if (i == 0) {
      // first key
      assertEquals(
          Arrays.asList(
              WindowedValue.of(KV.of(1, 1), now, window, paneInfo),
              WindowedValue.of(KV.of(1, 2), now.plus(1), window, paneInfo)),
          list);
    } else {
      // second key
      assertEquals(
          Arrays.asList(
              WindowedValue.of(KV.of(2, 3), now, window, paneInfo),
              WindowedValue.of(KV.of(2, 4), now.plus(2), window, paneInfo)),
          list);
    }
  }
}
 
Example 3
Source File: BatchViewOverrides.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public PaneInfo getPane() {
  return PaneInfo.NO_FIRING;
}
 
Example 4
Source File: ValueInEmptyWindows.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public PaneInfo getPane() {
  return PaneInfo.NO_FIRING;
}
 
Example 5
Source File: WindowedValue.java    From beam with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a {@code WindowedValue} with the given value in the {@link GlobalWindow} using the
 * default timestamp and pane.
 */
public static <T> WindowedValue<T> valueInGlobalWindow(T value) {
  return new ValueInGlobalWindow<>(value, PaneInfo.NO_FIRING);
}