erenavsarogullari commented on a change in pull request #3109: Add withStream() in Streamlet to support stream selection URL: https://github.com/apache/incubator-heron/pull/3109#discussion_r235563887
########## File path: heron/api/src/java/org/apache/heron/streamlet/impl/operators/SplitOperator.java ########## @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.heron.streamlet.impl.operators; + +import java.util.Map; + +import org.apache.heron.api.topology.OutputFieldsDeclarer; +import org.apache.heron.api.tuple.Fields; +import org.apache.heron.api.tuple.Tuple; +import org.apache.heron.api.tuple.Values; +import org.apache.heron.streamlet.SerializablePredicate; +import org.apache.heron.streamlet.impl.utils.StreamletUtils; + +/** + * SplitOperator is the class that implements the split functionality. + * It takes in the split function as the input and use it to process tuples and + * get the output stream id and emit to the specific streams. + * Note that one tuple can be emitted to multiple or zero streams. + */ +public class SplitOperator<R> extends StreamletOperator<R, R> { + private Map<String, SerializablePredicate<R>> splitFns; + + public SplitOperator(Map<String, SerializablePredicate<R>> splitFns) { + this.splitFns = splitFns; + // Make sure stream ids are not empty + for (String stream: splitFns.keySet()) { Review comment: This is already checked upper level ---------------------------------------------------------------- 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
