Return-Path: X-Original-To: apmail-giraph-dev-archive@www.apache.org Delivered-To: apmail-giraph-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 237D1D931 for ; Tue, 5 Mar 2013 05:21:31 +0000 (UTC) Received: (qmail 70997 invoked by uid 500); 5 Mar 2013 05:21:31 -0000 Delivered-To: apmail-giraph-dev-archive@giraph.apache.org Received: (qmail 70960 invoked by uid 500); 5 Mar 2013 05:21:30 -0000 Mailing-List: contact dev-help@giraph.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@giraph.apache.org Delivered-To: mailing list dev@giraph.apache.org Received: (qmail 70946 invoked by uid 99); 5 Mar 2013 05:21:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Mar 2013 05:21:30 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW X-Spam-Check-By: apache.org Received-SPF: unknown (athena.apache.org: error in processing during lookup of prvs=677634f10e=alessandro@fb.com) Received: from [67.231.153.30] (HELO mx0a-00082601.pphosted.com) (67.231.153.30) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Mar 2013 05:21:26 +0000 Received: from pps.filterd (m0004003 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id r255I1I4027278 for ; Mon, 4 Mar 2013 21:21:04 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=6wE05OPyupTSc1RSkzZn/7ItJLZKEytwuKbuXAWabnM=; b=k09eYJTZjvBBKXEaFuSLx9LXxtATWyHGl3/U1iiQtcdxcChImlsdxKiQT/6ckETIhCdX eZr0oic4pRnWrr60uQ1kQyG2vST81JuctESRjEX3CFnbDitlJmKOMMi9oTin1LMl+SUL amy9lmB+fRxXa5HytSiGMgy5QavmqPsnWDo= Received: from mail.thefacebook.com (prn1-cmdf-dc01-fw1-nat.corp.tfbnw.net [173.252.71.129] (may be forged)) by mx0b-00082601.pphosted.com with ESMTP id 1aw1pt9yg9-13 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Mon, 04 Mar 2013 21:21:04 -0800 Received: from PRN-MBX02-5.TheFacebook.com ([169.254.5.140]) by PRN-CHUB01.TheFacebook.com ([fe80::d5cc:849:f520:db6b%12]) with mapi id 14.02.0328.011; Mon, 4 Mar 2013 21:19:46 -0800 From: Alessandro Presta To: "dev@giraph.apache.org" Subject: Re: [jira] [Created] (GIRAPH-547) Allow in-place modification of edges Thread-Topic: [jira] [Created] (GIRAPH-547) Allow in-place modification of edges Thread-Index: AQHOFrZpGprKVXyuRk6GOoc0atvs25iXFxiA//99kgA= Date: Tue, 5 Mar 2013 05:19:44 +0000 Message-ID: <566834A0CA4ED742A53644FF331260D4380EAA34@PRN-MBX02-5.TheFacebook.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.57.29] Content-Type: text/plain; charset="us-ascii" Content-ID: <160CD769940A7A4E804261EED165ED70@fb.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.9.8327,1.0.431,0.0.0000 definitions=2013-03-05_02:2013-03-04,2013-03-05,1970-01-01 signatures=0 X-Virus-Checked: Checked by ClamAV on apache.org Hi Jiadong, Yes, that's not recommended because some optimized implementations reuse the same Edge object, so whatever change you make has no effect on the underlying data. It happens to work when using EdgeListVertex because there we actually have one Edge object per edge. Alessandro On 3/4/13 9:06 PM, "Jiadong Wu" wrote: >Hi guys, > >I may not understand this issue clearly, but if we do want in-place >modification why not simply use edge.getValue().set(newValue) instead? >I used this method a lot in my code, where the edge value is a >LongWritable. Is there any potential problem? >Thanks, > >Jiadong > >On Fri, Mar 1, 2013 at 2:53 PM, Alessandro Presta (JIRA) > wrote: >> Alessandro Presta created GIRAPH-547: >> ---------------------------------------- >> >> Summary: Allow in-place modification of edges >> Key: GIRAPH-547 >> URL: https://issues.apache.org/jira/browse/GIRAPH-547 >> Project: Giraph >> Issue Type: New Feature >> Reporter: Alessandro Presta >> Assignee: Alessandro Presta >> >> >> This is a somewhat long term item. >> >> Because of some optimized edge storage implementations (byte array, >>primitive array), we have a contract with the user that Edge objects >>returned by getEdges() are read-only. >> >> One concrete example where this is needed: in the weighted version of >>PageRank, you can store the weight sum and normalize each message sent, >>or you could more efficiently normalize the out-edges once in superstep >>0. >> >> The Pregel paper describes an OutEdgeIterator that allows for in-place >>modification of edges. I can see how that would be easy to implement in >>C++, where there is no need to reuse objects. >> >> Giraph "unofficially" supports this if one is using generic collections >>to represent edges (e.g. ArrayList or HashMap). >> >> It may be trickier in some optimized implementations, but in principle >>it should be doable. >> >> One way would be to have some special MutableEdge implementation which >>calls back to the edge data structure in order to save modifications: >> >> {code} >> for (Edge edge : getEdges()) { >> edge.setValue(newValue); >> } >> {code} >> >> Another option would be to add a special set() method to our edge >>iterator, where one can replace the current edge: >> >> {code} >> for (EdgeIterator it =3D getEdges().iterator(); it.hasNext();) { >> Edge edge =3D it.next(); >> edge.setValue(newValue); >> it.set(edge); >> } >> {code} >> >> We could actually implement the first version as syntactic sugar on top >>of the second version (the special MutableEdge would need a reference to >>the iterator in order to call set(this)). >> >> -- >> This message is automatically generated by JIRA. >> If you think it was sent incorrectly, please contact your JIRA >>administrators >> For more information on JIRA, see: >>http://www.atlassian.com/software/jira