|
| 1 | +# Apache Spark |
| 2 | + |
| 3 | +Spark is a fast and general cluster computing system for Big Data. It provides |
| 4 | +high-level APIs in Scala, Java, and Python, and an optimized engine that |
| 5 | +supports general computation graphs for data analysis. It also supports a |
| 6 | +rich set of higher-level tools including Spark SQL for SQL and structured |
| 7 | +data processing, MLlib for machine learning, GraphX for graph processing, |
| 8 | +and Spark Streaming for stream processing. |
| 9 | + |
| 10 | +<http://spark.apache.org/> |
| 11 | + |
| 12 | + |
| 13 | +## Online Documentation |
| 14 | + |
| 15 | +You can find the latest Spark documentation, including a programming |
| 16 | +guide, on the [project web page](http://spark.apache.org/documentation.html) |
| 17 | +and [project wiki](https://cwiki.apache.org/confluence/display/SPARK). |
| 18 | +This README file only contains basic setup instructions. |
| 19 | + |
| 20 | +## Building Spark |
| 21 | + |
| 22 | +Spark is built using [Apache Maven](http://maven.apache.org/). |
| 23 | +To build Spark and its example programs, run: |
| 24 | + |
| 25 | + mvn -DskipTests clean package |
| 26 | + |
| 27 | +(You do not need to do this if you downloaded a pre-built package.) |
| 28 | +More detailed documentation is available from the project site, at |
| 29 | +["Building Spark with Maven"](http://spark.apache.org/docs/latest/building-with-maven.html). |
| 30 | + |
| 31 | +## Interactive Scala Shell |
| 32 | + |
| 33 | +The easiest way to start using Spark is through the Scala shell: |
| 34 | + |
| 35 | + ./bin/spark-shell |
| 36 | + |
| 37 | +Try the following command, which should return 1000: |
| 38 | + |
| 39 | + scala> sc.parallelize(1 to 1000).count() |
| 40 | + |
| 41 | +## Interactive Python Shell |
| 42 | + |
| 43 | +Alternatively, if you prefer Python, you can use the Python shell: |
| 44 | + |
| 45 | + ./bin/pyspark |
| 46 | + |
| 47 | +And run the following command, which should also return 1000: |
| 48 | + |
| 49 | + >>> sc.parallelize(range(1000)).count() |
| 50 | + |
| 51 | +## Example Programs |
| 52 | + |
| 53 | +Spark also comes with several sample programs in the `examples` directory. |
| 54 | +To run one of them, use `./bin/run-example <class> [params]`. For example: |
| 55 | + |
| 56 | + ./bin/run-example SparkPi |
| 57 | + |
| 58 | +will run the Pi example locally. |
| 59 | + |
| 60 | +You can set the MASTER environment variable when running examples to submit |
| 61 | +examples to a cluster. This can be a mesos:// or spark:// URL, |
| 62 | +"yarn-cluster" or "yarn-client" to run on YARN, and "local" to run |
| 63 | +locally with one thread, or "local[N]" to run locally with N threads. You |
| 64 | +can also use an abbreviated class name if the class is in the `examples` |
| 65 | +package. For instance: |
| 66 | + |
| 67 | + MASTER=spark://host:7077 ./bin/run-example SparkPi |
| 68 | + |
| 69 | +Many of the example programs print usage help if no params are given. |
| 70 | + |
| 71 | +## Running Tests |
| 72 | + |
| 73 | +Testing first requires [building Spark](#building-spark). Once Spark is built, tests |
| 74 | +can be run using: |
| 75 | + |
| 76 | + ./dev/run-tests |
| 77 | + |
| 78 | +Please see the guidance on how to |
| 79 | +[run all automated tests](https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark#ContributingtoSpark-AutomatedTesting). |
| 80 | + |
| 81 | +## A Note About Hadoop Versions |
| 82 | + |
| 83 | +Spark uses the Hadoop core library to talk to HDFS and other Hadoop-supported |
| 84 | +storage systems. Because the protocols have changed in different versions of |
| 85 | +Hadoop, you must build Spark against the same version that your cluster runs. |
| 86 | + |
| 87 | +Please refer to the build documentation at |
| 88 | +["Specifying the Hadoop Version"](http://spark.apache.org/docs/latest/building-with-maven.html#specifying-the-hadoop-version) |
| 89 | +for detailed guidance on building for a particular distribution of Hadoop, including |
| 90 | +building for particular Hive and Hive Thriftserver distributions. See also |
| 91 | +["Third Party Hadoop Distributions"](http://spark.apache.org/docs/latest/hadoop-third-party-distributions.html) |
| 92 | +for guidance on building a Spark application that works with a particular |
| 93 | +distribution. |
| 94 | + |
| 95 | +## Configuration |
| 96 | + |
| 97 | +Please refer to the [Configuration guide](http://spark.apache.org/docs/latest/configuration.html) |
| 98 | +in the online documentation for an overview on how to configure Spark. |
0 commit comments