如何获得一个.llt< long,string>在爪哇
我正在使用以下方法来从Cassandra获取 Long 类型的列数据:
// com.datastax.driver.core.Row;
Set<Long> idSet= new HashSet<>();
idSet= row.getSet("rankids", Long.class);
因此,这对我来说很好。
现在,我有type = set&lt; map&lt; long的列,字符串&gt; 我正在尝试这样的尝试:
Set<Map<Long,String>> rankSet= new HashSet<>();
rankSet = row.getSet("ranks", Map.class);
rankSet.forEach((final Map rankMap) -> {
rankMap.forEach((k,v) ->LOGGER.info("Key = " + k + ", Value = " + v));
});
但是这不起作用。我需要在这里做什么。如何在此处正确使用 .class 。
更新
// import com.google.common.reflect.TypeToken;
row.getSet("ranks", new TypeToken<Map<Long, String>>() { });
这没有给出任何错误,但显示为不稳定的警告。
I am using the below approach to fetch column data of type Long from cassandra :
// com.datastax.driver.core.Row;
Set<Long> idSet= new HashSet<>();
idSet= row.getSet("rankids", Long.class);
So this is working fine from me.
Now I have column of type = Set<Map<Long,String>>
And I am trying like this :
Set<Map<Long,String>> rankSet= new HashSet<>();
rankSet = row.getSet("ranks", Map.class);
rankSet.forEach((final Map rankMap) -> {
rankMap.forEach((k,v) ->LOGGER.info("Key = " + k + ", Value = " + v));
});
But this not working. What I need to do here. How to use the .class properly here.
UPDATE
// import com.google.common.reflect.TypeToken;
row.getSet("ranks", new TypeToken<Map<Long, String>>() { });
This is not giving any error but it is showing as unstable warning.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论