Java Code Examples for com.datastax.driver.core.BatchStatement#size()

The following examples show how to use com.datastax.driver.core.BatchStatement#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchedWrite.java    From geowave with Apache License 2.0 6 votes vote down vote up
private void insertStatement(final GeoWaveRow row, final BoundStatement statement) {
  if (ASYNC) {
    if (batchSize > 1) {
      final BatchStatement currentBatch = addStatement(row, statement);
      synchronized (currentBatch) {
        if (currentBatch.size() >= batchSize) {
          writeBatch(currentBatch);
        }
      }
    } else {
      try {
        executeAsync(statement);
      } catch (final InterruptedException e) {
        LOGGER.warn("async write semaphore interrupted", e);
        writeSemaphore.release();
      }
    }
  } else {
    session.execute(statement);
  }
}
 
Example 2
Source File: CQLTransaction.java    From Doradus with Apache License 2.0 4 votes vote down vote up
private void executeBatch(BatchStatement batchState) {
    if (batchState.size() > 0) {
        m_logger.debug("Executing synchronous batch with {} statements", batchState.size());
        m_dbservice.getSession().execute(batchState);
    }
}