Reputation: 223
Currently, I have setup a project with springboot, I can use the CassandraRepository
to query the data from cassandra database.
But now, I have faced some problems:
I want to use BatchStatment.add(Statement)
to implement the batch query.
MappingManager.getSession().execute(statement)
Upvotes: 1
Views: 2803
Reputation: 43
The best approach to write to cassandra is through concurrent async writes.(supported by Datastax driver).
Does batch operation contains mixed partition key , if yes then batch would be slower compare to async writes
for mixed partition batch queries, we have implemented token aware batch statement method that really showed good performance with large set of data.
Follow that link for details: https://dzone.com/articles/efficient-cassandra-write
Upvotes: 0
Reputation: 16400
To use Springs version there is CassandraBatchOperations
from CassandraTemplate.batchOps()
.
The MappingManager is from the DataStax ORM so its kinda mixing things up. While it doesn't directly support batching (because it's usually wrong thing to do) you can call the mapper.saveQuery(obj)
method to get the raw Statement and add it to a new BatchStatement()
you created yourself and pass that to the Session.execute
.
Be sure you actually need batches (for the atomicity). They are slow, expensive and don't scale as well as normal inserts.
Upvotes: 4