int batchSize = batchedRows.size();
if (batchedSql != null && batchSize > 0) {
PreparedStatement ps = null;
try {
RowImpl onerow = null;
ps = prepareStatement(batchedSql);
if (batchSize == 1) {
// execute a single row.
onerow = (RowImpl) batchedRows.get(0);
flushSingleRow(onerow, ps);
} else {
// cache has more than one rows, execute as batch.
int count = 0;
int batchedRowsBaseIndex = 0;
Iterator itr = batchedRows.iterator();
while (itr.hasNext()) {
onerow = (RowImpl) itr.next();
if (_batchLimit == 1) {
flushSingleRow(onerow, ps);
} else {
if (count < _batchLimit || _batchLimit == -1) {
if (ps != null)
onerow.flush(ps, _dict, _store);
addBatch(ps, onerow, count);
count++;
} else {
// reach the batchLimit, execute the batch
int[] rtn = executeBatch(ps);
checkUpdateCount(rtn, batchedRowsBaseIndex, ps);
batchedRowsBaseIndex += _batchLimit;
if (ps != null)
onerow.flush(ps, _dict, _store);
addBatch(ps, onerow, count);
// reset the count to 1 for new batch
count = 1;
}
}