All,
I've been writing
java from the beginning but this is something I've never seen before so I thought I'd ask. I have tried to not bog things down with too much information. I hope I am giving enough.
I have two classes: (1) CurrStateByStage and (2) Visitors.
When, I add a visitor, a Visitors list is retrieved and the Visitor is added to a list successfully. During processing, Visitor(s) are added repeatedly and the list should grow, but it does not. It always has a size of 0 before the add and a size of 1 afterward; and the Visitors object appears to be different one (based on its hashcode, which is not shown) upon each call even though the CurrStateByStage object is always the same as is its member mapByStage. I should be adding visitors to the same list instance each time.
What is happening to Visitors? Why apparently a new object at every iteration? Could it have anything to do with my having a map of lists? could it have anything to do with this code executing within a Hadoop reducer class?
I have used ArrayList extensively and have never seen behavior like this.
Relevant parts:
From the log file with comments added:
qq.mr.prime.val.CurrStateByStage@27958cc2 vv=[]
// Note the reference id. Upon repeated calls it is always the same.
qq.mr.prime.val.Visitors: add=[]
qq.mr.prime.val.Visitors=[id=42322423 <irrelevant output here>] before=0 after=1
// Note the id. Note the before and after numbers are always 0 and 1 respectively.
qq.mr.prime.val.CurrStateByStage@27958cc2 vv=[]
// Note the reference id. It it still the same.
qq.mr.prime.val.Visitors: add=[]
qq.mr.prime.val.Visitors=[id=42334683 <irrelevant output here>] before=0 after=1
// Note the id is different because we're adding a different visitor. Note the before and after numbers are still 0 and 1.
Thanks in advance.