如何使用Cassandra Java驱动程序访问包含嵌套Map的列表

y0u0uwnf  于 2022-11-05  发布在  Cassandra
关注(0)|答案(1)|浏览(120)

我在获取包含Cassandra Java DriverMap的列表时遇到问题。
对于以下版本:

List<Map<Integer, Integer>> myList = state.getList(5, TypeTokens.mapOf(Integer.class, Integer.class));

错误如下:

InvalidRequest: Error from server: code=2200 [Invalid query] message="Java source compilation failed: Line 3: TypeTokens cannot be resolved"

对于版本,如下所示:

List<Map<Integer, Integer>> myList = state.getList(5 , Map.class);

错误如下:

InvalidRequest: Error from server: code=2200 [Invalid query] message="Java source compilation failed: Line 3: Type mismatch: cannot convert from List<Map> to List<Map<Integer,Integer>>

最后一个版本如下:

List<Map> myList = state.getList(5, Map.class);

编译器没有抱怨,但当我执行聚合时,错误如下:

FunctionFailure: Error from server: code=1400 [User Defined Function failure] message="execution of 'my_keyspace.count_min_udf[count_min_udt, int, int, text]' failed: com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [frozen<map<int, int>> <-> java.util.Map]"

state是一个UDT,定义如下:

CREATE TYPE count_min_udt(
  n int,
  m int,
  p bigint,
  hash_a list <bigint>,
  hash_b list <bigint>,
  values list<frozen <map<int, int>>>
);

我用错了吗?我很感激你的帮助

相关问题