Examples of TupleValueExpression


Examples of org.voltdb.expressions.TupleValueExpression

        countNode.setAggregateTypes(countColumnTypes);

        // The output column. Not really based on a TVE (it is really the
        // count expression represented by the count configured above). But
        // this is sufficient for now.
        TupleValueExpression tve = new TupleValueExpression();
        tve.setValueType(VoltType.BIGINT);
        tve.setValueSize(VoltType.BIGINT.getLengthInBytesForFixedTypes());
        tve.setColumnIndex(0);
        tve.setColumnName(m_context.get(colGuid).getDisplayName());
        tve.setColumnAlias(m_context.get(colGuid).getDisplayName());
        tve.setTableName("");
        PlanColumn colInfo = m_context.getPlanColumn(tve, "modified_tuples");
        countNode.appendOutputColumn(colInfo);

        // connect the nodes to build the graph
        countNode.addAndLinkChild(dmlRoot);
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

                    if (outputCol.alias.equals(plancol.getDisplayName()))
                    {
                        found = true;
                        expression = (AbstractExpression) plancol.m_expression.clone();
                        assert(expression instanceof TupleValueExpression);
                        TupleValueExpression tve = (TupleValueExpression) expression;
                        tve.setColumnIndex(offset);
                        break;
                    }
                    ++offset;
                }
                if (!found) {
                    LOG.error("PLANNER ERROR: could not match aggregate column alias");
                    LOG.error(getSQLText());
                    throw new RuntimeException("Could not match aggregate column alias.");
                }
                break;
            }

            // found a TVE - calculate its offset into the sourceColumns
            else if (currExp instanceof TupleValueExpression) {
                TupleValueExpression tve = (TupleValueExpression)currExp;
                boolean found = false;
                int offset = 0;
                for (Integer colguid : sourceColumns) {
                    PlanColumn plancol = m_context.get(colguid);
                    /* System.out.printf("Expression: %s/%s. Candidate column: %s/%s\n",
                            tve.getColumnAlias(), tve.getTableName(),
                            plancol.originColumnName(), plancol.originTableName()); */
                    if (tve.getColumnName().equals(plancol.originColumnName()) &&
                        tve.getTableName().equals(plancol.originTableName()))
                    {
                        tve.setColumnIndex(offset);
                        found = true;
                        break;
                    }
                    ++offset;
                }
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

                    rootExpr.getExpressionType() == ExpressionType.AGGREGATE_COUNT_STAR)
                {
                    PlanColumn aggregateColumn = null;
                    if (rootExpr.getLeft() instanceof TupleValueExpression)
                    {
                        TupleValueExpression nested =
                            (TupleValueExpression) rootExpr.getLeft();

                        if (((AggregateExpression)rootExpr).m_distinct) {
                            root = addDistinctNode(root, nested);
                        }

                        aggregateColumn =
                            root.findMatchingOutputColumn(nested.getTableName(),
                                                          nested.getColumnName(),
                                                          nested.getColumnAlias());
                    }
                    // count(*) hack.  we're not getting AGGREGATE_COUNT_STAR
                    // expression types from the parsing, so we have
                    // to detect the null inner expression case and do the
                    // switcharoo ourselves.
                    else if (rootExpr.getExpressionType() == ExpressionType.AGGREGATE_COUNT &&
                             rootExpr.getLeft() == null)
                    {
                        aggregateColumn =
                            m_context.get(root.getOutputColumnGUIDs().get(0));
                        agg_expression_type = ExpressionType.AGGREGATE_COUNT_STAR;
                    }
                    else
                    {
                        throw new PlanningErrorException("Expressions in aggregates currently unsupported");
                    }

                    aggNode.getAggregateColumnGuids().add(aggregateColumn.guid());
                    aggNode.getAggregateColumnNames().add(aggregateColumn.getDisplayName());
                    aggNode.getAggregateTypes().add(agg_expression_type);

                    // A bit of a hack: ProjectionNodes using PlanColumns after the
                    // aggregate node need the output columns here to
                    // contain TupleValueExpressions (effectively on a temp table).
                    // So we construct one based on the output of the
                    // aggregate expression, the column alias provided by HSQL,
                    // and the offset into the output table schema for the
                    // aggregate node that we're computing.
                    TupleValueExpression tve = new TupleValueExpression();
                   
                    // If this is an AVG, then our type should be DECIMAL
                    if (agg_expression_type == ExpressionType.AGGREGATE_AVG) {
                        tve.setValueType(VoltType.FLOAT);
                        tve.setValueSize(VoltType.FLOAT.getLengthInBytesForFixedTypes());
                    }
                    // Otherwise it can be whatever the rootExpression is
                    else {
                        tve.setValueType(rootExpr.getValueType());
                        tve.setValueSize(rootExpr.getValueSize());
                    }
                    tve.setColumnIndex(outputColumnIndex);
                    tve.setColumnName("");
                    tve.setColumnAlias(col.alias);
                    tve.setTableName(AGGREGATE_TEMP_TABLE);
                    PlanColumn colInfo = m_context.getPlanColumn(tve, col.alias);
                    aggNode.appendOutputColumn(colInfo);
                    aggNode.getAggregateOutputColumns().add(outputColumnIndex);
                }
                else
                {
                    /*
                     * These columns are the pass through columns that are not being
                     * aggregated on. These are the ones from the SELECT list. They
                     * MUST already exist in the child node's output. Find them and
                     * add them to the aggregate's output.
                     */
                    PlanColumn passThruColumn =
                        root.findMatchingOutputColumn(col.tableName,
                                                      col.columnName,
                                                      col.alias);
                    aggNode.appendOutputColumn(passThruColumn);
                }

                outputColumnIndex++;
            }

            aggNode.addAndLinkChild(root);
            root = aggNode;
        }
       
        // PAVLO: Push non-AVG aggregates down into the scan for multi-partition queries
        // 2012-02-15: Moved to AggregatePushdownOptimization

        // handle select distinct a from t - which is planned as an aggregate but
        // doesn't trigger the above aggregate conditions as it is neither grouped
        // nor does it have aggregate expressions
        if (aggNode == null && m_parsedSelect.distinct) {
            // We currently can't handle DISTINCT of multiple columns.
            // Throw a planner error if this is attempted.
            if (m_parsedSelect.displayColumns.size() > 1)
            {
                throw new PlanningErrorException("Multiple DISTINCT columns currently unsupported");
            }
            for (ParsedSelectStmt.ParsedColInfo col : m_parsedSelect.displayColumns) {
                if (col.expression instanceof TupleValueExpression)
                {
                    TupleValueExpression colexpr = (TupleValueExpression)(col.expression);
                    root = addDistinctNode(root, colexpr);

                    // aggregate handlers are expected to produce the required projection.
                    // the other aggregates do this inherently but distinct may need a
                    // projection node.
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

                if (!(col1.getExpression() instanceof TupleValueExpression) ||
                    !(col2.getExpression() instanceof TupleValueExpression))
                {
                    throw new ClassCastException();
                }
                TupleValueExpression tve1 =
                    (TupleValueExpression) col1.getExpression();
                TupleValueExpression tve2 =
                    (TupleValueExpression) col2.getExpression();
                if (tve1.getColumnIndex() < tve2.getColumnIndex())
                {
                    return -1;
                }
                else if (tve1.getColumnIndex() > tve2.getColumnIndex())
                {
                    return 1;
                }
                return 0;
            }
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

        for (int i = 0; i < m_columns.size(); ++i)
        {
            SchemaColumn col = m_columns.get(i);
            String colAlias = col.getColumnAlias();

            TupleValueExpression tve = new TupleValueExpression(tableAlias, tableAlias, colAlias, colAlias, i);
            tve.setTypeSizeBytes(col.getType(), col.getSize(), col.getExpression().getInBytes());
            SchemaColumn sc = new SchemaColumn(tableAlias, tableAlias, colAlias, colAlias, tve);
            copy.addColumn(sc);
        }

        return copy;
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

                if (!(col1.getExpression() instanceof TupleValueExpression) ||
                    !(col2.getExpression() instanceof TupleValueExpression))
                {
                    throw new ClassCastException();
                }
                TupleValueExpression tve1 =
                    (TupleValueExpression) col1.getExpression();
                TupleValueExpression tve2 =
                    (TupleValueExpression) col2.getExpression();
                if (tve1.getColumnIndex() < tve2.getColumnIndex())
                {
                    return -1;
                }
                else if (tve1.getColumnIndex() > tve2.getColumnIndex())
                {
                    return 1;
                }
                return 0;
            }
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

        NodeSchema input_schema = m_children.get(0).getOutputSchema();
        for (SchemaColumn col : m_outputSchema.getColumns())
        {
            // At this point, they'd better all be TVEs.
            assert(col.getExpression() instanceof TupleValueExpression);
            TupleValueExpression tve = (TupleValueExpression)col.getExpression();
            int index = tve.resolveColumnIndexesUsingSchema(input_schema);
            tve.setColumnIndex(index);
        }
        m_outputSchema.sortByTveIndex();

        // Now resolve the indexes in the distinct expression
        List<TupleValueExpression> distinct_tves =
            ExpressionUtil.getTupleValueExpressions(m_distinctExpression);
        for (TupleValueExpression tve : distinct_tves)
        {
            int index = tve.resolveColumnIndexesUsingSchema(input_schema);
            tve.setColumnIndex(index);
        }
    }
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

     * Return a copy of this SchemaColumn, but with the input expression
     * replaced by an appropriate TupleValueExpression.
     */
    public SchemaColumn copyAndReplaceWithTVE()
    {
        TupleValueExpression new_exp = null;
        if (m_expression instanceof TupleValueExpression)
        {
            new_exp = (TupleValueExpression) m_expression.clone();
        }
        else
        {
            new_exp = new TupleValueExpression(m_tableName, m_tableAlias, m_columnName, m_columnAlias);
            // XXX not sure this is right
            new_exp.setTypeSizeBytes(m_expression.getValueType(), m_expression.getValueSize(),
                    m_expression.getInBytes());
        }
        return new SchemaColumn(m_tableName, m_tableAlias, m_columnName, m_columnAlias,
                                new_exp);
    }
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

        m_tableAlias = tbAlias;
        m_columnName = colName;
        m_columnAlias = colAlias;

        if (m_expression instanceof TupleValueExpression) {
            TupleValueExpression tve = (TupleValueExpression) m_expression;
            tve.setTableName(m_tableName);
            tve.setTableAlias(m_tableAlias);
            tve.setColumnName(m_columnName);
            tve.setColumnAlias(m_columnAlias);
        }
    }
View Full Code Here

Examples of org.voltdb.expressions.TupleValueExpression

            List<ColumnRef> indexedColRefs = CatalogUtil.getSortedCatalogItems(m_catalogIndex.getColumns(), "index");
            assert(nextKeyIndex < indexedColRefs.size());
            for (int i = 0; i <= nextKeyIndex; i++) {
                ColumnRef colRef = indexedColRefs.get(i);
                Column col = colRef.getColumn();
                TupleValueExpression tve = new TupleValueExpression(m_targetTableName, m_targetTableAlias,
                        col.getTypeName(), col.getTypeName());
                tve.setTypeSizeBytes(col.getType(), col.getSize(), col.getInbytes());

                indexedExprs.add(tve);
            }
        } else {
            try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.