gpt4 book ai didi

java - Datastax Cassandra Java 驱动程序, future 结果集似乎以一致的数据返回

转载 作者:太空宇宙 更新时间:2023-11-04 12:35:39 24 4
gpt4 key购买 nike

我正在使用 Cassandra Driver 3.0 。当我异步读取数据时,我得到的数据是一致的。

例如:在给定的员工 ID 列表 [id1, id2] 中,我请求 id1 和 id2 的数据。我正在获取 id1 和 id2 的数据,有时还获取 id1 和 id1 的数据。这是不一致的。我提供了下面的代码。你能帮忙吗?

public List<Employee> getEmployeeShortProfile(List<String> employeeIds) throws InterruptedException,
ExecutionException {
List<ResultSetFuture> rsFutureList = new ArrayList<ResultSetFuture>();
List<Employee> EmployeeList = new ArrayList<Employee>();


for (String EmployeeId : EmployeeIds) {

//Please NOTE
//preparedStatement.getbStGetShortProfileById() below in the code returns the following prepared statement
//client.getSession().prepare(
//"select employee_id, company_name, company_icon_url, product_icon_image, company_display_name, employee_information, detail_description from samplekeysapce.tbl_master_employees where employee_id = ? limit 15");
// FYI, I did not set the consistency level in the execute.

BoundStatement bStGetShortProfileById = preparedStatement.getbStGetShortProfileById();

logger.debug("... setting the short profile id ..."+EmployeeId);
bStGetShortProfileById.bind(EmployeeId);
Session session = client.getSession();
ResultSetFuture rs = session.executeAsync(bStGetShortProfileById);
rsFutureList.add(rs);
}


for(ResultSetFuture rsF : rsFutureList){
ResultSet rs = rsF.getUninterruptibly();
Iterator<Row> rowIterator = rs.iterator();
Employee c = extractEmployee(rowIterator);
if(c!= null){
EmployeeList.add(c);

}


}
return EmployeeList;
}

最佳答案

Datastax 团队 ( https://datastax-oss.atlassian.net/secure/ViewProfile.jspa?name=omichallat ) 的 Olivier Michallat 能够帮助我们指出 BoundStatement 每次都需要不同的实例。

我们验证了我们的代码,我们没有返回不同的 BoundStatement 实例。我们更正了我们这边的代码,问题就解决了。

我们和 Datastax 团队之间的对话在这里 https://datastax-oss.atlassian.net/browse/JAVA-1198 .

谢谢 https://stackoverflow.com/users/438154/sotirios-delimanolis寻求支持。

关于java - Datastax Cassandra Java 驱动程序, future 结果集似乎以一致的数据返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37369603/

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