Package org.voltdb.expressions

Examples of org.voltdb.expressions.AbstractExpression


                    for (int i = 0, cnt = catalog_tbl.getColumns().size(); i < cnt; i++) {
                        int col_guid = proj_node.getOutputColumnGUID(i);
                        PlanColumn plan_col = state.plannerContext.get(col_guid);
                        assert (plan_col != null);

                        AbstractExpression col_exp = plan_col.getExpression();
                        assert (col_exp != null);
                        if ((col_exp instanceof TupleValueExpression) == false) {
                            if (debug.val)
                                LOG.debug("SKIP - Inline " + proj_node + " does not have a TupleValueExpression for output column #" + i);
                            return;
View Full Code Here


            AbstractPlanNode root_node = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);

            try {
                // WHERE Clause
                if (catalog_stmt.getExptree() != null && !catalog_stmt.getExptree().isEmpty()) {
                    AbstractExpression root_exp = ExpressionUtil.deserializeExpression(catalog_db, catalog_stmt.getExptree());
                    CatalogUtil.extractExpressionPredicates(catalog_stmt,
                                                           catalog_db,
                                                           cset,
                                                           root_exp,
                                                           convert_params,
View Full Code Here

                // We should find the Materialize node before the Insert
                if (node instanceof MaterializePlanNode) {
                    for (Integer column_guid : node.getOutputColumnGUIDs()) {
                        PlanColumn column = PlannerContext.singleton().get(column_guid);
                        assert (column != null);
                        AbstractExpression exp = column.getExpression();

                        // Now extract the CatalogType objects that are being
                        // referenced by this materialization column
                        final List<CatalogType> catalog_refs = new ArrayList<CatalogType>();
                        new ExpressionTreeWalker() {
                            @Override
                            protected void callback(AbstractExpression exp) {
                                if (!(exp instanceof AbstractValueExpression))
                                    return;
                                CatalogType element = null;
                                switch (exp.getExpressionType()) {
                                    case VALUE_PARAMETER: {
                                        int param_idx = ((ParameterValueExpression) exp).getParameterId();
                                        element = catalog_stmt.getParameters().get(param_idx);
                                        if (element == null) {
                                            LOG.warn("ERROR: Unable to find Parameter object in catalog [" + ((ParameterValueExpression) exp).getParameterId() + "]");
                                            this.stop();
                                        }
                                        // We want to use the ProcParameter instead of the StmtParameter
                                        // It's not an error if the StmtParameter is not mapped to a
                                        // ProcParameter
                                        if (convert_params && ((StmtParameter) element).getProcparameter() != null) {
                                            LOG.debug(element + "(" + element + ") --> ProcParameter[" + element.getField("procparameter") + "]");
                                            element = ((StmtParameter) element).getProcparameter();
                                        }
                                        break;
                                    }
                                    case VALUE_TUPLE_ADDRESS:
                                    case VALUE_TUPLE: {
                                        // This shouldn't happen, but it is nice
                                        // to be told if it does...
                                        LOG.warn("Unexpected " + exp.getClass().getSimpleName() + " node when examining " + node.getClass().getSimpleName() + " for " + catalog_stmt);
                                        break;
                                    }
                                    default: {
                                        // Do nothing...
                                    }
View Full Code Here

                    assert (catalog_idx != null);

                    // Search Key Expressions
                    List<ColumnRef> index_cols = CatalogUtil.getSortedCatalogItems(catalog_idx.getColumns(), "index");
                    for (int i = 0, cnt = cast_node.getSearchKeyExpressions().size(); i < cnt; i++) {
                        AbstractExpression index_exp = cast_node.getSearchKeyExpressions().get(i);
                        Column catalog_col = index_cols.get(i).getColumn();
                        if (debug.val)
                            LOG.debug("[" + i + "] " + catalog_col);
                        exps.add(CatalogUtil.createTempExpression(catalog_col, index_exp));
                        if (debug.val)
                            LOG.debug("Added temp index search key expression:\n" + ExpressionUtil.debug(exps.get(exps.size() - 1)));
                    } // FOR

                    // End Expression
                    if (cast_node.getEndExpression() != null) {
                        exps.add(cast_node.getEndExpression());
                        if (debug.val)
                            LOG.debug("Added scan end expression:\n" + ExpressionUtil.debug(exps.get(exps.size() - 1)));
                    }

                    // Post-Scan Expression
                    if (cast_node.getPredicate() != null) {
                        exps.add(cast_node.getPredicate());
                        if (debug.val)
                            LOG.debug("Added post-scan predicate:\n" + ExpressionUtil.debug(exps.get(exps.size() - 1)));
                    }

                    // SeqScanPlanNode
                } else if (node instanceof SeqScanPlanNode) {
                    SeqScanPlanNode cast_node = (SeqScanPlanNode) node;
                    if (cast_node.getPredicate() != null) {
                        exps.add(cast_node.getPredicate());
                        if (debug.val)
                            LOG.debug("Adding scan node predicate:\n" + ExpressionUtil.debug(exps.get(exps.size() - 1)));
                    }

                    // Materialize
                } else if (node instanceof MaterializePlanNode) {
                    // Assume that if we're here, then they want the mappings
                    // from columns to StmtParameters
                    assert (tables.size() == 1);
                    Table catalog_tbl = CollectionUtil.first(tables);
                    for (int ctr = 0, cnt = node.getOutputColumnGUIDs().size(); ctr < cnt; ctr++) {
                        int column_guid = node.getOutputColumnGUIDs().get(ctr);
                        PlanColumn column = PlannerContext.singleton().get(column_guid);
                        assert (column != null);

                        Column catalog_col = catalog_tbl.getColumns().get(column.getDisplayName());
                        assert (catalog_col != null) : "Invalid column name '" + column.getDisplayName() + "' for " + catalog_tbl;

                        AbstractExpression exp = column.getExpression();
                        if (exp instanceof ParameterValueExpression) {
                            StmtParameter catalog_param = catalog_stmt.getParameters().get(((ParameterValueExpression) exp).getParameterId());
                            cset.add(catalog_col, catalog_param, ExpressionType.COMPARE_EQUAL, catalog_stmt);
                        } else if (exp instanceof AbstractValueExpression) {
                            if (debug.val)
View Full Code Here

                    } // FOR
                }

                for (int i = 0, cnt = output_cols.size(); i < cnt; i++) {
                    PlanColumn column = output_cols.get(i);
                    AbstractExpression exp = output_exps.get(i);
                    // Skip TupleAddressExpression
                    if (!(exp instanceof TupleAddressExpression)) {
                        //
                        // Make a temporary expression where COL = Expression
                        // Har har har! I'm so clever!
                        //
                        String column_name = (column.originColumnName() != null ? column.originColumnName() : column.getDisplayName());
                        Column catalog_col = catalog_tbl.getColumns().get(column_name);
                        if (catalog_col == null)
                            System.err.println(catalog_tbl + ": " + CatalogUtil.debug(catalog_tbl.getColumns()));
                        assert (catalog_col != null) : "Missing column '" + catalog_tbl.getName() + "." + column_name + "'";
                        AbstractExpression root_exp = CatalogUtil.createTempExpression(catalog_col, exp);
                        // System.out.println(ExpressionUtil.debug(root_exp));
                        CatalogUtil.extractExpressionPredicates(catalog_stmt, catalog_db, cset, root_exp, convert_params, tables);
                    }
                } // FOR
            }
View Full Code Here

            List<AbstractExpression> exps0 = new ArrayList<AbstractExpression>(PlanNodeUtil.getExpressionsForPlanNode(node0));
            List<AbstractExpression> exps1 = new ArrayList<AbstractExpression>(PlanNodeUtil.getExpressionsForPlanNode(node1));
           
            assertEquals(exps0.size(), exps1.size());
            for (int j = 0; j < exps0.size(); j++) {
                AbstractExpression exp0 = exps0.get(j);
                assertNotNull(exp0);
                AbstractExpression exp1 = exps1.get(j);
                assertNotNull(exp1);
//                assertFalse(exp0 == exp1);
                if (exp0.equals(exp1) == false) {
                    System.err.println("Failed to clone " + node0);
                    String col0 = "";
View Full Code Here

        String columnName = columnNameAttr.getNodeValue();

        assert(tableName.equalsIgnoreCase(table.getTypeName()));
        Column column = table.getColumns().getIgnoreCase(columnName);

        AbstractExpression expr = null;
        NodeList children = columnNode.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node node = children.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                expr = parseExpressionTree(node, db);
View Full Code Here

            }

            ArrayList<AbstractExpression> searchKeyExpressions = new ArrayList<AbstractExpression>(innerNode.getSearchKeyExpressions());
            innerNode.getSearchKeyExpressions().clear();
            for (int ctr = 0, cnt = searchKeyExpressions.size(); ctr < cnt; ctr++) {
                AbstractExpression expr = null;
                try {
                    expr = ExpressionUtil.clone(searchKeyExpressions.get(ctr));
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(-1);
View Full Code Here

                parseCondition(child, db);
        }
    }

    void parseCondition(Node conditionNode, Database db) {
        AbstractExpression tempWhere = null;
        for (Node exprNode = conditionNode.getFirstChild(); exprNode != null; exprNode = exprNode.getNextSibling()) {
            if (exprNode.getNodeType() != Node.ELEMENT_NODE) continue;
            if (tempWhere == null) {
                tempWhere = parseExpressionTree(exprNode, db);
            }
View Full Code Here

     * @return configured AbstractExpression
     */
    AbstractExpression parseExpressionTree(Node root, Database db) {
        String elementName = root.getNodeName().toLowerCase();
        NamedNodeMap attrs = root.getAttributes();
        AbstractExpression retval = null;

        if (elementName.equals("value")) {
            retval = parseValueExpression(root, attrs);
        }
        if (elementName.equals("columnref")) {
View Full Code Here

TOP

Related Classes of org.voltdb.expressions.AbstractExpression

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.