hadoop 计数器
生活随笔
收集整理的這篇文章主要介紹了
hadoop 计数器
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
一、hadoop有非常多自帶的計數(shù)器,相信看過執(zhí)行l(wèi)og的都會看到各種數(shù)據(jù) 二、用戶自己定義計數(shù)器 在開發(fā)中常常須要記錄錯誤的數(shù)據(jù)條數(shù),就能夠用計數(shù)器來解決。
2、使用 在map和reduce端均可使用,job會在技術后收集數(shù)據(jù)。 在須要記錄的地方: context.getCounter(RecordsCounter.WRONG_COUNTER).increment(1);
在run函數(shù)中,在job運行完后得到結果: Counters counters = job.getCounters(); Counter counter = counters.findCounter(RecordsCounter.WRONG_COUNTER); Long wrongCount = counter.getValue();
1、定義:用一個枚舉來定義一組計數(shù)器,枚舉中的每一個元素都是一個計數(shù)器
在main類中定義
enum RecordsCounter{RIGHT_COUNTER,WRONG_COUNTER};2、使用 在map和reduce端均可使用,job會在技術后收集數(shù)據(jù)。 在須要記錄的地方: context.getCounter(RecordsCounter.WRONG_COUNTER).increment(1);
在run函數(shù)中,在job運行完后得到結果: Counters counters = job.getCounters(); Counter counter = counters.findCounter(RecordsCounter.WRONG_COUNTER); Long wrongCount = counter.getValue();
轉載于:https://www.cnblogs.com/jzssuanfa/p/7121243.html
總結
以上是生活随笔為你收集整理的hadoop 计数器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [bzoj4625][BeiJing20
- 下一篇: iOS 更改项目名称