Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03FC391A4 for ; Tue, 17 Apr 2012 12:24:39 +0000 (UTC) Received: (qmail 50237 invoked by uid 500); 17 Apr 2012 12:24:37 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 50195 invoked by uid 500); 17 Apr 2012 12:24:37 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 50187 invoked by uid 99); 17 Apr 2012 12:24:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2012 12:24:37 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of doug.meil@explorysmedical.com designates 216.32.181.182 as permitted sender) Received: from [216.32.181.182] (HELO ch1outboundpool.messaging.microsoft.com) (216.32.181.182) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2012 12:24:29 +0000 Received: from mail157-ch1-R.bigfish.com (10.43.68.230) by CH1EHSOBE003.bigfish.com (10.43.70.53) with Microsoft SMTP Server id 14.1.225.23; Tue, 17 Apr 2012 12:24:08 +0000 Received: from mail157-ch1 (localhost [127.0.0.1]) by mail157-ch1-R.bigfish.com (Postfix) with ESMTP id 4F59D3402D7 for ; Tue, 17 Apr 2012 12:24:08 +0000 (UTC) X-SpamScore: -11 X-BigFish: PS-11(zzbb2dI9371I1432N98dKzz1202hzz8275bh8275dhz2fh2a8h668h839h944h) X-Forefront-Antispam-Report: CIP:157.56.244.181;KIP:(null);UIP:(null);IPV:NLI;H:CH1PRD0410HT001.namprd04.prod.outlook.com;RD:none;EFVD:NLI Received-SPF: pass (mail157-ch1: domain of explorysmedical.com designates 157.56.244.181 as permitted sender) client-ip=157.56.244.181; envelope-from=doug.meil@explorysmedical.com; helo=CH1PRD0410HT001.namprd04.prod.outlook.com ;.outlook.com ; Received: from mail157-ch1 (localhost.localdomain [127.0.0.1]) by mail157-ch1 (MessageSwitch) id 1334665446103515_17508; Tue, 17 Apr 2012 12:24:06 +0000 (UTC) Received: from CH1EHSMHS004.bigfish.com (snatpool2.int.messaging.microsoft.com [10.43.68.234]) by mail157-ch1.bigfish.com (Postfix) with ESMTP id 09FFB3200C7 for ; Tue, 17 Apr 2012 12:24:06 +0000 (UTC) Received: from CH1PRD0410HT001.namprd04.prod.outlook.com (157.56.244.181) by CH1EHSMHS004.bigfish.com (10.43.70.4) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 17 Apr 2012 12:24:04 +0000 Received: from CH1PRD0410MB392.namprd04.prod.outlook.com ([169.254.11.109]) by CH1PRD0410HT001.namprd04.prod.outlook.com ([10.255.147.36]) with mapi id 14.16.0143.004; Tue, 17 Apr 2012 12:23:56 +0000 From: Doug Meil To: "user@hbase.apache.org" Subject: Re: Hbase Map/reduce-How to access individual columns of the table? Thread-Topic: Hbase Map/reduce-How to access individual columns of the table? Thread-Index: AQHNHIIRKqICWLEqvkWkm8Q7wCIuQpaerdSA Date: Tue, 17 Apr 2012 12:23:56 +0000 Message-ID: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.255.147.4] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: explorysmedical.com X-Virus-Checked: Checked by ClamAV on apache.org 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" wrote: > have a table called User with two columns ,one called visitorId and the >other=20 >called friend which is a list of strings. I want to check whether the >VisitorId=20 >is in the friendlist. Can anyone direct me as to how to access the table >columns=20 >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 { > > private int numRecords =3D 0; > private static final IntWritable one =3D new IntWritable(1); > > > private final IntWritable ONE =3D new IntWritable(1); > private Text text =3D new Text(); > @Override > public void map(ImmutableBytesWritable row, Result values, Context >context)=20 >throws IOException { > > //What should i do here??how do i access the individual columns >and =20 >compare? > ImmutableBytesWritable userKey =3D 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 =3D HBaseConfiguration.create(); > Job job =3D new Job(conf, "CheckVisitor"); > job.setJarByClass(MapReduce.class); > Scan scan =3D new Scan(); > Filter f =3D 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); > >} > >