cql

How to know affected rows in Cassandra(CQL)?

你离开我真会死。 提交于 2019-12-08 17:30:25
问题 There doesn't seem to be any direct way to know affected rows in cassandra for update, and delete statements. For example if I have a query like this: DELETE FROM xyztable WHERE PKEY IN (1,2,3,4,5,6); Now, of course, since I've passed 6 keys, it is obvious that 6 rows will be affected. But, like in RDBMS world, is there any way to know affected rows in update/delete statements in datastax-driver? I've read cassandra gives no feedback on write operations here. Except that I could not see any

Disable colors in cqlsh

帅比萌擦擦* 提交于 2019-12-08 16:27:20
问题 cqlsh, the CQL command prompt for Apache Cassandra, is programmed to show colors in the query results. Is there an easy way to disable colors in cqlsh ? 回答1: Just have $TERM set to something that doesn't support color. For example, ~$ TERM=dumb cqlsh 回答2: To disable color output use ./bin/cqlsh --no-color Refer 回答3: It appears that although there is a --color option, it does not provide a way to disable colors, so I've opened CASSANDRA-4634 to fix that. As a side note, if the --file option is

Cassandra query on Map - Contains Clause [duplicate]

寵の児 提交于 2019-12-08 13:21:30
This question already has answers here : SELECT Specific Value from map (3 answers) Closed 4 years ago . I am trying to query a table containing Map. Is it possible to apply contains clause on map data type table? CREATE TABLE data.Table1 ( fetchDataMap map<text, frozen<Config>>, userId text , PRIMARY KEY(userId) ); Getting following Error: cqlsh> SELECT * FROM data.Table1 WHERE fetchDataMap CONTAINS '233322554843924'; InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted columns support the provided operators: " Please enlighten me with better query

Leveled Compaction Strategy with low disk space

China☆狼群 提交于 2019-12-08 13:17:08
问题 We have Cassandra 1.1.1 servers with Leveled Compaction Strategy. The system works so that there are read and delete operations. Every half a year we delete approximately half of the data while new data comes in. Sometimes it happens that disk usage goes up to 75% while we know that real data take about 40-50% other space is occupied by tombstones. To avoid disk overflow we force compaction of our tables by dropping all SSTables to Level 0. For that we remove .json manifest file and restart

Parameterized queries with the Python Cassandra Module

点点圈 提交于 2019-12-08 13:08:55
问题 I've been experimenting with the CQL plugin for Python (http://code.google.com/a/apache-extras.org/p/cassandra-dbapi2/) which has support for parameterized queries. From their documentation: import cql connection = cql.connect(host, port, keyspace) cursor = connection.cursor() cursor.execute("CQL QUERY", dict(kw='Foo', kw2='Bar', etc...)) My question is whether its possible to parameterize and execute the same query multiple times in a loop, and what the methods look like to accomplish that.

How do I achieve the throughput of 50k/sec in inserting my data in Cassandra while reading input from a csv file?

一个人想着一个人 提交于 2019-12-08 11:39:37
问题 My aim is to increase the throughput of versioning data in Cassandra. I have used concurrent reads and writes and have also increased the chunk size that my code reads from the file. My machine is 16gb with 8 cores and yes, I have changed Cassandra's yaml file for 10k concurrent reads and writes and when timed it, I found out that 10000 writes/reads takes less than a second. My minimal, viable code is: import json import logging import os import sys from datetime import datetime from hashlib

Cassandra query on Map - Contains Clause [duplicate]

99封情书 提交于 2019-12-08 06:42:55
问题 This question already has answers here : SELECT Specific Value from map (3 answers) Closed 4 years ago . I am trying to query a table containing Map. Is it possible to apply contains clause on map data type table? CREATE TABLE data.Table1 ( fetchDataMap map<text, frozen<Config>>, userId text , PRIMARY KEY(userId) ); Getting following Error: cqlsh> SELECT * FROM data.Table1 WHERE fetchDataMap CONTAINS '233322554843924'; InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on

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

淺唱寂寞╮ 提交于 2019-12-08 06:27:49
问题 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 ? 回答1: 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)); 回答2: In

Many-to-many in Cassandra 3

◇◆丶佛笑我妖孽 提交于 2019-12-08 05:45:34
问题 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

Importing cassandra table into spark via sparklyr - possible to select only some columns?

て烟熏妆下的殇ゞ 提交于 2019-12-07 15:44:22
问题 I've been working with sparklyr to bring large cassandra tables into spark, register these with R and conduct dplyr operations on them. I have been successfully importing cassandra tables with the code that looks like this: # import cassandra table into spark cass_df <- sparklyr:::spark_data_read_generic( sc, "org.apache.spark.sql.cassandra", "format", list(keyspace = "cass_keyspace", table = "cass_table") ) %>% invoke("load") # register table in R cass_tbl <- sparklyr:::spark_partition