ArrayList Issue in Reducer
Hi I'm performing some calculations in reducer and trying to load the data into an ArrayList. When I perform a get operation on ArrayList at later point of code, all objects in ArrayList have same value.
public ArrayList<some_class> temp = new ArrayList<some_class>();
//This is global variable
@Override
public void reduce(Key_class key, Iterator<some_class> values,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
if(this.output==null){
this.output=output;
}
while(values.hasNext())
{
//if i print here
//and do the following values.next().val1
//I'm getting the right result
temp.add(values.next());
}
System.out.println(temp.get(0).val1);//Wrong result
}
I'm getting output as below: 12/10/2012 10:13 12/10/2012 10:13
Actual output should be : 12/10/2012 09:10 12/10/2012 10:13
Appreciate your help. Thanks!!!
Hi I'm performing some calculations in reducer and trying to load the data into an ArrayList. When I perform a get operation on ArrayList at later point of code, all objects in ArrayList have same value.
public ArrayList<some_class> temp = new ArrayList<some_class>();
//This is global variable
@Override
public void reduce(Key_class key, Iterator<some_class> values,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
if(this.output==null){
this.output=output;
}
while(values.hasNext())
{
//if i print here
//and do the following values.next().val1
//I'm getting the right result
temp.add(values.next());
}
System.out.println(temp.get(0).val1);//Wrong result
}
I'm getting output as below: 12/10/2012 10:13 12/10/2012 10:13
Actual output should be : 12/10/2012 09:10 12/10/2012 10:13
Appreciate your help. Thanks!!!
No comments:
Post a Comment