Codec not found for frozen<map<frozen<map<text, text>>,int>>

358 views
Skip to first unread message

Jakub Liska

unread,
Jun 28, 2017, 1:04:20 PM6/28/17
to DataStax Java Driver for Apache Cassandra User Mailing List
Hey,

I can create table with : 

data frozen<map<frozen<map<text, text>>,int>>

but when I'm trying to read it (Scala) : 

row.getMap("data", classOf[java.util.Map[String,String]], classOf[Integer])

Codec not found for requested operation: [map<varchar, varchar> <-> java.util.Map]

So I'm thinking, is frozen<map<frozen<map<text, text>>,int>> supported ?

Andrew Tolbert

unread,
Jun 28, 2017, 2:04:10 PM6/28/17
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi Jakub,

I think this might because because generic type information is not discernible (in java) when using classOf because of type erasure.

Instead, you could try using the TypeToken variant of getMap, i.e.:

import static com.datastax.driver.core.TypeTokens;
import com.google.common.reflect.TypeToken
row.getMap("data", TypeTokens.mapOf(classOf[String], classOf[String]), TypeToken.of(classOf[Integer]))

Thanks,
Andy

Andrew Tolbert

unread,
Jun 28, 2017, 2:06:31 PM6/28/17
to DataStax Java Driver for Apache Cassandra User Mailing List
A bit of a copy paste fail on my part:

import static com.datastax.driver.core.TypeTokens;

should be:

import com.datastax.driver.core.TypeTokens

Jakub Liska

unread,
Jun 28, 2017, 4:16:05 PM6/28/17
to DataStax Java Driver for Apache Cassandra User Mailing List
Big thanks Andrew, I didn't find it in TypeToken and I completely missed the TypeTokens class. 
Reply all
Reply to author
Forward
0 new messages