J'utilise Cassandra Driver 3.0 .Quand je lis des données de manière asynchrone, je reçois les données en cohérence. Par exemple: Dans la liste donnée des ID d'employé, [id1, id2], je demande les données pour id1 et id2. J'obtiens des données pour id1 et id2 et parfois id1 et id1. C'est incohérent. J'ai fourni le code ci-dessous. Peux-tu aider s'il te plait?Pilote Java Datastax Cassandra, jeu de résultats futurs semble revenir en données cohérentes
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;
}
ticket jira associé pour le référencement croisé: https://datastax-oss.atlassian.net/browse/JAVA-1198 –
Merci Sotirios Delimanolis – fsheriff