@Override public PlanNode visitDistinctLimit(DistinctLimitNode node, RewriteContext<Set<Symbol>> context) { Set<Symbol> expectedInputs; if (node.getHashSymbol().isPresent()) { expectedInputs = ImmutableSet.copyOf(concat(node.getDistinctSymbols(), ImmutableList.of(node.getHashSymbol().get()))); } else { expectedInputs = ImmutableSet.copyOf(node.getDistinctSymbols()); } PlanNode source = context.rewrite(node.getSource(), expectedInputs); return new DistinctLimitNode(node.getId(), source, node.getLimit(), node.isPartial(), node.getDistinctSymbols(), node.getHashSymbol()); }
@Override public PlanNode visitDistinctLimit(DistinctLimitNode node, RewriteContext<Set<Symbol>> context) { Set<Symbol> expectedInputs; if (node.getHashSymbol().isPresent()) { expectedInputs = ImmutableSet.copyOf(concat(node.getDistinctSymbols(), ImmutableList.of(node.getHashSymbol().get()))); } else { expectedInputs = ImmutableSet.copyOf(node.getDistinctSymbols()); } PlanNode source = context.rewrite(node.getSource(), expectedInputs); return new DistinctLimitNode(node.getId(), source, node.getLimit(), node.isPartial(), node.getDistinctSymbols(), node.getHashSymbol()); }
@Override public Void visitDistinctLimit(DistinctLimitNode node, Integer indent) { print(indent, "- DistinctLimit%s[%s]%s => [%s]", node.isPartial() ? "Partial" : "", node.getLimit(), formatHash(node.getHashSymbol()), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }
@Override public PlanWithProperties visitDistinctLimit(DistinctLimitNode node, StreamPreferredProperties parentPreferences) { // final limit requires that all data be in one stream StreamPreferredProperties requiredProperties; StreamPreferredProperties preferredProperties; if (node.isPartial()) { requiredProperties = parentPreferences.withoutPreference().withDefaultParallelism(session); preferredProperties = parentPreferences.withDefaultParallelism(session); } else { // a final changes the input organization completely, so we do not pass through parent preferences requiredProperties = singleStream(); preferredProperties = defaultParallelism(session); } return planAndEnforceChildren(node, requiredProperties, preferredProperties); }
@Override public Void visitDistinctLimit(DistinctLimitNode node, Integer indent) { print(indent, "- DistinctLimit%s[%s]%s => [%s]", node.isPartial() ? "Partial" : "", node.getLimit(), formatHash(node.getHashSymbol()), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }
@Override public PlanWithProperties visitDistinctLimit(DistinctLimitNode node, StreamPreferredProperties parentPreferences) { // final limit requires that all data be in one stream StreamPreferredProperties requiredProperties; StreamPreferredProperties preferredProperties; if (node.isPartial()) { requiredProperties = parentPreferences.withoutPreference().withDefaultParallelism(session); preferredProperties = parentPreferences.withDefaultParallelism(session); } else { // a final changes the input organization completely, so we do not pass through parent preferences requiredProperties = singleStream(); preferredProperties = defaultParallelism(session); } return planAndEnforceChildren(node, requiredProperties, preferredProperties); }
@Override public PlanWithProperties visitDistinctLimit(DistinctLimitNode node, HashComputationSet parentPreference) { // skip hash symbol generation for single bigint if (canSkipHashGeneration(node.getDistinctSymbols())) { return planSimpleNodeWithProperties(node, parentPreference); } Optional<HashComputation> hashComputation = computeHash(node.getDistinctSymbols()); PlanWithProperties child = planAndEnforce( node.getSource(), new HashComputationSet(hashComputation), false, parentPreference.withHashComputation(node, hashComputation)); Symbol hashSymbol = child.getRequiredHashSymbol(hashComputation.get()); // TODO: we need to reason about how pre-computed hashes from child relate to distinct symbols. We should be able to include any precomputed hash // that's functionally dependent on the distinct field in the set of distinct fields of the new node to be able to propagate it downstream. // Currently, such precomputed hashes will be dropped by this operation. return new PlanWithProperties( new DistinctLimitNode(node.getId(), child.getNode(), node.getLimit(), node.isPartial(), node.getDistinctSymbols(), Optional.of(hashSymbol)), ImmutableMap.of(hashComputation.get(), hashSymbol)); }
@Override public PlanWithProperties visitDistinctLimit(DistinctLimitNode node, HashComputationSet parentPreference) { // skip hash symbol generation for single bigint if (canSkipHashGeneration(node.getDistinctSymbols())) { return planSimpleNodeWithProperties(node, parentPreference); } Optional<HashComputation> hashComputation = computeHash(node.getDistinctSymbols()); PlanWithProperties child = planAndEnforce( node.getSource(), new HashComputationSet(hashComputation), false, parentPreference.withHashComputation(node, hashComputation)); Symbol hashSymbol = child.getRequiredHashSymbol(hashComputation.get()); // TODO: we need to reason about how pre-computed hashes from child relate to distinct symbols. We should be able to include any precomputed hash // that's functionally dependent on the distinct field in the set of distinct fields of the new node to be able to propagate it downstream. // Currently, such precomputed hashes will be dropped by this operation. return new PlanWithProperties( new DistinctLimitNode(node.getId(), child.getNode(), node.getLimit(), node.isPartial(), node.getDistinctSymbols(), Optional.of(hashSymbol)), ImmutableMap.of(hashComputation.get(), hashSymbol)); }
@Override public PlanNode visitDistinctLimit(DistinctLimitNode node, RewriteContext<Void> context) { return new DistinctLimitNode(node.getId(), context.rewrite(node.getSource()), node.getLimit(), node.isPartial(), canonicalizeAndDistinct(node.getDistinctSymbols()), canonicalize(node.getHashSymbol())); }
@Override public PlanNode visitDistinctLimit(DistinctLimitNode node, RewriteContext<Void> context) { return new DistinctLimitNode(node.getId(), context.rewrite(node.getSource()), node.getLimit(), node.isPartial(), canonicalizeAndDistinct(node.getDistinctSymbols()), canonicalize(node.getHashSymbol())); }