A C++ library to access Cassandra servers

libQtCassandra LogoThe libQtCassandra library is an advanced C++ library used to access Cassandra servers in C++.

Contrary to the basic Cassadra server interface, this C++ library brings you separate objects that handle each level of the server data, i.e. the cluster, contexts, table, rows, cells.

Details for developers can be found on the reference pages (a 100% complete Doxygen documentation of the library including source code and working examples.)

You may also want to refer to the Installation Instructions to get Cassandra on Ubuntu page on how to install Cassandra on your Ubuntu server. Note that the libQtCassandra library works under MS-Windows as well.


You have 2 requirements to compile the library:

  1. cmake, make, and a C++ compiler for the build process
  2. Qt 4.8+
  3. Thrift -- this library is directly included in our tarball! (download)
  4. Cassandra 2.0.x or better (download .deb); the library works with Cassandra since 0.8.4 and is very likely to work with your current version1

Obviously, I suspect you're using Linux. Other Unix systems should be capable of compiling the code. MS-Windows, I have no clue, but I would imagine so. I'll gladly accept comments and patches (questions, comments, patches, anger should be posted on instead.)

Ubuntu Packages

You can now directly install the Debian packages for Ubuntu 12.10, 13.04, 13.10, 14.04. We build the packages as part of the Snap! project using launchpad (packages).


You can download the source code from

We also offer ready to install packages on LaunchPad: Snap CPP (for Ubuntu users.)

Programmer Documentation

Search for the libQtCassandra entries under References.

The documentation is also found inline in the .cpp files of the project. Corrections to the documentation are very welcome!

Supported Features

The following are the main features of libQtCassandra:

  • Create contexts, tables & counters, rows, columns, and cells; individually.
  • Support array syntax to access the data (read [getter] and write [setter])
  • For counters, support the increment/decrement operators: ++, --, +=, -=.
  • Cache the data read or written for much faster data access.
  • Lamport's Bakery Algorithm offering a lock capability using Cassandra.

Cassandra Proxy Server (to be implemented)

Servers Organization using a Proxy (click to enlarge)When connecting to a Cassandra Cluster, one should always use the proxy server. This is a small front end that allows your software to connect to a Cassandra Cluster opposed to just connecting to a Cassandra Node. The concept is pretty simple: if you directly connect to a node, then the connection may fail because that specific node may be down when the cluster as a whole may still be working just fine.

The Cassandra Proxy Server resolves that problems by connecting to multiple Cassandra Nodes and maintaining statistics about the whole cluster. It is capable of connecting to additional nodes when it loses connections to existing nodes. It can also load balance requests so you avoid hitting nodes that are really busy.

The concept is simple, your server connects to the proxy server, which we expect is running on the same local network, and sends normal Cassandra requests to that proxy. The proxy passes your requests to one of the Cassandra nodes it is already connected with and returns the answer as is from Cassandra, so in effect the proxy is transparent to your process.

Adding an additional network connection can cause some slowness, but since this is a local network connection, it should still be really fast (time to copy data buffers in memory,) especially because this one connection does not require any encryption.

Quick Compilation Instructions (see also INSTALL.txt)

To recompile libQtCassandra you need cmake, make, g++, and all the dependencies (Cassandra, thrift, Qt...)

The instructions to compile the library are something like:

tar xf libQtCassandra-0.5.0.tar.gz
mkdir BUILD
cmake ../libQtCassandra-0.5.0
make install

You can create a Debian package or a Windows Package with "make package". Create the package with wpkg is not yet fully supported.

For other targets that you can build, try "make help".

If you cd back out of the BUILD folder, you can use "make -C BUILD" to run make inside the BUILD folder.

Although you can directly run cmake in the libQtCassandra directory, if you plan to do any development work in that folder, I strongly advice for the creation of a separate build folder so you don't mix original source files and generated files.


Patches, problems, please report on the page.

You may also find posts of interest in our Snap! C++ Journal under Cassandra such as these few:

The latest source published on (tarball) has a really bad problem in the content::clearCache() function. It will clear the tables from memory, but it will completely lose track of all the tables, even those that still exist in Cassandra. Version 5.5 has a fix. You can find the code in the project under Code (in git). We also offer a pre-compiled version for Ubuntu via launchpad.

Projects using this library

Got a project now officially using the libQtCassandra library? Let us know and we'll include a link to your project/product here.

Common Problems Compiling

Missing dependencies

Building CXX object src/CMakeFiles/QtCassandra.dir/QCassandra.cpp.o
Cassandra.h:15:24: fatal error: TProcessor.h: No such file or directory

The thrift library needs to be compiled to work with C++. When it configures (look at the output) it tells you which language extensions it creates that version for. If you don't see C++ selected (...: yes), then you will get that error saying that TProcessor.h cannot be found.

This happens because some dependencies are missing. Unfortunately, I do not know exactly which dependencies. I will update this entry as I discover such. Also we intend, at some point, to detect missing dependencies and generate a clear error instead of moving forward and having strange compilation errors.

Thrift not working?

As you start build, the configure script of the thrift library should be run by cmake. At some point the output should include something that looks like the following. This includes the thrift library version and the generators. You must have at least C++ indicated. If not, the configure script could not find your C++ compiler and thus skipped on it.

thrift 0.8.0

Building code generators ..... :

Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : no
Building C# Library .......... : no
Building Python Library ...... : no
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Erlang Library ...... : no
Building Go Library .......... : no

Building TZlibTransport ...... : yes
Building TNonblockingServer .. : yes

It is good if you have the TZ included since it will compress the data being sent on the network.

Other Systems of Interest

You may find a need for other systems that are required for your environment to function as expected. For example, if you have heavy needs for locks or work that needs to be serialized, then you may want to look into getting Apache ZooKeeper (a C library implementing a barrier (lock) and a queue.)

Lock Mechanism along Cassandra

There are many solutions for locks. I think that the one most often referenced is Apache ZooKeeper, but there are other solutions depending on your needs. Search around before making a decision.

  • Apache ZooKeeper - server written in C, supports Queues and Barriers
  • ActiveMQ - server written in Java, supports Queues (message based really)

For us, we use snapdb, a daemon that comes with Snap! At first we had a lock object in the libQtCassandra library, but that system does not work when you may end up sending orders to any number of Cassandra nodes. Actually, our lock mechanism opens a single connection to communicate with a single, specific snaplock daemon. Our implementation has very little in limitations, outside of the fact that you have to process one lock with one specific snapdb. For example, we do not have a centralized lock master node. If you are running 5 instances of snapdb, all 5 participate in the locking ability. If one goes down, the lock still continues to work with zero downtime. We could not find another external lock tool that had such a feature.

Right now our snapdb daemon makes use of our snapcommunicator communication system, but we plan to have a version that is a standalone and can be used with any project.

Changes / History

  • Version 0.6+

This version uses CQL instead of thrift. However and although it works great for us, it is not that well adapted to the outside as the previous version was. We are still weighing the pros and cons of whether we want to publish an official version of 0.6+. You may get the source code though.

I found a potential problem in the lock mechanism where a crash (abort, segmentation fault) or a process being killed (kill -KILL <pid>) could leave a lock remain in the database that would last forever preventing further locks with the same object name. I now put a TTL on the entering key so if such a crash occurs the key still disappears within seconds.

Bumped copyright noticed to 2016.

Various clean ups.

Note: the jump in version is due to the fact that I did not post source packages for a while on; it is also due to our nightly build which first was incrementing the wrong version number.

Added support for a regular expression to filter rows as they are read from the lowest level. This is through the row predicate class. This feature is SLOW but can be useful in special cases where you do not have an index and will not be running such requests over and over again.

Changed all shared pointers from the Qt version to the std version so that way we can properly make use of weak pointers.

Make use of the controlled_vars enum capability and avoid many casts.

Tweaked the CMakeLists.txt to define the system headers as such.

Repaired some warnings that the newer version of g++ generated.

Added a fix to clearTable() so it works as expected.

Documented the fact that QMap sorts from top to bottom even when reading data with the Reverse flag turned on.

Removed some debug code.

Compiled with version Cassandra interface version 2.0.1 and thrift version 0.9.0.

Fixed bug with QCassandraRow::exists(), I needed to test the return value of a function.

Created a Debian compatible changelog file.

Added an implementation of a Lambert's bakery lock (and a corresponding test.) See documentation.

Read consistency level can now be specified.

Added a synchronization function which is necessary if you are working on a cluster (more than 1 node) and want to create or change the schema to a context (table/column definitions.)

Updated all the tests so they also can work on a cluster of 3+ nodes.

Added a QCassandraValue test out of which I fixed the comparison operators (<, <=, >, >=).

Added support to use an index with QCassandraValue buffers (read-only right now.)

Moved the byte array data reads to the global scope.

Added Bool support to the QCassandraValue class.

Fixed the findContext() so it loads contexts first if not loaded yet.

Fixed the disconnected() so a QCassandra object can now be reused properly.

Fixed the snitch function which now returns the snitch (instead of the protocol version).

Fixed two use of column keys that would use a QString instead of a QByteArray (i.e. a null would inadvertendly end the column key.)

Fixed the dropCell() so it doesn't attempt to read the cell first.

Fixed the CMakeLists.txt so the libQtCassandra library is linked against the thrift library (so your tools do not have to know about thrift directly.) Also removed references to the boost_system library.

Reviewed the SSL connection capability. It is still not considered to be working but the password can now be specified from your application.

Updated documentation to be more accurate and define some missing entries.

  • Version 0.4.6

Added direct support for QUuid as row and column keys.

Added direct support for char * and wchar_t * so we do not have to first cast strings to QString everywhere.

Fixed bug testing row key size to limit of 64535 instead of 65535.

Added a test as row and column keys cannot be empty. It will now throw an error immediately if so.

Updated some documentation accordingly and with enhancements.

  • Version 0.4.5

Added a first_char and last_char variables (QChar) in column predicate which can be used to define "[nearly] All column names".

Fixed the names of two functions: setFinishColumnName() and setFinishColumnKey() are now setEndColumnName() and setEndColumnKey() respectively (as documented and so it matches the getters.)

Added support for indexes defined with columns. The column predicate now has a setIndex() function and that allows you to call readCells() repititively until all the columns matching the predicate were returned (very similar to reading a large set of rows.)

Fixed a few things in the documentation.

Added support for composite columns. It was functional before but with knowledge on how to build the column key which is actually quite complicated (okay, not that hard, but libQtCassandra is here to hide that sort of thing!) Use the compositeCell() function of your QCassandraRow objects.

  • Version 0.4.3

Added support for counters.

Fixed several usage of keys so 0 bytes works as expected. (in getValue() and insertValue())

Small fixes to documentation.

Fixed the QCassandraTable::readRows() so it automatically updates the row predicate with the last row as the new start key. This is very important because the rows returned to you get sorted by key in the table, whereas, in Cassandra they are not sorted that way at all. (At least not by default when you use the RandomPartitioner which is very likely.)

Fixed the QCassandraContext::descriptionOption() which would create empty options when the sought option did not exist in the context.

Upgraded the version of Thrift to 0.8.0. There are some problems with the output of the thrift command line option (some missing #include and invalid references.) I fixed the generated code as required so it compiles and the result works as expected.

Made updates to the code so it works with version 1.1 of Cassandra. This includes proper support for the replication factor which was deprecated as a direct field in the KsDef structure. The other deprecated fields are simply ignored at this point (those are in Tables, see CfDef in interface/cassandra.thrift of Cassandra 1.1)

Fixed replicateOnWrite() which now returns the expected value.

Fixed all the context and table get...() functions so if the value is marked as unset, empty or zero is returned instead of the current value saved in the object (which may not reflect what the database is defined as.)

Added the million_rows test to ensure we can create over 1 million rows and read them back. At this time, in my environment, it often crashes the Cassandra server... Java problems?

Added functions that return the partitioner and snitch information from the cluster.

Fixed QCassandraContext::prepareContextDefinition() which would force the replication factor to 1 instead of the user defined value.

The CMakeLists.txt now properly defines the folder where the compiled thrift library lies so it can link with it in the standalone version of the library.

  • Version 0.4.1

Fixed the size of the buffer used to save 64 bit integers.

Fixed the size of integers used to handle floating points.

Fixed the double being read as 8 bytes and somehow converted to a float instead of a double.

Fixed the test of the string set in a value to limit the UTF-8 version of the string to 64Mb (instead of the number of UCS-2 characters held by a QString.)

Enhanced documentation about the findRow() and findCell() which do not look for a row or cell in the Cassandra system, it only checks in memory!

Better support older versions of g++ (4.1 cannot properly cast the controlled variables for enumerations) -- thank you to John Griswold for reporting the problem.

Added some missing documentation.

  • Version 0.4.0

Enhanced the cmake scripts to make it even easier (find/use Qt, Thrift) and thus I jumped to version 0.4.0 because this is a pretty major change from 0.3.x

Removed the Qt sub-folder names from #include.

Made the getValue() function return false so we can know when it fails and react accordingly.

Fixed the use of the slice predicate and ignore the strings null terminator as they ought to be (i.e. a key can include a nul character.)

Added some try/catch to avoid a certain number of fairly legal exceptions (i.e. missing value or column.)

Removed all unwanted files from source package using a CPACK option.

Strip folder name from documentation to make it smaller.

Updated all copyrights to include 2012.

  • Version 0.3.2

Fixed the creation of a row predicate as it wasn't defining a column predicate which is necessary when we call readRows() with the default parameters on a table.

  • Version 0.3.1

Added support for installation targets and generation of binary packages.

  • Version 0.3.0

Added a dropContext() in the QCassandra object.

Added proper unparenting of the context and table classes.

Started to make use of the Controlled Variables (requires 1.3.0 or better.)


The following are things we intend to add at some point:

  • Support for multi-functions for faster retrievals (this is counter intuitive in our current environment though)
  • Support batch writes (switch your context to record all updates, inserts, and deletes and execute them all at once with one command call!)
  • See to accept all the default Cassandra types accepted as row and column keys. At this time we support UTF-8 (BytesTypes and UTF8Type) and UUIDs (LexicalUUIDType). Although all the other types are supported via the QByteArray, it is difficult (an annoyance really) to make use of a QByteArray for all the basic types. The missing types are: Ascii, Boolean, Date, Double, Float, Int32, Integer, Long.
  • Finish up the composite column support.
  • Proper support for SSL (there is some code in place, but it has not worked for us yet.) with more options.


  • 1. The download link is on the front page. Also, the version changes very quickly at this time as it is very actively being developed. We first developed libQtCassandra with 0.8.4, and made an update (0.4.2) to run with 1.1.0, but it should work with any version starting with 0.8.0 to 2.0.1 (libQtCassandra version 0.5.0 was used with 2.0.1 of Cassandra).



Re: libQtCassandra

I commented out QOBject as suggested and it compiled.

I get the following runtime exception in the creation of context from both test programs: context_management and read_write_data.

Exception is [ SimpleStrategy requires a replication_factor strategy option. ]

when I checked the code, it had the replication factor set as below:


Am I missing something here ?


Re: libQtCassandra

Hmmm... Interesting that I made the cassandra row and column predicates QObjects because we need to copy them. That's what the error you get says. Also, that's strange that the Ubuntu version doesn't generate the same error. I don't think we can copy a QObject under Ubuntu anymore than RedHat!

I just tried to remove the : QObject from the definitions and it all compiled:

class QCassandraColumnPredicate //: public QObject
class QCassandraRowPredicate //: public QObject

If you could try that and see if that solves your problem, it would be great.

Thank you.


Re: libQtCassandra

I'm using the libQtCore library built from the qt-everywhere-opensource-src-4.8.3 in Red Hat linux.

I got the following compilation errors when building the test program.

[100%] Building CXX object tests/CMakeFiles/read_write_data.dir/read_write_data.cpp.o

/home/AJ/usr/local/Trolltech/Qt-4.8.3/include/QtCore/qobject.h: In copy constructor 'QtCassandra::QCassandraColumnPredicate::QCassandraColumnPredicate(const QtCassandra::QCassandraColumnPredicate&)':

 /home/AJ/usr/local/Trolltech/Qt-4.8.3/include/QtCore/qobject.h:333: error: 'QObject::QObject(const QObject&)' is private

/home/AJ/libQtCassandra-0.3.2/tests/../include/QtCassandra/QCassandraColumnPredicate.h:57: error: within this context

/home/AJ/libQtCassandra-0.3.2/tests/read_write_data.cpp: In function 'int main(int, char**)':

/home/AJ/libQtCassandra-0.3.2/tests/read_write_data.cpp:185: note: synthesized method 'QtCassandra::QCassandraColumnPredicate::QCassandraColumnPredicate(const QtCassandra::QCassandraColumnPredicate&)' first required here

/home/AJ/libQtCassandra-0.3.2/tests/../include/QtCassandra/QCassandraRow.h:56: error: in passing argument 1 of 'int QtCassandra::QCassandraRow::cellCount(const QtCassandra::QCassandraColumnPredicate&)'

make[2]: *** [tests/CMakeFiles/read_write_data.dir/read_write_data.cpp.o] Error 1

make[1]: *** [tests/CMakeFiles/read_write_data.dir/all] Error 2

make: *** [all] Error 2


As the errors are related to the QObject from the Qt core library, am I using a imcompatible version of qt core library ?

If yes, where can I download the libqtcore source to build it in red hat linux.

Note: I was able to build and run the test program "cluster" successfully.



Re: libQtCassandra

Sorry... no tutorial, I hope someone will write one on their own time! 8-)

There is a reference though with examples and you have tests that can be used to get started (under the tests folder.)


Re: libQtCassandra

Where is a tutorial?


Re: libQtCassandra

Hi Radek,

With the newer version of thrift I had different problems. But assuming you cannot compile the thrift interfacem that's the thing you should look for.

The files are listed right here:

$ ls libQtCassandra/thrift-gencpp-cassandra/

To find the files with the wrong entry you may want to search using the grep command. Something like this:

grep apache::thrift::protocol libQtCassandra/thrift-gencpp-cassandra/* | grep -v '::apache::thrift::protocol'

If it returns anything then you'll need to fix it.

If you use the version of thrift-gencpp-cassandra shipped with the libQtCassandra library then you shouldn't have to do anything of the sort since I make the necessary changes.


Re: libQtCassandra


I found something like that in README.txt
With version 0.8.0, I had to fix the CassandraProcessor interface
because it made use of apache::thrift::protocol instead of
::apache::thrift::protocol (:: missing at the start.) Also, the
netinet/in.h header was not included. I fixed that by including
that header in src/QCassandraPrivate.h before including thrift.
Note that for the two templates you'll need a space
(... boost::shared_ptr< ::apache::...> ...) since <: is viewed as
a special character by g++.
In which files I should change apache to ::apache ?

Re: libQtCassandra

in README I found:

With version 0.8.0, I had to fix the CassandraProcessor interface because it made use of apache::thrift::protocol instead of ::apache::thrift::protocol (:: missing at the start.) Also, the netinet/in.h header was not included. I fixed that by including that header in src/QCassandraPrivate.h before including thrift. Note that for the two templates you'll need a space (... boost::shared_ptr< ::apache::...> ...) since <: is a special character.


Do you know in which file i should change apache::thrift::protocol to ::apache::thrift::protocol?


Re: libQtCassandra

I have to say, I never tried to compile on a Mac. However, I would imagine that it should work on Macs as well.

This is not in libQtCassandra, however, the problem occurs when linking the Thrift part of the C++ Cassandra generated code.

I'm not too sure where it breaks, but if the thrift library doesn't get compiled properly then something can be missing. This being said, it may be different enough on your platform that you may need to regenerate the files under libQtCassandra/thrift-gencpp-cassandra



Re: libQtCassandra


When i try to make libQtCassandra, I get this error:

Makefile:811: warning: overriding commands for target `gen-cpp/ThriftTest.cpp'
Makefile:808: warning: ignoring old commands for target `gen-cpp/ThriftTest.cpp'
[ 13%] Built target thrift-build
Linking CXX shared library libQtCassandra.dylib
Undefined symbols for architecture x86_64:
  "apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)", referenced from:
      org::apache::cassandra::CassandraClient::recv_login() in Cassandra.cpp.o

Re: libQtCassandra

I would create an index... something like this:

cassandra[context][table][row]["state"] = "TX";

cassandra[context][table+"_state_index"]["TX"][row] = QByteArray();

(The QByteArray() represents an empty entry since you don't have to put a specific value in that cell.)

I suppose "TX" would be a variable, obviously. Just used the string to clearly show where that variable would be used.

Know however that Cassandra does not offer a transactional system, so the index may not get created and thus you may never get the relation. This means you may need a backend process once in a while to fix all such relations!

Now you would search the table+"_state_index" table using a column predicate setting the row key to "TX" and call readCells() and cells().

You may also want to use the clearCache() function if you have more cells than the count of the predicate.

Now, there is a feature with a form of KEY where Cassandra automatically creates a form of index but I do not yet know how to use it.


Re: libQtCassandra

Hi - I got the library installed and was able to get started on a sample project. While I can save/retrieve data using the following form


I wanted to do some query like

get users where state = 'TX'

I have the 'state' column in 'users' table indexed and I was able to query that in cassandra-cli. Can you provide me a snippet of how to do this using libQtCassandra?

Thank you.


Re: Composite columns

Okay, I got composite columns working. It was actually possible to access them before, only you need to know how to transform the column names to work with Cassandra to do so!

To make it simpler, I added two functions called compositeCell() in the QCassandraRow class. There is a test that shows clearly how to make use of them. More or less, you want to create a vector of column names using QCassandraValue objects and use that in the compositeCell() calls. The library then transforms those values in the necessary column key.

It is a bit more work for the programmers than using "col1:col2:..." but the problem with such a simple syntax is that those column types would be required to transform the data back to their primary type (i.e. if you have a column name which is an integer 32 bit you'd have to convert it to text in a string and then the library would convert it back to an integer 32 bit... so instead we use the vector and avoid a double conversion.)


Re: buffer too small.

Hi Swathi,

You included colons in your column name. Are you using composite columns? If so, it may be trying to return the entire content of the composite column.

Otherwise, I would need a little more of your code, but I ran in problems like these when a column is viewed as a "char" instead of a "string". With libQtCassandra you at times need to make it explicit (use QString) to make sure it doesn't use char. But without seeing your code, it will be difficult to know.

If you want to add some debug printf() to help you find where it breaks, those tests are in libQtCassandra/src/QCassandraValue.cpp (search for the runtime error you mentioned, there are many instances for each basic C++ type.)


buffer not sufficient.

I am trying to retrieve a column value as shown below:


Answer should be "a57" but it is giving me error saying buffer is not enough for the value.

ERROR:Working on Cassandra Context true
Inside <row,col> <key,key>
terminate called after throwing an instance of 'std::runtime_error'
  what():  buffer too small for this value

I have called clearCache() function before retrieving from cassandra.

Will you please help me..

Thanks and Regards,



New 0.4.2 version coming out soon...

Okay! I found a definitive problem with the row predicate and looping through a set of rows. The new package will include a new test that creates 1.2 million rows with one column and checks them all by reading them back using the QCassandraTable::readRows() function.

The main problem was that in most cases Cassandra clusters are defined with the RandomPartioner and that means the rows are not sorted as expected. The sort used for the rows in memory depends on the QMap and QString implementations and both are definitively different from what Cassandra uses.

I hope to get the new version out very soon. It will also support Cassandra 1.0.0 and 1.1.0. At this point 1.1.3 crashes the Java interpretor! So I cannot run it at all.


Cannot read big tables rows in 0.4

Okay! I am working with a new test that is to create 1.2 million rows in a table to make sure that I can read all of them as expected. At this point, it fails miserably as indicated.

I started a post on the blog about the update I'm working on.


Thank you very much for the

Thank you very much for the prompt reply.


Re: Composite columns

Ah! I don't think I wrote anything to support composite columns. I started the work on Cassandra 0.8 and I'm pretty sure I read something about that, but I don't recall seeing a easy way to do it then.

Is it part of Cassandra 1.1 now? Without any special additions? If so, then I could look into a way to add the capability.


Super column support

That I can tell you. libQtCassandra does not yet support Super Columns. The concept breaks the default schema. C++ cannot easily know whether you are trying to access a super column or just a column. Also, that's not something I was in need of so I did not really look into implementing it.

The one other thing that is not there yet, but I want to implement, are counters...


I am trying to use super

I am trying to use super columns as well, and it would be great if you could point me to an example of how I can add supercolumn values using libqtCassandra.

I tried

qc[QString(keyspace)][QString(columnFamily)][key][QString(supercolumn)][QString(column)] = QString(value);

but it does not work. (I can add the value using the cassandra cli)


Composite columns

Sorry, I should have linked to this datastax page for composites:

Thank you for the prompt reply!


Re: Composite columns

Well... Just like that, I'd say I don't know. I'll have to create a test to see what's happening.

I'm not totally sure what you call composite columns. If that's using a colon to separate multiple names, then as far as I know that's legal in a regular column name. So that would not be the problem.

However, I'm wondering about the UTF-8 type. I don't think I tried that so I'm thinking that could be the culprit.

I don't have time to test right now, but I'll do my best to check later today to give you a better answer.

Thank you for checking out libQtCassandra!


Composite columns


I created a column family in cassandra that looks like:


create column family Test
  with column_type = 'Standard'
  and comparator = 'CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
  and default_validation_class = 'UTF8Type'
  and key_validation_class = 'UTF8Type'
  and rows_cached = 0.0
  and row_cache_save_period = 0
  and row_cache_keys_to_save = 2147483647
  and keys_cached = 200000.0
  and key_cache_save_period = 14400
  and read_repair_chance = 1.0
  and gc_grace = 864000
  and min_compaction_threshold = 4
  and max_compaction_threshold = 32
  and replicate_on_write = true
  and row_cache_provider = 'SerializingCacheProvider'
  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy';
I am planning on using composite columns, and was able to insert such values from the cassandra cli.  Current values from cassandra cli:
RowKey: a
=> (column=1:subject, value=subject, timestamp=1344792191596000)
=> (column=thing1:thing2, value=my composite value, timestamp=1344792156926000)
However, I cannot seem to find anything talking about how to insert values in composite columns using libQtCassandra-0.4.1.  Is this currently supported?
The cassandra cli command is:
set Test['myKey2']['comp1:comp2']='my value'; 
I tried doing 
qcassandra[QString(keyspace)][QString(columnFamily)][key][QString("anda1:anda2")] = QString(value);
but the application crashed with terminate called after throwing an instance of 'org::apache::cassandra::InvalidRequestException'
  what():  Default TException.
Any help would be appreciated.
Thank you.



Version 0.4 causes problems...

Great! I'm glad it worked for you in the end.

Have you tried to determine what could be the cause of the problem (what changed between 0.3 and 0.4 and see what would break your code)?

Thank you for using the library!


Version 0.4 bug

I tried the version 0.4 of libQtCassandra, and found that the code to read a full column family was not working properly.

There were some compilation errors, and when fixed, I could only read a portion of the table (the first rows read), and those would be returned every time, even when changing the start row name.

I later changed to 0.3 and the same code worked correctly.

Also, thanks for posting the source code. The library is great and has saved me months of development.




Re: installation help...

Installation Instructions

I updated this page with basic instructions.

Qt4 Core

While doing development, I would install libqt4-dev:

apt-get install libqt4-dev

You may also want to make sure you get qt4-dev-tools and qt4-qmake, I do not know whether they automatically get installed when you install the development library.

For runtime, you want to libqtcore4 only:

apt-get install libqtcore4

If you're not under a Debian system, you'll have to do some research. I would imagine that an RPM based system will have a similar breakup of the Qt environment.


We'll have to look into making this optional I guess. At this point the thrift library recompile is forced. It appears as the last entry in here:


But you may have to add some include paths to be able to compile the library if thrift appears in a folder not added by default.


installation help..


I couldn't find the build/installation instructions for libQtCassandra, can you please post them.

- Also, since libQtCassandra uses only QtCore, is there a way to install just QtCore

- I already have thrift installed on the system, but it seems libQtCassandra is re-doing it again, can we avoid that?



Include paths

Well... I guess it very much depends on your install. cmake is expected to find Qt for you. We have a newer version which I did not upload yet. I can look into doing so later today so you'll have it tomorrow and we can start from there.

Under Ubuntu, Qt is generally under /usr/include/qt4. However, the #include generally reference files found under many different folders there. So you'd have to add them all as far as I know.


The problem was that qmake wasn't in the path. qmake is run to gather all the Qt installation information.


Include paths

What include paths is this looking for in building? I have tried pointing QTDIR & QTINC & QTLIB to the built path for QtLib, I've tried pointing INCLUDE & LIB there, and the Makefile doesn't find the headers.


Clearly I am doing something wrong, but I haven't figured that out yet, and the boss it getting a little huffy. After all, it's "only software".


Thanks in advance,



Snap! Websites
An Open Source CMS System in C++

Contact Us Directly