Examples of TopNNode


Examples of com.facebook.presto.sql.planner.plan.TopNNode

        @Override
        public SubPlanBuilder visitTopN(TopNNode node, Void context)
        {
            SubPlanBuilder current = node.getSource().accept(this, context);

            current.setRoot(new TopNNode(node.getId(), current.getRoot(), node.getCount(), node.getOrderBy(), node.getOrderings(), false, node.getSampleWeight()));

            if (current.isDistributed()) {
                current.setRoot(new SinkNode(idAllocator.getNextId(), current.getRoot(), current.getRoot().getOutputSymbols()));

                // create merge plan fragment
                PlanNode source = new ExchangeNode(idAllocator.getNextId(), current.getId(), current.getRoot().getOutputSymbols());
                TopNNode merge = new TopNNode(idAllocator.getNextId(), source, node.getCount(), node.getOrderBy(), node.getOrderings(), true, node.getSampleWeight());
                current = createSingleNodePlan(merge)
                        .addChild(current.build());
            }

            return current;
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

            orderings.put(symbol, sortItems.next().getOrdering());
        }

        PlanNode planNode;
        if (limit.isPresent()) {
            planNode = new TopNNode(idAllocator.getNextId(), subPlan.getRoot(), Long.valueOf(limit.get()), orderBySymbols.build(), orderings.build(), false);
        }
        else {
            planNode = new SortNode(idAllocator.getNextId(), subPlan.getRoot(), orderBySymbols.build(), orderings.build());
        }
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

                Symbol canonical = canonicalize(symbol);
                symbols.add(canonical);
                orderings.put(canonical, node.getOrderings().get(symbol));
            }

            return new TopNNode(node.getId(), source, node.getCount(), symbols.build(), orderings.build(), node.isPartial());
        }
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

        @Override
        public PlanNode rewriteTopN(TopNNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), Long.MAX_VALUE);
            if (limit != Long.MAX_VALUE || rewrittenSource != node.getSource()) {
                return new TopNNode(node.getId(), rewrittenSource, Math.min(node.getCount(), limit), node.getOrderBy(), node.getOrderings(), node.isPartial());
            }
            return node;
        }
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

        @Override
        public PlanNode rewriteSort(SortNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), Long.MAX_VALUE);
            if (limit != Long.MAX_VALUE) {
                return new TopNNode(node.getId(), rewrittenSource, limit, node.getOrderBy(), node.getOrderings(), false);
            }
            else if (rewrittenSource != node.getSource()) {
                return new SortNode(node.getId(), rewrittenSource, node.getOrderBy(), node.getOrderings());
            }
            return node;
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

        {
            Set<Symbol> expectedInputs = ImmutableSet.copyOf(concat(expectedOutputs, node.getOrderBy()));

            PlanNode source = planRewriter.rewrite(node.getSource(), expectedInputs);

            return new TopNNode(node.getId(), source, node.getCount(), node.getOrderBy(), node.getOrderings(), node.isPartial());
        }
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

        @Override
        public SubPlanBuilder visitTopN(TopNNode node, Void context)
        {
            SubPlanBuilder current = node.getSource().accept(this, context);

            current.setRoot(new TopNNode(node.getId(), current.getRoot(), node.getCount(), node.getOrderBy(), node.getOrderings(), false));

            if (current.isDistributed()) {
                current.setRoot(new SinkNode(idAllocator.getNextId(), current.getRoot(), current.getRoot().getOutputSymbols()));

                // create merge plan fragment
                PlanNode source = new ExchangeNode(idAllocator.getNextId(), current.getId(), current.getRoot().getOutputSymbols());
                TopNNode merge = new TopNNode(idAllocator.getNextId(), source, node.getCount(), node.getOrderBy(), node.getOrderings(), true);
                current = createSingleNodePlan(merge)
                        .addChild(current.build());
            }

            return current;
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

                Symbol canonical = canonicalize(symbol);
                symbols.add(canonical);
                orderings.put(canonical, node.getOrderings().get(symbol));
            }

            return new TopNNode(node.getId(), source, node.getCount(), symbols.build(), orderings.build(), node.isPartial());
        }
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

        @Override
        public SubPlanBuilder visitTopN(TopNNode node, Void context)
        {
            SubPlanBuilder current = node.getSource().accept(this, context);

            current.setRoot(new TopNNode(node.getId(), current.getRoot(), node.getCount(), node.getOrderBy(), node.getOrderings(), false));

            if (current.isDistributed()) {
                current.setRoot(new SinkNode(idAllocator.getNextId(), current.getRoot(), current.getRoot().getOutputSymbols()));

                // create merge plan fragment
                PlanNode source = new ExchangeNode(idAllocator.getNextId(), current.getId(), current.getRoot().getOutputSymbols());
                TopNNode merge = new TopNNode(idAllocator.getNextId(), source, node.getCount(), node.getOrderBy(), node.getOrderings(), true);
                current = createSingleNodePlan(merge)
                        .addChild(current.build());
            }

            return current;
View Full Code Here

Examples of com.facebook.presto.sql.planner.plan.TopNNode

            orderings.put(symbol, toSortOrder(sortItems.next()));
        }

        PlanNode planNode;
        if (limit.isPresent()) {
            planNode = new TopNNode(idAllocator.getNextId(), subPlan.getRoot(), Long.valueOf(limit.get()), orderBySymbols.build(), orderings.build(), false);
        }
        else {
            planNode = new SortNode(idAllocator.getNextId(), subPlan.getRoot(), orderBySymbols.build(), orderings.build());
        }
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.