Pull a join order out of the join orders deque, compute all possible plans
for that join order, then append them to the computed plans deque.
17785
@Override
    protected AbstractPlanNode nextPlan() {

        // repeat (usually run once) until plans are created
        // or no more plans can be created
        while (m_plans.size() == 0) {
            // get the join order for us to make plans out of
            JoinNode joinTree = m_joinOrders.poll();

            // no more join orders => no more plans to generate
            if (joinTree == null) {
                return null;
            }

            // Analyze join and filter conditions
            joinTree.analyzeJoinExpressions(m_parsedStmt.m_noTableSelectionList);
            // a query that is a little too quirky or complicated.
            if (!m_parsedStmt.m_noTableSelectionList.isEmpty()) {
                throw new PlanningErrorException("Join with filters that do not depend on joined tables is not supported in VoltDB");
            }

            if ( ! m_partitioning.wasSpecifiedAsSingle()) {
                // Now that analyzeJoinExpressions has done its job of properly categorizing
                // and placing the various filters that the HSQL parser tends to leave in the strangest
                // configuration, this is the first opportunity to analyze WHERE and JOIN filters'
                // effects on statement partitioning.
                // But this causes the analysis to be run based on a particular join order.
                // Which join orders does this analysis actually need to be run on?
                // Can it be run on the first join order and be assumed to hold for all join orders?
                // If there is a join order that fails to generate a single viable plan, is its
                // determination of partitioning (or partitioning failure) always valid for other
                // join orders, or should the analysis be repeated on a viable join order
                // in that case?
                // For now, analyze each join order independently and when an invalid partitioning is
                // detected, skip the plan generation for that particular ordering.
                // If this causes all plans to be skipped, commonly the case, the PlanAssembler
                // should propagate an error message identifying partitioning as the problem.
                HashMap<AbstractExpression, Set<AbstractExpression>>
                    valueEquivalence = joinTree.getAllEquivalenceFilters();
                Collection<StmtTableScan> scans = m_parsedStmt.allScans();
                m_partitioning.analyzeForMultiPartitionAccess(scans, valueEquivalence);
                if ( ! m_partitioning.isJoinValid() ) {
                    // The case of more than one independent partitioned table
                    // would result in an illegal plan with more than two fragments.
                    // Don't throw a planning error here, in case the problem is just with this
                    // particular join order, but do leave a hint to the PlanAssembler in case
                    // the failure is unanimous -- a common case.
                    m_recentErrorMsg = m_partitioning.getJoinInvalidReason();
                    // This join order, at least, is not worth trying to plan.
                    continue;
                }
            }

            generateMorePlansForJoinTree(joinTree);
        }
        return m_plans.poll();
    }
1244362
public static void copyJoins(From<?, ?> from, From<?, ?> to) {
        for (Join<?, ?> j : from.getJoins()) {
            Join<?, ?> toJoin = to.join(j.getAttribute().getName(), j.getJoinType());
            toJoin.alias(getOrCreateAlias(j));

            copyJoins(j, toJoin);
        }

        for (Fetch<?, ?> f : from.getFetches()) {
            Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName());
            copyFetches(f, toFetch);

        }
    }
899867
def add_edge(edges, edge_points, coords, i, j):
    
    if (i, j) in edges or (j, i) in edges:
        # already added
        return( edges.add((i, j)), edge_points.append(coords[[i, j]]))
542867
def _minimize_joins(self):
        
        joins_group = []
        for join in self._joins:
            append_new = True
            for join_group in joins_group:
                if join_group[0]['table'] == join['table'] and join_group[0]['ons'] == join['ons']:
                    join_group.append(join)
                    append_new = False
                    break
            if append_new:
                joins_group.append([join])

        self._joins = []
        for joins in joins_group:
            if len(joins) > 1 and any(bool(join['type'] == INNER_JOIN) for join in joins):
                joins[0]['type'] = INNER_JOIN
                self._joins.append(joins[0])
            elif len(joins) > 1 and all(join['type'] == joins[0]['type'] for join in joins):
                self._joins.append(joins[0])
            else:
                self._joins.extend(joins)
957994
public OrderingList<S> concat(OrderingList<S> other) {
        if (size() == 0) {
            return other;
        }
        OrderingList<S> newList = this;
        if (other.size() > 0) {
            for (OrderedProperty<S> property : other) {
                newList = newList.concat(property);
            }
        }
        return newList;
    }
1125881
private static RecurrenceIterator join(List<RecurrenceIterator> iterators) {
		if (iterators.size() == 1) {
			return iterators.get(0);
		}
		RecurrenceIterator first = iterators.get(0);
		List<RecurrenceIterator> rest = iterators.subList(1, iterators.size());
		return RecurrenceIteratorFactory.join(first, rest.toArray(new RecurrenceIterator[0]));
	}
840201
def list_merge(list_a, list_b):
    
    #return list(collections.OrderedDict.fromkeys(list_a + list_b))
    #result = list(list_b)
    result = []
    for item in list_a:
        if not item in result:
            result.append(item)
    for item in list_b:
        if not item in result:
            result.append(item)
    return result
1286514
def recursively_collect_orders(
        name, ctx, all_inputs, orders=None, blacklist=None
        ):
    '''

    '''
    name = name.lower()
    if orders is None:
        orders = []
    if blacklist is None:
        blacklist = set()
    try:
        recipe = Recipe.get_recipe(name, ctx)
        dependencies = get_dependency_tuple_list_for_recipe(
            recipe, blacklist=blacklist
        )

        # handle opt_depends: these impose requirements on the build
        # order only if already present in the list of recipes to build
        dependencies.extend(fix_deplist(
            [[d] for d in recipe.get_opt_depends_in_list(all_inputs)
             if d.lower() not in blacklist]
        ))

        if recipe.conflicts is None:
            conflicts = []
        else:
            conflicts = [dep.lower() for dep in recipe.conflicts]
    except ValueError:
        # The recipe does not exist, so we assume it can be installed
        # via pip with no extra dependencies
        dependencies = []
        conflicts = []

    new_orders = []
    # for each existing recipe order, see if we can add the new recipe name
    for order in orders:
        if name in order:
            new_orders.append(deepcopy(order))
            continue
        if order.conflicts():
            continue
        if any([conflict in order for conflict in conflicts]):
            continue

        for dependency_set in product(*dependencies):
            new_order = deepcopy(order)
            new_order[name] = set(dependency_set)

            dependency_new_orders = [new_order]
            for dependency in dependency_set:
                dependency_new_orders = recursively_collect_orders(
                    dependency, ctx, all_inputs, dependency_new_orders,
                    blacklist=blacklist
                )

            new_orders.extend(dependency_new_orders)

    return new_orders
386447
function runSubqueries (subQueries, callback, collection) {
        var i,
            responsesReceived = 0,
            length = subQueries.length,
            joinedSet = [];//The array where the results are going to get stuffed

        if (subQueries.length > 0) {
            for (i = 0; i < subQueries.length; i += 1) {

                collection.aggregate(subQueries[i], function (err, results) {
                    joinedSet = joinedSet.concat(results);
                    responsesReceived += 1;

                    if (responsesReceived === length) {
                        callback(joinedSet);
                    }
                });
            }
        } else {
            callback([]);
        }

        return joinedSet;
    }
286899
public void getScanNodeList_recurse(ArrayList<AbstractScanPlanNode> collected,
            HashSet<AbstractPlanNode> visited) {
        if (visited.contains(this)) {
            assert(false): "do not expect loops in plangraph.";
            return;
        }
        visited.add(this);
        for (AbstractPlanNode n : m_children) {
            n.getScanNodeList_recurse(collected, visited);
        }

        for (AbstractPlanNode node : m_inlineNodes.values()) {
            node.getScanNodeList_recurse(collected, visited);
        }
    }
1293968
def build(self, **kwargs):
        
        self.tasks += self.compute_tasks(**kwargs)
        return self.finalize()
595659
def _compile_update_from(self, query):
        
        if not query.joins:
            return ""

        froms = []

        for join in query.joins:
            froms.append(self.wrap_table(join.table))

        if len(froms):
            return " FROM %s" % ", ".join(froms)

        return ""
498980
private void completeFutures() {
    long commitIndex = queues.values().stream()
        .map(queue -> queue.ackedIndex)
        .reduce(Math::min)
        .orElse(0L);
    for (long i = context.getCommitIndex() + 1; i <= commitIndex; i++) {
      CompletableFuture<Void> future = futures.remove(i);
      if (future != null) {
        future.complete(null);
      }
    }
    context.setCommitIndex(commitIndex);
  }
186502
def join(self, *args):
        
        call_args = list(args)
        joiner = call_args.pop(0)
        self.random.shuffle(call_args)
        return joiner.join(call_args)
1069648
private static <T> ImmutableList<T> concatImmutableLists(
      ImmutableList<T> first, ImmutableList<T> second) {
    if (first.isEmpty()) {
      return second;
    }
    if (second.isEmpty()) {
      return first;
    }

    return ImmutableList.<T>builder().addAll(first).addAll(second).build();
  }
639856
def traverse_preorder(self, leaves=True, internal=True):
        '''
        '''
        s = deque(); s.append(self)
        while len(s) != 0:
            n = s.pop()
            if (leaves and n.is_leaf()) or (internal and not n.is_leaf()):
                yield n
            s.extend(n.children)
524549
def fq_merge(R1, R2):
    
    c = itertools.cycle([1, 2, 3, 4])
    for r1, r2 in zip(R1, R2):
        n = next(c)
        if n == 1:
            pair = [[], []]
        pair[0].append(r1.strip())
        pair[1].append(r2.strip())
        if n == 4:
            yield pair