DoFnTester.finishBundle
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.apache.beam.sdk.transforms.DoFnTester.finishBundle(Showing top 12 results out of 315)

origin: apache/beam

@Override
public void close() throws Exception {
 if (state == State.BUNDLE_STARTED) {
  finishBundle();
 }
 if (state == State.BUNDLE_FINISHED) {
  fnInvoker.invokeTeardown();
  fn = null;
  fnInvoker = null;
 }
 state = State.TORN_DOWN;
}
origin: apache/beam

/**
 * A convenience operation that first calls {@link #startBundle},
 * then calls {@link #processElement} on each of the input elements, then
 * calls {@link #finishBundle}, then returns the result of
 * {@link #takeOutputElements}.
 */
public List<OutputT> processBundle(Iterable <? extends InputT> inputElements) throws Exception {
 startBundle();
 for (InputT inputElement : inputElements) {
  processElement(inputElement);
 }
 finishBundle();
 return takeOutputElements();
}
origin: apache/beam

@Test
public void fnWithSideInputExplicit() throws Exception {
 PCollection<Integer> pCollection = p.apply(Create.of(-2));
 final PCollectionView<Integer> value = pCollection.apply(
   View.<Integer>asSingleton().withDefaultValue(0));
 try (DoFnTester<Integer, Integer> tester = DoFnTester.of(new SideInputDoFn(value))) {
  tester.setSideInput(value, GlobalWindow.INSTANCE, -2);
  tester.processElement(16);
  tester.processElement(32);
  tester.processElement(64);
  tester.processElement(128);
  tester.finishBundle();
  assertThat(tester.peekOutputElements(), containsInAnyOrder(-2, -2, -2, -2));
 }
}
origin: apache/beam

@Test
public void peekValuesInWindow() throws Exception {
 try (DoFnTester<Long, String> tester = DoFnTester.of(new CounterDoFn())) {
  tester.startBundle();
  tester.processElement(1L);
  tester.processElement(2L);
  tester.finishBundle();
  assertThat(
    tester.peekOutputElementsInWindow(GlobalWindow.INSTANCE),
    containsInAnyOrder(
      TimestampedValue.of("1", new Instant(1000L)),
      TimestampedValue.of("2", new Instant(2000L))));
  assertThat(
    tester.peekOutputElementsInWindow(new IntervalWindow(new Instant(0L), new Instant(10L))),
    Matchers.emptyIterable());
 }
}
origin: apache/beam

@Test
public void testSupportsWindowParameter() throws Exception {
 Instant now = Instant.now();
 try (DoFnTester<Integer, KV<Integer, BoundedWindow>> tester =
   DoFnTester.of(new DoFnWithWindowParameter())) {
  BoundedWindow firstWindow = new IntervalWindow(now, now.plus(Duration.standardMinutes(1)));
  tester.processWindowedElement(1, now, firstWindow);
  tester.processWindowedElement(2, now, firstWindow);
  BoundedWindow secondWindow = new IntervalWindow(now, now.plus(Duration.standardMinutes(4)));
  tester.processWindowedElement(3, now, secondWindow);
  tester.finishBundle();
  assertThat(
    tester.peekOutputElementsInWindow(firstWindow),
    containsInAnyOrder(
      TimestampedValue.of(KV.of(1, firstWindow), now),
      TimestampedValue.of(KV.of(2, firstWindow), now)));
  assertThat(
    tester.peekOutputElementsInWindow(secondWindow),
    containsInAnyOrder(
      TimestampedValue.of(KV.of(3, secondWindow), now)));
 }
}
origin: apache/beam

assertThat(take, hasItems("5", "6"));
tester.finishBundle();
origin: org.apache.beam/beam-sdks-java-core

/**
 * @deprecated Use {@link TestPipeline} with the {@code DirectRunner}.
 */
@Deprecated
@Override
public void close() throws Exception {
 if (state == State.BUNDLE_STARTED) {
  finishBundle();
 }
 if (state == State.BUNDLE_FINISHED) {
  fnInvoker.invokeTeardown();
  fn = null;
  fnInvoker = null;
 }
 state = State.TORN_DOWN;
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * @deprecated Use {@link TestPipeline} with the {@code DirectRunner}.
 */
@Deprecated
public List<OutputT> processBundle(Iterable <? extends InputT> inputElements) throws Exception {
 startBundle();
 for (InputT inputElement : inputElements) {
  processElement(inputElement);
 }
 finishBundle();
 return takeOutputElements();
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void fnWithSideInputExplicit() throws Exception {
 PCollection<Integer> pCollection = p.apply(Create.of(-2));
 final PCollectionView<Integer> value = pCollection.apply(
   View.<Integer>asSingleton().withDefaultValue(0));
 try (DoFnTester<Integer, Integer> tester = DoFnTester.of(new SideInputDoFn(value))) {
  tester.setSideInput(value, GlobalWindow.INSTANCE, -2);
  tester.processElement(16);
  tester.processElement(32);
  tester.processElement(64);
  tester.processElement(128);
  tester.finishBundle();
  assertThat(tester.peekOutputElements(), containsInAnyOrder(-2, -2, -2, -2));
 }
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void peekValuesInWindow() throws Exception {
 try (DoFnTester<Long, String> tester = DoFnTester.of(new CounterDoFn())) {
  tester.startBundle();
  tester.processElement(1L);
  tester.processElement(2L);
  tester.finishBundle();
  assertThat(
    tester.peekOutputElementsInWindow(GlobalWindow.INSTANCE),
    containsInAnyOrder(
      TimestampedValue.of("1", new Instant(1000L)),
      TimestampedValue.of("2", new Instant(2000L))));
  assertThat(
    tester.peekOutputElementsInWindow(new IntervalWindow(new Instant(0L), new Instant(10L))),
    Matchers.emptyIterable());
 }
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testSupportsWindowParameter() throws Exception {
 Instant now = Instant.now();
 try (DoFnTester<Integer, KV<Integer, BoundedWindow>> tester =
   DoFnTester.of(new DoFnWithWindowParameter())) {
  BoundedWindow firstWindow = new IntervalWindow(now, now.plus(Duration.standardMinutes(1)));
  tester.processWindowedElement(1, now, firstWindow);
  tester.processWindowedElement(2, now, firstWindow);
  BoundedWindow secondWindow = new IntervalWindow(now, now.plus(Duration.standardMinutes(4)));
  tester.processWindowedElement(3, now, secondWindow);
  tester.finishBundle();
  assertThat(
    tester.peekOutputElementsInWindow(firstWindow),
    containsInAnyOrder(
      TimestampedValue.of(KV.of(1, firstWindow), now),
      TimestampedValue.of(KV.of(2, firstWindow), now)));
  assertThat(
    tester.peekOutputElementsInWindow(secondWindow),
    containsInAnyOrder(
      TimestampedValue.of(KV.of(3, secondWindow), now)));
 }
}
origin: org.apache.beam/beam-sdks-java-core

assertThat(take, hasItems("5", "6"));
tester.finishBundle();
org.apache.beam.sdk.transformsDoFnTesterfinishBundle

Javadoc

Calls the DoFn.FinishBundle method of the DoFn under test.

If #setCloningBehavior was called with CloningBehavior#CLONE_PER_BUNDLE, then also calls DoFn.Teardown on the DoFn, and it will be cloned and DoFn.Setup again when processing the next bundle.

Popular methods of DoFnTester

  • of
  • processBundle
  • processElement
  • peekOutputElementsInWindow
  • setCloningBehavior
  • startBundle
  • takeOutputElements
  • getMutableOutput
  • peekOutputElements
  • peekOutputElementsWithTimestamp
  • processTimestampedElement
  • processWindowedElement
  • processTimestampedElement,
  • processWindowedElement,
  • setSideInput,
  • clearOutputElements,
  • close,
  • createProcessContext,
  • getImmutableOutput,
  • getMainOutputTag,
  • getOutputs

Popular classes and methods

  • requestLocationUpdates (LocationManager)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • getExternalFilesDir (Context)
  • Kernel (java.awt.image)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)