Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

11/3/2017

Reading time:1 min

waldmark/spark-cassandra-batch-s3-examples

by John Doe

README.md Spark Casaandra ExampleJava example of Apache Spark consuming and processing 911 calls stored in Cassandra. Requirements:Java 8 installedCassandraScality S3 serverThis demo was developed using docker images running locally for Cassandra and Scality S3. Other instances of Cassandra and S3 should work as well.The example can be run from an IDE (like IntelliJ), or from a runnable jar. See instructions below on building the runnable uber-jar.Stand alone processing from a fileThe class com.objectpartners.spark.rt911.standalone.MainApplication has a runnable main. It loads data into Cassandra;once loaded, it uses the Spark Cassandra Connector to read and then analyze data from Cassandra, and then store the results into S3.Building a runnable jarA standalone jar can be created using Gradle. In the project root directory, in a terminal run gradle:gradle clean buildgradle shadowjarThe uber-jar will be built and placed in the {$project.dir}/build/libs directory.ResourcesIn src/main/resources are two gzips containing 911 call data in csv format:Seattle_Real_Time_Fire_911_Calls_10_Test.csv.gz contains 10 911 calls (10 lines) and can be used for simple testing.Note that the application assumes the first line contains header data, so only 9 calls are actually processed.Seattle_Real_Time_Fire_911_Calls_Chrono.csv.gzA chronologically ordered set of (lots of) calls.

Illustration Image

README.md

Spark Casaandra Example

Alt text

Java example of Apache Spark consuming and processing 911 calls stored in Cassandra.

Requirements:

  • Java 8 installed
  • Cassandra
  • Scality S3 server

This demo was developed using docker images running locally for Cassandra and Scality S3. Other instances of Cassandra and S3 should work as well.

The example can be run from an IDE (like IntelliJ), or from a runnable jar. See instructions below on building the runnable uber-jar.

Stand alone processing from a file

The class com.objectpartners.spark.rt911.standalone.MainApplication has a runnable main. It loads data into Cassandra; once loaded, it uses the Spark Cassandra Connector to read and then analyze data from Cassandra, and then store the results into S3.

Building a runnable jar

A standalone jar can be created using Gradle. In the project root directory, in a terminal run gradle:

  1. gradle clean build
  2. gradle shadowjar

The uber-jar will be built and placed in the {$project.dir}/build/libs directory.

Resources

In src/main/resources are two gzips containing 911 call data in csv format:

  1. Seattle_Real_Time_Fire_911_Calls_10_Test.csv.gz contains 10 911 calls (10 lines) and can be used for simple testing. Note that the application assumes the first line contains header data, so only 9 calls are actually processed.
  2. Seattle_Real_Time_Fire_911_Calls_Chrono.csv.gz A chronologically ordered set of (lots of) calls.

Related Articles

python
cassandra
spark

GitHub - andreia-negreira/Data_streaming_project: Data streaming project with robust end-to-end pipeline, combining tools such as Airflow, Kafka, Spark, Cassandra and containerized solution to easy deployment.

andreia-negreira

12/2/2023

cassandra
spark

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cassandra