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_r223661085
########## 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 <InputT> input type. + * @param <OutputT> output type. + */ +public final class SimpleDoFnTransform<InputT, OutputT> implements + Transform<WindowedValue<InputT>, WindowedValue<OutputT>> { + + private OutputCollector<WindowedValue<OutputT>> outputCollector; + private final TupleTag<OutputT> mainOutputTag; + private final List<TupleTag<?>> additionalOutputTags; + private final Collection<PCollectionView<?>> sideInputs; + private final WindowingStrategy<?, ?> windowingStrategy; + private final DoFn<InputT, OutputT> doFn; + private final SerializablePipelineOptions serializedOptions; + private transient DoFnRunner<InputT, OutputT> doFnRunner; Review comment: Add a friendly note that `transient` means the fields should not be serialized? (I just learned it from https://stackoverflow.com/a/910522) ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
