Search in sources :

Example 1 with NeverDeduplicator

use of org.apache.beam.runners.direct.UnboundedReadDeduplicator.NeverDeduplicator in project beam by apache.

the class UnboundedReadEvaluatorFactoryTest method processElement.

private void processElement(final TestUnboundedSource<String> source) throws Exception {
    final EvaluationContext context = EvaluationContext.create(MockClock.fromInstant(Instant.now()), CloningBundleFactory.create(), DirectGraph.create(emptyMap(), emptyMap(), LinkedListMultimap.create(), emptySet(), emptyMap()), emptySet(), Executors.newCachedThreadPool());
    final UnboundedReadEvaluatorFactory factory = new UnboundedReadEvaluatorFactory(context, p.getOptions());
    final SplittableParDo.PrimitiveUnboundedRead<String> unbounded = new SplittableParDo.PrimitiveUnboundedRead(Read.from(source));
    final Pipeline pipeline = Pipeline.create(p.getOptions());
    final PCollection<String> pCollection = pipeline.apply(unbounded);
    final AppliedPTransform<PBegin, PCollection<String>, SplittableParDo.PrimitiveUnboundedRead<String>> application = AppliedPTransform.of("test", new HashMap<>(), singletonMap(new TupleTag(), pCollection), unbounded, ResourceHints.create(), pipeline);
    final TransformEvaluator<UnboundedSourceShard<String, TestCheckpointMark>> evaluator = factory.forApplication(application, null);
    final UnboundedSource.UnboundedReader<String> reader = source.createReader(p.getOptions(), null);
    final UnboundedSourceShard<String, TestCheckpointMark> shard = UnboundedSourceShard.of(source, new NeverDeduplicator(), reader, null);
    final WindowedValue<UnboundedSourceShard<String, TestCheckpointMark>> value = WindowedValue.of(shard, BoundedWindow.TIMESTAMP_MAX_VALUE, GlobalWindow.INSTANCE, PaneInfo.NO_FIRING);
    TestUnboundedSource.readerClosedCount = 0;
    evaluator.processElement(value);
}
Also used : TupleTag(org.apache.beam.sdk.values.TupleTag) PBegin(org.apache.beam.sdk.values.PBegin) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Pipeline(org.apache.beam.sdk.Pipeline) SplittableParDo(org.apache.beam.runners.core.construction.SplittableParDo) PCollection(org.apache.beam.sdk.values.PCollection) UnboundedSourceShard(org.apache.beam.runners.direct.UnboundedReadEvaluatorFactory.UnboundedSourceShard) NeverDeduplicator(org.apache.beam.runners.direct.UnboundedReadDeduplicator.NeverDeduplicator) UnboundedSource(org.apache.beam.sdk.io.UnboundedSource)

Aggregations

SplittableParDo (org.apache.beam.runners.core.construction.SplittableParDo)1 NeverDeduplicator (org.apache.beam.runners.direct.UnboundedReadDeduplicator.NeverDeduplicator)1 UnboundedSourceShard (org.apache.beam.runners.direct.UnboundedReadEvaluatorFactory.UnboundedSourceShard)1 Pipeline (org.apache.beam.sdk.Pipeline)1 UnboundedSource (org.apache.beam.sdk.io.UnboundedSource)1 TestPipeline (org.apache.beam.sdk.testing.TestPipeline)1 PBegin (org.apache.beam.sdk.values.PBegin)1 PCollection (org.apache.beam.sdk.values.PCollection)1 TupleTag (org.apache.beam.sdk.values.TupleTag)1