Utils オブジェクトの作成

次に、オペレーターのさまざまなクラス間で使用するいくつかのユーティリティ関数と定数を保持する Utils オブジェクトを作成します。

    手順
  1. DatasetGeneratorUtils というオブジェクトを作成します。
    object DatasetGeneratorUtils {
    }
  2. このオブジェクト内に以下を追加します。
    • このチュートリアルの後半で入力に使用するパラメーター キーの定数。
    • 結果 DataFrame の出力スキーマを取得する関数。
    /**
        * The key for the parameter for the "Number of Things"
    	*/
    	val numberRowsParamKey = "number"

    この変数は、次のセクションの GUI ノードと Spark ジョブで参照されます。

  3. 結果の出力スキーマを定義する関数を追加します。

    この関数は、設計時 (オペレーターを実行する前に、オペレーターのパラメーターを設定しているとき)に使用されます。この例では、一連のカラム定義 (stringint)から表形式のスキーマを作成します。

    def getOutputSchema(params: OperatorParameters) : TabularSchema = {
        // create an return a tabular schema object
          TabularSchema(Seq(
            ColumnDef("Thing", ColumnType.String), // the first field in our output dataset
            ColumnDef("Number", ColumnType.Int))  // the second field in our output dataset
          )
      }
次に行うアクションGUI ノード クラスを作成します