Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions examples/src/main/python/pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
if __name__ == "__main__":
"""
Usage: pi [partitions]
Monte Carlo method is used to estimate Pi in the below example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below example -> example below

"""
spark = SparkSession\
.builder\
.appName("PythonPi")\
.getOrCreate()

# If no arguments are passed(i.e. `len(sys.argv) < = 1` )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after passed, problem in "< ="
This comment just restates the code below.

# 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

Expand Down