Database Reference
In-Depth Information
Figure3-6.The basic structure of a super column
Each column family is stored on disk in its own separate file. So to optimize performance, it's
important to keep columns that you are likely to query together in the same column family, and
a super column can be helpful for this.
The SuperColumn class implements both the IColumn and the IColumnContainer classes, both
from the org.apache.cassandra.db package. The Thrift API is the underlying RPC serialization
mechanism for performing remote operations on Cassandra. Because the Thrift API has no no-
tion of inheritance, you will sometimes see the API refer to a ColumnOrSupercolumn type;
when data structures use this type, you are expected to know whether your underlying column
family is of type Super or Standard .
NOTE
Fun fact: super columns were one of the updates that Facebook added to Google's Bigtable data model.
Here we see some more of the richness of the data model. When using regular columns, as we
saw earlier, Cassandra looks like a four-dimensional hashtable. But for super columns, it becomes
more like a five-dimensional hash:
[Keyspace][ColumnFamily][Key][SuperColumn][SubColumn]
To use a super column, you define your column family as type Super . Then, you still have row
keys as you do in a regular column family, but you also reference the super column, which is
simply a name that points to a list or map of regular columns (sometimes called the subcolumns).
Here is an example of a super column family definition called PointOfInterest . In the hotelier
domain, a “point of interest” is a location near a hotel that travelers might like to visit, such as a
park, museum, zoo, or tourist attraction:
PointOfInterest (SCF)
SCkey: Cambria Suites Hayden
{
key: Phoenix Zoo
{
phone: 480-555-9999,
desc: They have animals here.
Search WWH ::




Custom Search