I have code that uses Hector to access Cassandra and needs to create column families on the fly if and only if they don't already exist. What is the proper way to check for the existence of a column family in a keyspace?
A column family is a database object that contains columns of related data. It is a tuple (pair) that consists of a key–value pair, where the key is mapped to a value that is a set of columns. In analogy with relational databases, a column family is as a "table", each key-value pair being a "row".
A Cassandra column family consists of a collection of ordered columns in rows which represent a structured version of the stored data. The keyspace holds these Cassandra column families and each keyspace has at least one column family.
Column Family is nothing but a table which is analogous to a table in an RDBMS world. There are certain types to it, namely; Static column Family – Static Column family is where the names and data types are defined. So when the column family is created, the option to name the column name and data types is available.
A column-family data model is not the same as a column-oriented model. A column-family database stores a row with all its column families together, whereas a column-oriented database simply stores data tables by column rather than by row.
I posted some info in our Hector wiki.
https://github.com/rantav/hector/wiki/Getting-started-%285-minutes%29
Basically once you get the KeyspaceDef you can call:
keyspaceDef.getCfDefs() and see if the CF is there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With