Member since
10-17-2016
4
Posts
0
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
2241 | 10-19-2016 02:52 PM |
10-19-2016
02:52 PM
Maybe I've missed the documentation where this is discussed, but the problem seems to be that HIVE maintains a reference to the objects that it passes to the merge() function. I'm presenting here the solution, in case someone else comes across this error. Therefore, the Info items in the List<Info> that is the parameter to the merge() may be overwritten (that is, their contents may change) after they've been passed to the method. This, of course, creates all kinds of problems w/ the Set<> as the contents change, while the object itself is not removed / reinserted to the set. The proper way of handling this is by creating a new object and adding that to the set. The merge() method should therefore be as follows: public boolean merge( List<Info> otherInfo ){
for ( Info i : otherInfo ){
Info copy = new Info();
copy.x1 = i.x1;
copy.x2 = i.x2;
copy.x3 = i.x3;
this.details.add( copy );
}
} The rest of the code doesn't have to change. Hope this helps and others don't need to waste as much time. Cheers, George
... View more