dictionary - 如何在 cassandra 数据库 2.2.1 中创建嵌套集合 map<text,list<text>> 类型

标签 dictionary collections cassandra nested cql3

create table tbl_master_values (
  dbid int primary key,
  user_dbid int, reg_dbid int,
  module_dbid int,
  fields_value map<text,list<text>>,
  created_date timestamp,
  modified_date timestamp);

它返回此错误:
InvalidRequest: code=2200 [Invalid query] 
message="Non-frozen collections are not allowed inside collections: map<text, list<text>>"

最佳答案

在 Cassandra 中,如果您打算通过 in-Cassandra 查询添加或删除条目,则可以使用非卡住集合。但是当您打算在 map 中使用 UDT 或嵌套集合时,您必须将前者声明为卡住。
例如在你的情况下:

    create table tbl_master_values (
    dbid int primary key,
    user_dbid int, reg_dbid int,
    module_dbid int,
    fields_value map<text,frozen<list<text>>>,
    created_date timestamp,
    modified_date timestamp);

如果您使用 Map 来存储和检索信息,而不更新行,您可以将其声明为:
    frozen<map<text, list<text>>>

请记住frozen<> 关键字不会让您更新该实体并将其存储为blob 类型。
阅读此处以了解更新:

https://docs.datastax.com/en/cql/3.3/cql/cql_using/useInsertMap.html

关于dictionary - 如何在 cassandra 数据库 2.2.1 中创建嵌套集合 map<text,list<text>> 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35036354/

相关文章:

python - 如何将多个列表转换为python中的字典?

集合或数组的 Java printf 功能

支持连接池的 Golang cassandra 客户端

python - 在 python 中更改字典

python - 词典理解和创建过程中的键检查

Python-将列表的列表映射到字典

java - 尽管我输入了不同的值,但打印列表时 LinkedList 获得相同的值

java - 为什么 Collections.UnmodifiableMap.UnmodifiableEntrySet 覆盖 stream() 方法?

cassandra - 如果指定了分区键,Cassandra 二级索引是否被优化?

nosql - 在我的场景中提高 Cassandra 读取性能的方法