cql

Order By any field in Cassandra

随声附和 提交于 2019-12-07 09:54:40
问题 I am researching cassandra as a possible solution for my up coming project. The more I research the more I keep hearing that it is a bad idea to sort on fields that is not setup for sorting when the table was created. Is it possible to sort on any field? If there is a performance impact for sorting on fields not in the cluster what is that performance impact? I need to sort around or about 2 million records in the table. 回答1: I keep hearing that it is a bad idea to sort on fields that is not

Many-to-many in Cassandra 3

ぐ巨炮叔叔 提交于 2019-12-07 07:44:25
What's the right way to model many-to-many relationships in Cassandra (using 3.10 at the moment)? From what answers I was able to find, denormalization into two relationship tables is suggested (as in here, for example: Modeling many-to-many relations in Cassandra 2 with CQL3 ). But there are problems with that on deletes, and those answers are so sparse they do not mention any details on that. Suppose we have the following tables: CREATE TABLE foo ( key UUID PRIMARY KEY, content TEXT ) CREATE TABLE bar ( key UUID PRIMARY KEY, content TEXT ) CREATE TABLE foo_bar ( foo UUID, bar UUID, PRIMARY

Understanding Cassandra's storage overhead

烈酒焚心 提交于 2019-12-07 04:21:37
问题 I have been reading this section of the Cassandra docs and found the following a little puzzling: Determine column overhead: regular_total_column_size = column_name_size + column_value_size + 15 counter - expiring_total_column_size = column_name_size + column_value_size + 23 Every column in Cassandra incurs 15 bytes of overhead. Since each row in a table can have different column names as well as differing numbers of columns, metadata is stored for each column. For counter columns and

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

Cassandra Allow filtering

倾然丶 夕夏残阳落幕 提交于 2019-12-07 02:23:13
问题 I have a table as below CREATE TABLE test ( day int, id varchar, start int, action varchar, PRIMARY KEY((day),start,id) ); I want to run this query Select * from test where day=1 and start > 1475485412 and start < 1485785654 and action='accept' ALLOW FILTERING Is this ALLOW FILTERING efficient? I am expecting that cassandra will filter in this order 1. By Partitioning column(day) 2. By the range column(start) on the 1's result 3. By action column on 2's result. So the allow filtering will not

Finding distinct values of non Primary Key column in CQL Cassandra

旧时模样 提交于 2019-12-07 01:24:34
问题 I use the following code for creating table: CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; USE mykeyspace; CREATE TABLE users ( user_id int PRIMARY KEY, fname text, lname text ); INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith'); INSERT INTO users (user_id, fname, lname) VALUES (1744, 'john', 'doe'); INSERT INTO users (user_id, fname, lname) VALUES (1746, 'john', 'smith'); I would like to find the distinct value

Cassandra Non-Counter Family

旧巷老猫 提交于 2019-12-06 20:43:12
问题 I'm attempted to execute the following CQL 3 statement CREATE TABLE summary ( id uuid, "client" bigint, "campaign" text, "unit" bigint, "view" counter, PRIMARY KEY ("client", "campaign", "unit")); The error I'm getting is that I cannot create a counter column on a non-counter column family. Any ideas? 回答1: The solution to this issue is that any non-counter column must be part of the primary key. The column id uuid was the one causing the issue, removing it allowed the table to be created. 回答2

Non frozen collections and user defined types on Cassandra 2.1.8

瘦欲@ 提交于 2019-12-06 17:22:27
问题 I'm trying to run the following example from here CREATE TYPE address ( street text, city text, zip int ); CREATE TABLE user_profiles ( login text PRIMARY KEY, first_name text, last_name text, email text, addresses map<text, address> ); However, when I try to create the user_profiles table, I get the following error: InvalidRequest: code=2200 [Invalid query] message="Non-frozen collections are not allowed inside collections: map<text, address> Any thoughts on why this could be happening? 回答1:

Create a table in Cassandra 1.2 with CQL3 where column names will be created at runtime

大兔子大兔子 提交于 2019-12-06 16:41:08
I want to store snapshots of an object in Apache Cassandra 1.2 Row key is the Object#ID and there will be a column for each snapshot. -------- latest -------- v2 -------- v1 id-122 100 -------- 50 -------- 66 -------- So column names are created dynamically at runtime. How to create the previous table in Cassandra 1.2 using CQL3 ? You would use the compound primary key feature of CQL3: CREATE TABLE foo ( object_id int, version int, value int, PRIMARY KEY (object_id, version)); In CQL3, Table schema is fixed. So you can't really get dynamic column names. For that you have to switch to CQL2. 来源:

Cassandra assynchronous execution in multiple processes blocking synchronous requests

妖精的绣舞 提交于 2019-12-06 14:49:06
I have an application that reads a series of XML files containing logs of vehicles passages in a road. The application then processes each record, transform a few of the informations to match the database columns and inserts it into a cassandra database (running a single node in a remote server [it's in an internal network so connection isn't really an issue]). After inserting data in the database, the process for each file then goes on to read this data and produce information for summary tables, that leaves information ready for a drilldown analysis made in an unrelated part of the