Search in sources :

Example 1 with JdbcQueryFetchRequest

use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest 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;
}
Also used : JdbcQuery(org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery) JdbcBatchExecuteRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest) JdbcQueryMetadataRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataRequest) JdbcQueryCloseRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCloseRequest) IpcClientTcpEndpoint(org.apache.ignite.internal.util.ipc.loopback.IpcClientTcpEndpoint) JdbcQueryFetchRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest)

Example 2 with JdbcQueryFetchRequest

use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest in project ignite by apache.

the class JdbcThinResultSet method next.

/**
 * {@inheritDoc}
 */
@Override
public boolean next() throws SQLException {
    ensureAlive();
    if ((rowsIter == null || !rowsIter.hasNext()) && !finished) {
        JdbcQueryFetchResult res = stmt.conn.sendRequest(new JdbcQueryFetchRequest(cursorId, fetchSize), stmt, stickyIO).response();
        rows = res.items();
        finished = res.last();
        rowsIter = rows.iterator();
    }
    if (rowsIter != null) {
        if (rowsIter.hasNext()) {
            curRow = rowsIter.next();
            curPos++;
            return true;
        } else {
            rowsIter = null;
            curRow = null;
            return false;
        }
    } else
        return false;
}
Also used : JdbcQueryFetchResult(org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchResult) JdbcQueryFetchRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest)

Aggregations

JdbcQueryFetchRequest (org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest)2 JdbcBatchExecuteRequest (org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest)1 JdbcQuery (org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery)1 JdbcQueryCloseRequest (org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCloseRequest)1 JdbcQueryFetchResult (org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchResult)1 JdbcQueryMetadataRequest (org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataRequest)1 IpcClientTcpEndpoint (org.apache.ignite.internal.util.ipc.loopback.IpcClientTcpEndpoint)1