question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I'm running the latest build of the Docker Apple Silicon Preview. I created the tutorial container/images and it works fine. When I went to create a custom YAML file and run docker-compose I get the following error when pulling mysql: ERROR: no matching manifest for linux/arm64/v8 in the manifest list entries Here is a...
Well, technically it will not solve your issue (running MySQL on ARM), but for the time being, you could add platform to your service like: services: db: platform: linux/x86_64 image: mysql:5.7 ... Alternatively, consider using MariaDB, which should work as a drop-in replacement like e.g. this: services:...
MySQL
65,456,814
496
Bearing in mind that I'll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database?
Basically it depends on the precision you need for your locations. Using DOUBLE you'll have a 3.5nm precision. DECIMAL(8,6)/(9,6) goes down to 16cm. FLOAT is 1.7m... This very interesting table has a more complete list: http://mysql.rjweb.org/doc.php/latlng : Datatype Bytes Resolution Deg*100 ...
MySQL
159,255
496
I'm interested in learning some (ideally) database agnostic ways of selecting the nth row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: SQL Server MySQL PostgreSQL SQLite Oracle I am currently doing something like the fo...
There are ways of doing this in optional parts of the standard, but a lot of databases support their own way of doing it. A really good site that talks about this and other things is http://troels.arvin.dk/db/rdbms/#select-limit. Basically, PostgreSQL and MySQL supports the non-standard: SELECT... LIMIT y OFFSET x Or...
MySQL
16,568
495
I need to add multiple columns to a table but position the columns after a column called lastname. I have tried this: ALTER TABLE `users` ADD COLUMN ( `count` smallint(6) NOT NULL, `log` varchar(12) NOT NULL, `status` int(10) unsigned NOT NULL ) AFTER `lastname`; I get this error: You have an error in yo...
Try this ALTER TABLE users ADD COLUMN `count` SMALLINT(6) NOT NULL AFTER `lastname`, ADD COLUMN `log` VARCHAR(12) NOT NULL AFTER `count`, ADD COLUMN `status` INT(10) UNSIGNED NOT NULL AFTER `log`; check the syntax
MySQL
17,541,312
494
I asked a question and got this reply which helped. UPDATE TABLE_A a JOIN TABLE_B b ON a.join_col = b.join_col AND a.column_a = b.column_b SET a.column_c = a.column_c + 1 Now I am looking to do this if there are three tables involved something like this. UPDATE tableC c JOIN tableB b JOIN tableA a My que...
The answer is yes, you can. Try it like this: UPDATE TABLE_A a JOIN TABLE_B b ON a.join_col = b.join_col AND a.column_a = b.column_b JOIN TABLE_C c ON [condition] SET a.column_c = a.column_c + 1 For a general update join: UPDATE TABLEA a JOIN TABLEB b ON a.join_colA = b.join_colB SET a.columnToUpdate = [someth...
MySQL
15,209,414
493
I am trying to rename a column in MySQL community server 5.5.27 using this SQL expression: ALTER TABLE table_name RENAME COLUMN old_col_name TO new_col_name; I also tried ALTER TABLE table_name RENAME old_col_name TO new_col_name; But it says: Error: check the Manual that corresponds to your MySQL server version
Use this query: ALTER TABLE tableName CHANGE oldcolname newcolname datatype(length); The RENAME function is used in Oracle databases. ALTER TABLE tableName RENAME COLUMN oldcolname TO newcolname datatype(length); @lad2025 mentions it below, but I thought it'd be nice to add what he said. Thank you @lad2025! You can ...
MySQL
30,290,880
489
When we create a table in MySQL with a VARCHAR column, we have to set the length for it. But for TEXT type we don't have to provide the length. What are the differences between VARCHAR and TEXT?
TL;DR TEXT fixed max size of 65535 characters (you cannot limit the max size) takes 2 + c bytes of disk space, where c is the length of the stored string. cannot be (fully) part of an index. One would need to specify a prefix length. VARCHAR(M) variable max size of M characters M needs to be between 1 and 65535 take...
MySQL
25,300,821
485
My MySQL database contains several tables using different storage engines (specifically myisam and innodb). How can I find out which tables are using which engine?
SHOW TABLE STATUS WHERE Name = 'xxx' This will give you (among other things) an Engine column, which is what you want.
MySQL
213,543
481
I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
If you're looking for a way to normalize a date into MySQL format, use the following $phpdate = strtotime( $mysqldate ); $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); The line $phpdate = strtotime( $mysqldate ) accepts a string and performs a series of heuristics to turn that string into a unix timestamp. The line $my...
MySQL
136,782
481
How would I delete all duplicate data from a MySQL Table? For example, with the following data: SELECT * FROM names; +----+--------+ | id | name | +----+--------+ | 1 | google | | 2 | yahoo | | 3 | msn | | 4 | google | | 5 | google | | 6 | yahoo | +----+--------+ I would use SELECT DISTINCT name FROM nam...
Editor warning: This solution is computationally inefficient and may bring down your connection for a large table. NB - You need to do this first on a test copy of your table! When I did it, I found that unless I also included AND n1.id <> n2.id, it deleted every row in the table. If you want to keep the row with th...
MySQL
4,685,173
477
My problem started off with me not being able to log in as root any more on my mysql install. I was attempting to run mysql without passwords turned on... but whenever I ran the command # mysqld_safe --skip-grant-tables & I would never get the prompt back. I was trying to follow these instructions to recover the pas...
Try this command, sudo service mysql start
MySQL
11,990,708
474
Some background: I have a Java 1.6 webapp running on Tomcat 7. The database is MySQL 5.5. Previously, I was using Mysql JDBC driver 5.1.23 to connect to the DB. Everything worked. I recently upgraded to Mysql JDBC driver 5.1.33. After the upgrade, Tomcat would throw this error when starting the app. WARNING: Unexpected...
Apparently, to get version 5.1.33 of MySQL JDBC driver to work with UTC time zone, one has to specify the serverTimezone explicitly in the connection string. jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
MySQL
26,515,700
470
The DynamoDB Wikipedia article says that DynamoDB is a "key-value" database. However, calling it a "key-value" database completely misses an extremely fundamental feature of DynamoDB, that of the sort key: Keys have two parts (partition key and sort key) and items with the same partition key can be efficiently retrieve...
Before CQL was introduced, Cassandra adhered more strictly the wide column store data model, where you only had rows identified by a row key and containing sorted key/value columns. With the introduction of CQL, rows became known as partitions and columns could optionally be grouped in to logical rows via clustering k...
Cassandra
60,798,118
15
I have two procesess each process do 1) connect oracle db read a specific table 2) form dataframe and process it. 3) save the df to cassandra. If I am running both process parallelly , both try to read from oracle and I am getting below error while second process read the data ERROR ValsProcessor2: org.apache.spark....
I was closing the sparkSession in finally block in the first processor/called class. I moved it out of the processor and placed inside the calling class which solved the issue.
Cassandra
53,011,256
15
When I try to start Cassandra after patching my OS, I get this error: Exception (java.lang.AbstractMethodError) encountered during startup: org.apache.cassandra.utils.JMXServerUtils$Exporter.exportObject(Ljava/rmi/Remote;ILjava/rmi/server/RMIClientSocketFactory;Ljava/rmi/server/RMIServerSocketFactory;Lsun/misc/ObjectIn...
This seems to relate to an upgrade to the JDK to 8u161 which was released 2 days ago. A ticket has been opened on the Cassandra Jira There is no published work-around that I can find. You might have to go back to an earlier version of the JDK or wait for Cassandra 3.11.2 which fixes the issue. Edit: Its worth pointing...
Cassandra
48,328,661
15
I'm trying to run Cassandra in a docker container and connect to it from my Mac (the host) but I keep getting Connection refused errors. The docker command: => docker run --rm --name cassandra -d cassandra:3.11 -p 9042:9042 => docker ps CONTAINER ID IMAGE COMMAND CREATED ...
Port is still not exposed outside Try this docker run -p 9042:9042 --rm --name cassandra -d cassandra:3.11 Do docker ps you should see something like this 0.0.0.0:9042->9042/tcp For more info : https://docs.docker.com/engine/reference/commandline/run/
Cassandra
47,672,400
15
I have come to this dilemma that I cannot choose what solution is going to be better for me. I have a very large table (couple of 100GBs) and couple of smaller (couple of GBs). In order to create my data pipeline in Spark and use spark ML I need to join these tables and do couple of GroupBy (aggregate) operations. Thos...
Cassandra is also a good solution for analytics use cases, but in another way. Before you model your keyspaces, you have to know how you need to read the data. You can also use where and range queries, but in a hard restricted way. Sometimes you will hate this restriction, but there are reasons for these restrictions. ...
Cassandra
37,806,066
15
I am trying to configure Cassandra Datastax Community Edition for remote connection on windows, Cassandra Server is installed on a Windows 7 PC, With the local CQLSH it connects perfectly to the local server. But when i try to connect with CQLSH from another PC in the same Network, i get this error message: Connecti...
How about this: Make these changes in the cassandra.yaml config file: start_rpc: true rpc_address: 0.0.0.0 broadcast_rpc_address: [node-ip] listen_address: [node-ip] seed_provider: - class_name: ... - seeds: "[node-ip]" reference: https://gist.github.com/andykuszyk/7644f334586e8ce29eaf8b93ec6418c4
Cassandra
36,133,127
15
I have a RHEL 7.0 server running Cassandra 2.2.3 which I tried to upgrade to 3.0. When I run yum update it showed me there is a new version of Cassandra for update, and upgraded the server to 2.2.4-1, but not 3.0. Now if I search yum for dsc30 I can find it, and presumably I can install it too, but why the automated up...
It's a different application and you can have 2.* and 3.* in parallel. Use yum install dsc30 to install version 3. If you want to upgrade your current installation then follow the steps described here
Cassandra
34,355,949
15
I cannot cqlsh to remote host ./cqlsh xx.xx.x.xxx 9042 Connection error: ('Unable to connect to any servers', {'10.101.33.163': ConnectionException(u'Did not get expected SupportedMessage response; instead, got: <ErrorMessage code=0000 [Server error] message="io.netty.handler.codec.DecoderExcepti...
1) Make sure the service is running: $ ps aux | grep cassandra Example: 106 7387 5.1 70.9 2019816 1454636 ? SLl Sep02 16:39 /usr/lib/jvm/java-7-oracle/jre//bin/java -Ddse.system_cpu_cores=2 -Ddse.system_memory_in_mb=2003 -Dcassandra.config.loader=com.datastax.bdp.config.DseConfigurationLoader -Ddse.system_...
Cassandra
32,364,969
15
I'm logging in with on Ubuntu 14.10 on Cassandra 2.0.8 with Java 1.7.0_60-b19 cqlsh -u cassandra -p cassandra I'm running: CREATE USER a WITH PASSWORD 'a' NOSUPERUSER; I'm getting the error: Bad Request: Only superusers are allowed to perform CREATE USER queries The problem with reasoning - I am logged in as the sup...
You need to enable PasswordAuthenticator in cassandra.yaml file. To enable PasswordAuthenticator you need to change authenticator property in cassandra.yaml Change authenticator: AllowAllAuthenticator to authenticator: PasswordAuthenticator After that login with following command and then you will be able to add new...
Cassandra
24,219,953
15
I have gone though this article and here is the schema I have got from it. This is helpful for my application for maintaining statuses of a user, but how can I extend this to maintain one to one chat archive and relations between users, relations mean people belong to specific group for me. I am new to this and need an...
With C* you need to store data in the way you'll use it. So let's see how this would look like for this case: I want to store messages between user-user in a table. Whenever a user want to load messages by a user. I want to retrieve them back and send it to user. CREATE TABLE chat_messages ( message_id uuid, f...
Cassandra
24,176,883
15
I have full access to the Cassandra installation files and a PasswordAuthenticator configured in cassandra.yaml. What do I have to do to reset admin user's password that has been lost, while keeping the existing databases intact?
The hash has changed for Cassandra 2.1: Switch to authenticator: AllowAllAuthenticator Restart cassandra UPDATE system_auth.credentials SET salted_hash = '$2a$10$H46haNkcbxlbamyj0OYZr.v4e5L08WTiQ1scrTs9Q3NYy.6B..x4O' WHERE username='cassandra'; Switch back to authenticator: PasswordAuthenticator Restart cassandra Logi...
Cassandra
18,398,987
15
I've cobbled together the below code that doesn't do anything complex -- just creates a byte[] variable, writes it into a blob field in Cassandra (v1.2, via the new Datastax CQL library), then reads it back out again. When I put it in it's 3 elements long, and when I read it back it's 84 elements long...! This means t...
The problem is almost certainly because the array returned by ByteBuffer.array() is the full backing array, but the data may only be contained within a portion of it. The valid data that is being returned starts at ByteBuffer.arrayOffset() and is of length ByteBuffer.remaining(). To get a byte array containing just th...
Cassandra
17,282,361
15
I'm developing a little web application for studying Apache Cassandra and Java EE 6. Cassandra version is 1.1.6. Have a problem driving me mad... I created a table with a counter (using cqlsh v. 3.0.0) CREATE TABLE test ( author varchar PRIMARY KEY, tot counter ) and put some values this way: update test set tot =...
Cassandra has some strict limits on deleting counters. You cannot really delete a counter and then use it again in any short period of time. From the Cassandra wiki: Counter removal is intrinsically limited. For instance, if you issue very quickly the sequence "increment, remove, increment" it is possible for the re...
Cassandra
13,653,681
15
For operations monitoring of my application, I am looking for something similar to the commonly used "SQL connection validation" query SELECT 1; in Cassandra, using the Hector driver. I have tried things like looking at Cluster.getKnownPoolHosts() and .getConnectionManager().getActivePools(). But it seems that their ...
With CQL3, I'm using the following query: SELECT now() FROM system.local; It would be nice to get rid of the FROM clause altogther to make this generic, in case the user does not have access to the system keyspace or local column family for some reason. But as with the other answers, at least this should not give fals...
Cassandra
10,246,287
15
I just wanted to know if there is a fundamental difference between hbase, cassandra, couchdb and monogodb ? In other words, are they all competing in the exact same market and trying to solve the exact same problems. Or they fit best in different scenarios? All this comes to the question, what should I chose when. Matt...
Those are some long answers from @Bohzo. (but they are good links) The truth is, they're "kind of" competing. But they definitely have different strengths and weaknesses and they definitely don't all solve the same problems. For example Couch and Mongo both provide Map-Reduce engines as part of the main package. HBase ...
Cassandra
3,652,310
15
We are looking at using a NoSQL database system for a large project. Currently, we have read a bit about MongoDB and Cassandra, though we have absolutely no experience with either. We are very proficient with traditional relational databases like MySQL and Microsoft SQL, but the NoSQL (key/value store) is a new paradig...
MongoDB has built-in support for geospatial indexes: http://www.mongodb.org/display/DOCS/Geospatial+Indexing As an example to find the 10 closest devices to that location you can just do db.devices.find({location: {$near: [-118.12719739973545, 33.859012351859946]}}).limit(10)
Cassandra
3,527,956
15
Can someone explain how MapReduce works with Cassandra .6? I've read through the word count example, but I don't quite follow what's happening on the Cassandra end vs. the "client" end. https://svn.apache.org/repos/asf/cassandra/trunk/contrib/word_count/ For instance, let's say I'm using Python and Pycassa, how would I...
From what I've heard (and from here), the way that a developer writes a MapReduce program that uses Cassandra as the data source is as follows. You write a regular MapReduce program (the example you linked to is for the pure-Java version) and the jars that are now available provide a CustomInputFormat that allows the i...
Cassandra
2,734,005
15
EDIT: Although yukim's workaround does work, I found that by downgrading to JDK 8u251 vs 8u261, the sigar lib works correctly. Windows 10 x64 Pro Cassandra 3.11.7 NOTE: I have JDK 11.0.7 as my main JDK, so I override JAVA_HOME and PATH in the batch file for Cassandra. Opened admin prompt and... java -version java ver...
I think it is sigar-lib that cassandra uses that is causing the problem (especially on the recent JDK8). It is not necessary to run cassandra, so you can comment out this line from cassandra-env.ps1 in conf directory: https://github.com/apache/cassandra/blob/cassandra-3.11.7/conf/cassandra-env.ps1#L357
Cassandra
63,144,295
14
I'm trying to access my Cassandra server through a CQLSH client to import a huge CSV file. I'm getting a module' object has no attribute 'parse_options error. I run the follow command: cqlsh XXX.XXX.XX.XX XXXX --cqlversion="3.4.2" --execute="copy evolvdso.teste from '2016-10-26 15:25:10.csv' WITH DELIMITER =',' AND HEA...
Has the same issue when I use cqlsh from pip install cqlsh. Try just use cassandra's tool cqlsh sudo docker run -it cassandra /usr/bin/cqlsh Refer to jira
Cassandra
40,289,324
14
From two different links of the Cassandra's documentation, I found: link 1 A structure stored in memory that checks if row data exists in the memtable before accessing SSTables on disk and link2 Cassandra checks the Bloom filter to discover which SSTables are likely to have the request partition data. My question ...
A Bloom filter is a generic data structure used to check if an element is present in a set or not. Its algorithm is designed to be extremely fast, at the cost of risking to return false positives. Cassandra uses bloom filters to test if any of the SSTables is likely to contain the requested partition key or not, withou...
Cassandra
39,327,427
14
I have read about C* replication, Is setting the partitioner in Cassandra setup to Murmur Partitioner makes the cluster C* cluster?
"C*" is an abbreviation for "Cassandra". They are the same thing.
Cassandra
36,028,926
14
I am trying to setup cassandra in my RHEL 6.5 server. When i start cassandara, i get an ERROR related to JNA. The exception says class not found. However, I see in the logs that the jna jar is added to the classpath. I tried using both apache-cassandra-3.0.0 and apache-cassandra-2.2.3, i am getting the same exception i...
I went through the code in CLibrary.java and found following code where the exception is caught - catch (UnsatisfiedLinkError e) { logger.warn("JNA link failure, one or more native method will be unavailable."); logger.trace("JNA link failure details: {}", e.getMessage()); } I restarted cassandra by changing...
Cassandra
34,059,020
14
I'm having trouble trying to model my data such that I can efficiently query Cassandra for the last 10 (any number actually) records that were most recently modified. Each record has a last_modified_date column that is set by the application when inserting/updating the record. I've excluded the data columns from this e...
I think what you're trying to do is more of a relational database model and is somewhat of an anti-pattern in Cassandra. Cassandra only sorts things based on clustering columns, but the sort order isn't expected to change. This is because when memtables are written to disk as SSTables (Sorted String Tables), the SSTab...
Cassandra
32,014,367
14
Writing data to Cassandra without causing it to create tombstones are vital in our case, due to the amount of data and speed. Currently we have only written a row once, and then never had the need to update the row again, only fetch the data again. Now there has been a case, where we actually need to write data, and th...
Tombstones will only created when deleting data or using TTL values. Cassandra does align very well to your described use case. Incrementally adding data will work for both INSERT and UPDATE statements. Cassandra will store data in different locations in case of adding data over time for the same partition key. Period...
Cassandra
31,053,406
14
I have a three nodes Cassandra Cluster and I have created one table which has more than 2,000,000 rows. When I execute this (select count(*) from userdetails) query in cqlsh, I got this error: OperationTimedOut: errors={}, last_host=192.168.1.2 When I run count function for less row or with limit 50,000 it works fine...
count(*) actually pages through all the data. So a select count(*) from userdetails without a limit would be expected to timeout with that many rows. Some details here: http://planetcassandra.org/blog/counting-key-in-cassandra/ You may want to consider maintaining the count yourself, using Spark, or if you just want a...
Cassandra
29,394,382
14
I am new to Cassandra and I want to install it. So far I've read a small article on it. But there one thing that I do not understand and it is the meaning of 'node'. Can anyone tell me what a 'node' is, what it is for, and how many nodes we can have in one cluster ?
A node is the storage layer within a server. Newer versions of Cassandra use virtual nodes, or vnodes. There are 256 vnodes per server by default. A vnode is essentially the storage layer. machine: a physical server, EC2 instance, etc. server: an installation of Cassandra. Each machine has one installation of Cassand...
Cassandra
28,456,921
14
My table looks like this create table Notes( user_id varchar, real_time timestamp, insertion_time timeuuid, read boolean PRIMARY KEY (user_id,real_time,insertion_time) ); create index read_index on Notes (read); I want update all the rows with user_id = 'xxx' without having to specify all the clusteri...
While this might be possible with a RDBMS and SQL, it is not possible with cql in Cassandra. From the DataStax documentation on the UPDATE command: Each update statement requires a precise set of primary keys to be specified using a WHERE clause. You need to specify all keys in a table having compound and clustering ...
Cassandra
27,295,679
14
In Cassandra, I can create a composite partition key, separate from my clustering key: CREATE TABLE footable ( column1 text, column2 text, column3 text, column4 text, PRIMARY KEY ((column1, column2)) ) As I understand it, quering by partition key is an extremely efficient (the most efficient?) meth...
This is not the case in Cassandra, because it is not possible. Doing so will yield the following error: Partition key part entity must be restricted since preceding part is Check out this Cassandra 2014 SF Summit presentation from DataStax MVP Robbie Strickland titled "CQL Under the Hood." Slides 62-64 show that th...
Cassandra
27,277,025
14
I have a delicate Spark problem, where i just can't wrap my head around. We have two RDDs ( coming from Cassandra ). RDD1 contains Actions and RDD2 contains Historic data. Both have an id on which they can be matched/joined. But the problem is the two tables have an N:N relation ship. Actions contains multiple rows wi...
It's an interesting problem. I also spent some time figuring out an approach. This is what I came up with: Given case classes for Action(id, time, x) and Historic(id, time, y) Join the actions with the history (this might be heavy) filter all historic data not relevant for a given action key the results by (id,time)...
Cassandra
27,138,392
14
I am trying to evaluate number of tombstones getting created in one of tables in our application. For that I am trying to use nodetool cfstats. Here is how I am doing it: create table demo.test(a int, b int, c int, primary key (a)); insert into demo.test(a, b, c) values(1,2,3); Now I am making the same insert as above...
For tombstone counts on a query your best bet is to enable tracing. This will give you the in depth history of a query including how many tombstones had to be read to complete it. This won't give you the total tombstone count, but is most likely more relevant for performance tuning. In cqlsh you can enable this with ...
Cassandra
27,063,508
14
Given an example of the following select in CQL: SELECT * FROM tickets WHERE ID IN (1,2,3,4) Given ID is a partition key, is using IN relation better than doing multiple queries or is there no difference?
I remembered seeing someone answer this question in the Cassandra user mailing list a short while back, but I cannot find the exact message right now. Ironically, Cassandra Evangelist Rebecca Mills just posted an article that addresses this issue (Things you should be doing when using Cassandra drivers...points #13 an...
Cassandra
26,999,098
14
Executing two identical requests but the DISTINCT keyword gives unexpected results. Without the keyword, the result is ok but with DISTINCT, it looks like the where clause is ignored. Why ? Cqlsh version: Connected to Test Cluster at localhost:9160. [cqlsh 4.1.1 | Cassandra 2.0.6 | CQL spec 3.1.1 | Thrift protocol 19.3...
It happens that way because in Cassandra CQL DISTINCT is designed to return only the partition (row) keys of your table (column family)...which must be unique. Therefore, the WHERE clause can only operate on partition keys when used with DISTINCT (which in your case, isn't terribly useful). If you take the DISTINCT o...
Cassandra
26,548,788
14
We are currently evaluating Cassandra as the data store for an analytical application. The plan was to dump raw data in Cassandra and then run mainly aggregation queries over it. Looking at CQL, it does not seem to support some traditional SQL operators like: Typical aggregation functions like average, sum, count-Dist...
Aggregation is available in cassandra as part of CASSANDRA-4914 which is available in the 2.2.0-rc1 release.
Cassandra
23,532,128
14
I'm currently using the Datastax Cassandra driver for Cassandra 2 to execute cql3. This works correctly. I started using PreparedStatement's: Session session = sessionProvider.getSession(); try { PreparedStatement ps = session.prepare(cql); ResultSet rs = session.execute(ps.bind(objects)); if (irsr != null)...
You may just initialize the PreparedStatement once and cache it while the app is running. It should be available for use as long as the Cassandra cluster is up. Using the statement from multiple threads is fine (as long as you don't modify it throught setXXX() methods). When you call bind(), the code underneath only ...
Cassandra
22,915,840
14
I'm trying to understand the connection pooling in Datastax Cassandra Driver, so I can better use it in my web service. I have version 1.0 of the documentation. It says: The Java driver uses connections asynchronously, so multiple requests can be submitted on the same connection at the same time. What do they underst...
The accepted answer (at the time of this writing) is giving the correct advice: As long as you use the same Session object, you [will] be reusing connections. However, some parts were originally oversimplified. I hope the following provides insight into the scope of each object type and their respective purposes. Bu...
Cassandra
20,421,763
14
Let's say I use CQL to define this table. CREATE TABLE songs ( id uuid PRIMARY KEY, title text, album text, artist text, tags set<text>, data blob); How can other developers (or myself after a few weeks) (re)discover the layout of this table? I'm thinking of an equivalent to the MySQL DESCR...
You should try the cqlsh tool which will show you exactly what you want: lyubent@vm: ~$ ./cqlsh cqlsh> use system; cqlsh> describe columnfamily local; CREATE TABLE local ( key text PRIMARY KEY, bootstrapped text, cluster_name text, cql_version text, data_center text, gossip_generation int, host_id uuid,...
Cassandra
18,106,043
14
I'm using Cassandra to store pictures. We are currently mass migrating pictures from an old system. Everything works great for a while, but eventually we'd get a TimedOutException when saving which I assume is because the work queue was filled. However, after waiting (several hours) for it to finish, the situation cont...
I guess you're just overloading one of your nodes with writes - i.e. you write faster than it is capable to digest. This is pretty easy if your writes are huge. The MutationStage is increasing even after you stopped writing to the cluster, because the other nodes are still processing queued mutation requests and send ...
Cassandra
14,714,413
14
We have a lot of user interaction data from various websites stored in Cassandra such as cookies, page-visits, ads-viewed, ads-clicked, etc.. that we would like to do reporting on. Our current Cassandra schema supports basic reporting and querying. However we also would like to build large queries that would typically ...
In my experience Cassandra is better suited to processes where you need real-time access to your data, fast random reads and just generally handle large traffic loads. However, if you start doing complex analytics, the availability of your Cassandra cluster will probably suffer noticeably. In general from what I've see...
Cassandra
14,532,230
14
I am pretty new to Cassandra, just started learning Cassandra a week ago. I first read, that it was a NoSQL, but when i started using CQL, I started to wonder whether Cassandra is a NoSQL or SQL DB? Can someone explain why CQL is more or less like SQL?
CQL is declarative like SQL and the very basic structure of the query component of the language (select things where condition) is the same. But there are enough differences that one should not approach using it in the same way as conventional SQL. The obvious items: 1. There are no joins or subqueries. 2. No tran...
Cassandra
11,154,547
14
There are four high level APIs to access Cassandra and I do not have time to try them all. So I hoped to find somebody who could help me to choose the proper one. I'll try to write down my findings about them: Datanucleus-Cassandra-Plugin pros: supports JPA1, JPA2, JDO1 - JDO3 - as I read in a review, JDO scales bette...
I tried most of these solutions and find hector the best. Even when you have some problem you can always reach people who wrote hector in #cassandra in freenode. and the code is more mature as far as I concern. In cassandra client the most critical part would be connection pooling management (since all the clients do m...
Cassandra
5,232,123
14
What is the meaning of eventual consistency in Cassandra when nodes in a single cluster do not contain the copies of same data but data is distributed among nodes. Now since a single peice of data is recorded at a single place (node). Why wouldn't Cassandra return the recent value from that single place of record? How ...
Cassandra's consistency is tunable. What can be tuned? Number of nodes needed to agree on the data for reads... call it R Number of nodes needed to agree on the data for writes... call it W In case of 3 nodes, if we chose 2R and 2W, then during a read, if 2 nodes agree on a value, that is the true value. The 3rd may ...
Cassandra
4,584,353
14
Lately I have been reading a lot of blog topics about big sites(facebook, twitter, digg, reddit to name a few) using cassandra as their datastore instead of MysqL. I would like to gather a list of resources to learn using cassandra. Hopefully some videos or podcasts explaining how to use cassandra. My list Twissandra ...
I found these articles really helpful coming from the relational world: http://www.sodeso.nl/?p=80 http://www.sodeso.nl/?p=108 http://www.sodeso.nl/?p=207 Right now the docs available for cassandra is limited in some places. I've been watching the Cassandra user and dev email list like a hawk. That seems to be where ...
Cassandra
2,438,362
14
Surely one can run a single node cluster but I'd like some level of fault-tolerance. At present I can afford to lease two servers (8GB RAM, private VLAN @1GigE) but not 3. My understanding is that 3 nodes is the minimum needed for a Cassandra cluster because there's no possible majority between 2 nodes, and a majority ...
If you need availability on a RF=2, clustersize=2 system, then you can't use ALL or you will not be able to write when a node goes down. That is why people recommend 3 nodes instead of 2, because then you can do quorum reads+writes and still have both strong consistency and availability if a single node goes down. With...
Cassandra
2,330,562
14
We're planning on migrating our environment from Java 8 to OpenJDK 10. Doing this on my local machine, I've found that Cassandra will no longer start for me, giving the following error : I can't find any solid information online that says it is definitely not supported. This post from 4 months ago suggests that they d...
Cassandra 4.0 has explicit support for both Java 8 and Java 11. In fact, they even split-up the configuration files as such: $ pwd /Users/aaron/local/apache-cassandra-4.0-SNAPSHOT/conf $ ls -a jvm* jvm-clients.options jvm11-clients.options jvm8-clients.options jvm-server.options jvm11-server.options jvm8-server....
Cassandra
52,334,649
13
I'm trying to explore the database and want to see all tables that exist there. What's the command that's equivalent to SHOW TABLES; in SQL?
to get all table names : DESC tables; to get detailed view of a table : DESC table <table_name>; to get detailed view of all tables in a keyspace : DESC keyspace <keyspace_name>;
Cassandra
51,274,364
13
I read this from the official DSE doc but it did not go in depth in to how. Can someone explain or provide any links to how?
It's better to look into architecture guide for this kind of information. There are multiple places that could be considered as some kind of load balancers. First - you can send requests to any node in the cluster, and this node will work as "coordinator", re-sending the request to the nodes that actually owns the data...
Cassandra
50,400,961
13
I'm modeling my table for Cassandra 3.0+. The objective is to build a table that store user's activities, here what i've done so far: (userid come from another database Mysql) CREATE TABLE activity ( userid int, type int, remoteid text, time timestamp, imported timestamp, visibility int, tit...
If you are always going to use the partition key I recommend using secondary indexes. Materialized views are better when you do not know the partition key References: Principal Article! • Cassandra Secondary Index Preview #1 Here is a comparison with the Materialized Views and the secondary indices • Materialized View ...
Cassandra
42,158,945
13
If I am not wrong, one can connect to a Cassandra cluster knowing at least one of the nodes that is in the cluster, and then the others can be discovered. Lets say I have three nodes (1, 2 and 3) and I connect to those nodes like this: Cluster.builder().addContactPoints("1,2,3".split(",")).build(); Then, if node 3 for...
This validation is only to make sure that all the provided hosts can be resolved, it doesn't even check if a Cassandra server is running on each host. So it is basically to ensure that you did not do any typos while providing the hosts as indeed it doesn't assume that it could be a normal use case to have a provided ho...
Cassandra
39,727,744
13
Using Cassandra, I want to create keyspace and tables dynamically using Spring Boot application. I am using Java based configuration. I have an entity annotated with @Table whose schema I want to be created before application starts up since it has fixed fields that are known beforehand. However depending on the logg...
The easiest thing to do would be to add the Spring Boot Starter Data Cassandra dependency to your Spring Boot application, like so... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-cassandra</artifactId> <version>1.3.5.RELEASE</version> </dependency> In addition, th...
Cassandra
37,352,689
13
In particular I was looking at this page where it says: If lightweight transactions are used to write to a row within a partition, only lightweight transactions for both read and write operations should be used. I'm confused as to what using LWTs for read operations looks like. Specifically how this relates to per-qu...
How does Cassandra know to check for in-progress transactions when you do a read? This is exactly what the SERIAL consistency level indicates. It makes sure that a query will only return results after all pending transactions have been fully executed. What is the new update that is proposed while you're trying to ...
Cassandra
34,790,674
13
How should I check for an empty resultset using datastax java cassandra driver? Suppose I'm executing the following query "SELECT * FROM my_table WHERE mykey=something" there is a great chance that the query will not be matched. The following code does not work: if (rs != null) rs.one().getString("some_column");
You were pretty close, the correct solution is: Row r = rs.one(); if (r != null) r.getString("some_column"); The driver will always return a result set, whether or not there were any returned results. The documentation for one() states that if no rows were returned rs.one() returns null. You can also use getAvai...
Cassandra
29,471,658
13
I'm trying to replicate a SQL database in Cassandra, but, while I had no problem creating the tables, I found that I cannot find an example easy to understand that shows how I can create foreign keys in Cassandra. So, If I have this in SQL: CREATE TABLE COOP_USUARIO ( CI VARCHAR2 (13 BYTE) NOT NULL ,...
Simple answer is: There is no CQL code for the same purpose. CQL does not have a concept of foreign keys or any concept of constraints between tables in the same way that you can't do joins between tables. If you need a constraint between tables then you would need to handle this in code.
Cassandra
27,676,995
13
I have a date column in a Cassandra column family. When I retrieve data from this CF using datastax java API, this date object can be taken as a java.util.Date object. It has a getYear() method but it is deprecated. The corresponding javadoc says: As of JDK version 1.1, replaced by Calendar.get(Calendar.YEAR) - 1900. ...
Could you try like tihs; // create a calendar Calendar cal = Calendar.getInstance(); cal.setTime(datetime); //use java.util.Date object as arguement // get the value of all the calendar date fields. System.out.println("Calendar's Year: " + cal.get(Calendar.YEAR)); System.out.println...
Cassandra
27,489,980
13
I read that in nosql (cassandra for instance) data is often stored denormalized. For instance see this SO answer or this website. An example is if you have a column family of employees and departments and you want to execute a query: select * from Emps where Birthdate = '25/04/1975' Then you have to make a column famil...
"Yes" for the most part, taking an approach of query-based data modeling really is the best way to do it. That is still a good idea to do, because the speed of your query times make it worth it. Yes, there's a little more housecleaning to do. I haven't had to execute 100s of deletes from other column families, but o...
Cassandra
27,281,536
13
I get the above error when I try to use following cql statement, not sure whats wrong with it. CREATE TABLE Stocks( id uuid,   market text,   symbol text, value text, time timestamp,   PRIMARY KEY(id) ) WITH CLUSTERING ORDER BY (time DESC); Bad Request: Only clustering key columns can be defined in CLUSTERING ORD...
"can't I use some column which is not part of primary key to arrange my rows?" No, you cannot. From the DataStax documentation on the SELECT command: ORDER BY clauses can select a single column only. That column has to be the second column in a compound PRIMARY KEY. This also applies to tables with more than two colu...
Cassandra
27,235,061
13
I want to verify that rows are getting added to the table. What cql statement would show the last n rows from the table below? Table description below: cqlsh:timeseries> describe table option_data; CREATE TABLE option_data ( ts bigint, id text, strike decimal, callask decimal, callbid decimal, maturity ti...
You didn't specify last n "by what". To get the last N per id: SELECT * FROM option_data WHERE ts=1 ORDER BY id DESC LIMIT N; ORDER BY clause can only be applied to the second column in a compound primary key. If you need to query by time you will need to think about your data model a little more. If your queries are ...
Cassandra
26,168,859
13
I am writing an application and I need to be able to tell if an inserts and updates succeed. I am using "INSERT ... IF NOT EXISTS" to get the light weight transaction behavior and noticed that the result set returned from execute, contains a row with updated data and an "[applied]" column that can be queried. That is...
In Cassandra insert/update/delete behave the same and they are called mutations. If your client is not returning any exceptions, then the mutation is done. If you are concerned about consistency of your mutation calls, then add USING CONSISTENCY with higher levels. http://www.datastax.com/docs/1.0/references/cql/index...
Cassandra
21,147,871
13
Is there a CQL query to list all existing indexes for particular key space, or column family?
You can retrieve primary keys and secondary indexes using the system keyspace: SELECT column_name, index_name, index_options, index_type, component_index FROM system.schema_columns WHERE keyspace_name='samplekp'AND columnfamily_name='sampletable'; Taking, for example, the following table declaration: CREATE TABLE sa...
Cassandra
21,092,524
13
Can a primary key in Cassandra contain a collection column? Example: CREATE TABLE person ( first_name text, emails set<text>, description text PRIMARY KEY (first_name, emails) );
Collection types cannot be part of the primary key, and neither can the counter type. You can easily test this yourself, but the reason might not be obvious. Sets, list, maps are hacks on top of the storage model (but I don’t mean that in a negative way). A set is really just a number of columns with the same key prefi...
Cassandra
16,470,776
13
I need to check if certain keyspace exists in Cassandra database. I need to write smth like this: if (keyspace KEYSPACE_NAME not exists) create keyspace KEYSPACE_NAME; There's a command describe keyspace, but can I somehow retrieve information from it in cql script?
Just providing fresh information. As of CQL3 while creating a keyspace you can add if statement like this CREATE KEYSPACE IF NOT EXISTS Test WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3}
Cassandra
9,656,371
13
Here's a sample of the scenario I'm facing. Say I have this column family: create column family CompositeTypeCF with comparator = 'CompositeType(IntegerType,UTF8Type)' and key_validation_class = 'UTF8Type' and default_validation_class = 'UTF8Type' Here's some sample Java code using Hector as to how ...
Good starting point tutorial here. But, after finally having the need to use a composite component and attempting to write queries against the data, I figured out a few things that I wanted to share. When searching Composite columns, the results will be a contiguous block of columns. So, assuming a s composite of 3 Str...
Cassandra
8,916,820
13
Does anyone have advice on using cassandra with scala? There is no native scala-cassandra client supporting cassandra version 8.0+, so I have to use hector, and it seems to work OK but not to be concise. Do you have any attempts, recommendations or any wrapper code,.. etc for hector ?
The official Scala driver for Apache Cassandra and Datastax Enterprise, with full support for CQL 3.0, is phantom. Phantom was developed at Outworkers, official Datastax partners, explicitly to superseed all other drivers. It's being actively developed and maintained, with full support for all the newest Cassandra feat...
Cassandra
6,382,763
13
Anyone familiar enough with the Cassandra engine (via PHP using phpcassa lib) to know offhand whether there's a corollary to the sql-injection attack vector? If so, has anyone taken a stab at establishing best practices to thwart them? If not, would anyone like to ; )
No. The Thrift layer used by phpcassa is an rpc framework, not based on string parsing.
Cassandra
5,998,838
13
Like many these days, I am an old relational-model user approaching Cassandra for the first time. I have been trying to understand Cassandra's data model, and when I read about it I frequently encounter statements that encourage me to think about it as 4 and 5 dimensional maps. Now I'm familiar with an ordinary key/va...
Map<String, String> -- One dimension Map<String, Map<String, String>> -- Two dimensions Map<String, Map<String, Map<String,String>>> -- Three dimensions etc...
Cassandra
5,719,437
13
I'm running a 4-node Cassandra cluster. Some of our nodes have some very large snapshots, and we're running out of disk space. I need to delete the snapshots, but I can't find any documentation which states how to do this properly. Do I just shut the node down and delete the files in the snapshots directory? Is there s...
OK I figured this one out (with the help of IRC). It's nodetool -h localhost clearsnapshot.
Cassandra
5,554,710
13
Has anyone had any success with connecting to a Cassandra cluster using DBeaver Community Edition? I've tried to follow this post, but haven't had any success. I have to have authentication enabled, and I get an error saying: Authentication error on host /x.x.x.x:9042: Host /x.x.x.x:9042 requires authentication, but no...
IMPORTANT UPDATE The Simba JDBC driver from Magnitude is no longer available for free. It is no longer downloadable from the DataStax website so the instructions in this post is obsolete. The alternative option is to use ING Bank's open-source JDBC wrapper and I have documented the steps for using it with DBeaver Commu...
Cassandra
69,027,126
12
I have a Cassandra node running in a Docker container and I want to launch a CQL script when the database is ready. I tried checking the port to detect when it's ready : while ! nc -z localhost 7199; do sleep 1 done echo "Cassandra is ready" cqlsh -f ./createTables.cql But the port is opened before the database is...
First, you need to wait on another port: 9042. This is the port that is used by CQLSH. Another approach could be also waiting for execution of cqlsh instead of nc (or as a second step, because nc is much faster to execute). For example, you can use something like these commands: while ! cqlsh -e 'describe cluster' ; d...
Cassandra
48,034,869
12
Using Java, can I scan a Cassandra table and just update the TTL of a row? I don't want to change any data. I just want to scan Cassandra table and set TTL of a few rows. Also, using java, can I set TTL which is absolute. for example (2016-11-22 00:00:00). so I don't want to specify the TTL in seconds, but specify the ...
Cassandra doesn't allow to set the TTL value for a row, it allows to set TTLs for columns values only. In the case you're wondering why you are experiencing rows expiration, this is because if all the values of all the columns of a record are TTLed then the row disappears when you try to SELECT it. However, this is o...
Cassandra
40,730,510
12
I am trying to calculate the the partition size for each row in a table with arbitrary amount of columns and types using a formula from the Datastax Academy Data Modeling Course. In order to do that I need to know the "size in bytes" for some common Cassandra data types. I tried to google this but I get a lot of sugges...
I think, from a pragmatic point of view, that it is wise to get a back-of-the-envelope estimate of worst case using the formulae in the ds220 course up-front at design time. The effect of compression often varies depending on algorithms and patterns in the data. From ds220 and http://cassandra.apache.org/doc/latest/cql...
Cassandra
40,087,926
12
cassandra cql shell window got disappears after installation in windows? this was installed using MSI installer availalbe in planet cassandra. Why this happens ? please help me.. Thanks in advance.
I had the same issue with DataStax 3.9. This is how I sorted this: Step 1: Open file: DataStax-DDC\apache-cassandra\conf\cassandra.yaml Step 2: Uncomment the cdc_raw_directory and set new value to (for windows) cdc_raw_directory: "C:/Program Files/DataStax-DDC/data/cdc_raw" Step 3: Goto Windows Services and Start the ...
Cassandra
39,893,193
12
I know that Vnodes form many token ranges for each node by setting num_tokens in cassandra.yaml file. say for example (a), i have 6 nodes, each node i have set num_token=256. How many virtual nodes are formed among these 6 nodes that is, how many virtual nodes or sub token ranges contained in each physical node. Accord...
Every partition key in Cassandra is converted to a numerical token value using the MurMur3 hash function. The token range is between -263 to +263-1. num_token defines how many token ranges are assigned to a node. This is the same as the signed java long. Each node calculates 256 (num_tokens) random values in the token ...
Cassandra
37,940,630
12
I have a large table with several columns. One of the columns is created_at, which is a timestamp. Now I want to add a new column called last_activated. This column should initially be filled with the value of created_at. At first I just altered the table to add the new column -> No problem there but than I tried UPD...
No its not possible. At first place where clause is must with UPDATE
Cassandra
37,795,916
12
Cassandra does not comply with ACID like RDBMS but CAP. So Cassandra picks AP out of CAP and leaves it to the user for tuning consistency. I definitely cannot use Cassandra for core banking transaction because C* is slightly inconsistent. But Cassandra writes are extremely fast which is good for OLTP. I can use C* for...
ACID are properties of relational databases where BASE are properties of most nosql databases and Cassandra is one of the. CAP theorem just explains the problem of consistency, availability and partition tolerance in distributed systems. Good thing about Cassandra is that it has tunable consistency so you can be pretty...
Cassandra
37,434,016
12
How do I collect these metrics on a console (Spark Shell or Spark submit job) right after the task or job is done. We are using Spark to load data from Mysql to Cassandra and it is quite huge (ex: ~200 GB and 600M rows). When the task the done, we want to verify how many rows exactly did spark process? We can get the n...
Found the answer. You can get the stats by using SparkListener. If your job has no input or output metrics you might get None.get exceptions which you can safely ignore by providing if stmt. sc.addSparkListener(new SparkListener() { override def onTaskEnd(taskEnd: SparkListenerTaskEnd) { val metrics = taskEnd.ta...
Cassandra
36,898,511
12
I can't run describe keyspaces for some reason, even though I'm clearly connecting to my Cassandra 3.3 host via the 3.1 python driver. Some other commands seem to work fine. Thanks in advance! from cassandra.cluster import Cluster cluster = Cluster(['192.168.1.53']) #session = cluster.connect('nod...
DESCRIBE is a cqlsh-specific command, so it is not supported by the drivers since it is not considered a CQL command. You can find a full listing of the cqlsh commands here. Alternatively you can get at a keyspace's schema using the python-driver by accessing Cluster.metadata and then accessing the keyspaces dict.
Cassandra
35,986,136
12
In the introduction course of Cassandra DataStax they say that all of the clocks of a Cassandra cluster nodes, have to be synchronized, in order to prevent READ queries to 'old' data. If one or more nodes are down they can not get updates, but as soon as they back up again - they would update and there is no problem.....
In general it is always a good idea to keep your server clocks in sync, but a primary reason why clock sync is needed between nodes is because Cassandra uses a concept called 'Last Write Wins' to resolve conflicts and determine which mutation represents the most correct up-to date state of data. This is explained in ...
Cassandra
34,898,693
12
I need to add some new columns to my existing column_family/table in cassandra. I can add single column like this : ALTER TABLE keyspace_name.table_name ADD column_name cql_type; Can I add all new columns using a single query? If yes, how to do it using cql and datastax cassandra driver?
This is fixed in Cassandra 3.6 https://issues.apache.org/jira/browse/CASSANDRA-10411 ALTER TABLE foo ADD (colname1 int, colname2 int)
Cassandra
34,607,181
12
I'm new in Cassandra and I've read that Cassandra encourages denormalization and duplication of data. This leaves me a little confused. Let us imagine the following scenario: I have a keyspace with four tables: A,B,C and D. CREATE TABLE A ( tableID int, column1 int, column2 varchar, column3 varchar, column4 ...
Cassandra provides BATCH for this purpose. From the documentation: A BATCH statement combines multiple data modification language (DML) statements (INSERT, UPDATE, DELETE) into a single logical operation, and sets a client-supplied timestamp for all columns written by the statements in the batch. Batching multiple sta...
Cassandra
34,231,718
12
I am trying to set up a multinode cassandra database on two different machines. How am i supposed to configure the cassandra.yaml file? The datastax documentation says listen_address¶ (Default: localhost ) The IP address or hostname that other Cassandra nodes use to connect to this node. If left unset, the hostnam...
Configuring the nodes and seed nodes is fairly simple in Cassandra but certain steps must be followed. The procedure for setting up a multi node cluster is well documented and I will quote from the linked document. I think it is easier to illustrate the set up of nodes with 4 instead of 2 since 2 nodes would make littl...
Cassandra
32,689,794
12
I am trying to connect to cassandra, which is running on local desktop, via cassandra-driver for python using this simple code. from cassandra.cluster import Cluster cluster = Cluster() session = cluster.connect() and getting this error: NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': InvalidRe...
Are you possibly using the driver to connect to Cassandra 3.0.0-alpha1? If so, you'd need to be running the driver installed from this commit: https://github.com/datastax/python-driver/tree/1a480f196ade42798596f5257d2cbeffcadf154f Alternatively: If you're just experimenting, the released drivers as of today work wit...
Cassandra
31,824,537
12
I'm trying to start up a docker image that runs cassandra. I need to use thrift to communicate with cassandra, but it looks like that's disabled by default. Checking out the cassandra logs shows: INFO 21:10:35 Not starting RPC server as requested. Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift...
The sed workaround (and subsequent custom Dockerfiles that enable only this behavior) is no longer necessary. Newer official Docker containers support a CASSANDRA_START_RPC environment variable using the -e flag. For example: docker run --name cassandra1 -d -e CASSANDRA_START_RPC=true -p 9160:9160 -p 9042:9042 -p 71...
Cassandra
31,620,494
12
I converted an RDD[myClass] to dataframe and then register it as an SQL table my_rdd.toDF().registerTempTable("my_rdd") This table is callable and can be demonstrated with following command %sql SELECT * from my_rdd limit 5 But the next step gives error, saying Table Not Found: my_rdd val my_df = sqlContext.sql("...
Make sure to import the implicits._ from the same SQLContext. Temporary tables are kept in-memory in one specific SQLContext. val sqlContext = new SQLContext(sc) import sqlContext.implicits._ my_rdd.toDF().registerTempTable("my_rdd") val my_df = sqlContext.sql("SELECT * from my_rdd LIMIT 5") my_df.collect().foreach(pr...
Cassandra
30,263,646
12
I am trying cassandra node driver and stuck in problem while inserting a record, it looks like cassandra driver is not able to insert float values. Problem: When passing int value for insertion in db, api gives following error: Debug: hapi, internal, implementation, error ResponseError: Expected 4 or 0 byt...
Following words are as it is picked from cassandra node driver data type documentation When encoding data, on a normal execute with parameters, the driver tries to guess the target type based on the input type. Values of type Number will be encoded as double (as Number is double / IEEE 754 value). Consider the followin...
Cassandra
26,682,873
12
I read about Cassandra 2's lightweight transactions. Is the consistency level of such a write always at QUORUM? Would this mean that even if I have a multi data center setup with 100s of nodes, then quorum of the entire cluster (majority of the row's replicas across all data centers) is involved? Won't this be really s...
The suggested Consistency Level for lightweight transactions is SERIAL. Behind the scenes however SERIAL is even worse than QUORUM, because it's a multi-phase QUORUM. As you said the situation can get hard to handle when you have multiple DC -- Datastax estimate "effectively a degradation to one-third of normal". There...
Cassandra
24,986,578
12
Does anyone know how to generate TimeBased UUIDs in Java/Scala? Here is the column family: CREATE table col(ts timeuuid) I'm using Cassandra 1.2.4 Appreciate your help!
If you are using the Datastax drivers you can use the utility class, UUIDs, to generate one import com.datastax.driver.core.utils.UUIDs; .... UUID timeBasedUuid = UUIDs.timeBased();
Cassandra
24,952,066
12
I want to build a RESTful API with Java and Cassandra 2.x (on Jersey framework). I'm new to both technologies so I would like to ask you is that the correct way to integrate and share Cassandra driver. 0. Get the driver though Maven <dependency> <groupId>com.datastax.cassandra</groupId> <artifac...
I just developed what you are going to develop. What you wrote works but it's not my favourite approach. I'd rather create a Singleton (since 1 session is enough for an application). Following Joshua Bloch enum's singleton's pattern here is what I did public enum Cassandra { DB; private Session se...
Cassandra
24,687,991
12
I have a cassandra table containing 3 million rows. Now I am trying to fetch all the rows and write them to several csv files. I know it is impossible to perform select * from mytable. Could someone please tell how I can do this? Or are there any ways to read the rows n rows by n rows without specifying any where condi...
as I know, one improvement in cassandra 2.0 'on the driver side' is automatic-paging. you can do something like this : Statement stmt = new SimpleStatement("SELECT * FROM images LIMIT 3000000"); stmt.setFetchSize(100); ResultSet rs = session.execute(stmt); // Iterate over the ResultSet here for more read Improvements...
Cassandra
23,745,322
12
Question to all Cassandra experts out there. I have a column family with about a million records. I would like to query these records in such a way that I should be able to perform a Not-Equal-To kind of operation. I Googled on this and it seems I have to use some sort of Map-Reduce. Can somebody tell me what are the o...
I can suggest a few approaches. 1) If you have a limited number of values that you would like to test for not-equality, consider modeling those as a boolean columns (i.e.: column isEqualToUnitedStates with true or false). 2) Otherwise, consider emulating the unsupported query != X by combining results of two separate...
Cassandra
21,925,525
12