How to use method bulkSaveToCassandra with spark-c

2019-07-29 10:07发布

问题:

I'm trying to use the method bulkSaveToCassandra with spark-cassandra-connector to optimize my insertions in Cassandra Database. However, I can't find out the method and I don't know how to import the lib.

Currently, I'm using this dependency:

<dependency>
            <groupId>com.datastax.spark</groupId>
            <artifactId>spark-cassandra-connector_2.11</artifactId>
            <version>2.0.2</version>
</dependency>

Below the reference of method bulkSaveToCassandra from Datastax: http://docs.datastax.com/en/datastax_enterprise/4.7/datastax_enterprise/migration/migratingBulkSparkRDD.html

I used the import presented in link but it don't work anyway.

Best regards,

回答1:

That method is only available in DataStax Enterprise.

The required class is inside of the dse-spark*.jar which comes with the DSE Installation.

For example this would be available from the dse spark shell.

I would recommend just using the normal write method though for most use cases as the bulkMethod uses the sstable writer which has availability issues which don't jive well with production use cases.