You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by Fatih Haltas <fa...@nyu.edu> on 2013/03/12 08:18:18 UTC
Multiple outputs
Hi Everyone,
I would like to have 2 different output (having different columns of a same
input text file.)
When I googled a bit, I got multipleoutputs classes, is this the common way
of doing it or is there any way to create context<iterable> kind of
things/is there context array/is it possible to have two different context
object as reducer output by changing the "public void reduce(Text
key,Iterable<Text> values, Context context)" part as one more Context
context1, Context context2) ?
Any help will be appraciated.
Thank you very much.
Below is my reducer function, how should I modify it?
static class MyReducer extends Reducer<Text,Text,Text,Text>
{
public void reduce(Text key,Iterable<Text> values, Context
context) throws IOException,
InterruptedException
{
Iterator<Text> iter = values.iterator();
while(iter.hasNext())
{
Text externalip_starttime_endtime =
iter.next();
Text outValue = new
Text(externalip_starttime_endtime);
context.write(key, new Text(outValue));
}
}
}
Re: Multiple outputs
Posted by Harsh J <ha...@cloudera.com>.
MultipleOutputs is the way to go :)
On Tue, Mar 12, 2013 at 12:48 PM, Fatih Haltas <fa...@nyu.edu> wrote:
> Hi Everyone,
>
> I would like to have 2 different output (having different columns of a same
> input text file.)
> When I googled a bit, I got multipleoutputs classes, is this the common way
> of doing it or is there any way to create context<iterable> kind of
> things/is there context array/is it possible to have two different context
> object as reducer output by changing the "public void reduce(Text
> key,Iterable<Text> values, Context context)" part as one more Context
> context1, Context context2) ?
>
> Any help will be appraciated.
> Thank you very much.
>
>
>
>
> Below is my reducer function, how should I modify it?
>
>
>
> static class MyReducer extends Reducer<Text,Text,Text,Text>
> {
> public void reduce(Text key,Iterable<Text> values, Context context)
> throws IOException,
> InterruptedException
> {
> Iterator<Text> iter = values.iterator();
> while(iter.hasNext())
> {
> Text externalip_starttime_endtime = iter.next();
> Text outValue = new
> Text(externalip_starttime_endtime);
> context.write(key, new Text(outValue));
>
> }
>
> }
> }
--
Harsh J
Re: Multiple outputs
Posted by Harsh J <ha...@cloudera.com>.
MultipleOutputs is the way to go :)
On Tue, Mar 12, 2013 at 12:48 PM, Fatih Haltas <fa...@nyu.edu> wrote:
> Hi Everyone,
>
> I would like to have 2 different output (having different columns of a same
> input text file.)
> When I googled a bit, I got multipleoutputs classes, is this the common way
> of doing it or is there any way to create context<iterable> kind of
> things/is there context array/is it possible to have two different context
> object as reducer output by changing the "public void reduce(Text
> key,Iterable<Text> values, Context context)" part as one more Context
> context1, Context context2) ?
>
> Any help will be appraciated.
> Thank you very much.
>
>
>
>
> Below is my reducer function, how should I modify it?
>
>
>
> static class MyReducer extends Reducer<Text,Text,Text,Text>
> {
> public void reduce(Text key,Iterable<Text> values, Context context)
> throws IOException,
> InterruptedException
> {
> Iterator<Text> iter = values.iterator();
> while(iter.hasNext())
> {
> Text externalip_starttime_endtime = iter.next();
> Text outValue = new
> Text(externalip_starttime_endtime);
> context.write(key, new Text(outValue));
>
> }
>
> }
> }
--
Harsh J
Re: Multiple outputs
Posted by Harsh J <ha...@cloudera.com>.
MultipleOutputs is the way to go :)
On Tue, Mar 12, 2013 at 12:48 PM, Fatih Haltas <fa...@nyu.edu> wrote:
> Hi Everyone,
>
> I would like to have 2 different output (having different columns of a same
> input text file.)
> When I googled a bit, I got multipleoutputs classes, is this the common way
> of doing it or is there any way to create context<iterable> kind of
> things/is there context array/is it possible to have two different context
> object as reducer output by changing the "public void reduce(Text
> key,Iterable<Text> values, Context context)" part as one more Context
> context1, Context context2) ?
>
> Any help will be appraciated.
> Thank you very much.
>
>
>
>
> Below is my reducer function, how should I modify it?
>
>
>
> static class MyReducer extends Reducer<Text,Text,Text,Text>
> {
> public void reduce(Text key,Iterable<Text> values, Context context)
> throws IOException,
> InterruptedException
> {
> Iterator<Text> iter = values.iterator();
> while(iter.hasNext())
> {
> Text externalip_starttime_endtime = iter.next();
> Text outValue = new
> Text(externalip_starttime_endtime);
> context.write(key, new Text(outValue));
>
> }
>
> }
> }
--
Harsh J
Re: Multiple outputs
Posted by Harsh J <ha...@cloudera.com>.
MultipleOutputs is the way to go :)
On Tue, Mar 12, 2013 at 12:48 PM, Fatih Haltas <fa...@nyu.edu> wrote:
> Hi Everyone,
>
> I would like to have 2 different output (having different columns of a same
> input text file.)
> When I googled a bit, I got multipleoutputs classes, is this the common way
> of doing it or is there any way to create context<iterable> kind of
> things/is there context array/is it possible to have two different context
> object as reducer output by changing the "public void reduce(Text
> key,Iterable<Text> values, Context context)" part as one more Context
> context1, Context context2) ?
>
> Any help will be appraciated.
> Thank you very much.
>
>
>
>
> Below is my reducer function, how should I modify it?
>
>
>
> static class MyReducer extends Reducer<Text,Text,Text,Text>
> {
> public void reduce(Text key,Iterable<Text> values, Context context)
> throws IOException,
> InterruptedException
> {
> Iterator<Text> iter = values.iterator();
> while(iter.hasNext())
> {
> Text externalip_starttime_endtime = iter.next();
> Text outValue = new
> Text(externalip_starttime_endtime);
> context.write(key, new Text(outValue));
>
> }
>
> }
> }
--
Harsh J