Thanks,
I've resolve it with the same way.
I create a list object hold every attribute in the custom object, may be
more efficient, but i don't think it looks beautiful.........

On Sun, Dec 27, 2009 at 9:00 AM, Bryan McCormick <br...@mccormi.com> wrote:

> I actually just ran into the same problem. Took an evening of poking around
> to see what was going on. What appears to be going on is that the
> Iterable<Text> values seemed to be reusing the Text object being exposed in
> the for loop and just changing the content of the Text.
>
> Try doing this instead:
>
> for(Text val:values){
>        activeList.add(new Text(val.toString));
>        context.write(key, activeList.get(0));
> }
>
> I was using a custom object that implemented Writable and instead of
> getting a list of objects, I got n copies of the same object in my list. By
> copying the object out of the values Iterable into a new object that I then
> inserted into my list everything worked properly.
>
> Hope this helps,
>
> Bryan
>
>
>
>
> On Dec 23, 2009, at 3:01 AM, oo famcr 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()  ));
>>     }
>>   }
>>
>
>

Reply via email to