mapreduce - how to proceess individul file in hadoop using MR code -
i have file having fileds meterid, hour, watts ... , other field. made composite key meterid , hour , sum watts each hour each meterid. mr code work fine single file.
i have multiple file , file name date
14-05-2015.txt, 15-05-2015.txt etc.
i execute same code , add watts corresponding meterid , hour. want watts sum each file corresponding meter id , hour not file.
to solve easily, may include filename in composite key compose. group keys generated every file seperately before reduce phase.
so first have find file name mapper class's setup() method, may use below snippet in mapper setup() method,
string filename = ((filesplit) context.getinputsplit()).getpath().tostring();
add file name in composite key respective equality check implementations, , keys grouped considering file name solve problem. hope helps.
Comments
Post a Comment