Thanks, this client library is really great! It should be included in the Apache Cassandra Wiki's "High level clients" page (
Anyway, here is the code I created (using the cassandra-driver-core Maven artifact).

Cluster cluster = Cluster.builder().addContactPoints("").build();
Session session = cluster.connect("graph");
for (Row row : session.execute("SELECT * FROM vertices")) {
System.out.println("id: " + row.getString("id"));
System.out.println("properties: ");
Map<String, String> map = row.getMap("properties", String.class, String.class);
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("- " + entry.getKey() + ": " + entry.getValue());


On 25 March 2013 14:52, Sylvain Lebresne <> wrote:
I would advise you not to use raw thrift. It's just a low-level transport as far as CQL3 is concerned, and what you will get is binary encoded data that you will have to decode manually. Use a client library (like that will do that for you.

Though to answer your initial question, the binary format used by map (that you will have to decode yourself) is described in;a=blob;f=doc/native_protocol.spec (Section 6).


On Mon, Mar 25, 2013 at 2:30 PM, Szárnyas Gábor <> wrote:

I got stuck when trying to query CQL3 collections from Java. 
I'm using Cassandra 1.2.3 with CQL3. I created a column family to store a property graph's edges with the following command:

CREATE TABLE vertices ( 
  id text PRIMARY KEY, 
  properties map<text, text>

I can access the data from the cqlsh, however, I couldn't figure out how to iterate through the map entries in Java. 
The following code iterates through the rows and columns, but does not retrieve the key-value pairs of the "properties" map.

String query = "SELECT * FROM vertices";
CqlResult cqlResult = client.execute_cql3_query(ByteBuffer.wrap(query.getBytes()), COMPRESSION_LEVEL.NONE, CONSISTENCY_LEVEL.ALL);

Iterator<CqlRow> rowsIterator = cqlResult.getRowsIterator();
while (rowsIterator.hasNext()) {
  CqlRow cqlRow =;
  Iterator<Column> columnsIterator = cqlRow.getColumnsIterator();
  while (columnsIterator.hasNext()) {
    Column cqlColumn =;

    byte[] name = cqlColumn.getName();
    String nameString = new String(name);
    System.out.print(nameString + ": ");

    byte[] value = cqlColumn.getValue();
    String string = new String(value);

The cqlResult.getSchema() method shows the column with the type "org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)". How can I create a HashMap<String, String> from each row's properties cell?