Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.sql.planner;
import static com.facebook.presto.util.ImmutableCollectors.toImmutableMultiset;
public class SubPlan
    private final PlanFragment fragment;
    private final List<SubPlanchildren;
    public SubPlan(PlanFragment fragmentList<SubPlanchildren)
    {
        Preconditions.checkNotNull(fragment"fragment is null");
        Preconditions.checkNotNull(children"children is null");
        this. = fragment;
        this. = ImmutableList.copyOf(children);
    }
    public PlanFragment getFragment()
    {
        return ;
    }
    public List<SubPlangetChildren()
    {
        return ;
    }

    
Flattens the subplan and returns all PlanFragments in the tree
    public List<PlanFragmentgetAllFragments()
    {
        ImmutableList.Builder<PlanFragmentfragments = ImmutableList.builder();
        fragments.add(getFragment());
        for (SubPlan child : getChildren()) {
            fragments.addAll(child.getAllFragments());
        }
        return fragments.build();
    }
    public void sanityCheck()
    {
        Multiset<PlanFragmentIdexchangeIds = .getSources().stream()
                .filter(RemoteSourceNode.class::isInstance)
                .map(RemoteSourceNode.class::cast)
                .map(RemoteSourceNode::getSourceFragmentIds)
                .flatMap(List::stream)
                .collect(toImmutableMultiset());
        Multiset<PlanFragmentIdchildrenIds = .stream()
                .map(SubPlan::getFragment)
                .map(PlanFragment::getId)
                .collect(toImmutableMultiset());
        Preconditions.checkState(exchangeIds.equals(childrenIds), "Subplan exchange ids don't match child fragment ids (%s vs %s)"exchangeIdschildrenIds);
        for (SubPlan child : ) {
            child.sanityCheck();
        }
    }
New to GrepCode? Check out our FAQ X