如何获得一个.llt< long,string>在爪哇

发布于 2025-02-01 22:52:49 字数 842 浏览 1 评论 0原文

我正在使用以下方法来从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文