<commit_before># Documentation

## Connecting to Cassandra 
This section describes how Spark connects to Cassandra and 
how to execute CQL statements from Spark applications.

### Preparing `SparkContext` to work with Cassandra

To connect your Spark application to Cassandra, set connection options in the 
`SparkConf` object. These are prefixed with `spark.` so that they can be recognized
from the spark-shell and set within the $SPARK_HOME/conf/spark-default.conf.
The following options are available on `SparkConf` object:

Property name                                  | Description                                       | Default value
-----------------------------------------------|---------------------------------------------------|--------------------
spark.cassandra.connection.host                | contact point to connect to the Cassandra cluster | address of the Spark master host
spark.cassandra.connection.rpc.port            | Cassandra thrift port                             | 9160
spark.cassandra.connection.native.port         | Cassandra native port                             | 9042
spark.cassandra.connection.conf.factory        | name of a Scala module or class implementing `CassandraConnectionFactory` providing connections to the Cassandra cluster | `com.datastax.spark.connector.cql.DefaultConnectionFactory`
spark.cassandra.auth.username                  | login name for password authentication            |
spark.cassandra.auth.password                  | password for password authentication              |
spark.cassandra.auth.conf.factory              | name of a Scala module or class implementing `AuthConfFactory` providing custom authentication configuration | `com.datastax.spark.connector.cql.DefaultAuthConfFactory`

Additionally, the following global system properties are available:

Property name                                        | Description                                                   | Default value
-----------------------------------------------------|---------------------------------------------------------------|--------------------
spark.cassandra.connection.keep_alive_ms             | period of time to keep unused connections open                | 250 ms
spark.cassandra.connection.timeout_ms                | maximum period of time to attempt connecting to a node        | 5000 ms
spark.cassandra.connection.reconnection_delay_ms.min | minimum period of time to attempt reconnecting to a dead node | 1000 ms 
spark.cassandra.connection.reconnection_delay_ms.max | maximum period of time to attempt reconnecting to a dead node | 60000 ms 
spark.cassandra.connection.local_dc                  | the local DC to connect to (other nodes will be ignored)      | none
spark.cassandra.query.retry.count                    | number of times to retry a timed-out query                    | 10 
spark.cassandra.read.timeout_ms                      | maximum period of time to wait for a read to return           | 12000 ms
  
Example:

```scala
System.setProperty("spark.cassandra.query.retry.count", "1")  // don't retry<commit_msg>SPARKC-200: fix name of Cassandra connection factory in docs<commit_after># Documentation

## Connecting to Cassandra 
This section describes how Spark connects to Cassandra and 
how to execute CQL statements from Spark applications.

### Preparing `SparkContext` to work with Cassandra

To connect your Spark application to Cassandra, set connection options in the 
`SparkConf` object. These are prefixed with `spark.` so that they can be recognized
from the spark-shell and set within the $SPARK_HOME/conf/spark-default.conf.
The following options are available on `SparkConf` object:

Property name                                  | Description                                       | Default value
-----------------------------------------------|---------------------------------------------------|--------------------
spark.cassandra.connection.host                | contact point to connect to the Cassandra cluster | address of the Spark master host
spark.cassandra.connection.rpc.port            | Cassandra thrift port                             | 9160
spark.cassandra.connection.native.port         | Cassandra native port                             | 9042
spark.cassandra.connection.factory             | name of a Scala module or class implementing `CassandraConnectionFactory` providing connections to the Cassandra cluster | `com.datastax.spark.connector.cql.DefaultConnectionFactory`
spark.cassandra.auth.username                  | login name for password authentication            |
spark.cassandra.auth.password                  | password for password authentication              |
spark.cassandra.auth.conf.factory              | name of a Scala module or class implementing `AuthConfFactory` providing custom authentication configuration | `com.datastax.spark.connector.cql.DefaultAuthConfFactory`

Additionally, the following global system properties are available:

Property name                                        | Description                                                   | Default value
-----------------------------------------------------|---------------------------------------------------------------|--------------------
spark.cassandra.connection.keep_alive_ms             | period of time to keep unused connections open                | 250 ms
spark.cassandra.connection.timeout_ms                | maximum period of time to attempt connecting to a node        | 5000 ms
spark.cassandra.connection.reconnection_delay_ms.min | minimum period of time to attempt reconnecting to a dead node | 1000 ms 
spark.cassandra.connection.reconnection_delay_ms.max | maximum period of time to attempt reconnecting to a dead node | 60000 ms 
spark.cassandra.connection.local_dc                  | the local DC to connect to (other nodes will be ignored)      | none
spark.cassandra.query.retry.count                    | number of times to retry a timed-out query                    | 10 
spark.cassandra.read.timeout_ms                      | maximum period of time to wait for a read to return           | 12000 ms
  
Example:

```scala
System.setProperty("spark.cassandra.query.retry.count", "1")  // don't retry
{'fraction_non_alphanumeric': 0.13142308307987835, 'fraction_numerical': 0.010725148071074116, 'mean_word_length': 1.8194945848375452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3470266', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1312, 'n_words': 507}