Java Code Examples for org.apache.beam.sdk.transforms.Flatten#pCollections()

The following examples show how to use org.apache.beam.sdk.transforms.Flatten#pCollections() . 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: UnconsumedReadsTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
public void doesNotConsumeAlreadyConsumedRead() {
  Unbounded<Long> transform = Read.from(CountingSource.unbounded());
  final PCollection<Long> output = pipeline.apply(transform);
  final Flatten.PCollections<Long> consumer = Flatten.pCollections();
  PCollectionList.of(output).apply(consumer);
  UnconsumedReads.ensureAllReadsConsumed(pipeline);
  pipeline.traverseTopologically(
      new PipelineVisitor.Defaults() {
        @Override
        public void visitPrimitiveTransform(Node node) {
          // The output should only be consumed by a single consumer
          if (node.getInputs().values().contains(output)) {
            assertThat(node.getTransform(), Matchers.is(consumer));
          }
        }
      });
}
 
Example 2
Source File: TestExpansionService.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public PTransform<PCollectionList<Long>, PCollection<Long>> getTransform(
    RunnerApi.FunctionSpec spec) {
  return Flatten.pCollections();
}