簡體   English   中英

Datastax Cassandra Java驅動程序,未來結果集似乎返回一致的數據

[英]Datastax Cassandra Java Driver, Future Result Set appears to return in consistent data

我正在使用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團隊的Olivier Michallat( https://datastax-oss.atlassian.net/secure/ViewProfile.jspa?name=omichallat )能夠幫助我們指出BoundStatement每次都需要是不同的實例。

我們驗證了我們的代碼,我們沒有返回不同的BoundStatement實例。 我們糾正了我們這邊的代碼,問題得到了解決。

我們和Datastax團隊之間的對話在這里https://datastax-oss.atlassian.net/browse/JAVA-1198

感謝https://stackoverflow.com/users/438154/sotirios-delimanolis的支持。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM