Perfect Balanceのインストール・ディレクトリには、Perfect Balance APIを使用するJava MapReduceプログラムの完全な例(入力データを含む)が含まれています。
転置インデックスの例と実行方法については、orabalancer-<version>-h2/examples/invindx/README.txt
を参照してください。
変更されたJavaコードを探すには、orabalancer-<version>-h2/examples/jsrc/oracle/hadoop/balancer/examples/invindx/InvertedIndexMapred.java
またはInvertedIndexMapreduce.java
を参照してください。
Perfect Balanceを実行するための変更には、次のものが含まれます。
createBalancer
メソッドは、構成プロパティを検証し、Balancer
インスタンスを返します。
waitForCompletion
メソッドは、データをサンプリングし、パーティショニング・プランを作成します。
addBalancingPlan
メソッドは、パーティショニング・プランをジョブ構成設定に追加します。
configureCountingReducer
メソッドは、追加のロード統計を収集します。
save
メソッドは、パーティショニング・レポートを保存し、Job Analyzerレポートを生成します。
例5-3は、転置インデックスのJavaコードの一部を示したものです。
関連項目:
Oracle Big Data Appliance Perfect Balance Java APIリファレンス
例5-3 MapReduceジョブでのPerfect Balanceの実行
. . . import oracle.hadoop.balancer.Balancer; . . . ///// BEGIN: CODE TO INVOKE BALANCER (PART-1, before job submission) ////// Configuration conf = job.getConfiguration(); Balancer balancer = null; boolean useBalancer = conf.getBoolean("oracle.hadoop.balancer.driver.balance", true); if(useBalancer) { balancer = Balancer.createBalancer(conf); balancer.waitForCompletion(); balancer.addBalancingPlan(conf); } if(conf.getBoolean("oracle.hadoop.balancer.tools.useCountingReducer", true)) { Balancer.configureCountingReducer(conf); } ////////////// END: CODE TO INVOKE BALANCER (PART-1) ////////////////////// boolean isSuccess = job.waitForCompletion(true); /////////////////////////////////////////////////////////////////////////// // BEGIN: CODE TO INVOKE BALANCER (PART-2, after job completion, optional) // If balancer ran, this saves the partition file report into the _balancer // sub-directory of the job output directory. It also writes a JobAnalyzer // report. Balancer.save(job); ////////////// END: CODE TO INVOKE BALANCER (PART-2) ////////////////////// . . . }