[ https://issues.apache.org/jira/browse/GIRAPH-112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13173936#comment-13173936 ]
jirapos...@reviews.apache.org commented on GIRAPH-112: ------------------------------------------------------ ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/3287/#review4036 ----------------------------------------------------------- Ship it! I ran into the same issue yesterday and the solution presented here is correct. For reasons of efficiency, list.elements() returns the internal underlying array for the list, which might be bigger than the number of elements stored in the list. Therefore you should only iterate until list.size() or use the foreachKey() callback. - Sebastian On 2011-12-21 07:50:20, Avery Ching wrote: bq. bq. ----------------------------------------------------------- bq. This is an automatically generated e-mail. To reply, visit: bq. https://reviews.apache.org/r/3287/ bq. ----------------------------------------------------------- bq. bq. (Updated 2011-12-21 07:50:20) bq. bq. bq. Review request for giraph. bq. bq. bq. Summary bq. ------- bq. bq. As pointed out by YuanYua, the array returned by elements() cannot have its length used since the array contains all the elements currently stored in the mahout collections, even including invalid elements between size and capacity. bq. bq. Whenever possible I converted elements() into forEach(), forEachKey(), forEachPair(). Used size() in other cases. bq. bq. Fixed some formatting violations as well in LongDoubleFloatDoubleVertex.java. bq. bq. bq. This addresses bug GIRAPH-112. bq. https://issues.apache.org/jira/browse/GIRAPH-112 bq. bq. bq. Diffs bq. ----- bq. bq. http://svn.apache.org/repos/asf/incubator/giraph/trunk/src/main/java/org/apache/giraph/graph/LongDoubleFloatDoubleVertex.java 1221634 bq. bq. Diff: https://reviews.apache.org/r/3287/diff bq. bq. bq. Testing bq. ------- bq. bq. Local unittests and MR unittests. bq. bq. bq. Thanks, bq. bq. Avery bq. bq. > Use elements() properly in LongDoubleFloatDoubleVertex > ------------------------------------------------------ > > Key: GIRAPH-112 > URL: https://issues.apache.org/jira/browse/GIRAPH-112 > Project: Giraph > Issue Type: Bug > Components: graph > Affects Versions: 0.70.0 > Environment: Any > Reporter: Yuanyuan Tian > Fix For: 0.70.0 > > Attachments: GIRAPH-112.patch > > Original Estimate: 5m > Remaining Estimate: 5m > > I found a bug in LongDoubleFloatDoubleVertex.write(DataOutput out) when > running a small graph algorithm. The symptom is that a vertex read from a > different worker becomes junk after the RPC communication. And the source of > the problem is the writing of the messages in > LongDoubleFloatDoubleVertex.write(DataOutput out): > for(double msg : messageList.elements()) { > out.writeDouble(msg); > } > Here messageList.elements() will returns all the elements currently stored in > the mahout DoubleArrayList, even including invalid elements between size and > capacity. Therefore, the write() function will write a bunch of invalid > messages, which will cause error when reading them back in readfields(). > The following is a simple solution: > double[] elements=messageList.elements(); > for(int i=0; i<messageList.size(); i++) { > out.writeDouble(elements[i]); > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira