datastax-java-driver

How to increase the write performance in cassandra?

↘锁芯ラ 提交于 2019-12-07 19:46:24
问题 I have a column family called Emails and i am saving mails into this CF, it is taking 100+seconds to write 5000 mails . I am using i3 processor, 8gb ram . My data center has 6 nodes with replication factor = 2. Does the size of the data what we store into the Cassandra affects the performance ? What are all the factors that affects write performance and how do i increase the performance ? Thanks in advance.. 回答1: Some of factors you are asking about are: connection speed and latency between

What is the most efficient way to map/transform/cast a Cassandra BoundStatement's ResultSet to a Java classe built using the Object-mapping API?

青春壹個敷衍的年華 提交于 2019-12-07 07:37:53
问题 Is there a builtin way in DataStax Java for Apache Cassandra to map the ResultSet coming from a BoundStatement to the domain objects Java classes built with using the Object-mapping API? I am a newbie moving from the Mapper + Accessor approach to BoundStatement approach and would like to continue using the domain objects' Java classes built with the Object-mapping API so I do minimal changes to the implementation of my DAO methods while moving to the BoundStatement. I am looking to do it in a

How to efficiently use Batch writes to cassandra using datastax java driver?

流过昼夜 提交于 2019-12-07 05:02:28
问题 I need to write in Batches to Cassandra using Datastax Java driver and this is my first time I am trying to use batch with datastax java driver so I am having some confusion - Below is my code in which I am trying to make a Statement object and adding it to Batch and setting the ConsistencyLevel as QUORUM as well. Session session = null; Cluster cluster = null; // we build cluster and session object here and we use DowngradingConsistencyRetryPolicy as well // cluster = builder

How will i know that record was duplicate or it was inserted successfully?

爱⌒轻易说出口 提交于 2019-12-07 02:33:56
问题 Here is my CQL table: CREATE TABLE user_login ( userName varchar PRIMARY KEY, userId uuid, fullName varchar, password text, blocked boolean ); I have this datastax java driver code PreparedStatement prepareStmt= instances.getCqlSession().prepare("INSERT INTO "+ AppConstants.KEYSPACE+".user_info(userId, userName, fullName, bizzCateg, userType, blocked) VALUES(?, ?, ?, ?, ?, ?);"); batch.add(prepareStmt.bind(userId, userData.getEmail(), userData.getName(), userData.getBizzCategory(), userData

How to increase the write performance in cassandra?

孤街醉人 提交于 2019-12-06 13:43:55
I have a column family called Emails and i am saving mails into this CF, it is taking 100+seconds to write 5000 mails . I am using i3 processor, 8gb ram . My data center has 6 nodes with replication factor = 2. Does the size of the data what we store into the Cassandra affects the performance ? What are all the factors that affects write performance and how do i increase the performance ? Thanks in advance.. Jacek L. Some of factors you are asking about are: connection speed and latency between the client and the cluster, and between machines in the cluster (as mentioned by @omnibear )

range query in Cassandra

守給你的承諾、 提交于 2019-12-06 13:02:42
I'm using Cassandra 2.1.2 with the corresponding DataStax Java driver and the Object mapping provided by DataStax. following table definition: CREATE TABLE IF NOT EXISTS ses.tim (id text PRIMARY KEY, start bigint, cid int); the mapping: @Table(keyspace = "ses", name = "tim") class MyObj { @PartitionKey private String id; private Long start; private int cid; } the accessor @Accessor interface MyAccessor { @Query("SELECT * FROM ses.tim WHERE id = :iid") MyObj get(@Param("iid") String id); @Query(SELECT * FROM ses.tim WHERE start <= :sstart") Result<MyObj> get(@Param("sstart") long start); } as

How to executing batch statement and LWT as a transaction in Cassandra

谁都会走 提交于 2019-12-06 12:16:27
I have two table with below model: CREATE TABLE IF NOT EXISTS INV ( CODE TEXT, PRODUCT_CODE TEXT, LOCATION_NUMBER TEXT, QUANTITY DECIMAL, CHECK_INDICATOR BOOLEAN, VERSION BIGINT, PRIMARY KEY ((LOCATION_NUMBER, PRODUCT_CODE))); CREATE TABLE IF NOT EXISTS LOOK_INV ( LOCATION_NUMBER TEXT, CHECK_INDICATOR BOOLEAN, PRODUCT_CODE TEXT, CHECK_INDICATOR_DDTM TIMESTAMP, PRIMARY KEY ((LOCATION_NUMBER), CHECK_INDICATOR, PRODUCT_CODE)) WITH CLUSTERING ORDER BY (CHECK_INDICATOR ASC, PRODUCT_CODE ASC); I have a business operation where i need to update CHECK_INDICATOR in both the tables and QUANTITY in INV

Creating a custom index on a collection using CQL 3.0

孤街醉人 提交于 2019-12-06 12:04:20
I have been looking at the CQL 3.0 data modelling documentation which describes a column family of songs with tags, created like this: CREATE TABLE songs ( id uuid PRIMARY KEY, title text, tags set<text> ); I would like to get a list of all songs which have a specific tag, so I need to add an appropriate index. I can create an index on the title column easily enough, but if I try to index the tags column which is a collection, like this: CREATE INDEX ON songs ( tags ); I get the following error from the DataStax Java driver 1.0.4: Exception in thread "main" com.datastax.driver.core.exceptions

How can I store Objects in cassandra using the blob datatype

荒凉一梦 提交于 2019-12-06 11:13:09
I tried with the data type blob . That's giving some Datastax exception. I tried the object itself, bytearray. Still no good: Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Invalid STRING constant ([B@547248ad) for user_object of type blob This is the failing INSERT: executeSting.append("INSERT INTO htadb.objecttable (object_id, bucket_name, object_key, link, user_status, user_object) ") .append("VALUES (") .append(objectId).append(",'") .append(bucketName).append("','") .append(key).append("','") .append(link).append("','") .append("online").append("','") .append

Cassandra data stax Query Builder Update

↘锁芯ラ 提交于 2019-12-06 06:42:19
问题 I am trying to write a simple Update query - Update table set col1 = val1, col2 = val2 where col3 = val3; Can you please provide an example of writing a simple UPDATE in Cassandra using the Query builder API? 回答1: Try this out. v1.x: Query exampleQuery = update("table").with(set("col1", "val1")).and(set("col2","val2")).where(eq("col3","val3")); v2.x: Statement exampleQuery = update("table").with(set("col1", "val1")).and(set("col2","val2")).where(eq("col3","val3")); Patrick 来源: https:/