hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ninad Raut <hbase.user.ni...@gmail.com>
Subject Re: Doubt in implementing TableReduce Interface
Date Tue, 28 Jul 2009 07:55:42 GMT
the method looks fine. Put some logging inside the reduce method to trace
the inputs to the reduce.  Here's an example... change IntWritable to Text
in your case...
 static class ReadTableReduce2 extends MapReduceBase implements
TableReduce<Text, IntWritable>{

  SortedMap<Text, Text> buzz = new TreeMap<Text, Text>();
  @Override
  public void reduce(Text key,
  Iterator<IntWritable> values,
  OutputCollector<ImmutableBytesWritable, BatchUpdate> output,
  Reporter report) throws IOException {

  Integer sum =0;
  while(values.hasNext()) {
  sum += values.next().get();
  }
  if (sum >=3) {
  BatchUpdate outval = new BatchUpdate(rowCounter.toString());
  String keyStr = key.toString();
  String[] keyArr=keyStr.split(":");
  outval.put("buzzcount:"+keyArr[1], sum.toString().getBytes());
  report.incrCounter(Counters.REDUCE_LINES, 1);
  report.setStatus("sum:"+sum);
  rowCounter++;
  output.collect(new ImmutableBytesWritable(key.getBytes()), outval);
  }

  }


On Fri, Jul 24, 2009 at 11:29 PM, bharath vissapragada <
bharat_v@students.iiit.ac.in> wrote:

> Hi all,
>
> i have implemented TableMap interface succesfully to emit <Text,Text> pairs
> .. so now i must implement TableReduce interface to receive those
> <Text,Text> pairs correspondingly ...  Is the following code correct
>
> public class MyTableReduce
> extends MapReduceBase
> implements TableReduce<Text, Text> {
>
>  public void reduce(Text key, Iterator<Text> values,
>      OutputCollector<ImmutableBytesWritable, BatchUpdate> output,
>      @SuppressWarnings("unused") Reporter reporter)
>      throws IOException {
> }
> }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message