Examples of TableGroupJoinNode


Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

        // so that we can BranchLookup over there and still be able to
        // get all the required ancestors. If there aren't any
        // ancestors, anyplace that BranchLookup can take us to will
        // do.
        boolean findRequired = !ancestors.isEmpty();
        TableGroupJoinNode leafMostChild = leafTable;
        TableGroupJoinNode leafMostParent = null;
        while (leafMostChild != rootTable) {
            TableGroupJoinNode parent = leafMostChild.getParent();
            if (findRequired ? isRequired(parent) : isParent(parent)) {
                leafMostParent = parent;
                break;
            }
            leafMostChild = parent;
        }
        TableGroupJoinNode sideBranch = null;
        if (leafMostParent != null) {
            TableGroupJoinNode childParent = null;
            // Is some child of the leaf-most ancestor required or a
            // parent? If so, there is something beneath it, so it's a
            // good choice.
            for (TableGroupJoinNode table = leafMostParent.getFirstChild(); table != null; table = table.getNextSibling()) {
                if (isRequired(table)) {
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

     */
    protected PlanNode fillBranch(PlanNode input, List<TableSource> lookupTables,
                                  TableGroupJoinNode underRoot,
                                  TableGroupJoinNode flattenRoot,
                                  TableGroupJoinNode sideRoot) {
        TableGroupJoinNode leafTable = singleBranchPending(underRoot, lookupTables);
        return fillSideBranches(flatten(input, leafTable, flattenRoot),
                                leafTable, sideRoot);
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

        List<TableSource> tableSources = new ArrayList<>();
        List<TableNode> tableNodes = new ArrayList<>();
        List<JoinType> joinTypes = new ArrayList<>();
        JoinType joinType = null;
        ConditionList joinConditions = new ConditionList(0);
        TableGroupJoinNode table = leafTable;
        while (true) {
            if (isRequired(table)) {
                assert !isPending(table);
                if (joinType != null)
                    joinTypes.add(joinType);
                tableSources.add(table.getTable());
                tableNodes.add(table.getTable().getTable());
                if (table != rootTable) {
                    joinType = table.getParentJoinType();
                    if (table.getJoinConditions() != null) {
                        for (ConditionExpression joinCondition : table.getJoinConditions()) {
                            if (joinCondition.getImplementation() != ConditionExpression.Implementation.GROUP_JOIN) {
                                joinConditions.add(joinCondition);
                            }
                        }
                    }
                }
            }
            if (table == rootTable) break;
            table = table.getParent();
        }
        Collections.reverse(tableSources);
        Collections.reverse(tableNodes);
        Collections.reverse(joinTypes);
        if (!joinConditions.isEmpty())
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

     * branches that are needed.
     */
    protected PlanNode fillSideBranches(PlanNode input,
                                        TableGroupJoinNode leafTable,
                                        TableGroupJoinNode rootTable) {
        TableGroupJoinNode branchTable = leafTable;
        while (branchTable != rootTable) {
            TableGroupJoinNode parent = branchTable.getParent();
            if (isBranchpoint(parent)) {
                List<PlanNode> subplans = new ArrayList<>(2);
                subplans.add(input);
                for (TableGroupJoinNode sibling = parent.getFirstChild();
                     sibling != null; sibling = sibling.getNextSibling()) {
                    if ((sibling == branchTable) ||
                        (leafLeftMostPending(sibling) == null))
                        continue;
                    List<TableSource> tables = new ArrayList<>();
                    PlanNode subplan = new BranchLookup(null, // no input means _Nested.
                                                        parent.getTable().getTable(),
                                                        sibling.getTable().getTable(),
                                                        tables);
                    subplan = fillBranch(subplan, tables, sibling, parent, sibling);
                    if (subplans == null)
                        subplans = new ArrayList<>();
                    subplans.add(subplan);
                }
                if (subplans.size() > 1)
                    input = new Product(parent.getTable().getTable(), subplans);
            }
            branchTable = parent;
        }
        return input;
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

     * fill out branches.
     */
    protected PlanNode fillGroupLoopBranches(PlanNode input,
                                             TableGroupJoinNode parentTable,
                                             TableGroupJoinNode rootTable) {
        TableGroupJoinNode leafTable = parentTable;
        if (isParent(parentTable)) {
            // Also has children within the group tree. Take one for
            // in-stream branch.
            leafTable = parentTable.getFirstChild();
            List<TableSource> tables = new ArrayList<>();
            input = new BranchLookup(input,
                                     parentTable.getTable().getTable(),
                                     leafTable.getTable().getTable(),
                                     tables);
            input = fillBranch(input, tables, leafTable, parentTable, leafTable);
        }
        return fillSideBranches(input, leafTable, rootTable);
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

    /** Pick a branch beneath <code>rootTable</code> that is pending,
     * gather it into <code>tableSources</code> and return its leaf.
     */
    protected TableGroupJoinNode singleBranchPending(TableGroupJoinNode rootTable,
                                                     List<TableSource> tableSources) {
        TableGroupJoinNode leafTable = leafLeftMostPending(rootTable);
        assert (leafTable != null);
        pendingTableSources(leafTable, rootTable, tableSources);
        return leafTable;
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

     * that flag along the way.
     */
    protected void pendingTableSources(TableGroupJoinNode leafTable,
                                       TableGroupJoinNode rootTable,
                                       List<TableSource> tableSources) {
        TableGroupJoinNode table = leafTable;
        while (true) {
            if (isPending(table)) {
                clearPending(table);
                tableSources.add(table.getTable());
            }
            if (table == rootTable) break;
            table = table.getParent();
        }
        Collections.reverse(tableSources); // Want root to leaf.
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

        Collections.reverse(tableSources); // Want root to leaf.
    }

    /** Find a pending leaf under the the given root. */
    protected TableGroupJoinNode leafLeftMostPending(TableGroupJoinNode rootTable) {
        TableGroupJoinNode leafTable = null;
        for (TableGroupJoinNode table : rootTable) {
            if ((leafTable != null) && !isAncestor(table, leafTable))
                break;
            if (isPending(table))
                leafTable = table;
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.TableGroupJoinTree.TableGroupJoinNode

        }
        List<TableSource> orderedSources = new ArrayList<>(tableSources.values());
        Collections.sort(orderedSources, tableSourceById);
        Map<TableSource,TableGroupJoinNode> nodes =
            new HashMap<>();
        TableGroupJoinNode root = null;
        for (TableSource tableSource : orderedSources) {
            nodes.put(tableSource, new TableGroupJoinNode(tableSource));
        }
        for (TableSource childSource : orderedSources) {
            TableGroupJoinNode childNode = nodes.get(childSource);
            TableSource parentSource = childSource.getParentTable();
            if (parentSource == null) {
                root = childNode;
                continue;
            }
            TableGroupJoinNode parentNode = nodes.get(parentSource);
            childNode.setParent(parentNode);
            childNode.setNextSibling(parentNode.getFirstChild());
            parentNode.setFirstChild(childNode);
        }
        TableGroupJoinTree joinTree = new TableGroupJoinTree(root);
        return costEstimator.costFlatten(joinTree, indexTable,
                                         new HashSet<>(requiredTables));
    }
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.