Search in sources :

Example 16 with TupleValueExpression

use of org.voltdb.expressions.TupleValueExpression in project voltdb by VoltDB.

the class IndexScanPlanNode method resolveColumnIndexes.

@Override
public void resolveColumnIndexes() {
    // IndexScanPlanNode has TVEs that need index resolution in
    // several expressions.
    // Collect all the TVEs in the AbstractExpression members.
    List<TupleValueExpression> index_tves = new ArrayList<>();
    index_tves.addAll(ExpressionUtil.getTupleValueExpressions(m_endExpression));
    index_tves.addAll(ExpressionUtil.getTupleValueExpressions(m_initialExpression));
    index_tves.addAll(ExpressionUtil.getTupleValueExpressions(m_skip_null_predicate));
    // and update their indexes against the table schema
    for (TupleValueExpression tve : index_tves) {
        tve.setColumnIndexUsingSchema(m_tableSchema);
    }
    // Do the same for each search key expression.
    for (AbstractExpression search_exp : m_searchkeyExpressions) {
        index_tves = ExpressionUtil.getTupleValueExpressions(search_exp);
        // and update their indexes against the table schema
        for (TupleValueExpression tve : index_tves) {
            tve.setColumnIndexUsingSchema(m_tableSchema);
        }
    }
    // now do the common scan node work
    super.resolveColumnIndexes();
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) ArrayList(java.util.ArrayList)

Example 17 with TupleValueExpression

use of org.voltdb.expressions.TupleValueExpression in project voltdb by VoltDB.

the class LimitPlanNode method resolveColumnIndexes.

@Override
public void resolveColumnIndexes() {
    // Need to order and resolve indexes of output columns
    assert (m_children.size() == 1);
    AbstractPlanNode childNode = m_children.get(0);
    childNode.resolveColumnIndexes();
    NodeSchema inputSchema = childNode.getOutputSchema();
    for (SchemaColumn col : m_outputSchema.getColumns()) {
        AbstractExpression colExpr = col.getExpression();
        // At this point, they'd better all be TVEs.
        assert (colExpr instanceof TupleValueExpression);
        TupleValueExpression tve = (TupleValueExpression) colExpr;
        tve.setColumnIndexUsingSchema(inputSchema);
    }
    m_outputSchema.sortByTveIndex();
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 18 with TupleValueExpression

use of org.voltdb.expressions.TupleValueExpression in project voltdb by VoltDB.

the class TupleScanPlanNode method generateOutputSchema.

@Override
public void generateOutputSchema(Database db) {
    if (m_tableSchema == null) {
        m_tableSchema = new NodeSchema();
        int columnIdx = 1;
        for (AbstractExpression colExpr : m_columnList) {
            assert (colExpr instanceof ParameterValueExpression);
            ParameterValueExpression pve = (ParameterValueExpression) colExpr;
            // must produce a tuple value expression for this column.
            String columnName = "C" + Integer.toString(columnIdx);
            TupleValueExpression tve = new TupleValueExpression(m_targetTableName, m_targetTableAlias, columnName, columnName, pve, columnIdx);
            m_tableSchema.addColumn(m_targetTableName, m_targetTableAlias, columnName, columnName, tve);
            ++columnIdx;
        }
        m_outputSchema = m_tableSchema;
        m_hasSignificantOutputSchema = true;
    }
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) ParameterValueExpression(org.voltdb.expressions.ParameterValueExpression)

Example 19 with TupleValueExpression

use of org.voltdb.expressions.TupleValueExpression in project voltdb by VoltDB.

the class TupleScanPlanNode method resolveColumnIndexes.

@Override
public void resolveColumnIndexes() {
    // output columns
    for (SchemaColumn col : m_outputSchema.getColumns()) {
        AbstractExpression colExpr = col.getExpression();
        // At this point, they'd better all be TVEs.
        assert (colExpr instanceof TupleValueExpression);
        TupleValueExpression tve = (TupleValueExpression) colExpr;
        tve.setColumnIndexUsingSchema(m_tableSchema);
    }
    m_outputSchema.sortByTveIndex();
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 20 with TupleValueExpression

use of org.voltdb.expressions.TupleValueExpression in project voltdb by VoltDB.

the class WindowFunctionPlanNode method resolveColumnIndexesUsingSchema.

public void resolveColumnIndexesUsingSchema(NodeSchema inputSchema) {
    Collection<TupleValueExpression> allTves;
    // get all the TVEs in the output columns
    for (SchemaColumn col : m_outputSchema.getColumns()) {
        AbstractExpression colExpr = col.getExpression();
        allTves = ExpressionUtil.getTupleValueExpressions(colExpr);
        for (TupleValueExpression tve : allTves) {
            int index = tve.setColumnIndexUsingSchema(inputSchema);
            if (index == -1) {
                // check to see if this TVE is the aggregate output
                if (!tve.getTableName().equals(AbstractParsedStmt.TEMP_TABLE_NAME)) {
                    throw new RuntimeException("Unable to find index for column: " + tve.getColumnName());
                }
            }
        }
    }
    // sure these should be TVEs in the long term.
    for (List<AbstractExpression> agg_exps : m_aggregateExpressions) {
        if (agg_exps != null) {
            for (AbstractExpression agg_exp : agg_exps) {
                allTves = ExpressionUtil.getTupleValueExpressions(agg_exp);
                for (TupleValueExpression tve : allTves) {
                    tve.setColumnIndexUsingSchema(inputSchema);
                }
            }
        }
    }
    // Aggregates also need to resolve indexes for partition by inputs
    for (AbstractExpression group_exp : m_partitionByExpressions) {
        allTves = ExpressionUtil.getTupleValueExpressions(group_exp);
        for (TupleValueExpression tve : allTves) {
            tve.setColumnIndexUsingSchema(inputSchema);
        }
    }
    // one, which is the general case.
    for (AbstractExpression obExpr : m_orderByExpressions) {
        allTves = ExpressionUtil.getTupleValueExpressions(obExpr);
        for (TupleValueExpression tve : allTves) {
            tve.setColumnIndexUsingSchema(inputSchema);
        }
    }
    /*
         * Is this needed?
         */
    resolveSubqueryColumnIndexes();
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Aggregations

TupleValueExpression (org.voltdb.expressions.TupleValueExpression)83 AbstractExpression (org.voltdb.expressions.AbstractExpression)59 SchemaColumn (org.voltdb.plannodes.SchemaColumn)19 Column (org.voltdb.catalog.Column)17 ArrayList (java.util.ArrayList)16 HashSet (java.util.HashSet)14 Constraint (org.voltdb.catalog.Constraint)13 Table (org.voltdb.catalog.Table)10 ColumnRef (org.voltdb.catalog.ColumnRef)9 ParameterValueExpression (org.voltdb.expressions.ParameterValueExpression)9 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)9 JSONException (org.json_voltpatches.JSONException)8 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)8 NodeSchema (org.voltdb.plannodes.NodeSchema)8 ConstantValueExpression (org.voltdb.expressions.ConstantValueExpression)7 VoltXMLElement (org.hsqldb_voltpatches.VoltXMLElement)6 Set (java.util.Set)5 Index (org.voltdb.catalog.Index)5 StmtTargetTableScan (org.voltdb.planner.parseinfo.StmtTargetTableScan)5 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)5