Package org.voltdb.plannodes

Examples of org.voltdb.plannodes.IndexScanPlanNode


    public void testDebug() throws Exception {
        // Just make sure this doesn't throw an Exception
        AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
        assertNotNull(root);
        //System.err.println(PlanNodeUtil.debug(root));
        IndexScanPlanNode scan_node = CollectionUtil.first(PlanNodeUtil.getPlanNodes(root, IndexScanPlanNode.class));
        assertNotNull(scan_node);
       
        AbstractExpression exp = scan_node.getEndExpression();
        assertNotNull(exp);
        String debug = ExpressionUtil.debug(exp);
        assertNotNull(debug);
        assertFalse(debug.isEmpty());
    }
View Full Code Here


        switch (node_type) {
            // ---------------------------------------------------
            // SCANS
            // ---------------------------------------------------
            case INDEXSCAN: {
                IndexScanPlanNode idx_node = (IndexScanPlanNode) node;
                if (idx_node.getEndExpression() != null)
                    exps.add(idx_node.getEndExpression());
                for (AbstractExpression exp : idx_node.getSearchKeyExpressions()) {
                    if (exp != null)
                        exps.add(exp);
                } // FOR

                // Fall through down into SEQSCAN....
View Full Code Here

            protected void callback(AbstractPlanNode node) {
                Set<AbstractExpression> exps = new HashSet<AbstractExpression>();
                switch (node.getPlanNodeType()) {
                    // SCANS
                    case INDEXSCAN: {
                        IndexScanPlanNode idx_node = (IndexScanPlanNode) node;
                        exps.add(idx_node.getEndExpression());
                        exps.addAll(idx_node.getSearchKeyExpressions());
                    }
                    case SEQSCAN: {
                        AbstractScanPlanNode scan_node = (AbstractScanPlanNode) node;
                        exps.add(scan_node.getPredicate());
                        break;
View Full Code Here

            PlanColumn col = PlannerContext.singleton().get(dist_node.getDistinctColumnGuid());
            sb.append(inner_spacer).append("DistinctColumn[" + col + "]\n");

            // IndexScanPlanNode
        } else if (node instanceof IndexScanPlanNode) {
            IndexScanPlanNode cast_node = (IndexScanPlanNode) node;
            sb.append(inner_spacer).append("TargetIndexName[" + cast_node.getTargetIndexName() + "]\n");
            sb.append(inner_spacer).append("EnableKeyIteration[" + cast_node.getKeyIterate() + "]\n");
            sb.append(inner_spacer).append("IndexLookupType[" + cast_node.getLookupType() + "]\n");
            sb.append(inner_spacer).append("SearchKey Expressions:\n");
            for (AbstractExpression search_key : cast_node.getSearchKeyExpressions()) {
                sb.append(ExpressionUtil.debug(search_key, line_spacer));
            }
            sb.append(inner_spacer).append("End Expression: " + (cast_node.getEndExpression() != null ? "\n" + ExpressionUtil.debug(cast_node.getEndExpression(), line_spacer) : null + "\n"));
            sb.append(inner_spacer).append("Post-Scan Expression: " + (cast_node.getPredicate() != null ? "\n" + ExpressionUtil.debug(cast_node.getPredicate(), line_spacer) : null + "\n"));

            // InsertPlanNode
        } else if (node instanceof InsertPlanNode) {
            sb.append(inner_spacer).append("MultiPartition[" + ((InsertPlanNode) node).getMultiPartition() + "]\n");

            // LimitPlanNode
        } else if (node instanceof LimitPlanNode) {
            sb.append(inner_spacer).append("Limit[" + ((LimitPlanNode) node).getLimit() + "]\n");
            sb.append(inner_spacer).append("Offset[" + ((LimitPlanNode) node).getOffset() + "]\n");

            // NestLoopIndexPlanNode
        } else if (node instanceof NestLoopIndexPlanNode) {
            // Nothing

            // NestLoopPlanNode
        } else if (node instanceof NestLoopPlanNode) {
            // Nothing

        } else if (node instanceof OrderByPlanNode) {
            OrderByPlanNode cast_node = (OrderByPlanNode) node;
            sb.append(inner_spacer).append(PlanNodeUtil.debugOutputColumns("SortColumns", cast_node.getSortColumnGuids(), line_spacer));

        } else if (node instanceof ProjectionPlanNode) {
            // ProjectionPlanNode cast_node = (ProjectionPlanNode)node;
            if (node instanceof MaterializePlanNode) {
                sb.append(line_spacer).append("Batched[" + ((MaterializePlanNode) node).isBatched() + "]\n");
View Full Code Here

        }
        // NestLoopIndexNode
        else if (node instanceof NestLoopIndexPlanNode) {
            NestLoopIndexPlanNode cast_node = (NestLoopIndexPlanNode) node;
            assert (cast_node.getInlinePlanNodeCount() == 1);
            IndexScanPlanNode idx_node = cast_node.getInlinePlanNode(PlanNodeType.INDEXSCAN);
            table_name = idx_node.getTargetTableName();
        }
        // AbstractOperationPlanNode
        else if (node instanceof AbstractOperationPlanNode) {
            AbstractOperationPlanNode cast_node = (AbstractOperationPlanNode) node;
            table_name = cast_node.getTargetTableName();
View Full Code Here

        new PlanNodeTreeWalker(true) {
            @Override
            protected void callback(AbstractPlanNode element) {
                // IndexScanNode
                if (element instanceof IndexScanPlanNode) {
                    IndexScanPlanNode cast_node = (IndexScanPlanNode)element;
                    String table_name = cast_node.getTargetTableName();
                    assert(table_name != null);
                    assert(table_name.isEmpty() == false);
                   
                    String index_name = cast_node.getTargetIndexName();
                    assert(index_name != null);
                    assert(index_name.isEmpty() == false);
               
                    Table catalog_tbl = catalog_db.getTables().get(table_name);
                    assert(catalog_tbl != null) :
View Full Code Here

            protected void _callback(final AbstractPlanNode node) throws Exception {
                ListOrderedSet<AbstractExpression> exps = new ListOrderedSet<AbstractExpression>();

                // IndexScanPlanNode
                if (node instanceof IndexScanPlanNode) {
                    IndexScanPlanNode cast_node = (IndexScanPlanNode) node;
                    Table catalog_tbl = catalog_db.getTables().get(cast_node.getTargetTableName());
                    assert (catalog_tbl != null);
                    Index catalog_idx = catalog_tbl.getIndexes().get(cast_node.getTargetIndexName());
                    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)
                                LOG.debug("Ignoring AbstractExpressionType type: " + exp);
                        } else {
                            throw new Exception("Unexpected AbstractExpression type: " + exp);
                        }

                    } // FOR
                    // Join Nodes
                } else if (node instanceof AbstractJoinPlanNode) {
                    AbstractJoinPlanNode cast_node = (AbstractJoinPlanNode) node;
                    if (cast_node.getPredicate() != null) {
                        exps.add(cast_node.getPredicate());
                        if (debug.val)
                            LOG.debug("Added join node predicate: " + ExpressionUtil.debug(exps.get(exps.size() - 1)));
                    }
                }
View Full Code Here

        // now assume this will be an index scan and get the relevant index
        Index index = path.index;

        // build the list of search-keys for the index in question
        IndexScanPlanNode scanNode = new IndexScanPlanNode(m_context, PlanAssembler.getNextPlanNodeId());
        List<AbstractExpression> searchKeys = scanNode.getSearchKeyExpressions();
        for (AbstractExpression expr : path.indexExprs) {
            AbstractExpression expr2 = ExpressionUtil.getOtherTableExpression(expr, table.getTypeName());
            assert(expr2 != null);
            searchKeys.add(expr2);
        }

        // create the IndexScanNode with all its metadata
        scanNode.setKeyIterate(path.keyIterate);
        scanNode.setLookupType(path.lookupType);
        scanNode.setSortDirection(path.sortDirection);
        scanNode.setTargetTableName(table.getTypeName());
        scanNode.setTargetTableAlias(table.getTypeName());
        scanNode.setTargetIndexName(index.getTypeName());
        scanNode.setEndExpression(ExpressionUtil.combine(path.endExprs));
        scanNode.setPredicate(ExpressionUtil.combine(path.otherExprs));

        AbstractPlanNode rootNode = scanNode;

        // if we need to scan everywhere...
        if (tableRequiresDistributedScan(table)) {
View Full Code Here

        // ---------------------------------------------------
        } else {
            // Otherwise, just grab all of the columns for the target table in
            // the inline scan
            assert (node instanceof NestLoopIndexPlanNode);
            IndexScanPlanNode idx_node = node.getInlinePlanNode(PlanNodeType.INDEXSCAN);

            assert (idx_node != null);
            inner_node = idx_node;

            Table catalog_tbl = null;
            try {
                catalog_tbl = CollectionUtil.first(CatalogUtil.getReferencedTablesForPlanNode(state.catalog_db, idx_node));
            } catch (Exception ex) {
                LOG.fatal(ex);
                throw new RuntimeException(ex);
            }
            assert (catalog_tbl != null);
            if (debug.val)
                LOG.debug("Calculating INNER offsets from INLINE Scan: " + catalog_tbl);

            for (Column catalog_col : CatalogUtil.getSortedCatalogItems(catalog_tbl.getColumns(), "index")) {
                int i = catalog_col.getIndex();
                int offset_orig_idx = outer_orig_input_guids.size() + i;
                int offset_new_idx = offset + i;
                if (trace.val)
                    LOG.trace(String.format("INNER INLINE OFFSET %d => %d", offset_orig_idx, offset_new_idx));
                offset_xref.put(offset_orig_idx, offset_new_idx);

                // Since we're going in order, we know what column is at this
                // position.
                // That means we can grab the catalog object and convert it to a
                // PlanColumn GUID
                // Always try make a new PlanColumn and update the
                // TupleValueExpresion index
                // This ensures that we always get the ordering correct
                // int orig_guid =
                // idx_node.getOutputColumnGUID(offset_orig_idx);
                int orig_guid = CollectionUtil.first(state.column_guid_xref.get(catalog_col));
                assert (orig_guid != -1);
                PlanColumn orig_pc = state.plannerContext.get(orig_guid);
                assert (orig_pc != null);

                // PlanColumn new_pc = null;
                // int new_idx = 0;
                // for (Integer guid : idx_node.getOutputColumnGUIDs()) {
                // PlanColumn pc = state.m_context.get(guid);
                // assert (pc != null);
                // if (pc.equals(orig_pc, true, true)) {
                // if (trace.val)
                // LOG.trace(String.format("[%02d] Found inline output PlanColumn match:\nORIG: %s\nNEW: %s",
                // new_idx, orig_pc, pc));
                // new_pc = pc;
                // break;
                // }
                // new_idx++;
                // } // FOR
                // assert (new_pc != null);

                idx_node.getOutputColumnGUIDs().set(i, orig_pc.guid());
                new_output_guids.add(orig_pc.guid());
                // sorted_new_output_guids.put(i,orig_pc.guid());
                // TupleValueExpression clone_exp =
                // (TupleValueExpression)orig_col.getExpression().clone();
                // clone_exp.setColumnIndex(offset_new_idx);
View Full Code Here

        assertNotNull(root);
       
        // Make sure the bottom-most IndexScan has an inline projection with the right columns
        Collection<IndexScanPlanNode> scan_nodes = PlanNodeUtil.getPlanNodes(root, IndexScanPlanNode.class);
        assertEquals(1, scan_nodes.size());
        IndexScanPlanNode scan_node = CollectionUtil.first(scan_nodes);
        assertNotNull(scan_node);
        assertEquals(1, scan_node.getParentPlanNodeCount());
        assertEquals(0, scan_node.getChildPlanNodeCount());
        System.err.println(PlanNodeUtil.debug(root));
        assertEquals(1, scan_node.getInlinePlanNodeCount());
       
        final Map<String, Integer> col_offset_xref = new HashMap<String, Integer>();
        Table catalog_tbl = null;
       
        // STOCK
        if (scan_node.getTargetTableName().equals("STOCK")) {
            catalog_tbl = this.getTable("STOCK");
            for (String colName : new String[]{ "S_I_ID", "S_W_ID", "S_QUANTITY"}) {
                Column catalog_col = this.getColumn(catalog_tbl, colName);
                col_offset_xref.put(colName, catalog_col.getIndex());
            } // FOR
        }
        // ORDER_LINE
        else if (scan_node.getTargetTableName().equals("ORDER_LINE")) {
            catalog_tbl = this.getTable("ORDER_LINE");
            for (String colName : new String[]{ "OL_I_ID" }) {
                Column catalog_col = this.getColumn(catalog_tbl, colName);
                col_offset_xref.put(colName, catalog_col.getIndex());
            } // FOR
        }
        else {
            assert(false) : "Unexpected table '" + scan_node.getTargetTableName() + "'";
        }
        assertNotNull(catalog_tbl);
        assertFalse(col_offset_xref.isEmpty());
        assertEquals(catalog_tbl.getName(), scan_node.getTargetTableName());
       
        // The inline projection in the leaf ScanPlanNode should only output a
        // single column (S_I_ID), since this is the only column used in the JOIN
        ProjectionPlanNode proj_node = scan_node.getInlinePlanNode(PlanNodeType.PROJECTION);
        assertNotNull(proj_node);
        assertEquals(1, proj_node.getOutputColumnGUIDCount());
       
        System.err.println(PlanNodeUtil.debug(scan_node));
        checkExpressionOffsets(proj_node, col_offset_xref);
View Full Code Here

TOP

Related Classes of org.voltdb.plannodes.IndexScanPlanNode

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.