cql

Difference between Thrift and CQL 3 Columns/Rows

不羁岁月 提交于 2019-12-18 02:59:33
问题 At the Cassandra Summit, it was mentioned that Thrift and CQL 3 have subtle differences in their definitions of columns and rows. The Google hasn't helped me understand this difference. The only information I can find is that the metadata is different, and as such, I shouldn't mix thrift and CQL. What is the subtle difference (I've read a bit about metadata representations...)? in what way does it break the compatibility? Why is the change better? I'm happy to read any docs that will help me,

Cassandra: Generate a unique ID?

天涯浪子 提交于 2019-12-17 22:24:09
问题 I'm working on a distributed data base. I'm trying to generate a unique ID that will serve as a column family primary key in cassandra. I read some articles about doing this with Java using UUID but it seems like there is a probability for collision (even if it's very low). I wonder if there is a way to generate a unique ID based on time maybe? 回答1: You can use the TimeUUID type in Cassandra, which backs a Type 1 UUID . This uses the current time and the creator's MAC address and a sequence

Cassandra partition key for time series data

馋奶兔 提交于 2019-12-17 20:01:04
问题 I'm testing Cassandra as time series database. I create data model as below: CREATE KEYSPACE sm WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': 1 }; USE sm; CREATE TABLE newdata (timestamp timestamp, deviceid int, tagid int, decvalue decimal, alphavalue text, PRIMARY KEY (deviceid,tagid,timestamp)); In the Primary key, I set deviceid as the partition key which mean all data with same device id will write into one node (does it mean one machine or one partition. Each

MAX(), DISTINCT and group by in Cassandra

拜拜、爱过 提交于 2019-12-17 07:31:38
问题 I am trying to remodel a SQL database Cassandra such that, I can find the Cassandra equivalent for the SQL queries. I use CQL 3 and Cassandra v1.2. I modeled the db design in cassandra so that it supports the order by clauses and denormalized tables to support the join operation. However I am at sea when it comes to DISTINCT, SUM() and GROUPBY equvalents SELECT a1,MAX(b1) FROM demo1 group by a1. SELECT DISTINCT (a2) FROM demo2 where b2='sea' SELECT sum(a3), sum(b3) from demo3 where c3='water'

Why does cqlsh right-align strings?

a 夏天 提交于 2019-12-14 03:53:54
问题 I find that string-values displayed using cqlsh are right-aligned. Is there a reason for this? And is there a way to left-align strings? cqlsh:test> create table test (id int, a ascii, t text, primary key(id)); cqlsh:test> insert into test (id, a, t) values (1, 'ascii', 'text'); cqlsh:test> insert into test (id, a, t) values (2, 'a', 't'); cqlsh:test> select * from test; id | a | t ----+-------+------ 1 | ascii | text 2 | a | t (2 rows) 回答1: I think this is mostly done for aesthetic reasons,

Put primary keys in cassandra for updating record

怎甘沉沦 提交于 2019-12-14 02:24:15
问题 I have a table in cassandra. My task is: I want to select records with time range (so timestamp must be primary key, and not use allow filtering) when I insert record and provider_id and filename exists in table, the record is updated CREATE TABLE test ( name text, filename text, timestamp timestamp, is_deleted boolean, PRIMARY KEY (provider_id, filename, timestamp) ) 回答1: You can't update primary key column, It will insert another record . That's how cassandra work. You have to select the

Secondary index in Apache Cassandra

故事扮演 提交于 2019-12-13 18:09:19
问题 I tried to understand the secondary Index in Cassandra using the following link: https://www.youtube.com/watch?v=BPvZIj5fvl4 Let's say we have 5 node N1, N2, N3, N4 and N5 cluster with Replication Factor of 3 which means a partition data will be replicated to 3 nodes in the cluster (say N1, N2 and N3). Now when I execute this query: SELECT * FROM user WHERE partitionKey = "somedata" AND ClusteringKey = "test"; with the Read consistency as '2' It will query from any two of the nodes N1, N2 or

Kundera for Cassandra - Deleting record by row key

大兔子大兔子 提交于 2019-12-13 17:22:13
问题 I'm trying to delete specific record from database by row key. But when I try to execute this query: Query query = em.createQuery( "DELETE FROM User u WHERE u.userId = :u"); query.setParameter("u", userID).executeUpdate(); I got this exception: " Condition = is not suported for query on row key! ". Is there any workaround, or I missing something? 回答1: What you can do as a workaround is: Find using: User u = em.find(User.class, userId) and then, em.delete(u); 回答2: Also, http://groups.google

How can we convert com.datastax.driver.core.LocalDate to java.util.Date?

China☆狼群 提交于 2019-12-13 14:18:03
问题 I am working with dates. Datastax's CQL cassandra API Row.getDate() returns a com.datastax.driver.core.LocalDate . I want to convert the com.datastax.driver.core.LocalDate object returned by the API to java.util.Date . How can I do that? 回答1: The LocalDate.getMillisSinceEpoch() Javadoc says Returns the number of milliseconds since January 1st, 1970 GMT. And, the Date(long) constructor Javadoc says Allocates a Date object and initializes it to represent the specified number of milliseconds

Am I using cassandra efficiently?

China☆狼群 提交于 2019-12-13 05:51:31
问题 I have these table CREATE TABLE user_info ( userId uuid PRIMARY KEY, userName varchar, fullName varchar, sex varchar, bizzCateg varchar, userType varchar, about text, joined bigint, contact text, job set<text>, blocked boolean, emails set<text>, websites set<text>, professionTag set<text>, location frozen<location> ); create table publishMsg ( rowKey uuid, msgId timeuuid, postedById uuid, title text, time bigint, details text, tags set<text>, location frozen<location>, blocked boolean,