Ejemplo n.º 1
0
 @Override
 public PlanNode visitDistinctLimit(
     DistinctLimitNode node, RewriteContext<Set<Symbol>> context) {
   Set<Symbol> expectedInputs;
   if (node.getHashSymbol().isPresent()) {
     expectedInputs =
         ImmutableSet.copyOf(
             concat(node.getOutputSymbols(), ImmutableList.of(node.getHashSymbol().get())));
   } else {
     expectedInputs = ImmutableSet.copyOf(node.getOutputSymbols());
   }
   PlanNode source = context.rewrite(node.getSource(), expectedInputs);
   return new DistinctLimitNode(node.getId(), source, node.getLimit(), node.getHashSymbol());
 }
Ejemplo n.º 2
0
    @Override
    public SubPlanBuilder visitDistinctLimit(DistinctLimitNode node, Void context) {
      SubPlanBuilder current = node.getSource().accept(this, context);

      current.setRoot(new DistinctLimitNode(node.getId(), current.getRoot(), node.getLimit()));

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

        PlanNode source =
            new ExchangeNode(
                idAllocator.getNextId(), current.getId(), current.getRoot().getOutputSymbols());
        DistinctLimitNode merge =
            new DistinctLimitNode(idAllocator.getNextId(), source, node.getLimit());
        current = createSingleNodePlan(merge).addChild(current.build());
      }
      return current;
    }