我正在尝试将一个Scala Map(我正试图转换为java.util.Map)存储到Cassandra 2.1.8中。
数据结构如下:
Map[String -> Set[Tuple[String, String, String]]]
我按照以下方式创建了表格:
CREATE TABLE mailing (emailaddr text PRIMARY KEY, totalmails bigint, emails map<text, frozen<set<tuple<text, text, text>>>>);
首先,我尝试将Set转换为Java Set:
def emailsToCassandra(addr: emailAddress, mail: MailContent, number: Int) = {
println("Inserting emails into cassandra")
mail.emails.foreach(result =>
setAsJavaSet(result._2)
)
然后我建立查询并尝试将Map转换为Java Map:
val query = QueryBuilder.insertInto("emails", "mailing")
.value("emailAddr", addr.toString())
.value("totalmails", number)
.value("emails", mapAsJavaMap(mail.emails))
session.executeAsync(query)
我回来了:
java.lang.IllegalArgumentException: Value 1 of type class scala.collection.convert.Wrappers$MapWrapper does not correspond to any CQL3 type
我也尝试过这样做:
val lol = mail.emails.asInstanceOf[java.util.Map[String, java.util.Set[Tuple3[String, String, String]]]]
这不起作用
提前感谢你