運用MRUnit測試mapper和reducer

來源:互聯網
上載者:User

標籤:

MRUnit可以花費時間少,並且可以分別測試mapper和reducer

步驟:

1、  運用MRUnit測試mapper和reducer

2、  執行mapreduce代碼的本地化測試

3、  使用hadoop日誌

4、  通過計數器跟蹤執行指標

Testing Mapper的過程

1、  執行個體化mapdirver類,作為測試中mapper被參數化

2、  調用withmapper方法來添加想要測試的mapper執行個體

3、  根據情況選擇withconfiguration方法設定mapper的設定檔

4、  調用withinput方法來傳遞所需的key和value

5、  通過調用withoutput方法設定期望的輸出內容

6、  調用功能rantest方法將設定的輸入值傳遞給mapper

Testing Reducer的過程

1、  首先建立一個用做reducer輸入的intwritable對象列表

2、  執行個體化reducedriver對象

3、  調用withreduce方法來設定要測試的reducer執行個體

4、  通過withconfiguration來傳遞想要的配置

5、  調用withinput方法可以將輸入值傳遞給reducer

6、  調用withoutput方法來設定期望的reducer輸出

7、  最後調用runtest方法,把設定的輸入傳遞給reducer

 

運用MRUnit測試mapper和reducer

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.