Search in sources :

Example 11 with LocalResult

use of com.wplatform.ddal.result.LocalResult in project jdbc-shards by wplatform.

the class Select method queryMeta.

@Override
public ResultInterface queryMeta() {
    LocalResult result = new LocalResult(session, expressionArray, visibleColumnCount);
    result.done();
    return result;
}
Also used : LocalResult(com.wplatform.ddal.result.LocalResult)

Example 12 with LocalResult

use of com.wplatform.ddal.result.LocalResult in project jdbc-shards by wplatform.

the class SelectExecutor method executeQuery.

@Override
public LocalResult executeQuery(int maxRows, ResultTarget target) {
    int limitRows = maxRows == 0 ? -1 : maxRows;
    if (limitExpr != null) {
        Value v = limitExpr.getValue(session);
        int l = v == ValueNull.INSTANCE ? -1 : v.getInt();
        if (limitRows < 0) {
            limitRows = l;
        } else if (l >= 0) {
            limitRows = Math.min(l, limitRows);
        }
    }
    int columnCount = expressions.size();
    LocalResult result = null;
    if (target == null || !session.getDatabase().getSettings().optimizeInsertFromSelect) {
        result = createLocalResult(result);
    }
    if (sort != null) {
        result = createLocalResult(result);
        result.setSortOrder(sort);
    }
    if (distinct) {
        result = createLocalResult(result);
        result.setDistinct();
    }
    if (randomAccessResult) {
        result = createLocalResult(result);
    }
    if (isGroupQuery) {
        result = createLocalResult(result);
    }
    if (limitRows >= 0 || offsetExpr != null) {
        result = createLocalResult(result);
    }
    topTableFilter.startQuery(session);
    topTableFilter.reset();
    topTableFilter.lock(session, isForUpdate, isForUpdate);
    ResultTarget to = result != null ? result : target;
    if (limitRows != 0) {
        if (isAccordantQuery) {
            if (isGroupQuery) {
                queryGroupAccordant(columnCount, to);
            } else {
                queryFlatAccordant(columnCount, to, limitRows);
            }
        } else {
            if (isGroupQuery) {
                queryGroup(columnCount, result);
            } else {
                queryFlat(columnCount, to, limitRows);
            }
        }
    }
    if (offsetExpr != null) {
        result.setOffset(offsetExpr.getValue(session).getInt());
    }
    if (result != null) {
        result.done();
        if (target != null) {
            while (result.next()) {
                target.addRow(result.currentRow());
            }
            result.close();
            return null;
        }
        return result;
    }
    return null;
}
Also used : LocalResult(com.wplatform.ddal.result.LocalResult) ResultTarget(com.wplatform.ddal.result.ResultTarget) Value(com.wplatform.ddal.value.Value)

Example 13 with LocalResult

use of com.wplatform.ddal.result.LocalResult in project jdbc-shards by wplatform.

the class SelectExecutor method queryMeta.

public ResultInterface queryMeta() {
    LocalResult result = new LocalResult(session, expressionArray, visibleColumnCount);
    result.done();
    return result;
}
Also used : LocalResult(com.wplatform.ddal.result.LocalResult)

Example 14 with LocalResult

use of com.wplatform.ddal.result.LocalResult in project jdbc-shards by wplatform.

the class FunctionTable method getResult.

/**
 * Read the result from the function. This method buffers the result in a
 * temporary file.
 *
 * @param session the session
 * @return the result
 */
public ResultInterface getResult(Session session) {
    ValueResultSet v = getValueResultSet(session);
    if (v == null) {
        return null;
    }
    if (cachedResult != null && cachedValue == v) {
        cachedResult.reset();
        return cachedResult;
    }
    LocalResult result = LocalResult.read(session, v.getResultSet(), 0);
    if (function.isDeterministic()) {
        cachedResult = result;
        cachedValue = v;
    }
    return result;
}
Also used : LocalResult(com.wplatform.ddal.result.LocalResult) ValueResultSet(com.wplatform.ddal.value.ValueResultSet)

Aggregations

LocalResult (com.wplatform.ddal.result.LocalResult)14 Value (com.wplatform.ddal.value.Value)6 Expression (com.wplatform.ddal.command.expression.Expression)2 Column (com.wplatform.ddal.dbobject.table.Column)2 Database (com.wplatform.ddal.engine.Database)2 ExpressionColumn (com.wplatform.ddal.command.expression.ExpressionColumn)1 Session (com.wplatform.ddal.engine.Session)1 ResultTarget (com.wplatform.ddal.result.ResultTarget)1 StatementBuilder (com.wplatform.ddal.util.StatementBuilder)1 ValueResultSet (com.wplatform.ddal.value.ValueResultSet)1 ValueString (com.wplatform.ddal.value.ValueString)1 ResultSet (java.sql.ResultSet)1