incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Szárnyas Gábor <>
Subject Querying CQL3 collections from Java
Date Mon, 25 Mar 2013 13:30:06 GMT

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 =

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
How can I create a HashMap<String, String> from each row's properties cell?


View raw message