Empty Cells in Cassandra

As I work more and more with Cassandra, I bump in more and more side effects of how the system works.

Yesterday I noticed that I would always get new entries for a set of pages I create on Snap! websites. These pages had a parameter, a list of boxes, which could be empty because some theme do not allow any boxes at all.

Unfortunately, if I may say, Cassandra does not support empty data. That is, if a cell is set to an empty string (""), it is the same as deleting that cell. The problem with that is that the cell disappears completely. So the only way is to have at least one byte of data. That byte can be anything, including zero (0) but it has to have a length of at least one.

In my case, I resolved the problem by putting a period "." as a default value representing empty. It worked for that specific case, but I do not otherwise have a good way to handle this (unless you always create cells that sort with a size on 4 bytes and thus an empty cell is represented by the value zero on those 4 bytes...)

Note that I did not find the bug earlier because there is a bug in the current version of libQtCassandra: it does not detect such entries as non-existant if you created them in that session. In other words, if you do cell->setValue(QString("")), it now exists in the libQtCassandra library and the row->exists("of that cell") returns true, which is quite unfortunate because in reality Cassandra will ignore the setValue(), or more specifically view it as a row->dropCell()...

So... I'll fix the libQtCassandra library at some point. In the meantime, you must be careful and check whether the content of a cell is nullValue(), because if so it just does not exist.

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

Contact Us Directly