Return-Path: X-Original-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A9DE10BFB for ; Wed, 28 Aug 2013 03:11:55 +0000 (UTC) Received: (qmail 11507 invoked by uid 500); 28 Aug 2013 03:11:49 -0000 Delivered-To: apmail-hadoop-hdfs-user-archive@hadoop.apache.org Received: (qmail 11410 invoked by uid 500); 28 Aug 2013 03:11:49 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 11403 invoked by uid 99); 28 Aug 2013 03:11:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Aug 2013 03:11:49 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ravikiranmagham@gmail.com designates 209.85.128.170 as permitted sender) Received: from [209.85.128.170] (HELO mail-ve0-f170.google.com) (209.85.128.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Aug 2013 03:11:43 +0000 Received: by mail-ve0-f170.google.com with SMTP id 15so3818658vea.15 for ; Tue, 27 Aug 2013 20:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=3xt8J+BcBYBGzH2QPFAnzlvQz/ExZrcteTVVBnMXz8A=; b=CyIbNGwwBcgxB8WnAR+RYluzxxBBuq8OscljaKosYF3nMFHGnm492Q37qmJDqfbtAw 5ALZPPLObJalXDPhUerssfzbod7v2ent08cJkQGYbce1paTUvxnaaaR+CM2NopL3acym LUTDcFrlspbBqJlIIc4v7GflPJsxVYlIzVs37m4m6MiOxTQ/U5k4ijZd7q/yBu3XXv63 hXTFrnaX3Jkfye4kRWXBJ+4Y/cp1parmVkMqNMZLKbstiKJMn26jLxKRICA/1bauXpqa nu1+MKZ9Asvk21RMW3Cl0JnI1IpYpS7chvPCuBbALd+VivRJXu92jnKYeL4DWMctEY6V Lgkg== MIME-Version: 1.0 X-Received: by 10.220.206.195 with SMTP id fv3mr23260450vcb.15.1377659482988; Tue, 27 Aug 2013 20:11:22 -0700 (PDT) Received: by 10.58.37.199 with HTTP; Tue, 27 Aug 2013 20:11:22 -0700 (PDT) In-Reply-To: References: Date: Wed, 28 Aug 2013 08:41:22 +0530 Message-ID: Subject: Re: Writing multiple tables from reducer From: Ravi Kiran To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=001a11c2a8c01ae72004e4f958f7 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2a8c01ae72004e4f958f7 Content-Type: text/plain; charset=ISO-8859-1 I have written a blog on this a while ago where I was writing to multiple tables from my mapper class. You can look into it at http://bigdatabuzz.wordpress.com/2012/04/24/how-to-write-to-multiple-hbase-tables-in-a-mapreduce-job/ Key things are, a) job.setOutputFormatClass (MultiTableOutputFormat.class); b) In your reducer , you would stick with the if else to write to the corresponding HBase tables. Thanks Ravi Magham On Wed, Aug 28, 2013 at 3:50 AM, jamal sasha wrote: > Hi, > I am new to hbase and am trying to achieve the following. > > I am reading data from hdfs in mapper and parsing it.. > > So, in reducer I want my output to write to hbase instead of hdfs > But here is the thing. > > public static class MyTableReducer extends TableReducer ImmutableBytesWritable> { > > public void reduce(Text key, Iterable values, Context context) > throws IOException, InterruptedException { > int type = getType(values.toString()); > if (type == 1) // put data to table 1 > if (type==2) // put data to table 2 > > > } > } > > How do I do this? > Thanks > --001a11c2a8c01ae72004e4f958f7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I have written a blog on this a while ago where I was writ= ing to multiple tables from my mapper class. You can look into it at=A0http://bigdatabuzz.wordpress.com/2012/04= /24/how-to-write-to-multiple-hbase-tables-in-a-mapreduce-job/

Key things are,
a)=A0job.setOutputFormatClass (Mul= tiTableOutputFormat.class);
b) In your reducer , you would stick = with the if else to write to the corresponding HBase tables.

Thanks
Ravi Magham


<= /div>


On Wed, Aug 28, 2013 at 3:50 AM, jamal sasha <jamalshasha@gmail.co= m> wrote:
Hi,=A0
=A0 I am new to = hbase and am trying to achieve the following.

I am= reading data from hdfs in mapper and parsing it..

So, in reducer I want my output to write to hbase inste= ad of hdfs
But here is the thing.

public static cla= ss MyTableReducer extends TableReducer<Text, Text, ImmutableBytesWritabl= e> =A0{

= public void reduce(Tex= t key, Iterable<Text> values, Context context) throws IOException, In= terruptedException {
int t= ype =3D getType(values.toString());
if (type =3D=3D 1) // put data t= o table 1
if (t= ype=3D=3D2) // put data to table 2 =A0 =A0


=A0 }
}
=
How do I do this?
Thanks

--001a11c2a8c01ae72004e4f958f7--