Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


...

Page properties


Discussion thread

...

...

...

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyFLINK-23959

...

Releaseml-2.0.0


Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

...

Code Block
languagejava
/**
 * 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> {
    public Graph(List<GraphNode> nodes, TableId[] estimatorInputIds, TableId[] algoOpInputs, TableId[] outputs, TableId[] inputModelData, TableId[] outputModelData) {...}

    @Override
    public GraphModel fit(Table... inputs) {...}

    @Override
    public void save(String path) throws IOException {...}

    @Override
    public static Graph load(StreamTableEnvironment tEnv, String path) throws IOException {...}
}

...

Code Block
languagejava
/**
 * A GraphModel acts as a Model. A GraphModel consists of a DAG of stages, each of which could be an
 * Estimator, Model, Transformer or AlgoOperators. When `GraphModel::transform` is called, the
 * stages are executed in a topologically-sorted order. When a stage is executed, its
 * `AlgoOperator::transform` method will be called on the input tables (from the input edges) and
 * produce output tables to the output edges.
 */
public final class GraphModel implements Model<GraphModel> {

    public GraphModel(List<GraphNode> nodes, TableId[] inputIds, TableId[] outputIds, TableId[] inputModelData, TableId[] outputModelData) {...}

    @Override
    public Table[] transform(Table... inputTables) {...}

    @Override
    public void setModelData(Table... inputs) {...}

    @Override
    public Table[] getModelData() {...}

    @Override
    public void save(String path) throws IOException {...}

    public static GraphModel load(StreamTableEnvironment tEnv, String path) throws IOException {...}
}

...

Code Block
languagejava
/**
 * A GraphBuilder provides APIs to build Estimator/Model/AlgoOperator from a DAG of stages, each of
 * which could be an Estimator, Model, Transformer or AlgoOperator.
 */
@PublicEvolving
public final class GraphBuilder {     

     /**
     * Specifies the loose upper bound (could be loose) of the number of output tables that can be
 returned by the
  * returned by the* Model::getModelData() and AlgoOperator::transform() methods, for any stage
 involved in this
  * involved in this* Graph.
     *
     * <p>The default upper bound is 20.
     */
    public GraphBuilder setMaxOutputLengthsetMaxOutputTableNum(int maxOutputLength) {...}

    /**
     * Creates a TableId associated with this GraphBuilder. It can be used to specify the passing of
     * tables between stages, as well as the input/output tables of the Graph/GraphModel generated
     * by this builder.
     *
     * @return A TableId.
     */
    public TableId createTableId() {...}

    /**
     * Adds an AlgoOperator in the graph.
     *
     * <p>When the graph runs as Estimator, the transform() of the given AlgoOperator would be
     * invoked with the given inputs. Then when the GraphModel fitted by this graph runs, the
     * transform() of the given AlgoOperator would be invoked with the given inputs.
     *
     * <p>When the graph runs as AlgoOperator or Model, the transform() of the given AlgoOperator
     * would be invoked with the given inputs.
     *
     * @param<p>NOTE: algoOpthe Annumber AlgoOperatorof instance.
the returned TableIds does not * @param inputs A list of TableIds which represents inputs to transform() of the givenrepresent the actual number of Tables
     * outputted by transform(). This number could be configured using {@link
     * #setMaxOutputTableNum(int)}. Users should make AlgoOperator.
sure that this number >= *the @returnactual Anumber list of
 TableIds which represents the outputs of * Tables outputted by transform().
 of the  given *
     * @param algoOp An AlgoOperator AlgoOperatorinstance.
     */
 @param inputs A publiclist TableId[] addAlgoOperator(AlgoOperator<?> algoOp, TableId... inputs) {...}

    /**of TableIds which represents inputs to transform() of the given
     * Adds an Estimator in the graphAlgoOperator.
     *
 @return A list of TableIds *which <p>Whenrepresents the graphoutputs runsof as Estimator, the fit() transform() of the given
 Estimator would be invoked with
*     *AlgoOperator.
 the given inputs. Then when*/
 the GraphModel fitted bypublic this graph runs, the transform() of theTableId[] addAlgoOperator(AlgoOperator<?> algoOp, TableId... inputs) {...}

     /** Model
 fitted by the given Estimator* wouldAdds bean invokedEstimator within the given inputsgraph.
     *
     * <p>When the graph runs as AlgoOperatorEstimator, orthe Model, the fit() of the given Estimator would be invoked with
     * invoked with the given inputs. Then when the given inputs, then GraphModel fitted by this graph runs, the transform() of the
     * Model fitted by the given
     * Estimator would be invoked with the given inputs.
     *
     * @param<p>When estimatorthe Angraph Estimatorruns instance.
as AlgoOperator or   * @param inputs A list of TableIds which represents inputs to Model, the fit() of the given Estimator aswould be
     * invoked with the given wellinputs, asthen inputs tothe transform() of the Model fitted by the given Estimator.
     * @returnEstimator Awould listbe ofinvoked TableIdswith which represents the outputsgiven of transform() of the Model fitted byinputs.
     *
     * <p>NOTE: the number of the givenreturned Estimator.
TableIds does not represent the */
actual number of Tables
 public  TableId[] addEstimator(Estimator<?, ?> estimator, TableId... inputs) {...}

    /** * outputted by transform(). This number could be configured using {@link
     * Adds an Estimator in the graph.
     *#setMaxOutputTableNum(int)}. Users should make sure that this number >= the actual number of
     * <p>When the graph runs as Estimator, the fit() of the given Estimator would be invoked with Tables outputted by transform().
     *
     * @param estimator An Estimator instance.
     * estimatorInputs.@param Theninputs whenA thelist GraphModelof fittedTableIds bywhich thisrepresents graphinputs runs, the transformto fit() of the given Estimator as
     *  Model fitted by thewell givenas Estimatorinputs wouldto betransform() invokedof withthe modelInputs.
Model fitted by the given *Estimator.
     * <p>When@return A thelist graphof runsTableIds aswhich AlgoOperatorrepresents orthe Model,outputs theof fittransform() of the givenModel Estimatorfitted would beby
     * invoked with estimatorInputs, then the transform() of the Model fitted by the given Estimator
     * would be invoked with modelInputs.given Estimator.
     */
    public TableId[] addEstimator(Estimator<?, ?> estimator, TableId... inputs) {...}

     /**
     * Adds @paraman estimatorEstimator Anin Estimatorthe instancegraph.
     *
 @param   estimatorInputs A* list<p>When ofthe TableIdsgraph whichruns representsas inputsEstimator, tothe fit() of the given
 Estimator would be  *     Estimator.invoked with
     * estimatorInputs. @paramThen modelInputswhen Athe listGraphModel offitted TableIdsby whichthis representsgraph inputsruns, tothe transform() of the Model
     * Model    fitted by the given Estimator would be invoked with modelInputs.
     *
     @return* A<p>When listthe ofgraph TableIdsruns whichas representsAlgoOperator theor outputsModel, ofthe transformfit() of the given ModelEstimator fittedwould bybe
     * invoked with estimatorInputs, then the given Estimatortransform() of the Model fitted by the given Estimator
     * would be invoked with modelInputs.
     */
     public TableId[] addEstimator(
            Estimator<?, ?> estimator, TableId[] estimatorInputs, TableId[] modelInputs) {...}

    /** <p>NOTE: the number of the returned TableIds does not represent the actual number of Tables
     * outputted by transform(). This number could be configured using {@link
     * #setMaxOutputTableNum(int)}. Users should make sure that this number >= the actual number of
     * Tables outputted by transform().
     *
     * @param estimator An Estimator instance.
     * @param estimatorInputs A list of TableIds which represents inputs to fit() of the given
     *     Estimator.
     * @param modelInputs A list of TableIds which represents inputs to transform() of the Model
     *     fitted by the given Estimator.
     * @return A list of TableIds which represents the outputs of transform() of the Model fitted by
     *     the given Estimator.
     */
    public TableId[] addEstimator(
            Estimator<?, ?> estimator, TableId[] estimatorInputs, TableId[] modelInputs) {...}

    /**
     * When the graph runs as Estimator, it first generates a GraphModel that contains the Model
     * fitted by the given Estimator. Then when this GraphModel runs, the setModelData() of the
     * fitted Model would be invoked with the given inputs before its transform() is invoked.
     *
     * <p>When the graph runs as AlgoOperator or Model, the setModelData() of the Model fitted by
     * the given Estimator would be invoked with the given inputs before its transform() is invoked.
     *
     * @param estimator An Estimator instance.
     * @param inputs A list of TableIds which represents inputs to setModelData() of the Model
     *     fitted by the given Estimator.
     */
    public void setModelDataOnEstimator(Estimator<?, ?> estimator, TableId... inputs) {...}

    /**
     * When the graph runs as Estimator, the setModelData() of the given Model would be invoked with
     * the given inputs before its transform() is invoked. Then when the GraphModel fitted by this
     * graph runs, the setModelData() of the given Model would be invoked with the given inputs.
     *
     * <p>When the graph runs as AlgoOperator or Model, the setModelData() of the given Model would
     * be invoked with the given inputs before its transform() is invoked.
     *
     * @param model A Model instance.
     * @param inputs A list of TableIds which represents inputs to setModelData() of the given
     *     Model.
     */
    public void setModelDataOnModel(Model<?> model, TableId... inputs) {...}

    /**
     * When the graph runs as Estimator, it first generates a GraphModel that contains the Model
     * fitted by the given Estimator. Then when this GraphModel runs, the getModelData() of the
     * fitted Model would be invoked.
     *
     * <p>When the graph runs as AlgoOperator or Model, the getModelData() of the Model fitted by
     * the given Estimator would be invoked.
     *
     * <p>NOTE: the number of the returned TableIds does not represent the actual number of Tables
     * outputted by getModelData(). This number could be configured using {@link
     * #setMaxOutputTableNum(int)}. Users should make sure that this number >= the actual number of
     * Tables outputted by getModelData().
     *
     * @param estimator An Estimator instance.
     * @return A list of TableIds which represents the outputs of getModelData() of the Model fitted
     *     by the given Estimator.
     */
    public TableId[] getModelDataFromEstimator(Estimator<?, ?> estimator) {...}

    /**
     * When the graph runs as Estimator, the getModelData() of the given Model would be invoked.
     * Then when the GraphModel fitted by this graph runs, the getModelData() of the given Model
     * would be invoked.
     *
     * When<p>When the graph runs as Estimator, AlgoOperator or Model, the setModelDatagetModelData() of the given Model would
     * Model would be invoked with the given inputs.
     *
     * @param<p>NOTE: modelthe Anumber Modelof instance.
the     * @param inputs A list of returned TableIds whichdoes represents inputs to setModelData() of the given
     *     Model.
     */not represent the actual number of Tables
    public void setModelData(Model<?> model, TableId... inputs) {...}

    /*** outputted by getModelData(). This number could be configured using {@link
     * When the graph runs as Estimator, AlgoOperator or Model, the getModelData() of the given#setMaxOutputTableNum(int)}. Users should make sure that this number >= the actual number of
     * ModelTables wouldoutputted beby invokedgetModelData().
     *
     * @param model A Model instance.
     * @return A list of TableIds which represents the outputs of getModelData() of the given Model.
     */
    public TableId[] getModelDatagetModelDataFromModel(Model<?> model) {...}

    /**
     * Wraps nodes of the graph into an Estimator.
     *
     * <p>When the returned Estimator runs, and when the Model fitted by the returned Estimator
     * runs, the sequence of operations recorded by the {@code addAlgoOperator(...)}, {@code
     * addEstimator(...)}, {@code setModelData(...)} and {@code getModelData(...)} would be executed
     * as specified in the Java doc of the corresponding methods.
     *
     * @param inputs A list of TableIds which represents inputs to fit() of the returned Estimator
     *     as well as inputs to transform() of the Model fitted by the returned Estimator.
     * @param outputs A list of TableIds which represents outputs of transform() of the Model fitted
     *     by the returned Estimator.
     * @return An Estimator which wraps the nodes of this graph.
     */
    public Estimator<?, ?> buildEstimator(TableId[] inputs, TableId[] outputs) {...}

    /**
     * Wraps nodes of the graph into an Estimator.
     *
     * <p>When the returned Estimator runs, and when the Model fitted by the returned Estimator
     * runs, the sequence of operations recorded by the {@code addAlgoOperator(...)}, {@code
     * addEstimator(...)}, {@code setModelData(...)} and {@code getModelData(...)} would be executed
     * as specified in the Java doc of the corresponding methods.
     *
     * @param inputs A list of TableIds which represents inputs to fit() of the returned Estimator
     *     as well as inputs to transform() of the Model fitted by the returned Estimator.
     * @param outputs A list of TableIds which represents outputs of transform() of the Model fitted
     *     by the returned Estimator.
     * @param inputModelData A list of TableIds which represents inputs to setModelData() of the
     *     Model fitted by the returned Estimator.
     * @param outputModelData A list of TableIds which represents outputs of getModelData() of the
     *     Model fitted by the returned Estimator.
     * @return An Estimator which wraps the nodes of this graph.
     */
    public Estimator<?, ?> buildEstimator(
            TableId[] inputs,
            TableId[] outputs,
            TableId[] inputModelData,
            TableId[] outputModelData) {...}

    /**
     * Wraps nodes of the graph into an Estimator.
     *
     * <p>When the returned Estimator runs, and when the Model fitted by the returned Estimator
     * runs, the sequence of operations recorded by the {@code addAlgoOperator(...)}, {@code
     * addEstimator(...)}, {@code setModelData(...)} and {@code getModelData(...)} would be executed
     * as specified in the Java doc of the corresponding methods.
     *
     * @param estimatorInputs A list of TableIds which represents inputs to fit() of the returned
     *     Estimator.
     * @param modelInputs A list of TableIds which represents inputs to transform() of the Model
     *     fitted by the returned Estimator.
     * @param outputs A list of TableIds which represents outputs of transform() of the Model fitted
     *     by the returned Estimator.
     * @param inputModelData A list of TableIds which represents inputs to setModelData() of the
     *     Model fitted by the returned Estimator.
     * @param outputModelData A list of TableIds which represents outputs of getModelData() of the
     *     Model fitted by the returned Estimator.
     * @return An Estimator which wraps the nodes of this graph.
     */
    public Estimator<?, ?> buildEstimator(
            TableId[] estimatorInputs,
            TableId[] modelInputs,
            TableId[] outputs,
            TableId[] inputModelData,
            TableId[] outputModelData) {...}

    /**
     * Wraps nodes of the graph into an AlgoOperator.
     *
     * <p>When the returned AlgoOperator runs, the sequence of operations recorded by the {@code
     * addAlgoOperator(...)} and {@code addEstimator(...)} would be executed as specified in the
     * Java doc of the corresponding methods.
     *
     * @param inputs A list of TableIds which represents inputs to transform() of the returned
     *     AlgoOperator.
     * @param outputs A list of TableIds which represents outputs of transform() of the returned
     *     AlgoOperator.
     * @return An AlgoOperator which wraps the nodes of this graph.
     */
    public AlgoOperator<?> buildAlgoOperator(TableId[] inputs, TableId[] outputs) {...}

    /**
     * Wraps nodes of the graph into a Model.
     *
     * <p>When the returned Model runs, the sequence of operations recorded by the {@code
     * addAlgoOperator(...)} and {@code addEstimator(...)} would be executed as specified in the
     * Java doc of the corresponding methods.
     *
     * @param inputs A list of TableIds which represents inputs to transform() of the returned
     *     Model.
     * @param outputs A list of TableIds which represents outputs of transform() of the returned
     *     Model.
     * @return A Model which wraps the nodes of this graph.
     */
    public Model<?> buildModel(TableId[] inputs, TableId[] outputs) {...}

    /**
     * Wraps nodes of the graph into a Model.
     *
     * <p>When the returned Model runs, the sequence of operations recorded by the {@code
     * addAlgoOperator(...)}, {@code addEstimator(...)}, {@code setModelData(...)} and {@code
     * getModelData(...)} would be executed as specified in the Java doc of the corresponding
     * methods.
     *
     * @param inputs A list of TableIds which represents inputs to transform() of the returned
     *     Model.
     * @param outputs A list of TableIds which represents outputs of transform() of the returned
     *     Model.
     * @param inputModelData A list of TableIds which represents inputs to setModelData() of the
     *     returned Model.
     * @param outputModelData A list of TableIds which represents outputs of getModelData() of the
     *     returned Model.
     * @return A Model which wraps the nodes of this graph.
     */
    public Model<?> buildModel(
            TableId[] inputs,
            TableId[] outputs,
            TableId[] inputModelData,
            TableId[] outputModelData) {...}
}

...