Database Reference
In-Depth Information
Exploring cells
Looking at the name attribute, we see things like email , encrypted_password ,
version , and location . Clearly, the name attribute of the cells corresponds to the
names of columns in our CQL schema—although the relationship is more complex than it
might appear, as we'll explore in the next section.
The value field in the cells is a bit of a mystery; given that the name contains column
names, we might expect that the value would contain column values. However, what we
see in cassandra-cli are just some inscrutable hexadecimal blobs.
As it turns out, under the hood Cassandra represents all data as hexadecimal byte arrays;
the type system is part of CQL's abstraction layer. The cassandra-cli utility does give us a
way to retrieve human-readable values of individual columns, using the AS keyword to ex-
plicitly specify the type. Let's try to read the value of the cell with the name value as
email , from HappyCorp's user record:
GET users['happycorp']['email'] AS ascii;
The GET command allows us to access a single cell by first specifying the RowKey value,
then the cell name. We can also omit the cell name to return all the cells at a given
RowKey .
In this case, thanks to our use of AS , we can see a human-readable value for HappyCorp's
email address:
Thankfully, the CLI will remember our preference for reading emails in ASCII, and will
accordingly print out all cells named email from the users column family for the re-
mainder of the session.
Search WWH ::




Custom Search