cql3

Creating a custom index on a collection using CQL 3.0

有些话、适合烂在心里 提交于 2019-12-07 22:26:08
问题 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

When cassandra-driver was executing the query, cassandra-driver returned error OperationTimedOut

橙三吉。 提交于 2019-12-07 05:36:20
问题 I use python script, that passes to cassandra batch query, like this: query = 'BEGIN BATCH ' + 'insert into ... ; insert into ... ; insert into ...; ' + ' APPLY BATCH;' session.execute(query) It is work some time, but in about 2 minutes after start scripts fails and print: Traceback (most recent call last):<br> File "/home/fervid/Desktop/cassandra/scripts/parse_and_save_to_cassandra.cgi", line 127, in <module><br> session.execute(query)<br> File "/usr/local/lib/python2.7/dist-packages

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

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:

How to list column families in keyspace?

别来无恙 提交于 2019-12-06 16:50:36
问题 How can I get list of all column families in keyspace in Cassandra using CQL 3? 回答1: cqlsh> select columnfamily_name from system.schema_columnfamilies where keyspace_name = 'test'; columnfamily_name ------------------- commits foo has_all_types item_by_user test test2 user_by_item (7 rows) 回答2: Or even more simply (if you are using cqlsh), switch over to your keyspace with use and then execute describe tables : cqlsh> use products; cqlsh:products> describe tables; itemmaster itemhierarchy

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

Cassandra tombstones count multiple queries vs single query

风流意气都作罢 提交于 2019-12-06 10:50:32
I've a cassandra table definition as following CREATE TABLE mytable ( colA text, colB text, timeCol timestamp, colC text, PRIMARY KEY ((colA, colB, timeCol), colC) ) WITH.... I want to know if number of tombstones would vary between following types of queries: 1. delete from mytable where colA = '...' AND colB = '...' and timeCol = 111 Above query affect multiple records, (multiple values of colC) 2. delete from mytable where colA = '...' AND colB = '...' and timeCol = 111 AND colC = '...' However, 2nd query needs to be executed for each value of last column colC , while 1st query takes care

How to get top 5 records in cassandra 2.2

為{幸葍}努か 提交于 2019-12-06 05:44:45
问题 I need a help. I have a query which get top 5 records group by date (not date + time) and sum of amount. I wrote the following but it returns all the records not just top 5 records CREATE OR REPLACE FUNCTION state_groupbyandsum( state map<text, double>, datetime text, amount text ) CALLED ON NULL INPUT RETURNS map<text, double> LANGUAGE java AS 'String date = datetime.substring(0,10); Double count = (Double) state.get(date); if (count == null) count = Double.parseDouble(amount); else count =