Search in sources :

Example 46 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression 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 47 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression 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 48 with AbstractExpression

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

the class TupleScanPlanNode method toJSONString.

@Override
public void toJSONString(JSONStringer stringer) throws JSONException {
    super.toJSONString(stringer);
    // Output the correlated parameter ids
    stringer.key(Members.PARAM_IDX.name()).array();
    for (AbstractExpression colExpr : m_columnList) {
        assert (colExpr instanceof ParameterValueExpression);
        ParameterValueExpression pve = (ParameterValueExpression) colExpr;
        stringer.value(pve.getParameterIndex());
    }
    stringer.endArray();
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression) ParameterValueExpression(org.voltdb.expressions.ParameterValueExpression)

Example 49 with AbstractExpression

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

the class TupleScanPlanNode method loadFromJSONObject.

@Override
public void loadFromJSONObject(JSONObject jobj, Database db) throws JSONException {
    super.loadFromJSONObject(jobj, db);
    if (jobj.has(Members.PARAM_IDX.name())) {
        JSONArray paramIdxArray = jobj.getJSONArray(Members.PARAM_IDX.name());
        int paramSize = paramIdxArray.length();
        assert (m_outputSchema != null && paramSize == m_outputSchema.size());
        for (int i = 0; i < paramSize; ++i) {
            int paramIdx = paramIdxArray.getInt(i);
            ParameterValueExpression pve = new ParameterValueExpression();
            pve.setParameterIndex(paramIdx);
            AbstractExpression expr = m_outputSchema.getColumns().get(i).getExpression();
            pve.setValueSize(expr.getValueSize());
            pve.setValueType(expr.getValueType());
            m_columnList.add(pve);
        }
    }
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression) JSONArray(org.json_voltpatches.JSONArray) ParameterValueExpression(org.voltdb.expressions.ParameterValueExpression)

Example 50 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression 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)

Aggregations

AbstractExpression (org.voltdb.expressions.AbstractExpression)215 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)59 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)55 ArrayList (java.util.ArrayList)43 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)26 SchemaColumn (org.voltdb.plannodes.SchemaColumn)25 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)23 Constraint (org.voltdb.catalog.Constraint)22 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)22 HashSet (java.util.HashSet)21 Column (org.voltdb.catalog.Column)21 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)21 JSONException (org.json_voltpatches.JSONException)19 ColumnRef (org.voltdb.catalog.ColumnRef)19 Table (org.voltdb.catalog.Table)17 AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)16 ParameterValueExpression (org.voltdb.expressions.ParameterValueExpression)16 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)16 ExpressionType (org.voltdb.types.ExpressionType)16 VoltXMLElement (org.hsqldb_voltpatches.VoltXMLElement)14