<commit_before>package org.mit.jstreamit;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

/**
 * Visits the stream graph, connecting the primitive workers with channels
 * and keeping references to the first and last filters.  Subclasses override
 * the makeChannel() method to provide Channels to connect filters together.
 * This visitor does not add input or output channels to the first or last
 * filters respectively.
 *
 * This class uses lots of raw types to avoid having to recapture the
 * unbounded wildcards all the time.
 * @author <NAME> <<EMAIL>>
 * @since 1/23/2013 (originally internal to DebugStreamCompiler)
 */
abstract class ConnectPrimitiveWorkersVisitor extends StreamVisitor {
	/**
	 * The first worker in the stream graph.
	 */
	private PrimitiveWorker<?, ?> source;
	/**
	 * During the visitation, the last worker encountered.  After the visitation
	 * is complete, the last worker in the stream graph.
	 */
	private PrimitiveWorker<?, ?> cur;
	private Deque<SplitjoinContext> stack = new ArrayDeque<>();

	/**
	 * Used for remembering information about splitjoins while traversing:
	 * so we can reset cur to splitter when we enter a branch, and so we
	 * record cur at the end of a branch to connect it to the joiner after
	 * all branches are processed.
	 */
	private static class SplitjoinContext {
		private Splitter<?, ?> splitter;
		private List<PrimitiveWorker<?, ?>> branchEnds = new ArrayList<>();
	}

	protected ConnectPrimitiveWorkersVisitor() {}

	/**
	 * Creates a Channel object to be used to connect the given two workers
	 * together.
	 * @param <E> the type of element in the Channel
	 * @param upstream the upstream worker
	 * @param downstream the downstream worker
	 * @return a Channel that will be used to connect the upstream and<commit_msg>TODO in ConnectPrimitiveWorkersVisitor<commit_after>package org.mit.jstreamit;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

/**
 * Visits the stream graph, connecting the primitive workers with channels
 * and keeping references to the first and last filters.  Subclasses override
 * the makeChannel() method to provide Channels to connect filters together.
 * This visitor does not add input or output channels to the first or last
 * filters respectively.
 *
 * This class uses lots of raw types to avoid having to recapture the
 * unbounded wildcards all the time.
 * @author <NAME> <<EMAIL>>
 * @since 1/23/2013 (originally internal to DebugStreamCompiler)
 */
abstract class ConnectPrimitiveWorkersVisitor extends StreamVisitor {
	/**
	 * The first worker in the stream graph.
	 */
	private PrimitiveWorker<?, ?> source;
	/**
	 * During the visitation, the last worker encountered.  After the visitation
	 * is complete, the last worker in the stream graph.
	 */
	private PrimitiveWorker<?, ?> cur;
	private Deque<SplitjoinContext> stack = new ArrayDeque<>();

	/**
	 * Used for remembering information about splitjoins while traversing:
	 * so we can reset cur to splitter when we enter a branch, and so we
	 * record cur at the end of a branch to connect it to the joiner after
	 * all branches are processed.
	 */
	private static class SplitjoinContext {
		private Splitter<?, ?> splitter;
		private List<PrimitiveWorker<?, ?>> branchEnds = new ArrayList<>();
	}

	protected ConnectPrimitiveWorkersVisitor() {}

	/**
	 * Creates a Channel object to be used to connect the given two workers
	 * together.
	 *
	 * TODO: generic bounds are too strict -- the filters don't have to exactly
	 * agree on type, but merely be compatible
	 * @param <E> the type of element in the Channel
	 * @param upstream the upstream worker
	 * @param downstream the downstream worker
	 * @return a Channel that will be used to connect the upstream and
{'fraction_non_alphanumeric': 0.07692307692307693, 'fraction_numerical': 0.0036382536382536385, 'mean_word_length': 4.077836411609499, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '934068', 'n_tokens_mistral': 1045, 'n_tokens_neox': 965, 'n_words': 474}