From dev-return-1370-archive-asf-public=cust-asf.ponee.io@nemo.apache.org Tue Oct 9 13:46:19 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 167FD1807BA for ; Tue, 9 Oct 2018 13:46:16 +0200 (CEST) Received: (qmail 42560 invoked by uid 500); 9 Oct 2018 11:46:11 -0000 Mailing-List: contact dev-help@nemo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nemo.apache.org Delivered-To: mailing list dev@nemo.apache.org Received: (qmail 41973 invoked by uid 99); 9 Oct 2018 11:46:10 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Oct 2018 11:46:10 +0000 From: GitBox To: dev@nemo.apache.org Subject: [GitHub] johnyangk commented on a change in pull request #122: [NEMO-213] Use Beam's DoFnRunners to execute DoFn Message-ID: <153908557029.3043.2383523740199598214.gitbox@gitbox.apache.org> Date: Tue, 09 Oct 2018 11:46:10 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit johnyangk commented on a change in pull request #122: [NEMO-213] Use Beam's DoFnRunners to execute DoFn URL: https://github.com/apache/incubator-nemo/pull/122#discussion_r223660577 ########## File path: compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/SimpleDoFnTransform.java ########## @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2018 Seoul National University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nemo.compiler.frontend.beam.transform; + +import org.apache.beam.runners.core.*; +import org.apache.beam.runners.core.construction.SerializablePipelineOptions; +import org.apache.beam.sdk.coders.Coder; +import org.apache.beam.sdk.options.PipelineOptions; +import org.apache.beam.sdk.transforms.DoFn; +import org.apache.beam.sdk.transforms.reflect.DoFnInvoker; +import org.apache.beam.sdk.transforms.reflect.DoFnInvokers; +import org.apache.beam.sdk.util.WindowedValue; +import org.apache.beam.sdk.values.PCollectionView; +import org.apache.beam.sdk.values.TupleTag; +import org.apache.beam.sdk.values.WindowingStrategy; +import org.apache.nemo.common.ir.OutputCollector; +import org.apache.nemo.common.ir.vertex.transform.Transform; +import org.apache.nemo.compiler.frontend.beam.NemoPipelineOptions; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * DoFn transform implementation. + * + * @param input type. + * @param output type. + */ +public final class SimpleDoFnTransform implements + Transform, WindowedValue> { + + private OutputCollector> outputCollector; + private final TupleTag mainOutputTag; + private final List> additionalOutputTags; + private final Collection> sideInputs; + private final WindowingStrategy windowingStrategy; + private final DoFn doFn; + private final SerializablePipelineOptions serializedOptions; + private transient DoFnRunner doFnRunner; + private transient SideInputReader sideInputReader; + private transient DoFnInvoker doFnInvoker; + private final Coder inputCoder; + private final Map, Coder> outputCoders; + + /** + * DoTransform Constructor. + * + * @param doFn doFn. + * @param options Pipeline options. + */ + public SimpleDoFnTransform(final DoFn doFn, + final Coder inputCoder, + final Map, Coder> outputCoders, + final TupleTag mainOutputTag, + final List> additionalOutputTags, + final WindowingStrategy windowingStrategy, + final Collection> sideInputs, + final PipelineOptions options) { + this.doFn = doFn; + this.inputCoder = inputCoder; + this.outputCoders = outputCoders; + this.mainOutputTag = mainOutputTag; + this.additionalOutputTags = additionalOutputTags; + this.sideInputs = sideInputs; + this.serializedOptions = new SerializablePipelineOptions(options); + this.windowingStrategy = windowingStrategy; + } + + @Override + public void prepare(final Context context, final OutputCollector> oc) { + // deserialize pipeline option + final NemoPipelineOptions options = serializedOptions.get().as(NemoPipelineOptions.class); + + this.outputCollector = oc; + + // create output manager + final DoFnRunners.OutputManager outputManager = new DefaultOutputManager<>( + outputCollector, context, mainOutputTag); + + // create side input reader + sideInputReader = NullSideInputReader.of(sideInputs); + if (!sideInputs.isEmpty()) { + sideInputReader = new BroadcastGlobalValueSideInputReader(context, sideInputs); + } Review comment: else { sideInputReader = NullSideInputReader.of(sideInputs); } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services