package FlowCount2;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FlowCountReducer extends Reducer<Text, FlowBean, Text, FlowBean> {

    @Override
    protected void reduce(Text key, Iterable<FlowBean> values, Context context) throws IOException, InterruptedException {
        long sumUpFLow =0;
        long sumDownFLow =0;
        for(FlowBean value_i: values) {
            sumUpFLow+=value_i.getUpFlow();
            sumDownFLow+=value_i.getDownFlow();
        }

        context.write(key, new FlowBean(sumUpFLow, sumDownFLow));
    }
}