Examples of InsertPlanNode


Examples of org.voltdb.plannodes.InsertPlanNode

        // ---------------------------------------------------
        // INSERT
        // ---------------------------------------------------
            case INSERT: {
                // All columns are accessed whenever we insert a new record
                InsertPlanNode ins_node = (InsertPlanNode) node;
                Table catalog_tbl = catalog_db.getTables().get(ins_node.getTargetTableName());
                assert (catalog_tbl != null) : "Missing table " + ins_node.getTargetTableName();
                updateReferenceColumns(catalog_tbl.getColumns(), false, allCols, modifiedCols, readOnlyCols);
                break;
            }
            // ---------------------------------------------------
            // UPDATE
View Full Code Here

Examples of org.voltdb.plannodes.InsertPlanNode

                        materialize_elements.add(catalog_refs);
                    } // FOR

                    // InsertPlanNode
                } else if (node instanceof InsertPlanNode) {
                    InsertPlanNode insert_node = (InsertPlanNode) node;
                    Table catalog_tbl = catalog_db.getTables().get(insert_node.getTargetTableName());

                    // We only support when the Materialize node is inserting
                    // data into all columns
                    if (materialize_elements.size() != catalog_tbl.getColumns().size()) {
                        String msg = String.format("%s has %d columns but the MaterializePlanNode has %d output columns", catalog_tbl, catalog_tbl.getColumns().size(), materialize_elements.size());
View Full Code Here

Examples of org.voltdb.plannodes.InsertPlanNode

            msg += " in a single-partition procedure.";
            throw new PlanningErrorException(msg);
        }

        // the root of the insert plan is always an InsertPlanNode
        InsertPlanNode insertNode = new InsertPlanNode(m_context, getNextPlanNodeId());
        insertNode.setTargetTableName(targetTable.getTypeName());
        insertNode.setMultiPartition(m_singlePartition == false);

        // the materialize node creates a tuple to insert (which is frankly not
        // always optimal)
        MaterializePlanNode materializeNode =
            new MaterializePlanNode(m_context, getNextPlanNodeId());

        // get the ordered list of columns for the targettable using a helper
        // function they're not guaranteed to be in order in the catalog
        List<Column> columns =
            CatalogUtil.getSortedCatalogItems(targetTable.getColumns(), "index");

        // for each column in the table in order...
        for (Column column : columns) {

            // get the expression for the column
            AbstractExpression expr = m_parsedInsert.columns.get(column);

            // if there's no expression, make sure the column has
            // some supported default value
            if (expr == null) {
                // if it's not nullable or defaulted we have a problem
                if (column.getNullable() == false && column.getDefaulttype() == 0)
                {
                    throw new PlanningErrorException("Column " + column.getName()
                            + " has no default and is not nullable.");
                }
                ConstantValueExpression const_expr =
                    new ConstantValueExpression();
                expr = const_expr;
                if (column.getDefaulttype() != 0)
                {
                    const_expr.setValue(column.getDefaultvalue());
                }
                else
                {
                    const_expr.setValue("NULL");
                }
            }
            // set the expression type to match the corresponding Column.
            // in reality, the expression will cast its resulting NValue to
            // the intermediate table's tuple; but, that tuple takes its
            // type from these expression types (for now). The tempTuple is
            // eventually tableTuple::copy()'d into the persistent table
            // and must match the persistent table's column type and size.
            // A little round-about, I know. Will get better.
            expr.setValueSize(column.getSize());
            expr.setValueType(VoltType.get((byte)column.getType()));

            // add column to the materialize node.
            PlanColumn colInfo = m_context.getPlanColumn(expr, column.getTypeName());
            materializeNode.appendOutputColumn(colInfo);
        }

        // connect the insert and the materialize nodes together
        insertNode.addAndLinkChild(materializeNode);
        AbstractPlanNode rootNode = insertNode;

        if (m_singlePartition == false) {
            // all sites to a scan -> send
            // root site has many recvs feeding into a union
            rootNode = insertCountInDMLPlan(rootNode);

            SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
            // this will make the child planfragment be sent to all partitions
            sendNode.isMultiPartition = true;
            sendNode.addAndLinkChild(rootNode);

            ReceivePlanNode recvNode = new ReceivePlanNode(m_context, getNextPlanNodeId());
            recvNode.addAndLinkChild(sendNode);
            rootNode = recvNode;

            // receive node requires the schema of its output table
            recvNode.updateOutputColumns(m_catalogDb);

            // add a count and send on top of the union
            rootNode = addSumAndSendToDMLNode(rootNode, targetTable.getIsreplicated());
           
        } else if (INCLUDE_SEND_FOR_ALL) {
            // XXX: PAVLO
            // rootNode = addCountAndSendToDMLNode(rootNode);
            SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
            sendNode.setFake(true);
            sendNode.addAndLinkChild(insertNode);
            sendNode.setOutputColumns(insertNode.getOutputColumnGUIDs());
            rootNode = sendNode;
        }

        return rootNode;
    }
View Full Code Here

Examples of org.voltdb.plannodes.InsertPlanNode

    public static AbstractPlanNode replaceInsertPlanNodeWithUpsert(AbstractPlanNode root) {
        if (root == null) return null;

        List<AbstractPlanNode> inserts = root.findAllNodesOfType(PlanNodeType.INSERT);
        if (inserts.size() == 1) {
            InsertPlanNode insertNode = (InsertPlanNode)inserts.get(0);
            insertNode.setUpsert(true);
        }

        return root;
    }
View Full Code Here

Examples of org.voltdb.plannodes.InsertPlanNode

            i++;
        }

        // the root of the insert plan is always an InsertPlanNode
        InsertPlanNode insertNode = new InsertPlanNode();
        insertNode.setTargetTableName(targetTable.getTypeName());

        // The field map tells the insert node
        // where to put values produced by child into the row to be inserted.
        insertNode.setFieldMap(fieldMap);

        if (matSchema != null) {
            MaterializePlanNode matNode = new MaterializePlanNode();
            matNode.setOutputSchema(matSchema);
            // connect the insert and the materialize nodes together
            insertNode.addAndLinkChild(matNode);

            retval.statementGuaranteesDeterminism(false, true);
        } else {
            insertNode.addAndLinkChild(retval.rootPlanGraph);
        }

        if (m_partitioning.wasSpecifiedAsSingle() || m_partitioning.isInferredSingle()) {
            insertNode.setMultiPartition(false);
            retval.rootPlanGraph = insertNode;
            return retval;
        }

        insertNode.setMultiPartition(true);
        AbstractPlanNode recvNode = SubPlanAssembler.addSendReceivePair(insertNode);

        // add a count or a limit and send on top of the union
        retval.rootPlanGraph = addSumOrLimitAndSendToDMLNode(recvNode, targetTable.getIsreplicated());
        return retval;
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.