use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery in project ignite by apache.
the class JdbcThinPreparedStatement method addBatch.
/**
* {@inheritDoc}
*/
@Override
public void addBatch() throws SQLException {
ensureNotClosed();
checkStatementEligibleForBatching(sql);
checkStatementBatchEmpty();
batchSize++;
if (conn.isStream())
conn.addBatch(sql, args);
else {
if (batch == null) {
batch = new ArrayList<>();
batch.add(new JdbcQuery(sql, args.toArray(new Object[args.size()])));
} else
batch.add(new JdbcQuery(null, args.toArray(new Object[args.size()])));
}
args = null;
}
use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery in project ignite by apache.
the class JdbcThinStatement method addBatch.
/**
* {@inheritDoc}
*/
@Override
public void addBatch(String sql) throws SQLException {
ensureNotClosed();
checkStatementEligibleForBatching(sql);
checkStatementBatchEmpty();
batchSize++;
if (conn.isStream()) {
conn.addBatch(sql, null);
return;
}
if (batch == null)
batch = new ArrayList<>();
batch.add(new JdbcQuery(sql, null));
}
use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery in project ignite by apache.
the class JdbcThinConnection method addBatch.
/**
* Add another query for batched execution.
* @param sql Query.
* @param args Arguments.
* @throws SQLException On error.
*/
void addBatch(String sql, List<Object> args) throws SQLException {
boolean newQry = (args == null || !F.eq(lastStreamQry, sql));
// Providing null as SQL here allows for recognizing subbatches on server and handling them more efficiently.
JdbcQuery q = new JdbcQuery(newQry ? sql : null, args != null ? args.toArray() : null);
if (streamBatch == null)
streamBatch = new ArrayList<>(streamBatchSize);
streamBatch.add(q);
// Null args means "addBatch(String)" was called on non-prepared Statement,
// we don't want to remember its query string.
lastStreamQry = (args != null ? sql : null);
if (streamBatch.size() == streamBatchSize)
executeBatch(false);
}
use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery in project ignite by apache.
the class JdbcThinTcpIo method guessCapacity.
/**
* Try to guess request capacity.
*
* @param req Request.
* @return Expected capacity.
*/
private static int guessCapacity(JdbcRequest req) {
int cap;
if (req instanceof JdbcBatchExecuteRequest) {
List<JdbcQuery> qrys = ((JdbcBatchExecuteRequest) req).queries();
int cnt = !F.isEmpty(qrys) ? Math.min(MAX_BATCH_QRY_CNT, qrys.size()) : 0;
// One additional byte for autocommit and last batch flags.
cap = cnt * DYNAMIC_SIZE_MSG_CAP + 2;
} else if (req instanceof JdbcQueryCloseRequest)
cap = QUERY_CLOSE_MSG_SIZE;
else if (req instanceof JdbcQueryMetadataRequest)
cap = QUERY_META_MSG_SIZE;
else if (req instanceof JdbcQueryFetchRequest)
cap = QUERY_FETCH_MSG_SIZE;
else
cap = DYNAMIC_SIZE_MSG_CAP;
return cap;
}
Aggregations