本文整理汇总了Java中org.apache.beam.sdk.Pipeline.replaceAll方法的典型用法代码示例。如果您正苦于以下问题:Java Pipeline.replaceAll方法的具体用法?Java Pipeline.replaceAll怎么用?Java Pipeline.replaceAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.beam.sdk.Pipeline
的用法示例。
在下文中一共展示了Pipeline.replaceAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import org.apache.beam.sdk.Pipeline; //导入方法依赖的package包/类
/**
* Depending on if the job is a Streaming or a Batch one, this method creates
* the necessary execution environment and pipeline translator, and translates
* the {@link org.apache.beam.sdk.values.PCollection} program into
* a {@link org.apache.flink.api.java.DataSet}
* or {@link org.apache.flink.streaming.api.datastream.DataStream} one.
* */
public void translate(FlinkRunner flinkRunner, Pipeline pipeline) {
this.flinkBatchEnv = null;
this.flinkStreamEnv = null;
pipeline.replaceAll(FlinkTransformOverrides.getDefaultOverrides(options.isStreaming()));
PipelineTranslationOptimizer optimizer =
new PipelineTranslationOptimizer(TranslationMode.BATCH, options);
optimizer.translate(pipeline);
TranslationMode translationMode = optimizer.getTranslationMode();
FlinkPipelineTranslator translator;
if (translationMode == TranslationMode.STREAMING) {
this.flinkStreamEnv = createStreamExecutionEnvironment();
translator = new FlinkStreamingPipelineTranslator(flinkRunner, flinkStreamEnv, options);
} else {
this.flinkBatchEnv = createBatchExecutionEnvironment();
translator = new FlinkBatchPipelineTranslator(flinkBatchEnv, options);
}
translator.translate(pipeline);
}
示例2: adaptBoundedReads
import org.apache.beam.sdk.Pipeline; //导入方法依赖的package包/类
@VisibleForTesting
void adaptBoundedReads(Pipeline pipeline) {
pipeline.replaceAll(
Collections.singletonList(
PTransformOverride.of(
PTransformMatchers.classEqualTo(BoundedReadFromUnboundedSource.class),
new AdaptedBoundedAsUnbounded.Factory())));
}
示例3: replaceTransforms
import org.apache.beam.sdk.Pipeline; //导入方法依赖的package包/类
@VisibleForTesting
protected void replaceTransforms(Pipeline pipeline) {
boolean streaming = options.isStreaming() || containsUnboundedPCollection(pipeline);
// Ensure all outputs of all reads are consumed before potentially replacing any
// Read PTransforms
UnconsumedReads.ensureAllReadsConsumed(pipeline);
pipeline.replaceAll(getOverrides(streaming));
}
示例4: translate
import org.apache.beam.sdk.Pipeline; //导入方法依赖的package包/类
public void translate(Pipeline pipeline) {
List<PTransformOverride> overrides =
ImmutableList.<PTransformOverride>builder()
.add(PTransformOverride.of(
PTransformMatchers.classEqualTo(View.CreatePCollectionView.class),
new CreateStreamingGearpumpView.Factory()))
.build();
pipeline.replaceAll(overrides);
pipeline.traverseTopologically(this);
}
示例5: run
import org.apache.beam.sdk.Pipeline; //导入方法依赖的package包/类
@Override
public DirectPipelineResult run(Pipeline originalPipeline) {
Pipeline pipeline;
try {
RunnerApi.Pipeline protoPipeline = PipelineTranslation.toProto(originalPipeline);
pipeline = PipelineTranslation.fromProto(protoPipeline);
} catch (IOException exception) {
throw new RuntimeException("Error preparing pipeline for direct execution.", exception);
}
pipeline.replaceAll(defaultTransformOverrides());
MetricsEnvironment.setMetricsSupported(true);
DirectGraphVisitor graphVisitor = new DirectGraphVisitor();
pipeline.traverseTopologically(graphVisitor);
@SuppressWarnings("rawtypes")
KeyedPValueTrackingVisitor keyedPValueVisitor = KeyedPValueTrackingVisitor.create();
pipeline.traverseTopologically(keyedPValueVisitor);
DisplayDataValidator.validatePipeline(pipeline);
DisplayDataValidator.validateOptions(getPipelineOptions());
DirectGraph graph = graphVisitor.getGraph();
EvaluationContext context =
EvaluationContext.create(
getPipelineOptions(),
clockSupplier.get(),
Enforcement.bundleFactoryFor(enabledEnforcements, graph),
graph,
keyedPValueVisitor.getKeyedPValues());
TransformEvaluatorRegistry registry = TransformEvaluatorRegistry.defaultRegistry(context);
PipelineExecutor executor =
ExecutorServiceParallelExecutor.create(
options.getTargetParallelism(),
registry,
Enforcement.defaultModelEnforcements(enabledEnforcements),
context);
executor.start(graph, RootProviderRegistry.defaultRegistry(context));
DirectPipelineResult result = new DirectPipelineResult(executor, context);
if (options.isBlockOnRun()) {
try {
result.waitUntilFinish();
} catch (UserCodeException userException) {
throw new PipelineExecutionException(userException.getCause());
} catch (Throwable t) {
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
throw new RuntimeException(t);
}
}
return result;
}
示例6: performDirectOverrides
import org.apache.beam.sdk.Pipeline; //导入方法依赖的package包/类
public static void performDirectOverrides(Pipeline p) {
p.replaceAll(
DirectRunner.fromOptions(PipelineOptionsFactory.create().as(DirectOptions.class))
.defaultTransformOverrides());
}