javascalacassandrakey-value-storetypetoken

Unable to read data from Map of Primitive data type from Cassandra DB using Scala


Need help in reading data from Cassandra DB of type Map(varchar,double) in Scala.

i am using Cassandra core 3.0 and data is stored in DB by third party API so i cannot change type

I was trying to read using row.getMap("column_name", classOf[String], classOf[Double])) but i am facing following error: "IllegalArgumentException: Primitive type 'double' used as type parameter"

Thanks in advance.


Solution

  • I believe that the reason of the issue is that getMap returns java.util.Map and standard Java collections do not support value types (aka primitive types) as generic keys or values. Wrapper objects are used instead such as java.lang.Double (see also autoboxing). So try something like

    row.getMap("column_name", classOf[String], classOf[java.lang.Double]))