0

I am using cassandra 1.2.1. and datastax java driver 1.0.4

I have to add multiple record. I am doing as below

PreparedStatement   statement        = session.prepare("INSERT INTO domainCqlTables.PostPhotos(profile_id, post_id, image_id, image, feed_thumb, thumb_171x180, mime, time) VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
BoundStatement      boundStatement   = new BoundStatement(statement);

for(File file:files){
 .......... 
  ............
boundStatement.bind(.....);    
session.executeAsync(boundStatement);
}

Its executing but its very much slow. How can i do it efficiently?

Manish Kumar
  • 10,214
  • 25
  • 77
  • 147

1 Answers1

0

Try using batch statements.

With version 1.0.x of the driver, you'll have to build the CQL batch statement yourself and pass it to the driver.

Note that version 2.0.x, which is compatible with Cassandra 1.2.1, provides a more convenient API for building and executing batches.

Olivier Michallat
  • 2,302
  • 11
  • 13
  • how will i insert blob data. i am inserting it as withing singlw quote `'` `'myblobdata'` it throws `Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: cannot parse 'java.nio.HeapByteBuffer[pos=0 lim=48015 cap=48015]' as hex bytes` – Manish Kumar Aug 12 '14 at 05:54