Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you check for the existence of a column family in hector?

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?

like image 233
user430788 Avatar asked Jun 19 '11 00:06

user430788


People also ask

What is column family in database?

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".

What is column family in Cassandra?

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.

Is column family a table?

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.

How is the column family data model different from other data models?

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.


1 Answers

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.

like image 161
Patricio Avatar answered Oct 18 '22 20:10

Patricio