Write A Mapreduce Program To Find Dept Wise Salary. Empno Empname Dept Salary
Write A Mapreduce Program To Find Dept Wise Salary. Empno Empname Dept Salary
Mapper.py
#!/usr/bin/env python
import sys
line=line.strip()
words=line.split()
size=len(words)
Reducer.py
#!/usr/bin/env python
import sys
current_dept=None
dept=None
current_sal=0
line=line.strip()
dept,sal=line.split('\t',1)
try:
sal=int(sal)
except ValueError:
continue
if current_dept==dept:
current_sal+=sal
else:
if current_dept:
current_dept=dept
current_sal=sal
if current_dept==dept:
Input.txt
Output
Job Counters
Map-Reduce Framework
Spilled Records=20
Shuffled Maps =2
Failed Shuffles=0
Shuffle Errors
BAD_ID=0
CONNECTION=0
IO_ERROR=0
WRONG_LENGTH=0
WRONG_MAP=0
WRONG_REDUCE=0
Bytes Read=288
Bytes Written=42
Found 2 items
CSE 211000
ECE 91000
EEE 50000
Mech 80000
[cloudera@quickstart ~]$