Database Reference
In-Depth Information
for (ColumnOrSuperColumn cosc : row) {
Column c = cosc.column;
System.out.println(new String(c.name, "UTF-8") + " : "
+ new String(c.value, "UTF-8"));
}
}
conn.close();
System.out.println("All done.");
}
}
So we have a couple of row keys in the database, with identifiers I've kept purposefully short and
clear in order to help you visualize the structure. We have a variety of column sets between the
two rows but we're only interested in retrieving the a and c columns, so we use a slice predicate
and specify the column_names to limit the results. We also want to specify more than one row,
so we use a list of byte arrays to indicate which row keys we're after.
Running this code elicits the following result:
Running Multiget Slice.
Row k2 -->
a : 2.1
Row k1 -->
a : 1
c : 3
All done.
As you can see, there was no column named “b” defined for the row with key “k2”, and Cas-
sandra didn't return anything for it. There was a value for column “b” in row “k1”, but we didn't
ask for it in our slice, so we didn't get it.
NOTE
Because we're using Thrift as the underlying RPC mechanism to communicate with Cassandra, the res-
ults will come back to you unordered and you'll have to sort them on the client. That's because Thrift
can't preserve order. A multiget is actually just a wrapper over a series of get requests.
Deleting
Deleting data is not the same in Cassandra as it is in a relational database. In RDBMS, you simply
issue a delete statement that identifies the row or rows you want to delete. In Cassandra, a de-
Search WWH ::




Custom Search