cql3

How to auto generate uuid in cassandra CQL 3 command line

你说的曾经没有我的故事 提交于 2019-12-18 10:59:09
问题 Just learning cassandra, is there a way to insert a UUID using CQL, ie create table stuff (uid uuid primary key, name varchar); insert into stuff (name) values('my name'); // fails insert into stuff (uid, name) values(1, 'my name'); // fails Can you do something like insert into stuff (uid, name) values(nextuid(), 'my name'); 回答1: You can with time uuids (type 1 UUID) using the now() function e.g. insert into stuff (uid, name) values(now(), 'my name'); Works with uid or timeuuid. It generates

Difference between Thrift and CQL 3 Columns/Rows

痴心易碎 提交于 2019-12-18 03:00:24
问题 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,

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

CQL3 Each row to have its own schema

倾然丶 夕夏残阳落幕 提交于 2019-12-17 16:23:26
问题 I want to use Cassandra in a .Net application. My objective is to store some data in a column family, but each row of data will have varying schema. Example (A very simple one) I want to have a 'Toys' column family to store the following objects, (Notice how they have very different properties other than the ID property) Toy object 1 { "id":"1", "name":"Car", "number_of_doors":4, "likes":3} Toy object 2 { "id":"2", "type":"Plane", "flying_range":"100m"} Toy object 3 { "id":"3", "category":

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'

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

Astyanax getKey with compound key

╄→гoц情女王★ 提交于 2019-12-13 04:33:54
问题 I would like to run the following code with a compound primary key. Column<String> result = keyspace.prepareQuery(CF_COUNTER1) .getKey(rowKey) .getColumn("Column1") .execute().getResult(); Long counterValue = result.getLongValue(); Research seems to show that it can be a string that represents a key (if it's not a compound primary key). The documentation says that it is of type K , alas, I am not very experience with Java, and have no idea what that means. Is it just a base type that lots of

Selecting index from Cassandra list collection

社会主义新天地 提交于 2019-12-13 04:31:09
问题 I was curious if it's possible to SELECT a specific index from a list collection in Cassandra. Say I have: CREATE TABLE users ( user_id text PRIMARY KEY, order_list list<text> ); UPDATE users SET ordered_list = [ 'thing1', 'thing2', 'thing3' ] WHERE user_id = 'user1'; Is it possible to then get back an index of ordered_list, such as ordered_list[1] from a CQL query instead of the entire list? 回答1: No, you can't. You can UPDATE and DELETE with subscripts, but not SELECT or INSERT . 来源: https:/

Versioning in cassandra

烈酒焚心 提交于 2019-12-13 02:50:16
问题 I have a requirement of versioning to be done using cassandra. Following is my column family definition create table file_details(id text primary key, fname text, version int, mimetype text); I have a secondary index created on fname column. Whenever I do an insert for the same 'fname', the version should be incremented. And when I retrieve a row with fname it should return me the latest version row. Please suggest what approach needs to be taken. 回答1: If it's not possible to relax the