Database Reference
In-Depth Information
UTF8Type
UTF8Type
A string using UTF-8 as the character encoder. Although this may seem like a good default
type, that's probably because it's comfortable to programmers who are used to using XML
or other data exchange mechanism that requires common encoding. In Cassandra, however,
you should use UTF8Type only if you want your data validated.
Custom
Custom
You can create your own column sorting mechanism if you like. This, like many things
in Cassandra, is pluggable. All you have to do is extend the org.apache.cas-
sandra.db.marshal.AbstractType and specify your class name.
Column names are stored in sorted order according to the value of compare_with . Rows, on the
other hand, are stored in an order defined by the partitioner (for example, with RandomParti-
tioner, they are in random order, etc.). We examine partitioners in Chapter 6 .
It is not possible in Cassandra to sort by value, as we're used to doing in relational databases. This
may seem like an odd limitation, but Cassandra has to sort by column name in order to allow
fetching individual columns from very large rows without pulling the entire row into memory.
Performance is an important selling point of Cassandra, and sorting at read time would harm
performance.
NOTE
Column sorting is controllable, but key sorting isn't; row keys always sort in byte order.
Super Columns
A supercolumnis a special kind of column. Both kinds of columns are name/value pairs, but a
regular column stores a byte array value, and the value of a super column is a map of subcolumns
(which store byte array values). Note that they store only a map of columns; you cannot define a
super column that stores a map of other super columns. So the super column idea goes only one
level deep, but it can have an unbounded number of columns.
The basic structure of a super column is its name, which is a byte array (just as with a regular
column), and the columns it stores (see Figure 3-6 ). Its columns are held as a map whose keys
are the column names and whose values are the columns.
Search WWH ::




Custom Search