gaoyunhaii commented on a change in pull request #20: URL: https://github.com/apache/flink-ml/pull/20#discussion_r772109840
########## File path: flink-ml-core/src/main/java/org/apache/flink/ml/builder/Graph.java ########## @@ -0,0 +1,151 @@ +/* + * 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.flink.ml.builder; + +import org.apache.flink.annotation.PublicEvolving; +import org.apache.flink.ml.api.AlgoOperator; +import org.apache.flink.ml.api.Estimator; +import org.apache.flink.ml.api.Model; +import org.apache.flink.ml.api.Stage; +import org.apache.flink.ml.param.Param; +import org.apache.flink.ml.util.ParamUtils; +import org.apache.flink.ml.util.ReadWriteUtils; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.api.Table; +import org.apache.flink.util.Preconditions; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.ml.builder.GraphNode.StageType; + +/** + * A Graph acts as an Estimator. A Graph consists of a DAG of stages, each of which could be an + * Estimator, Model, Transformer or AlgoOperator. When `Graph::fit` is called, the stages are + * executed in a topologically-sorted order. If a stage is an Estimator, its `Estimator::fit` method + * will be called on the input tables (from the input edges) to fit a Model. Then the Model will be + * used to transform the input tables and produce output tables to the output edges. If a stage is + * an AlgoOperator, its `AlgoOperator::transform` method will be called on the input tables and + * produce output tables to the output edges. The GraphModel fitted from a Graph consists of the + * fitted Models and AlgoOperators, corresponding to the Graph's stages. + */ +@PublicEvolving +public final class Graph implements Estimator<Graph, GraphModel> { + private static final long serialVersionUID = 6354253958813529308L; + private final Map<Param<?>, Object> paramMap = new HashMap<>(); + private final List<GraphNode> nodes; + private final TableId[] estimatorInputIds; + private final TableId[] modelInputIds; + private final TableId[] outputIds; + private final TableId[] inputModelDataIds; + private final TableId[] outputModelDataIds; + + public Graph( + List<GraphNode> nodes, + TableId[] estimatorInputIds, + TableId[] modelInputs, + TableId[] outputs, + TableId[] inputModelDataIds, + TableId[] outputModelDataIds) { + this.nodes = nodes; Review comment: checkNotNull ? And similar to the other constructors if possible -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
