Database Reference
In-Depth Information
Set columns in column families
We'll start by looking at sets, which are the simplest of the three collection column types.
Let's take a look at
alice
's row in the
user_status_updates
column family:
GET user_status_updates['alice'];
Recall that, by only using the bracket operator once in the
GET
statement, we'll retrieve all
cells in the
alice
RowKey.
There are quite a few cells in
alice
's wide row, but we're particularly interested in those
having to do with the
starred_by_users
column, which is a set:
Note that the cell names here look like the cell names in
home_status_updates
, but
with yet another component: a short hexadecimal string appended to the end. Unfortu-
nately, there's no straightforward way to get cassandra-cli to print those hexadecimal
strings in a human-readable form, so you'll have to take my word for it that
0x626f62
is
the blob encoding of the string
bob
, and
0x6361726f6c
encodes the string
carol
.
With this cleared up, we can observe that the underlying representation of a CQL set is a
collection of cells, with each cell encoding one of the items in the set. The item is actually
encoded in the cell's
name
by appending it to the usual combination of clustering column
value and row name that comprises the name of a scalar cell.
Let's have a look at a set using the visual comparison we have been developing in the
course of this chapter. For clarity, I've omitted everything unrelated to the set: