Search code examples
javacollectionscassandraresultset

How to get nested map from Cassandra Result Set


I have a Cassandra table like this:

create table Engine (
    primayval text,
    Dataval  map<text,<map<text, double>>,
    PRIMARY KEY (tradeddate)
);

How can I retrieve this in a Java nested map Map<String,Map<String,Double>> using ResultSet-> getMap() without JSON conversion?


Solution

  • turned out to be quite straightforward :

        Map<String, Map<String,Double>> DataVal;
        Row rw = resultSet.one();
        DataVal=(rw.getMap("DataVal", TypeToken.of(String.class),new TypeToken<Map<String,Double>>() {}));