* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* 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.
visitorVisitor this walker is being used by.
org.apache.pig.impl.plan.VisitorExceptionif an error is encountered while walking.
// This is highly inefficient, but our graphs are small so it should be okay.
// The algorithm works by starting at any node in the graph, finding it's
// predecessors and calling itself for each of those predecessors. When it
// finds a node that has no unfinished predecessors it puts that node in the
// list. It then unwinds itself putting each of the other nodes in the list.
// It keeps track of what nodes it's seen as it goes so it doesn't put any
// nodes in the graph twice.
if (leaves == null) return;
// We haven't seen this one before.
Collection<Operator> preds = Utils.mergeCollection(plan.getPredecessors(node), plan.getSoftLinkPredecessors(node));
// Do all our predecessors before ourself
// Now do ourself