You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by ankurdave <gi...@git.apache.org> on 2014/06/04 05:35:40 UTC

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

GitHub user ankurdave opened a pull request:

    https://github.com/apache/spark/pull/967

    [SPARK-1552] Fix type comparison bug in {map,outerJoin}Vertices

    In GraphImpl, mapVertices and outerJoinVertices use a more efficient implementation when the map function conserves vertex attribute types. This is implemented by comparing the ClassTags of the old and new vertex attribute types. However, ClassTags store erased types, so the comparison will return a false positive for types with different type parameters, such as Option[Int] and Option[Double].
    
    This PR resolves the problem by unconditionally using the general implementation in mapVertices and outerJoinVertices, and introducing "Conserve" variants of these methods that enforce type equality and use the more efficient implementation.
    
    It also adds a test called "mapVertices changing type with same erased type" that failed before the PR and succeeds now.
    
    The "Conserve" naming comes from Scala's `List#mapConserve` method.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ankurdave/spark SPARK-1552

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/967.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #967
    
----
commit 16d6af8ef3eb20e88452db3cca1cdc307697b1c0
Author: Ankur Dave <an...@gmail.com>
Date:   2014-06-04T01:50:35Z

    [SPARK-1552] Fix type comparison bug in mapVertices and outerJoinVertices
    
    In GraphImpl, mapVertices and outerJoinVertices use a more efficient implementation when the map function conserves vertex attribute types. This is implemented by comparing the ClassTags of the old and new vertex attribute types. However, ClassTags store erased types, so the comparison will return a false positive for types with different type parameters, such as Option[Int] and Option[Double].
    
    This PR resolves the problem by unconditionally using the general implementation in mapVertices and outerJoinVertices, and introducing "Conserve" variants of these methods that enforce type equality and use the more efficient implementation.
    
    It also adds a test called "mapVertices changing type with same erased type" that failed before the PR and succeeds now.
    
    The "Conserve" naming comes from Scala's `List#mapConserve` method.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45157400
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/15458/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45050122
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/15430/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45151979
  
    
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/15456/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/967#discussion_r13372785
  
    --- Diff: graphx/src/main/scala/org/apache/spark/graphx/Graph.scala ---
    @@ -131,6 +131,19 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab
       def mapVertices[VD2: ClassTag](map: (VertexId, VD) => VD2): Graph[VD2, ED]
     
       /**
    +   * Transforms each vertex attribute in the graph using the map function. Like [[mapVertices]], but
    +   * since the type is conserved, is able to avoid moving unchanged vertex attributes when updating
    +   * the triplets view.
    +   *
    +   * @note The new graph has the same structure.  As a consequence the underlying index structures
    +   * can be reused.
    +   *
    +   * @param map the function from a vertex object to a new vertex value of the same type
    +   *
    +   */
    +  def mapVerticesConserve(map: (VertexId, VD) => VD): Graph[VD, ED]
    --- End diff --
    
    Would TypeTags solve this problem?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45151978
  
    Merged build finished. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45152347
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45156930
  
    Merged build finished. All automated tests passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45151783
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45152928
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by ankurdave <gi...@git.apache.org>.
Github user ankurdave commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45048620
  
    Actually, never mind about the backporting -- apparently introducing new methods breaks compatibility.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45048505
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45048510
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45306941
  
    Thanks. Merging this in master.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45151808
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by ankurdave <gi...@git.apache.org>.
Github user ankurdave commented on a diff in the pull request:

    https://github.com/apache/spark/pull/967#discussion_r13372794
  
    --- Diff: graphx/src/main/scala/org/apache/spark/graphx/Graph.scala ---
    @@ -131,6 +131,19 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab
       def mapVertices[VD2: ClassTag](map: (VertexId, VD) => VD2): Graph[VD2, ED]
     
       /**
    +   * Transforms each vertex attribute in the graph using the map function. Like [[mapVertices]], but
    +   * since the type is conserved, is able to avoid moving unchanged vertex attributes when updating
    +   * the triplets view.
    +   *
    +   * @note The new graph has the same structure.  As a consequence the underlying index structures
    +   * can be reused.
    +   *
    +   * @param map the function from a vertex object to a new vertex value of the same type
    +   *
    +   */
    +  def mapVerticesConserve(map: (VertexId, VD) => VD): Graph[VD, ED]
    --- End diff --
    
    Yes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by ankurdave <gi...@git.apache.org>.
Github user ankurdave commented on a diff in the pull request:

    https://github.com/apache/spark/pull/967#discussion_r13372714
  
    --- Diff: graphx/src/main/scala/org/apache/spark/graphx/Graph.scala ---
    @@ -131,6 +131,19 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab
       def mapVertices[VD2: ClassTag](map: (VertexId, VD) => VD2): Graph[VD2, ED]
     
       /**
    +   * Transforms each vertex attribute in the graph using the map function. Like [[mapVertices]], but
    +   * since the type is conserved, is able to avoid moving unchanged vertex attributes when updating
    +   * the triplets view.
    +   *
    +   * @note The new graph has the same structure.  As a consequence the underlying index structures
    +   * can be reused.
    +   *
    +   * @param map the function from a vertex object to a new vertex value of the same type
    +   *
    +   */
    +  def mapVerticesConserve(map: (VertexId, VD) => VD): Graph[VD, ED]
    --- End diff --
    
    Are you saying to detect whether it's correct to conserve by comparing ClassTags? That's the point of the change -- comparing ClassTags can give a false positive when the type is erased (i.e., classTag[Option[Int]] == classTag[Option[String]]), so it's unsafe to rely on it. See https://issues.apache.org/jira/browse/SPARK-1552.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/967


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by ankurdave <gi...@git.apache.org>.
Github user ankurdave commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45048487
  
    @rxin This is a binary-compatible bugfix, so it should also be backported into branch-1.0.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45156931
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/15457/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45157399
  
    Merged build finished. All automated tests passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by pwendell <gi...@git.apache.org>.
Github user pwendell commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45049523
  
    @ankurdave in general new methods should be fine wrt compatibility.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45050121
  
    Merged build finished. All automated tests passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45152326
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/967#discussion_r13371929
  
    --- Diff: graphx/src/main/scala/org/apache/spark/graphx/Graph.scala ---
    @@ -131,6 +131,19 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab
       def mapVertices[VD2: ClassTag](map: (VertexId, VD) => VD2): Graph[VD2, ED]
     
       /**
    +   * Transforms each vertex attribute in the graph using the map function. Like [[mapVertices]], but
    +   * since the type is conserved, is able to avoid moving unchanged vertex attributes when updating
    +   * the triplets view.
    +   *
    +   * @note The new graph has the same structure.  As a consequence the underlying index structures
    +   * can be reused.
    +   *
    +   * @param map the function from a vertex object to a new vertex value of the same type
    +   *
    +   */
    +  def mapVerticesConserve(map: (VertexId, VD) => VD): Graph[VD, ED]
    --- End diff --
    
    What if we just use mapVertices, but compare the two classtags and call the right mapVerticesConserve?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1552] Fix type comparison bug in {map,o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/967#issuecomment-45152909
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---