You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by nchammas <gi...@git.apache.org> on 2014/03/25 00:46:23 UTC

[GitHub] spark pull request: [SPARK-1308] Add partitions() method to PySpar...

GitHub user nchammas opened a pull request:

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

    [SPARK-1308] Add partitions() method to PySpark RDDs

    I've added the `partitions()` method per [the discussion here](http://apache-spark-user-list.1001560.n3.nabble.com/How-many-partitions-is-my-RDD-split-into-td3072.html).
    
    Looking at [the instructions here](https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark), it is not clear how to add tests for this kind of modification to PySpark.
    
    `sbt/sbt test` has 1 test fail -- `org.apache.spark.sql.hive.execution.HiveCompatibilitySuite` -- but this appears to be unrelated to my change. Reverting my changes and re-reunning `assembly` and `test` yield the same result.
    
    First-time committer. Forgive me if I’ve messed anything up.

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

    $ git pull https://github.com/nchammas/spark master

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

    https://github.com/apache/spark/pull/218.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 #218
    
----
commit e972d3e4cee76d4e2841722701dac709a2f923c5
Author: Nicholas Chammas <ni...@gmail.com>
Date:   2014-03-24T22:03:27Z

    [SPARK-1308] Add partitions() method to PySpark RDDs
    
    Per the discussion here:
    http://apache-spark-user-list.1001560.n3.nabble.com/How-many-partitions-
    is-my-RDD-split-into-td3072.html
    
    Looking at the instructions here
    (https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark
    ), it is not clear how to add tests for this kind of modification to
    PySpark.
    
    First-time committer. Forgive me if I’ve messed anything up.

----


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-38517526
  
    Can one of the admins verify this patch?


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-38520260
  
    It might be nicer if this just had a method that returned the number of partitions. The partitions are java objects which can't be returned safely to python.


---
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-1308] Add partitions() method to PySpar...

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

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


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-41062176
  
    Ah, looks like I have indeed [messed up this PR](http://stackoverflow.com/q/6102297/877069). I will revisit this issue later.


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-41060733
  
    Dunno if I've done this correctly, but I've rebased my fork and changed this method per our discussion here. The change list seems to contain everything I merged in, in addition to the one method I'm trying to add to PySpark RDD. Is that correct? 
    
    Anyway, feel free to close this PR if it should just be revisited at a later time.


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#discussion_r10913578
  
    --- Diff: python/pyspark/rdd.py ---
    @@ -202,6 +202,12 @@ def flatMap(self, f, preservesPartitioning=False):
             def func(s, iterator): return chain.from_iterable(imap(f, iterator))
             return self.mapPartitionsWithIndex(func, preservesPartitioning)
     
    +    def partitions(self):
    +        """
    +        Get the array of partitions of this RDD, taking into account whether the RDD is checkpointed or not.
    +        """
    +        return self._jrdd.splits()
    --- End diff --
    
    Actually, I'm not sure that having a Python method return a Java object is right thing to do. Or is it?
    
    `len(rdd.partitions())` works as you would expect, and so does `rdd.partitions().size()`, but I'm not sure how else this method might be used.


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-38526503
  
    Makes sense. Would you rather have the method be called `numPartitions()` or `getNumPartitions()`?
    
    The former lines up with the `numPartitions` input parameter to many methods. The latter lines up with the 2 other `get...()` methods.


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-38881853
  
    Can one of the admins verify this patch?


---
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-1308] Add partitions() method to PySpar...

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

    https://github.com/apache/spark/pull/218#issuecomment-38532691
  
    Hm - the naming for getters seems a little inconstent in the API. /cc @joshrosen any feelings about  `getNumPartitions` vs `numPartitions`?. Also it would be good to add a doctest:
    
    ```
    >>> sc.parallelize([1, 2, 3, 4, 5, 6], 4).getNumPartitions
    4
    ```


---
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.
---