From 74e93252763a281daeab3e859180f536beb9de66 Mon Sep 17 00:00:00 2001 From: Anirudh Date: Thu, 2 Nov 2017 01:12:33 +0530 Subject: [PATCH 1/3] Added documentation --- examples/src/main/python/pi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/src/main/python/pi.py b/examples/src/main/python/pi.py index 5839cc2874956..94a55d2ce692d 100755 --- a/examples/src/main/python/pi.py +++ b/examples/src/main/python/pi.py @@ -27,12 +27,16 @@ if __name__ == "__main__": """ Usage: pi [partitions] + + Monte Carlo method is used to estimate Pi in the below example. """ spark = SparkSession\ .builder\ .appName("PythonPi")\ .getOrCreate() - + + # If no arguments are passed(i.e. `len(sys.argv) < = 1` ) + # while calling this script, the default value assigned is 2 partitions = int(sys.argv[1]) if len(sys.argv) > 1 else 2 n = 100000 * partitions From d840c08bfe5d02424c587da8df3f27c4ed4a9a03 Mon Sep 17 00:00:00 2001 From: Anirudh Date: Thu, 2 Nov 2017 23:59:46 +0530 Subject: [PATCH 2/3] Update pi.py PEP8 --- examples/src/main/python/pi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/src/main/python/pi.py b/examples/src/main/python/pi.py index 94a55d2ce692d..0c9aedd52209c 100755 --- a/examples/src/main/python/pi.py +++ b/examples/src/main/python/pi.py @@ -27,15 +27,15 @@ if __name__ == "__main__": """ Usage: pi [partitions] - + Monte Carlo method is used to estimate Pi in the below example. """ spark = SparkSession\ .builder\ .appName("PythonPi")\ .getOrCreate() - - # If no arguments are passed(i.e. `len(sys.argv) < = 1` ) + + # If no arguments are passed(i.e. `len(sys.argv) < = 1` ) # while calling this script, the default value assigned is 2 partitions = int(sys.argv[1]) if len(sys.argv) > 1 else 2 n = 100000 * partitions From 173fd29f20eab1ca8384413548deb5aac509d629 Mon Sep 17 00:00:00 2001 From: Anirudh Date: Fri, 3 Nov 2017 00:17:41 +0530 Subject: [PATCH 3/3] Update index.md Description added for SparkPi example --- docs/index.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/index.md b/docs/index.md index b867c972b4b48..de1429cd2ac19 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,6 +44,9 @@ launching applications). For example, ./bin/run-example SparkPi 10 +The above example runs the Monte Carlo method to estimate the value of Pi. The arguement passed +(i.e. 10 in this case) is the number of partitions in the RDD. + You can also run Spark interactively through a modified version of the Scala shell. This is a great way to learn the framework.