Hi again,
I need some help with a map/reduce program I have which copies data from one
table to another. What I would like to do is iterate through an entire
HBase table, and for a given row key and column family count the number of
records. So the output table will have a single column family named 'count'
(e.g. entry would look something like 'rowKey1', 'count:count_for_rowkey1',
'534', where the rowkey could be the same as input table ).
here is my first attempt:
CONF:
=========================================================================
c.setInputFormat(TableInputFormat.class);
c.setOutputFormat(TableOutputFormat.class);
TableMapReduceUtil.initTableMapJob("inputTableName", "colFam1:*",
MapperClass.class,
ImmutableBytesWritable.class, RowResult.class, c);
TableMapReduceUtil.initTableReduceJob("outputTableName",
ReducerClass.class, c );
MapperClass:
=====================================================================
@Override
public void map(
ImmutableBytesWritable key,
RowResult row,
OutputCollector<ImmutableBytesWritable,
RowResult> collector,
Reporter reporter) throws IOException {
reporter.incrCounter(Counters.ROWS, 1);
collector.collect(key, row);
}
ReducerClass:================================================================
@Override
public void reduce(ImmutableBytesWritable k,
Iterator<RowResult> v,
OutputCollector<ImmutableBytesWritable,
BatchUpdate> c,
Reporter r) throws IOException {
while (v.hasNext()){
BatchUpdate bu = new BatchUpdate(k.get());
while (v.hasNext()){
RowResult row = v.next();
bu.put(Bytes.toBytes("count:rowToCountName"),
Bytes.toBytes(row.size()));
}
c.collect(k, bu);
}
}
========================================================================
It runs the map/reduce, but I get nothing in my output table.
Thanks.
llpind
--
View this message in context:
http://www.nabble.com/Help-with-Map-Reduce-program-tp23952252p23952252.html
Sent from the HBase User mailing list archive at Nabble.com.