OnPlacement メソッドの作成

このステップでは、onPlacement() メソッドから始まる GUI ノードのパラメータを選択します。

このチュートリアルで前述したように、onPlacement() メソッドは、ユーザーがオペレーターをサイドバーからワークフロー キャンバスにドラッグしたときのオペレーターの動作を定義します。このステップでは、TIBCO Data Science - Team Studio GUI からオペレーターを実行する際に、ユーザーが何を見、何を選択できるかを考えます。

出力データセットには出力する行数の整数が必要であるため、ここでそのパラメーターを追加します。さらに、ユーザーは結果データセットを保存する形式 (この場合は TSV、Avro、または Parquet)を選択できる必要があります。最後に、このジョブは Spark 上で実行されるため、ユーザーが Spark ジョブをカスタマイズできるようにパラメーターを追加します。

    手順
  1. 次のコードを追加します。
    override def onPlacement(
                            operatorDialog: OperatorDialog,
                            operatorDataSourceManager: OperatorDataSourceManager,
                            operatorSchemaManager: OperatorSchemaManager): Unit = {
        // add a parameter to the dialog so the user can enumerate the number of things (the
        // length of the dataset) to generate.
        operatorDialog.addIntegerBox(
            DatasetGeneratorUtils.numberRowsParamKey, // the constant we defined in DatasetGeneratorUtils, above
            "Number of things", // name of the parameter
            0, // minimum accepted value
            100,// maximum accepted value
            10 // default value
        )
        
        /*
        Use the HdfsParameterUtils class to add a dropdown list box, so the user can determine how the output data is stored (CSV, Avro, Parquet). Default to CSV.
        */
        HdfsParameterUtils.addHdfsStorageFormatParameter(operatorDialog, HdfsStorageFormatType.CSV)
        /*
        * Use the HdfsParameterUtils class to add parameters about how/where to store the output
        * dataset. In particular: the output directory, the output name, and whether to overwrite
        * anything already stored at that location.
        */
        HdfsParameterUtils.addStandardHdfsOutputParameters(operatorDialog)
        /*
        * Use the SparkParameterUtils class to add the some parameters to let the user configure the
        * Spark job.
        */
        SparkParameterUtils.addStandardSparkOptions(
            operatorDialog,
            additionalSparkParameters = List()
        )
        }