Package com.facebook.presto.sql.planner.plan

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(), canonicalize(node.getSampleWeight()));
        }
View Full Code Here


                count = Math.min(count, context.getCount());
                if (context.getSampleWeight().isPresent()) {
                    checkState(sampleWeight.isPresent() && sampleWeight.equals(context.getSampleWeight()), "limit and topN sample weight symbols don't match");
                }
            }
            return new TopNNode(node.getId(), rewrittenSource, count, node.getOrderBy(), node.getOrderings(), node.isPartial(), sampleWeight);
        }
View Full Code Here

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

                expectedInputs.add(node.getSampleWeight().get());
            }

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

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

    @Test
    public void testTopN()
            throws Exception
    {
        PlanNode node = new TopNNode(newId(),
                filter(baseTableScan,
                        and(
                                equals(AE, BE),
                                equals(BE, CE),
                                lessThan(CE, number(10)))),
View Full Code Here

    @Test
    public void testTopN()
            throws Exception
    {
        PlanNode node = new TopNNode(newId(),
                filter(baseTableScan,
                        and(
                                equals(AE, BE),
                                equals(BE, CE),
                                lessThan(CE, number(10)))),
View Full Code Here

                WindowNode windowNode = context.getWindowNode().get();
                if (windowNode.getOrderBy().isEmpty()) {
                    return new LimitNode(idAllocator.getNextId(), rewrittenNode, ((LongLiteral) context.getExpression()).getValue());
                }
                else {
                    return new TopNNode(
                            idAllocator.getNextId(),
                            rewrittenNode,
                            ((LongLiteral) context.getExpression()).getValue(),
                            windowNode.getOrderBy(),
                            windowNode.getOrderings(),
View Full Code Here

            SubPlanBuilder current = node.getSource().accept(this, context);

            // use partial TopN plan if distributed
            boolean partial = current.isDistributed();

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

            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(), false);
                current = createSingleNodePlan(merge)
                        .addChild(current.build());
            }

            return current;
View Full Code Here

                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

        {
            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

TOP

Related Classes of com.facebook.presto.sql.planner.plan.TopNNode

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.