use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class RangeVariable method addTableColumns.
void addTableColumns(Expression expression, HashSet exclude) {
HsqlArrayList list = new HsqlArrayList();
Table table = getTable();
int count = table.getColumnCount();
for (int i = 0; i < count; i++) {
ColumnSchema column = table.getColumn(i);
String columnName = columnAliases == null ? column.getName().name : (String) columnAliases.get(i);
if (exclude != null && exclude.contains(columnName)) {
continue;
}
Expression e = new ExpressionColumn(this, column, i);
list.add(e);
}
Expression[] nodes = new Expression[list.size()];
list.toArray(nodes);
expression.nodes = nodes;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class RangeVariableResolver method expandConditions.
void expandConditions(HsqlArrayList[] array, boolean isJoin) {
for (int i = 0; i < rangeVariables.length; i++) {
HsqlArrayList list = array[i];
map.clear();
set.clear();
boolean hasChain = false;
for (int j = 0; j < list.size(); j++) {
Expression e = (Expression) list.get(j);
if (!e.isColumnEqual || e.getLeftNode().getRangeVariable() == e.getRightNode().getRangeVariable()) {
continue;
}
if (e.getLeftNode().getRangeVariable() == rangeVariables[i]) {
map.put(e.getLeftNode().getColumn(), e.getRightNode());
if (!set.add(e.getLeftNode().getColumn())) {
hasChain = true;
}
} else {
map.put(e.getRightNode().getColumn(), e.getLeftNode());
if (!set.add(e.getRightNode().getColumn())) {
hasChain = true;
}
}
}
if (hasChain && !(hasOuterJoin && isJoin)) {
Iterator keyIt = map.keySet().iterator();
while (keyIt.hasNext()) {
Object key = keyIt.next();
Iterator it = map.get(key);
set.clear();
while (it.hasNext()) {
set.add(it.next());
}
while (set.size() > 1) {
Expression e1 = (Expression) set.remove(set.size() - 1);
for (int j = 0; j < set.size(); j++) {
Expression e2 = (Expression) set.get(j);
closeJoinChain(array, e1, e2);
}
}
}
}
}
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class ParserRoutine method readLocalDeclarationList.
/*
<SQL control statement> ::=
<call statement>
| <return statement>
<compound statement>
<case statement>
<if statement>
<iterate statement>
<leave statement>
<loop statement>
<while statement>
<repeat statement>
<for statement>
<assignment statement> SET (,,,) = (,,,) or SET a = b
*/
private Object[] readLocalDeclarationList(Routine routine, StatementCompound context) {
HsqlArrayList list = new HsqlArrayList();
while (token.tokenType == Tokens.DECLARE) {
Object var = readLocalVariableDeclarationOrNull();
if (var == null) {
var = readLocalHandlerDeclaration(routine, context);
}
list.add(var);
}
Object[] declarations = new Object[list.size()];
list.toArray(declarations);
return declarations;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList 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;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class QuerySpecification method addAllJoinedColumns.
private void addAllJoinedColumns(Expression e) {
HsqlArrayList list = new HsqlArrayList();
for (int i = 0; i < rangeVariables.length; i++) {
rangeVariables[i].addTableColumns(list);
}
Expression[] nodes = new Expression[list.size()];
list.toArray(nodes);
e.nodes = nodes;
}
Aggregations