本文整理匯總了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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}