Powered by Zoomin Software. For more details please contactZoomin

MarkLogic Data Hub

Gradleを使用

  • Last Updated: April 5, 2026
  • 14 minute read

Gradleによるステップの作成とフローへの追加

準備

以下が必要です。

このタスクについて

フローには少なくとも1つのステップを含める必要があります。ステップを作成する方法は2つあります。

  • ステップのサンプルをカスタマイズする。Gradleによるフローの作成を行った場合、結果として得られたフロー定義ファイルには、事前定義された各ステップタイプ(読み込み、マッピング、マッチング、マージング、マスタリング)ごとにステップのサンプルが含まれています。これらのステップをカスタマイズしていきます。
  • Gradleによるステップの作成とカスタマイズ。Gradleタスク**hubCreateStepDefinition**を使って、ステップ定義の初期化、フロー定義へのコピー、カスタマイズができます。

フロー定義ファイルで直接設定したステップ、あるいはGradleタスク**hubCreateStepDefinitionを実行することで作成されたステップ定義を使用したステップは、QuickStartが生成したカスタムステップと同等になっています。hubCreateStepDefinitionのstepDefTypeパラメータは、QuickStartのCustom Step Typeフィールドと同等です。1つ違うのは、Gradleシンタックスの-PstepDefType=customは、QuickStartではCustom Step Type**のOtherとなっているところです。

このタスクでは、Gradleによるステップ定義の作成およびカスタマイズの方法について説明します。

手順

これらの内容をカスタマイズするには、作成するステップのタイプを選択します。

読み込みマッピングマスタリングカスタム

  1. Gradleでステップ定義を作成します。
    1. コマンドラインウィンドウを開き、プロジェクトのルートディレクトリに移動します。

    2. プロジェクトルートで、Gradleタスク**hubCreateStepDefinition**を実行します。その際、stepType:ingestion、stepType:mapping、stepType:matching、stepType:merging、stepType:mastering、stepType:customと設定します。

      Unixシステム

./gradlew hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion -i
    **Windows**
gradlew.bat hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion -i
    **Unixシステム**
./gradlew hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping -i
    **Windows**
gradlew.bat hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping -i
    **Unixシステム**
./gradlew hubCreateStepDefinition -PstepDefName=your-matching-step-name -PstepDefType=matching -i
    **Windows**
gradlew.bat hubCreateStepDefinition -PstepDefName=your-matching-step-name -PstepDefType=matching -i
    **Unixシステム**
./gradlew hubCreateStepDefinition -PstepDefName=your-merging-step-name -PstepDefType=merging -i
    **Windows**
gradlew.bat hubCreateStepDefinition -PstepDefName=your-merging-step-name -PstepDefType=merging -i
    **Unixシステム**
./gradlew hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering -i
    **Windows**
gradlew.bat hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering -i
    **Unixシステム**
./gradlew hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom -i
    **Windows**
gradlew.bat hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom -i
    XQueryモジュール(デフォルトのJavaScriptモジュールではなく)をステップ定義に関連付けたい場合、`-Pformat=xqy`オプションを追加します。これにより、XQueryのサンプルモジュール(カスタマイズ可能)およびJavaScriptラッパーが作成されます。
    
    <div class="note">
    
    **注:**デフォルトのstepTypeは、`custom`です。
    
    </div>
    
    **Result:**
    
    以下のファイルが作成されます。
    
    *   ステップ定義ファイル
your-project-root/step-definitions/ingestion/your-ingestion-step-name/your-ingestion-step-name.step.json
your-project-root/step-definitions/mapping/your-mapping-step-name/your-mapping-step-name.step.json
your-project-root/step-definitions/matching/your-matching-step-name/your-matching-step-name.step.json
your-project-root/step-definitions/merging/your-merging-step-name/your-merging-step-name.step.json
your-project-root/step-definitions/mastering/your-mastering-step-name/your-mastering-step-name.step.json
your-project-root/step-definitions/custom/your-custom-step-name/your-custom-step-name.step.json
    *   カスタムモジュールファイル
your-project-root/src/main/ml-modules/root/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs
your-project-root/src/main/ml-modules/root/custom-modules/mapping/your-mapping-step-def-name/main.sjs
your-project-root/src/main/ml-modules/root/custom-modules/matching/your-matching-step-def-name/main.sjs
your-project-root/src/main/ml-modules/root/custom-modules/merging/your-merging-step-def-name/main.sjs
your-project-root/src/main/ml-modules/root/custom-modules/mastering/your-mastering-step-def-name/main.sjs
your-project-root/src/main/ml-modules/root/custom-modules/custom/your-custom-step-def-name/main.sjs
    ステップ定義内のmodulePath設定により、カスタムモジュールファイルが指定されます。
  1. 手作業でこのステップをフローに追加します。

    1. テキストエディタで、ステップ定義ファイルを開きます。

      カスタムの読み込みステップ定義ファイルには、以下が含まれています。

   {
    "language" : "zxx",
    "name" : "your-ingestion-step-def-name",
    "description" : null,
    "type" : "INGESTION",
    "version" : 1,
    "options" : {
      "collections" : [ "your-ingestion-step-def-name" ],
      "outputFormat" : "json",
      "targetDatabase" : "data-hub-STAGING"
    },
    "customHook" : { },
    "modulePath" : "/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs",
    "retryLimit" : 0,
    "batchSize" : 100,
    "threadCount" : 4,
    "fileLocations" : {
      "inputFilePath" : "",
      "outputURIReplacement" : "",
      "inputFileType" : ""
    }
  }

2.  同様に、フロー定義ファイルを開きます。
    
    フロー定義ファイルは、`your-project-root/flows`にあります。
    
    デフォルトのフロー定義ファイルにはステップがなく、以下のようになっています。
   {
    "name": "your-flow-name",
    "description": "",
    "batchSize": 100,
    "threadCount": 4,
    "options": {
      "sourceQuery": null
    },
    "steps": {}
  }

3.  `steps`ノードに、ステップをキー/バリューペアとして追加します。
    
    *   キーとして、シーケンスのステップの順序を示す数字を含む文字列を入力します。 <div class="note">
        
        **注:**フローの`steps`ノード内のキーが一意である限り、ステップは任意の順番で記載できます。キーが重複していた場合、予想外の結果が生じる場合があります。キーの数字は0より大きい値にしてください。
        
        </div>
    *   バリューとして、ステップ定義ファイルのコンテンツ全体をコピーして貼り付けます。
    
4.  フロー定義ファイル内のステップを編集します。
    
    *   nameをstepDefinitionNameに変更します。
    *   typeをstepDefinitionTypeに変更します。
    *   nameを新規作成し、ステップの名前を付けます。
    *   (オプション)次の設定を削除します。
        
        *   language
        *   version
        *   modulePath
        
        これらの設定の値は、ステップ定義から取得されます。
        
    

最初のステップ(「1」)としてデフォルトの読み込みステップをデフォルトのフローに追加すると、フロー定義ファイルは次のようになります。
   {
    "name": "your-flow-name",
    "description": "",
    "batchSize": 100,
    "threadCount": 4,
    "options": {
      "sourceQuery": null
    },
    "steps": {
      "1": {
        "name" : "your-step-name",
        "stepDefinitionName" : "your-ingestion-step-def-name",
        "description" : null,
        "stepDefinitionType" : "INGESTION",
        "options" : {
          "collections" : [ "your-ingestion-step-name" ],
          "outputFormat" : "json",
          "targetDatabase" : "data-hub-STAGING"
        },
        "customHook" : { },
        "retryLimit" : 0,
        "batchSize" : 100,
        "threadCount" : 4,
        "fileLocations" : {
          "inputFilePath" : "",
          "outputURIReplacement" : "",
          "inputFileType" : ""
        }
      }
    }
  }

次に行うこと

See Also

前のトピック:Gradleによるフローの作成

次のトピック:Gradleによるフローの実行

関連するコンセプト

関連するタスク

関連するリファレンス

TitleResults for “How to create a CRG?”Also Available inAlert