Search in sources :

Example 11 with HashMappedList

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

the class QueryExpression method getUnionColumns.

private HashMappedList getUnionColumns() {
    if (unionCorresponding || leftQueryExpression == null) {
        HashMappedList columns = ((TableDerived) resultTable).columnList;
        HashMappedList list = new HashMappedList();
        for (int i = 0; i < unionColumnMap.length; i++) {
            ColumnSchema column = (ColumnSchema) columns.get(i);
            list.add(column.getName().name, column);
        }
        return list;
    }
    return leftQueryExpression.getUnionColumns();
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList)

Example 12 with HashMappedList

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

the class QuerySpecification method getEquiJoinExpressions.

public Expression getEquiJoinExpressions(OrderedHashSet nameSet, RangeVariable rightRange, boolean fullList) {
    HashSet set = new HashSet();
    Expression result = null;
    OrderedHashSet joinColumnNames = new OrderedHashSet();
    for (int i = 0; i < rangeVariableList.size(); i++) {
        RangeVariable range = (RangeVariable) rangeVariableList.get(i);
        HashMappedList columnList = range.rangeTable.columnList;
        for (int j = 0; j < columnList.size(); j++) {
            ColumnSchema column = (ColumnSchema) columnList.get(j);
            String name = range.getColumnAlias(j);
            boolean columnInList = nameSet.contains(name);
            boolean namedJoin = range.namedJoinColumns != null && range.namedJoinColumns.contains(name);
            boolean repeated = !namedJoin && !set.add(name);
            if (repeated && (!fullList || columnInList)) {
                throw Error.error(ErrorCode.X_42578, name);
            }
            if (!columnInList) {
                continue;
            }
            joinColumnNames.add(name);
            int position = rightRange.rangeTable.getColumnIndex(name);
            ColumnSchema rightColumn = rightRange.rangeTable.getColumn(position);
            Expression e = new ExpressionLogical(range, column, rightRange, rightColumn);
            result = ExpressionLogical.andExpressions(result, e);
            ExpressionColumn col = range.getColumnExpression(name);
            if (col == null) {
                col = new ExpressionColumn(new Expression[] { e.getLeftNode(), e.getRightNode() }, name);
                range.addNamedJoinColumnExpression(name, col);
            } else {
                col.nodes = (Expression[]) ArrayUtil.resizeArray(col.nodes, col.nodes.length + 1);
                col.nodes[col.nodes.length - 1] = e.getRightNode();
            }
            rightRange.addNamedJoinColumnExpression(name, col);
        }
    }
    if (fullList && !joinColumnNames.containsAll(nameSet)) {
        throw Error.error(ErrorCode.X_42501);
    }
    rightRange.addNamedJoinColumns(joinColumnNames);
    return result;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HashSet(org.hsqldb_voltpatches.lib.HashSet) OrderedIntHashSet(org.hsqldb_voltpatches.lib.OrderedIntHashSet)

Example 13 with HashMappedList

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

the class QueryExpression method getResultColumnNames.

public HsqlName[] getResultColumnNames() {
    if (resultTable == null) {
        return leftQueryExpression.getResultColumnNames();
    }
    HashMappedList list = ((TableDerived) resultTable).columnList;
    HsqlName[] resultColumnNames = new HsqlName[list.size()];
    for (int i = 0; i < resultColumnNames.length; i++) {
        resultColumnNames[i] = ((ColumnSchema) list.get(i)).getName();
    }
    return resultColumnNames;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 14 with HashMappedList

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

the class QuerySpecification method createResultTable.

@Override
void createResultTable(Session session) {
    HsqlName tableName;
    HashMappedList columnList;
    int tableType;
    tableName = session.database.nameManager.getSubqueryTableName();
    tableType = persistenceScope == TableBase.SCOPE_STATEMENT ? TableBase.SYSTEM_SUBQUERY : TableBase.RESULT_TABLE;
    columnList = new HashMappedList();
    for (int i = 0; i < indexLimitVisible; i++) {
        Expression e = exprColumns[i];
        SimpleName simpleName = e.getSimpleName();
        String nameString = simpleName.name;
        HsqlName name = session.database.nameManager.newColumnSchemaHsqlName(tableName, simpleName);
        if (!accessibleColumns[i]) {
            nameString = HsqlNameManager.getAutoNoNameColumnString(i);
        }
        ColumnSchema column = new ColumnSchema(name, e.dataType, true, false, null);
        columnList.add(nameString, column);
    }
    try {
        resultTable = new TableDerived(session.database, tableName, tableType, columnTypes, columnList, null);
    } catch (Exception e) {
    }
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) SimpleName(org.hsqldb_voltpatches.HsqlNameManager.SimpleName) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 15 with HashMappedList

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

the class QueryExpression method createResultTable.

void createResultTable(Session session) {
    HsqlName tableName;
    HashMappedList columnList;
    int tableType;
    tableName = session.database.nameManager.getSubqueryTableName();
    tableType = persistenceScope == TableBase.SCOPE_STATEMENT ? TableBase.SYSTEM_SUBQUERY : TableBase.RESULT_TABLE;
    columnList = leftQueryExpression.getUnionColumns();
    try {
        resultTable = new TableDerived(session.database, tableName, tableType, unionColumnTypes, columnList, null);
    } catch (Exception e) {
    }
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Aggregations

HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)23 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)4 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)4 HashSet (org.hsqldb_voltpatches.lib.HashSet)3 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)3 Index (org.hsqldb_voltpatches.index.Index)2 Iterator (org.hsqldb_voltpatches.lib.Iterator)2 RowIterator (org.hsqldb_voltpatches.navigator.RowIterator)2 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)2 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)2 Result (org.hsqldb_voltpatches.result.Result)2 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 HashSet (java.util.HashSet)1 HsqlException (org.hsqldb_voltpatches.HsqlException)1 SimpleName (org.hsqldb_voltpatches.HsqlNameManager.SimpleName)1 RangeIteratorBase (org.hsqldb_voltpatches.RangeVariable.RangeIteratorBase)1