當前位置: 首頁>>代碼示例>>Java>>正文


Java BatchStatement.size方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.BatchStatement.size方法的典型用法代碼示例。如果您正苦於以下問題:Java BatchStatement.size方法的具體用法?Java BatchStatement.size怎麽用?Java BatchStatement.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.BatchStatement的用法示例。


在下文中一共展示了BatchStatement.size方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: untilApplied

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static boolean untilApplied(Session session, BatchStatement.Type type, Consumer<BatchStatement> transaction) {
    for (int i = 1; i <= MAX_RETRY; i ++) {
        BatchStatement batchStatement = new BatchStatement(type);
        transaction.accept(batchStatement);
        if (batchStatement.size() == 0) return false;
        boolean applied;
        if (batchStatement.size() > 1) {
            applied = session.execute(batchStatement).wasApplied();
        } else {
            Statement statement = Iterables.getOnlyElement(batchStatement.getStatements());
            applied = session.execute(statement).wasApplied();
        }
        if (applied) return true;
        log.warn("Attempt {}/{} failed executing {}", i, MAX_RETRY, batchStatement);
        try {
            Thread.sleep(100 * i);
        } catch (InterruptedException e) {
            throw new AttemptsFailedException(e);
        }
    }
    throw new AttemptsFailedException();
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:23,代碼來源:CassandraUtil.java

示例2: load

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public void load(Iterator<List<Object>> rows)
{
    PreparedStatement statement = session.prepare(insertQuery);

    BatchStatement batch = createBatchStatement();
    while (rows.hasNext()) {
        if (batch.size() >= batchRowsCount) {
            session.execute(batch);
            batch = createBatchStatement();
        }
        List<Object> row = rows.next();
        checkState(row.size() == columnsCount, "values count in a row is expected to be %d, but found: %d", columnsCount, row.size());
        batch.add(statement.bind(row.toArray()));
    }

    if (batch.size() > 0) {
        session.execute(batch);
    }
}
 
開發者ID:prestodb,項目名稱:tempto,代碼行數:20,代碼來源:CassandraBatchLoader.java

示例3: batch

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static ResultSet batch(Session session, BatchStatement.Type type, Consumer<BatchStatement> transaction) {
    BatchStatement batchStatement = new BatchStatement(type);
    transaction.accept(batchStatement);
    if (batchStatement.size() == 0) return null;
    if (batchStatement.size() > 1) {
        return session.execute(batchStatement);
    } else {
        Statement statement = Iterables.getOnlyElement(batchStatement.getStatements());
        return session.execute(statement);
    }
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:12,代碼來源:CassandraUtil.java

示例4: executeBatch

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
private void executeBatch(BatchStatement batchState) {
    if (batchState.size() > 0) {
        m_logger.debug("Executing synchronous batch with {} statements", batchState.size());
        m_dbservice.getSession().execute(batchState);
    }
}
 
開發者ID:QSFT,項目名稱:Doradus,代碼行數:7,代碼來源:CQLTransaction.java


注:本文中的com.datastax.driver.core.BatchStatement.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。