如何使用 Cassandra Java 驱动程序访问带有嵌套地图的列表
How to access list with nested maps with Cassandra Java Driver
我无法获取包含带有 Cassandra Java Driver
的地图的列表。
对于以下版本:
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>>>
);
我用错了吗?我会很感激一些帮助
我无法获取包含带有 Cassandra Java Driver
的地图的列表。
对于以下版本:
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
是一个定义为:
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>>>
);
我用错了吗?我会很感激一些帮助