The sparkle package

[Tags:bsd3, library, program]

See https://www.stackage.org/package/sparkle.


[Skip to Readme]

Properties

Versions 0.1, 0.1.0.1, 0.2, 0.3, 0.4, 0.4.0.1, 0.4.0.2, 0.5, 0.5.0.1, 0.6 (info)
Change log CHANGELOG.md
Dependencies base (>=4.8 && <5), binary (>=0.7), bytestring (>=0.10), choice (>=0.1), distributed-closure (>=0.3), filepath (>=1.4), inline-java (>=0.6.3 && <0.7), jni (>=0.3.0 && <0.4), jvm (>=0.2.1 && <0.3), jvm-streaming (>=0.1), process (>=1.2), regex-tdfa (>=1.2), singletons (>=2.0), sparkle, streaming (>=0.1), text (>=1.2), vector (>=0.11), zip-archive (>=0.2) [details]
License BSD3
Copyright (c) 2016-2017 EURL Tweag
Author Tweag I/O
Maintainer m@tweag.io
Category FFI, JVM, Java, Distributed Computing
Home page http://github.com/tweag/sparkle#readme
Source repository head: git clone https://github.com/tweag/sparkle(sparkle)
Uploaded Wed Aug 16 19:48:07 UTC 2017 by MathieuBoespflug
Distributions LTSHaskell:0.5.0.1, NixOS:0.6
Downloads 395 total (51 in the last 30 days)
Votes
0 []
Status Docs not available [build log]
All reported builds failed as of 2017-08-16 [all 3 reports]
Hackage Matrix CI

Modules

  • Control
    • Distributed
      • Control.Distributed.Spark
        • Control.Distributed.Spark.Closure
        • Control.Distributed.Spark.Context
        • ML
          • Feature
            • Control.Distributed.Spark.ML.Feature.CountVectorizer
            • Control.Distributed.Spark.ML.Feature.RegexTokenizer
            • Control.Distributed.Spark.ML.Feature.StopWordsRemover
          • Control.Distributed.Spark.ML.LDA
        • Control.Distributed.Spark.PairRDD
        • Control.Distributed.Spark.RDD
        • SQL
          • Control.Distributed.Spark.SQL.Column
          • Control.Distributed.Spark.SQL.Context
          • Control.Distributed.Spark.SQL.DataFrame
          • Control.Distributed.Spark.SQL.DataType
          • Control.Distributed.Spark.SQL.Metadata
          • Control.Distributed.Spark.SQL.Row
          • Control.Distributed.Spark.SQL.StructField
          • Control.Distributed.Spark.SQL.StructType

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for sparkle

Readme for sparkle-0.6

sparkle: Apache Spark applications in Haskell

wercker status

sparkle [spär′kəl]: a library for writing resilient analytics applications in Haskell that scale to thousands of nodes, using Spark and the rest of the Apache ecosystem under the hood. See this blog post for the details.

This is an early tech preview, not production ready.

Getting started

The tl;dr using the hello app as an example on your local machine:

$ stack build hello
$ stack exec -- sparkle package sparkle-example-hello
$ stack exec -- spark-submit --master 'local[1]' sparkle-example-hello.jar

How to use

To run a Spark application the process is as follows:

  1. create an application in the apps/ folder, in-repo or as a submodule;
  2. add your app to stack.yaml;
  3. build the app;
  4. package your app into a deployable JAR container;
  5. submit it to a local or cluster deployment of Spark.

If you run into issues, read the Troubleshooting section below first.

Build

Linux

Requirements

  • the Stack build tool (version 1.2 or above);
  • either, the Nix package manager,
  • or, OpenJDK, Gradle and Spark (version 1.6) installed from your distro.

To build:

$ stack build

You can optionally get Stack to download Spark and Gradle in a local sandbox (using Nix) for good build results reproducibility. This is the recommended way to build sparkle. Alternatively, you'll need these installed through your OS distribution's package manager for the next steps (and you'll need to tell Stack how to find the JVM header files and shared libraries).

To use Nix, set the following in your ~/.stack/config.yaml (or pass --nix to all Stack commands, see the Stack manual for more):

nix:
  enable: true

Other platforms

sparkle is not directly supported on non-Linux operating systems (e.g. Mac OS X or Windows). But you can use Docker to run sparkle natively inside a container on those platforms. First,

$ stack docker pull

Then, just add --docker as an argument to all Stack commands, e.g.

$ stack --docker build

By default, Stack uses the tweag/sparkle build and test Docker image, which includes everything that Nix does as in the Linux section. See the Stack manual for how to modify the Docker settings.

Package

To package your app as a JAR directly consumable by Spark:

$ stack exec -- sparkle package <app-executable-name>

Submit

Finally, to run your application, for example locally:

$ stack exec -- spark-submit --master 'local[1]' <app-executable-name>.jar

The <app-executable-name> is any executable name as given in the .cabal file for your app. See apps in the apps/ folder for examples.

See here for other options, including launching a whole cluster from scratch on EC2. This blog post shows you how to get started on the Databricks hosted platform and on Amazon's Elastic MapReduce.

How it works

sparkle is a tool for creating self-contained Spark applications in Haskell. Spark applications are typically distributed as JAR files, so that's what sparkle creates. We embed Haskell native object code as compiled by GHC in these JAR files, along with any shared library required by this object code to run. Spark dynamically loads this object code into its address space at runtime and interacts with it via the Java Native Interface (JNI).

Troubleshooting

jvm library or header files not found

You'll need to tell Stack where to find your local JVM installation. Something like the following in your ~/.stack/config.yaml should do the trick, but check that the paths match up what's on your system:

extra-include-dirs: [/usr/lib/jvm/java-7-openjdk-amd64/include]
extra-lib-dirs: [/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server]

Or use --nix: since it won't use your globally installed JDK, it will have no trouble finding its own locally installed one.

Can't build sparkle on OS X

OS X is not a supported platform for now. There are several issues to make sparkle work on OS X, tracked in this ticket.

Gradle <= 2.12 incompatible with JDK 9

If you're using JDK 9, note that you'll need to either downgrade to JDK 8 or update your Gradle version, since Gradle versions up to and including 2.12 are not compatible with JDK 9.

Anonymous classes in inline-java quasiquotes fail to deserialize

When using inline-java, it is recommended to use the Kryo serializer, which is currently not the default in Spark but is faster anyways. If you don't use the Kryo serializer, objects of anonymous class, which arise e.g. when using Java 8 function literals,

foo :: RDD Int -> IO (RDD Bool)
foo rdd = [java| $rdd.map((Integer x) -> x.equals(0)) |]

won't be deserialized properly in multi-node setups. To avoid this problem, switch to the Kryo serializer by setting the following configuration properties in your SparkConf:

do conf <- newSparkConf "some spark app"
   confSet conf "spark.serializer" "org.apache.spark.serializer.KryoSerializer"
   confSet conf "spark.kryo.registrator" "io.tweag.sparkle.kryo.InlineJavaRegistrator"

See #104 for more details.

License

Copyright (c) 2015-2016 EURL Tweag.

All rights reserved.

sparkle is free software, and may be redistributed under the terms specified in the LICENSE file.

Sponsors

         Tweag I/O              LeapYear

sparkle is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.