last day (15 days later) » 

5:56 AM
1
A: how to store hashmap in cassandra table

Raman Mishrayou can use method .setMap on the boundStatement. import scala.collection.JavaConvertors._ val statement = session.prepare(s"insert into $XYZ ($MAP) values (:$MAP)") val map: Map[lang.Long, util.List[lang.Double]] = Map(long2Long(351608084641351) -> List(0.0, 0.0, 1.0, 0.0, 1.547012087E9, 85.09...

 
my hashmap is HashMap[Long,List[Any]]
 
I think Object can take any kind of type in Java
 
it gives an error type mismatch; found : (Long, List[Any]) required: Double,in val map line
 
I have given list of double as the value of the map but it seems you have list of any change it to list of any it will work
 
what does this stand for?($MAP) values (:$MAP)
 
5:56 AM
@experiment these are constant for the column name in the table xyz we use s string interpolation to use variable in the string using $ this sign.
hey
 
okay,I am new to this ,tried to understand setMap fuction,but had some confusions,will it store the list elements in different columns?
hello
 
6:20 AM
no
it will save the data into the same column
which will have type map<key, value>
the type of the column will be map
as we give int
text
etc.
 
6:33 AM
i want it to be stored as seprate columns,what approach should I use?
 
then why you are using map
use simple columns
 
7:01 AM
I am using maps for comparison ,trying to avoid using joins in spark.Since joins are quadratic in nature.
so this map which I am using has to persisted somehwere
 
7:58 AM
see if you will use separate columns then i don't know how many columns you will need to save the value
 
8:22 AM
I would need these columns id d1 d2 d3 d4 evt lt ln s
 
then make it you don't need map then
 

last day (15 days later) »