You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by oo famcr <fa...@gmail.com> on 2009/12/23 15:30:24 UTC
How to use LinkedList in Hadoop?
Hello everyone
I want to save the value to a LinkedList, but THE ***activeList.get(0)***
have been changed every time.
I think it should be the first element, but it's not.
Thanks
Song
==========Part of WordCount===========
public static class IntSumReducer
extends Reducer<Text,Text,Text,Text> {
private List<Text> activeList = new LinkedList<Text>();
public void reduce(Text key, Iterable<Text> values,
Context context
) throws IOException, InterruptedException {
for (Text val : values) {
activeList.add(val);
context.write(key, new Text( activeList.get(0).toString() ));
}
}
Re: How to use LinkedList in Hadoop?
Posted by oo famcr <fa...@gmail.com>.
i think it's local var.
The codes below is changed little from wordcount.
On Wednesday, December 23, 2009, Jeff Zhang <zj...@gmail.com> wrote:
> What is the activeList ? a local variable or class member variable?
>
>
> On Wed, Dec 23, 2009 at 6:30 AM, oo famcr <fa...@gmail.com> wrote:
>
>> Hello everyone
>> I want to save the value to a LinkedList, but THE ***activeList.get(0)***
>> have been changed every time.
>> I think it should be the first element, but it's not.
>>
>> Thanks
>> Song
>>
>> ==========Part of WordCount===========
>> public static class IntSumReducer
>> extends Reducer<Text,Text,Text,Text> {
>> private List<Text> activeList = new LinkedList<Text>();
>> public void reduce(Text key, Iterable<Text> values,
>> Context context
>> ) throws IOException, InterruptedException {
>> for (Text val : values) {
>> activeList.add(val);
>> context.write(key, new Text( activeList.get(0).toString() ));
>> }
>> }
>>
>
Re: How to use LinkedList in Hadoop?
Posted by oo famcr <fa...@gmail.com>.
see the codes below.
thanks
On Wednesday, December 23, 2009, Jeff Zhang <zj...@gmail.com> wrote:
> What is the activeList ? a local variable or class member variable?
>
>
> On Wed, Dec 23, 2009 at 6:30 AM, oo famcr <fa...@gmail.com> wrote:
>
>> Hello everyone
>> I want to save the value to a LinkedList, but THE ***activeList.get(0)***
>> have been changed every time.
>> I think it should be the first element, but it's not.
>>
>> Thanks
>> Song
>>
>> ==========Part of WordCount===========
>> public static class IntSumReducer
>> extends Reducer<Text,Text,Text,Text> {
>> private List<Text> activeList = new LinkedList<Text>();
>> public void reduce(Text key, Iterable<Text> values,
>> Context context
>> ) throws IOException, InterruptedException {
>> for (Text val : values) {
>> activeList.add(val);
>> context.write(key, new Text( activeList.get(0).toString() ));
>> }
>> }
>>
>
Re: How to use LinkedList in Hadoop?
Posted by Jeff Zhang <zj...@gmail.com>.
What is the activeList ? a local variable or class member variable?
On Wed, Dec 23, 2009 at 6:30 AM, oo famcr <fa...@gmail.com> wrote:
> Hello everyone
> I want to save the value to a LinkedList, but THE ***activeList.get(0)***
> have been changed every time.
> I think it should be the first element, but it's not.
>
> Thanks
> Song
>
> ==========Part of WordCount===========
> public static class IntSumReducer
> extends Reducer<Text,Text,Text,Text> {
> private List<Text> activeList = new LinkedList<Text>();
> public void reduce(Text key, Iterable<Text> values,
> Context context
> ) throws IOException, InterruptedException {
> for (Text val : values) {
> activeList.add(val);
> context.write(key, new Text( activeList.get(0).toString() ));
> }
> }
>