我在获取包含Cassandra Java Driver
Map的列表时遇到问题。
对于以下版本:
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>>>
);
我用错了吗?我很感激你的帮助
1条答案
按热度按时间jpfvwuh41#
答案可以在这里找到:https://community.datastax.com/questions/3939/how-can-i-access-nested-collections-with-the-java.html