Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Repository files navigation

Spark2Cassandra

Spark Library for Bulk Loading into Cassandra

  • Build Status
  • Join the chat at https://gitter.im/SparkleFormation/sfn

Requirements

Spark2Cassandra supports Spark 2.2.

It is compatible with the following versions of Cassandra:

  • 2.1.5+
  • 2.2
  • 3.0.x

Downloads

SBT

libraryDependencies +="com.github.leoromanovsky"%%"spark2cassandra"%"3.0.0"

Maven

<dependency>
<groupId>com.github.leoromanovsky</groupId>
<artifactId>spark2cassandra_2.11</artifactId>
<version>x.y.z</version>
</dependency>

Features

Usage

Bulk Loading into Cassandra

// Import the following to have access to the `bulkLoadToEs()` function for RDDs or DataFrames.importcom.github.jparkie.spark.cassandra.rdd._importcom.github.jparkie.spark.cassandra.sql._valsparkConf=newSparkConf()
valsc=SparkContext.getOrCreate(sparkConf)
valsqlContext=SQLContext.getOrCreate(sc)
// https://datastax-oss.atlassian.net/browse/SPARKC-475implicitvalrwf:RowWriterFactory[Row] =SqlRowWriter.Factoryvalrdd= sc.parallelize(???)
valdf= sqlContext.read.parquet("<PATH>")
// Specify the `keyspaceName` and the `tableName` to write.
rdd.bulkLoadToCass(
keyspaceName ="twitter",
tableName ="tweets_by_date"
)
// Specify the `keyspaceName` and the `tableName` to write.
df.bulkLoadToCass(
keyspaceName ="twitter",
tableName ="tweets_by_author"
)

For more information, refer to:

Configurations

As Spark2Cassandra utilizes https://github.com/datastax/spark-cassandra-connector for serializations from Spark and session management, please refer to the following for more configurations: https://github.com/datastax/spark-cassandra-connector/blob/master/doc/reference.md.

SparkCassWriteConf

Refer to for more: SparkCassWriteConf.scala

Property NameDefaultDescription
spark.cassandra_bulk.write.partitionerorg.apache.cassandra.dht.Murmur3PartitionerThe 'partitioner' defined in cassandra.yaml.
spark.cassandra_bulk.write.throughput_mb_per_secInt.MaxValueThe maximum throughput to throttle.
spark.cassandra_bulk.write.connection_per_host1The number of connections per host to utilize when streaming SSTables.

SparkCassServerConf

Refer to for more: SparkCassServerConf.scala

Property NameDefaultDescription
spark.cassandra_bulk.server.storage.port7000The 'storage_port' defined in cassandra.yaml.
spark.cassandra_bulk.server.sslStorage.port7001The 'ssl_storage_port' defined in cassandra.yaml.
spark.cassandra_bulk.server.internode.encryption"none"The 'server_encryption_options:internode_encryption' defined in cassandra.yaml.
spark.cassandra_bulk.server.keyStore.pathconf/.keystoreThe 'server_encryption_options:keystore' defined in cassandra.yaml.
spark.cassandra_bulk.server.keyStore.passwordcassandraThe 'server_encryption_options:keystore_password' defined in cassandra.yaml.
spark.cassandra_bulk.server.trustStore.pathconf/.truststoreThe 'server_encryption_options:truststore' defined in cassandra.yaml.
spark.cassandra_bulk.server.trustStore.passwordcassandraThe 'server_encryption_options:truststore_password' defined in cassandra.yaml.
spark.cassandra_bulk.server.protocolTLSThe 'server_encryption_options:protocol' defined in cassandra.yaml.
spark.cassandra_bulk.server.algorithmSunX509The 'server_encryption_options:algorithm' defined in cassandra.yaml.
spark.cassandra_bulk.server.store.typeJKSThe 'server_encryption_options:store_type' defined in cassandra.yaml.
spark.cassandra_bulk.server.cipherSuitesTLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHAThe 'server_encryption_options:cipher_suites' defined in cassandra.yaml.
spark.cassandra_bulk.server.requireClientAuthfalseThe 'server_encryption_options:require_client_auth' defined in cassandra.yaml.

About

Spark Library for Bulk Loading into Cassandra

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages