2016-05-22 5 views
1

私はCassandra Driver 3.0を使用しています。データを非同期で読み取っているとき、データを一貫して取得しています。Datastax Cassandra Javaドライバ、将来の結果セットが一貫性のあるデータで返されるようです。

例:特定の従業員IDリスト[id1、id2]で、id1とid2のデータを要求しています。私はid1とid2、時にはid1とid1のデータを取得しています。これは矛盾しています。私は以下のコードを提供しました。あなたは助けてもらえますか? Datastaxチーム(https://datastax-oss.atlassian.net/secure/ViewProfile.jspa?name=omichallat)から

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; 
} 
+0

相互参照用のjiraチケット:https://datastax-oss.atlassian.net/browse/JAVA-1198 –

+0

ありがとうSotirios Delimanolis – fsheriff

答えて

0

オリヴィエMichallatは、私たちはBoundStatementが毎回別のインスタンスにする必要があることを指摘助けることができました。

コードを検証したところ、別のBoundStatementインスタンスが返されませんでした。コードを修正して問題を解決しました。

私たちとDatastaxチームとの会話はここにありますhttps://datastax-oss.atlassian.net/browse/JAVA-1198です。

ありがとう https://stackoverflow.com/users/438154/sotirios-delimanolisをサポートしています。

関連する問題