Package org.voltdb.types

Examples of org.voltdb.types.ExpressionType


    public static String debug(AbstractExpression exp, String spacer) {
        assert (exp != null);
        final String orig_spacer = spacer;
        String name = exp.getClass().getSimpleName();
        ExpressionType etype = exp.getExpressionType();

        final StringBuilder sb = new StringBuilder();
        spacer += "   ";
        sb.append(spacer).append("ValueType[").append(exp.getValueType()).append("]\n");

        if (exp instanceof AggregateExpression) {
            // Nothing
        } else if (exp instanceof ComparisonExpression) {
            name += "[" + etype.name().replace("COMPARE_", "") + "]";
        } else if (exp instanceof ConjunctionExpression) {
            name += "[" + etype.name().replace("CONJUNCTION_", "") + "]";
        } else if (exp instanceof ConstantValueExpression) {
            sb.append(spacer).append("Value[").append(((ConstantValueExpression) exp).getValue()).append("]\n");
        } else if (exp instanceof InComparisonExpression) {
            InComparisonExpression in_exp = (InComparisonExpression) exp;
            sb.append(spacer).append("Values[").append(in_exp.getValues().size()).append("]:\n");
            for (int ctr = 0, cnt = in_exp.getValues().size(); ctr < cnt; ctr++) {
                sb.append(ExpressionUtil.debug(in_exp.getValues().get(ctr), spacer));
            } // FOR
        } else if (exp instanceof NullValueExpression) {
            // Nothing
        } else if (exp instanceof OperatorExpression) {
            name += "[" + etype.name().replace("OPERATOR_", "") + "]";
        } else if (exp instanceof ParameterValueExpression) {
            sb.append(spacer).append("Parameter[").append(((ParameterValueExpression) exp).getParameterId()).append("]\n");
        } else if (exp instanceof TupleAddressExpression) {
            // Nothing
        } else if (exp instanceof TupleValueExpression) {
View Full Code Here


                                for (Pair<ExpressionType, CatalogType> pair : stmt_cache.predicates.get(catalog_col)) {
                                    if (trace.val)
                                        LOG.trace(String.format("Linking %s to predicate %s because of %s",
                                                  other_col.fullName(), pair, catalog_col.fullName()));
                                   
                                    ExpressionType expType = pair.getFirst();
                                    CatalogType param = pair.getSecond();
                                    stmt_cache.put(other_col, param, expType, (Table)other_col.getParent());
                                    frag_cache.put(other_col, param, expType, (Table)other_col.getParent());
                                } // FOR (StmtParameter.Index)
                            }
View Full Code Here

                                     final Column catalog_col) throws Exception {
        // Note that we have to go through all of the mappings from the partitioning column
        // to parameters. This can occur when the partitioning column is referenced multiple times
        // This allows us to handle complex WHERE clauses and what not.
        for (Pair<ExpressionType, CatalogType> pair : predicates) {
            ExpressionType expType = pair.getFirst();
            CatalogType param = pair.getSecond();
           
            // HACK HACK HACK
            // If this is not an equality comparison, then it has to go to all partitions.
            // If we ever want to support smarter range partitioning, then
View Full Code Here

// boolean has_count = (clone_types.contains(ExpressionType.AGGREGATE_COUNT) ||
// clone_types.contains(ExpressionType.AGGREGATE_COUNT_STAR));

        int orig_cnt = clone_types.size();
        for (int i = 0; i < orig_cnt; i++) {
            ExpressionType cloneType = clone_types.get(i);
            // Ok, strap on your helmets boys, here's what we got going on here...
            // In order to do a distributed average, we need to send the average
            // AND the count (in order to compute the weight average at the base partition).
            // We need check whether we already have a count already in our list
            // If not, then we'll want to insert it here.
            if (cloneType == ExpressionType.AGGREGATE_AVG) {
                if (has_count == false) {
                    // But now because we add a new output column that we're going to use internally,
                    // we need to make sure that our output columns reflect this.
                    clone_types.add(ExpressionType.AGGREGATE_COUNT_STAR);
                    has_count = true;
                   
                    // Aggregate Input Column
                    // We just need to do it against the first column in the child's output
                    // Picking the column that we want to use doesn't matter even if there is a GROUP BY
                    clone_agg.getAggregateColumnGuids().add(node.getChild(0).getOutputColumnGUID(0));

                    // Aggregate Output Column
                    TupleValueExpression exp = new TupleValueExpression();
                    exp.setValueType(VoltType.BIGINT);
                    exp.setValueSize(VoltType.BIGINT.getLengthInBytesForFixedTypes());
                    exp.setTableName(PlanAssembler.AGGREGATE_TEMP_TABLE);
                    exp.setColumnName("");
                    exp.setColumnAlias("_DTXN_COUNT");
                    exp.setColumnIndex(clone_agg.getOutputColumnGUIDCount());
                    PlanColumn new_pc = state.plannerContext.getPlanColumn(exp, exp.getColumnAlias());
                    clone_agg.getAggregateOutputColumns().add(clone_agg.getOutputColumnGUIDCount());
                    clone_agg.getAggregateColumnNames().add(new_pc.getDisplayName());
                    clone_agg.getOutputColumnGUIDs().add(new_pc.guid());
                }
            }
        } // FOR
       
        // Now go through the original AggregateNode (the one at the top of tree)
        // and change the ExpressiontTypes for the aggregates to handle ahat we're
        // doing down below in the distributed query
        List<ExpressionType> exp_types = node.getAggregateTypes();
        exp_types.clear();
        for (int i = 0; i < orig_cnt; i++) {
            ExpressionType cloneType = clone_types.get(i);
            switch (cloneType) {
                case AGGREGATE_COUNT:
                case AGGREGATE_COUNT_STAR:
                case AGGREGATE_SUM:
                    exp_types.add(ExpressionType.AGGREGATE_SUM);
View Full Code Here

    /**
     * testGetScanExpressionTypes
     */
    @Test
    public void testGetScanExpressionTypes() throws Exception {
        ExpressionType expected[] = {
            ExpressionType.COMPARE_EQUAL,
            ExpressionType.VALUE_PARAMETER,
            ExpressionType.VALUE_TUPLE,
        };
       
View Full Code Here

        VoltType retType = VoltType.INVALID;
        int retSize = 0;
        //
        // First get the value types for the left and right children
        //
        ExpressionType exp_type = exp.getExpressionType();
        AbstractExpression left_exp = exp.getLeft();
        AbstractExpression right_exp = exp.getRight();

        // -------------------------------
        // CONSTANT/NULL/PARAMETER/TUPLE VALUES
View Full Code Here

            int outputColumnIndex = 0;
            for (ParsedSelectStmt.ParsedColInfo col : m_parsedSelect.displayColumns) {

                AbstractExpression rootExpr = col.expression;
                ExpressionType agg_expression_type = rootExpr.getExpressionType();
                if (rootExpr.getExpressionType() == ExpressionType.AGGREGATE_SUM ||
                    rootExpr.getExpressionType() == ExpressionType.AGGREGATE_MIN ||
                    rootExpr.getExpressionType() == ExpressionType.AGGREGATE_MAX ||
                    rootExpr.getExpressionType() == ExpressionType.AGGREGATE_AVG ||
                    rootExpr.getExpressionType() == ExpressionType.AGGREGATE_COUNT ||
View Full Code Here

    }

    abstract protected void loadFromJSONObject(JSONObject obj, Database db) throws JSONException;

    public static AbstractExpression fromJSONObject(JSONObject obj, Database db) throws JSONException {
        ExpressionType type = ExpressionType.valueOf(obj.getString(Members.TYPE.name()));
        AbstractExpression expr;
        try {
            expr = type.getExpressionClass().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
            return null;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
View Full Code Here

     * @param db
     * @return
     */
    AbstractExpression parseOperationExpression(Node exprNode, NamedNodeMap attrs, Database db) {
        String type = attrs.getNamedItem("type").getNodeValue();
        ExpressionType exprType = ExpressionType.get(type);
        AbstractExpression expr = null;

        if (exprType == ExpressionType.INVALID) {
            throw new PlanningErrorException("Unsupported operation type '" + type + "'");
        }
        try {
            expr = exprType.getExpressionClass().newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
        expr.setExpressionType(exprType);
View Full Code Here

        m_valueSize = m_valueType.getLengthInBytesForFixedTypes();
    }

    @Override
    public String explain(String impliedTableName) {
        ExpressionType type = getExpressionType();
        return "(" + m_left.explain(impliedTableName) +
            " " + type.symbol() + " " +
            m_right.explain(impliedTableName) + ")";
    }
View Full Code Here

TOP

Related Classes of org.voltdb.types.ExpressionType

Copyright © 2018 www.massapicom. 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.