Hi there- Have you seen the chapter on MR in the RefGuide?
http://hbase.apache.org/book.html#mapreduce.example You use the Result instance just like you would from a client program. On 4/17/12 6:07 AM, "Ram" <[email protected]> wrote: > have a table called User with two columns ,one called visitorId and the >other >called friend which is a list of strings. I want to check whether the >VisitorId >is in the friendlist. Can anyone direct me as to how to access the table >columns >in a map function? I'm not able to picture how data is output from a map >function in hbase. My code is as follows. > >ublic class MapReduce { > >static class Mapper1 extends TableMapper<ImmutableBytesWritable, Text> { > > private int numRecords = 0; > private static final IntWritable one = new IntWritable(1); > > > private final IntWritable ONE = new IntWritable(1); > private Text text = new Text(); > @Override > public void map(ImmutableBytesWritable row, Result values, Context >context) >throws IOException { > > //What should i do here??how do i access the individual columns >and >compare? > ImmutableBytesWritable userKey = new >ImmutableBytesWritable(row.get(), >0, Bytes.SIZEOF_INT); > > context.write(userkey,One); > } > > //context.write(text, ONE); > } catch (InterruptedException e) { > throw new IOException(e); > } > > } >} > > > >public static void main(String[] args) throws Exception { > Configuration conf = HBaseConfiguration.create(); > Job job = new Job(conf, "CheckVisitor"); > job.setJarByClass(MapReduce.class); > Scan scan = new Scan(); > Filter f = new RowFilter(CompareOp.EQUAL,new >SubstringComparator("mId2")); > scan.setFilter(f); > scan.addFamily(Bytes.toBytes("visitor")); > scan.addFamily(Bytes.toBytes("friend")); > TableMapReduceUtil.initTableMapperJob("User", scan, Mapper1.class, >ImmutableBytesWritable.class,Text.class, job); > >} > >
