Search in sources :

Example 6 with HsqlList

use of org.hsqldb_voltpatches.lib.HsqlList in project voltdb by VoltDB.

the class Expression method resolveTableColumns.

// A VoltDB extension to support indexed expressions
private void resolveTableColumns(Table table) {
    HsqlList set = new HsqlArrayList();
    collectAllColumnExpressions(set);
    for (int i = 0; i < set.size(); i++) {
        ExpressionColumn array_element = (ExpressionColumn) set.get(i);
        ColumnSchema column = table.getColumn(table.getColumnIndex(array_element.getAlias()));
        array_element.setAttributesAsColumn(column, false);
    }
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) HsqlList(org.hsqldb_voltpatches.lib.HsqlList)

Example 7 with HsqlList

use of org.hsqldb_voltpatches.lib.HsqlList in project voltdb by VoltDB.

the class ParserDDL method getBaseColumnNames.

/// Collect the names of the unique columns underlying a list of indexed expressions.
private OrderedHashSet getBaseColumnNames(java.util.List<Expression> indexExprs) {
    OrderedHashSet set = new OrderedHashSet();
    HsqlList col_list = new HsqlArrayList();
    for (Expression expression : indexExprs) {
        expression.collectAllColumnExpressions(col_list);
    }
    for (int i = 0; i < col_list.size(); i++) {
        String colName = ((ExpressionColumn) col_list.get(i)).columnName;
        set.add(colName);
    }
    return set;
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlList(org.hsqldb_voltpatches.lib.HsqlList)

Example 8 with HsqlList

use of org.hsqldb_voltpatches.lib.HsqlList in project voltdb by VoltDB.

the class Expression method collectRangeVariables.

/**
     * collects all range variables in expression tree
     */
void collectRangeVariables(RangeVariable[] rangeVariables, Set set) {
    for (int i = 0; i < nodes.length; i++) {
        if (nodes[i] != null) {
            nodes[i].collectRangeVariables(rangeVariables, set);
        }
    }
    if (subQuery != null && subQuery.queryExpression != null) {
        HsqlList unresolvedExpressions = subQuery.queryExpression.getUnresolvedExpressions();
        if (unresolvedExpressions != null) {
            for (int i = 0; i < unresolvedExpressions.size(); i++) {
                Expression e = (Expression) unresolvedExpressions.get(i);
                e.collectRangeVariables(rangeVariables, set);
            }
        }
    }
}
Also used : HsqlList(org.hsqldb_voltpatches.lib.HsqlList)

Example 9 with HsqlList

use of org.hsqldb_voltpatches.lib.HsqlList in project voltdb by VoltDB.

the class ParserRoutine method readCaseWhen.

private HsqlArrayList readCaseWhen(Routine routine, StatementCompound context) {
    HsqlArrayList list = new HsqlArrayList();
    RangeVariable[] rangeVariables = context == null ? routine.getParameterRangeVariables() : context.getRangeVariables();
    HsqlList unresolved = null;
    Expression condition = null;
    Statement statement;
    Statement[] statements;
    do {
        readThis(Tokens.WHEN);
        condition = XreadBooleanValueExpression();
        unresolved = condition.resolveColumnReferences(rangeVariables, rangeVariables.length, unresolved, false);
        ExpressionColumn.checkColumnsResolved(unresolved);
        unresolved = null;
        condition.resolveTypes(session, null);
        statement = new StatementSimple(StatementTypes.CONDITION, condition);
        list.add(statement);
        readThis(Tokens.THEN);
        statements = readSQLProcedureStatementList(routine, context);
        for (int i = 0; i < statements.length; i++) {
            list.add(statements[i]);
        }
        if (token.tokenType != Tokens.WHEN) {
            break;
        }
    } while (true);
    return list;
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) HsqlList(org.hsqldb_voltpatches.lib.HsqlList)

Example 10 with HsqlList

use of org.hsqldb_voltpatches.lib.HsqlList in project voltdb by VoltDB.

the class ParserRoutine method readSimpleCaseWhen.

private HsqlArrayList readSimpleCaseWhen(Routine routine, StatementCompound context) {
    HsqlArrayList list = new HsqlArrayList();
    RangeVariable[] rangeVariables = context == null ? routine.getParameterRangeVariables() : context.getRangeVariables();
    HsqlList unresolved = null;
    Expression condition = null;
    Statement statement;
    Statement[] statements;
    Expression predicand = XreadRowValuePredicand();
    do {
        readThis(Tokens.WHEN);
        do {
            Expression newCondition = XreadPredicateRightPart(predicand);
            if (predicand == newCondition) {
                newCondition = new ExpressionLogical(predicand, XreadRowValuePredicand());
            }
            unresolved = newCondition.resolveColumnReferences(rangeVariables, rangeVariables.length, unresolved, false);
            ExpressionColumn.checkColumnsResolved(unresolved);
            unresolved = null;
            newCondition.resolveTypes(session, null);
            if (condition == null) {
                condition = newCondition;
            } else {
                condition = new ExpressionLogical(OpTypes.OR, condition, newCondition);
            }
            if (token.tokenType == Tokens.COMMA) {
                read();
            } else {
                break;
            }
        } while (true);
        statement = new StatementSimple(StatementTypes.CONDITION, condition);
        list.add(statement);
        readThis(Tokens.THEN);
        statements = readSQLProcedureStatementList(routine, context);
        for (int i = 0; i < statements.length; i++) {
            list.add(statements[i]);
        }
        if (token.tokenType != Tokens.WHEN) {
            break;
        }
    } while (true);
    return list;
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) HsqlList(org.hsqldb_voltpatches.lib.HsqlList)

Aggregations

HsqlList (org.hsqldb_voltpatches.lib.HsqlList)24 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)10 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)7 ArrayListIdentity (org.hsqldb_voltpatches.lib.ArrayListIdentity)2 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)1 CompileContext (org.hsqldb_voltpatches.ParserDQL.CompileContext)1 Iterator (org.hsqldb_voltpatches.lib.Iterator)1 RangeIterator (org.hsqldb_voltpatches.navigator.RangeIterator)1