hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chengi Liu <chengi.liu...@gmail.com>
Subject Reducer to output only json
Date Tue, 04 Jun 2013 18:09:38 GMT
Hi,

 I have the following redcuer class

public static class TokenCounterReducer
    extends Reducer<Text, Text, Text, Text> {
    public void reduce(Text key, Iterable<Text> values, Context context)
        throws IOException, InterruptedException {

    //String[] fields = s.split("\t", -1)
    JSONObject jsn = new JSONObject();
        int sum = 0;
        for (Text value : values) {
        String[] vals = value.toString().split("\t");
        String[] targetNodes = vals[0].toString().split(",",-1);
        jsn.put("source",vals[1] );
        jsn.put("target",targetNodes);
            //sum += value.get();
        }
       // context.write(key, new Text(sum));
    }
}

I want to save that json to hdfs?

It was very trivial in hadoop streaming.. but how do i do it in hadoop java?
Thanks

Mime
View raw message