gpt4 book ai didi

java - 从 Cassandra 检索数据 block

转载 作者:搜寻专家 更新时间:2023-11-01 02:58:58 26 4
gpt4 key购买 nike

我在 Cassandra 中有一个包含大约 5 亿条记录的表。我需要传递所有这些记录并进行一些处理,然后将处理过的记录插入到其他表中。由于内存问题,我需要以 block 的形式检索这些记录。有没有办法做到这一点?例如,在第一个 block 中我需要获取第一个 2M,然后在第二个 block 中我需要检索第二个 2M 等等。

最佳答案

如果您只是运行一个常规的execute 方法,您会得到一个ResultSet。如文档中所述:

The retrieval of the rows of a ResultSet is generally paged (a first page of result is fetched and the next one is only fetched once all the results of the first one has been consumed). The size of the pages can be configured either globally through QueryOptions.setFetchSize(int) or per-statement with Statement.setFetchSize(int). Though new pages are automatically (and transparently) fetched when needed, it is possible to force the retrieval of the next page early through fetchMoreResults().

因此,您只需运行查询以获取所有数据并将提取大小设置为您的 block 大小。然后遍历你的 ResultSet 直到你得到你的记录 block ,处理,插入,然后再次开始迭代。

关于java - 从 Cassandra 检索数据 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42046091/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com