Book Image

Fast Data Processing with Spark

By : Holden Karau
Book Image

Fast Data Processing with Spark

By: Holden Karau

Overview of this book

<p>Spark is a framework for writing fast, distributed programs. Spark solves similar problems as Hadoop MapReduce does but with a fast in-memory approach and a clean functional style API. With its ability to integrate with Hadoop and inbuilt tools for interactive query analysis (Shark), large-scale graph processing and analysis (Bagel), and real-time analysis (Spark Streaming), it can be interactively used to quickly process and query big data sets.</p> <p>Fast Data Processing with Spark covers how to write distributed map reduce style programs with Spark. The book will guide you through every step required to write effective distributed programs from setting up your cluster and interactively exploring the API, to deploying your job to the cluster, and tuning it for your purposes.</p> <p>Fast Data Processing with Spark covers everything from setting up your Spark cluster in a variety of situations (stand-alone, EC2, and so on), to how to use the interactive shell to write distributed code interactively. From there, we move on to cover how to write and deploy distributed jobs in Java, Scala, and Python.</p> <p>We then examine how to use the interactive shell to quickly prototype distributed programs and explore the Spark API. We also look at how to use Hive with Spark to use a SQL-like query syntax with Shark, as well as manipulating resilient distributed datasets (RDDs).</p>
Table of Contents (16 chapters)
Fast Data Processing with Spark
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Saving your data


While distributed computational jobs are a lot of fun, they are much more applicable when the results get stored somewhere useful. While the methods for loading an RDD are largely found in the SparkContext class, the methods for saving an RDD are defined on the RDD classes. In Scala, implicit conversion exists so that an RDD that can be saved as a sequence file is converted to the appropriate type, and in Java explicit conversion must be used.

Here are the different ways to save an RDD:

  • Scala:

    rddOfStrings.saveAsTextFile("out.txt")
    keyValueRdd.saveAsSequenceFile("sequenceOut")
  • Java:

    rddOfStrings.saveAsTextFile("out.txt")
    keyValueRdd.saveAsSequenceFile("sequenceOut")
  • Python:

    rddOfStrings.saveAsTextFile("out.txt")