split out because episode map method was too complex for intellij
969901
@SuppressWarnings({"ConstantConditions"})
    private Map<String, String> buildEpisodeMap(String[] showIds, String[] episodeIds, String searchTerm,
                                                SearchType searchType, TagMode tagMode, Episode.EpisodeStatus status,
                                                SortBy sortBy, SortDir sortDir, Boolean includeViews, Integer page,
                                                Integer perPage, Integer embedWidth, Integer embedHeight) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("expires", expires());
        if (showIds != null) map.put("show_id", join(showIds));
        if (episodeIds != null) map.put("id", join(episodeIds));
        if (searchTerm != null) map.put("search_type", searchType.name());
        if (tagMode != null) map.put("tag_mode", tagMode.name());
        if (status != null) map.put("status", status.name());
        if (sortBy != null) map.put("sort_by", sortBy.name());
        if (sortDir != null) map.put("sort_dir", sortDir.name());
        if (includeViews != null) map.put("include_views", includeViews.toString());
        if (page != null) map.put("page", page.toString());
        if (perPage != null) map.put("per_page", perPage.toString());
        if (embedWidth != null) map.put("embed_width", embedWidth.toString());
        if (embedHeight != null) map.put("embed_height", embedHeight.toString());
        return map;
    }
901249
private static void copyTo(Map lastMap, Dialect d) {
		Map<String, String> target = d.functions;
		target.clear();
		target.putAll(lastMap);
	}
327823
def _organize_output(output, combine_map, file_key, combine_arg_keys):
    
    out_map = collections.defaultdict(list)
    extra_args = collections.defaultdict(list)
    final_args = collections.OrderedDict()
    extras = []
    for data in output:
        cur_file = data.get(file_key)
        if not cur_file:
            extras.append([data])
        else:
            cur_out = combine_map[cur_file]
            out_map[cur_out].append(cur_file)
            extra_args[cur_out].append([data[x] for x in combine_arg_keys])
            data[file_key] = cur_out
            if cur_out not in final_args:
                final_args[cur_out] = [data]
            else:
                extras.append([data])
    combine_args = [[v, k] + _get_extra_args(extra_args[k], combine_arg_keys)
                    for (k, v) in out_map.items()]
    return combine_args, list(final_args.values()) + extras
605056
private static void processSeasonEpisodes(Element eEpisodeList, EpisodeList epList) {
        // Get the season number
        String season = eEpisodeList.getAttribute("no");

        NodeList nlEpisode = eEpisodeList.getElementsByTagName(EPISODE);
        if (nlEpisode == null || nlEpisode.getLength() == 0) {
            return;
        }

        for (int eLoop = 0; eLoop < nlEpisode.getLength(); eLoop++) {
            Node nEpisode = nlEpisode.item(eLoop);
            if (nEpisode.getNodeType() == Node.ELEMENT_NODE) {
                epList.addEpisode(parseEpisode((Element) nEpisode, season));
            }
        }

    }
1222714
def merge_maps(m, base):
    
    
    for k in base.keys():
        if k not in m:
            m[k] = base[k]
818727
function removeLayerFromSplitMaps(state, layer) {
  return state.splitMaps.map(settings => {
    const {layers} = settings;
    /* eslint-disable no-unused-vars */
    const {[layer.id]: _, ...newLayers} = layers;
    /* eslint-enable no-unused-vars */
    return {
      ...settings,
      layers: newLayers
    };
  });
}
1286420
function map ( input, inputMin, inputMax, outputMin, outputMax, clamp, ease ) {
    input = ( input - inputMin ) / ( inputMax - inputMin );
    if ( ease ) {
        input = ease(input);
    } 
    var output = input * ( outputMax - outputMin ) + outputMin;
    if ( !!clamp ) {
        if ( outputMax < outputMin ) {
            if ( output < outputMax ) {
                output = outputMax;
            }
            else if ( output > outputMin ) {
                output = outputMin;
            }
        } else {
            if ( output > outputMax ) {
                output = outputMax;
            }
            else if ( output < outputMin ) {
                output = outputMin;
            }
        }
    }
    return output;
}
658077
def mergeSplitsOnInterfaces(root: LNode):
    
    for ch in root.children:
        if ch.children:
            mergeSplitsOnInterfaces(ch)

    ctx = MergeSplitsOnInterfacesCtx()
    for ch in root.children:
        srcPorts = None
        try:
            if ch.name == "CONCAT":
                p = single(ch.east, lambda x: True)
                e = single(p.outgoingEdges, lambda x: True)
                srcPorts = e.dsts
            elif ch.name == "SLICE":
                p = single(ch.west, lambda x: True)
                e = single(p.incomingEdges, lambda x: True)
                srcPorts = e.srcs
        except (DuplicitValueExc, NoValueExc):
            continue

        if srcPorts is not None:
            for srcPort in srcPorts:
                if isinstance(srcPort.parent, LPort):
                    # only for non primitive ports
                    rootPort = getRootIntfPort(srcPort)
                    ctx.register(rootPort, ch, e)

    # join them if it is possible
    for srcPort, splitsAndConcats in ctx.iterPortSplits():
        if len(splitsAndConcats) <= 1:
            continue

        name = "SPLIT" if srcPort.direction == PortType.OUTPUT else "CONCAT"
        newSplitNode = root.addNode(name)
        copyPort(srcPort, newSplitNode, True, "")
        n = splitsAndConcats[0][0]
        for i in range(max(len(n.west),
                           len(n.east))):
            copyPort(
                srcPort, newSplitNode,
                False, "[%d]" % i)

        reconnectPorts(root, srcPort, splitsAndConcats,
                       newSplitNode)
1008205
private void repartitionBroadcastState(
			Map<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>> broadcastState,
			List<Map<StreamStateHandle, OperatorStateHandle>> mergeMapList) {

		int newParallelism = mergeMapList.size();
		for (int i = 0; i < newParallelism; ++i) {

			final Map<StreamStateHandle, OperatorStateHandle> mergeMap = mergeMapList.get(i);

			// for each name, pick the i-th entry
			for (Map.Entry<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>> e :
					broadcastState.entrySet()) {

				int previousParallelism = e.getValue().size();

				Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo> handleWithMetaInfo =
					e.getValue().get(i % previousParallelism);

				OperatorStateHandle operatorStateHandle = mergeMap.get(handleWithMetaInfo.f0);
				if (operatorStateHandle == null) {
					operatorStateHandle = new OperatorStreamStateHandle(
						new HashMap<>(broadcastState.size()),
						handleWithMetaInfo.f0);
					mergeMap.put(handleWithMetaInfo.f0, operatorStateHandle);
				}
				operatorStateHandle.getStateNameToPartitionOffsets().put(e.getKey(), handleWithMetaInfo.f1);
			}
		}
	}
974818
private static Multimap<?, ?> annotateEmptyStringsMultimap(Multimap<?, ?> multimap) {
    if (multimap.containsKey("") || multimap.containsValue("")) {
      ListMultimap<Object, Object> annotatedMultimap = LinkedListMultimap.create();
      for (Entry<?, ?> entry : multimap.entries()) {
        Object key = "".equals(entry.getKey()) ? HUMAN_UNDERSTANDABLE_EMPTY_STRING : entry.getKey();
        Object value =
            "".equals(entry.getValue()) ? HUMAN_UNDERSTANDABLE_EMPTY_STRING : entry.getValue();
        annotatedMultimap.put(key, value);
      }
      return annotatedMultimap;
    } else {
      return multimap;
    }
  }
196267
@Override
  public Streamlet<R> split(Map<String, SerializablePredicate<R>> splitFns) {
    // Make sure map and stream ids are not empty
    require(splitFns.size() > 0, "At least one entry is required");
    require(splitFns.keySet().stream().allMatch(stream -> StringUtils.isNotBlank(stream)),
            "Stream Id can not be blank");

    SplitStreamlet<R> splitStreamlet = new SplitStreamlet<R>(this, splitFns);
    addChild(splitStreamlet);
    return splitStreamlet;
  }
47723
@Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    splitHistory.writeExternal(out);
  }
598365
static Map<String, Object> merge(Map<String, Object>... args) {
        if (args.length > 1) {
            Map<String, Object> obj = args[0];
            for (int i = 1; i < args.length; i++) {
                obj = mergeTwo(obj, args[i]);
            }
            return obj;
        } else if (args.length == 1) {
            return args[0];
        } else {
            return null;
        }
    }
54237
function mapLastPart(mapper, separator) {
  return str => {
    const idx = str.lastIndexOf(separator);
    const mapped = mapper(str.slice(idx + separator.length));
    return str.slice(0, idx + separator.length) + mapped;
  };
}
1275218
private static Map<String, Set<String>> flatten(Map<String, Set<String>> data) {
    Map<String, Set<String>> territories = new TreeMap<>();
    Set<String> keys = data.keySet();
    for (String key : keys) {
      Set<String> values = flatten(key, territories, data);
      territories.put(key, values);
    }
    return territories;
  }
894934
def replace(self, episodes, length, rows=None):
    
    rows = tf.range(self._capacity) if rows is None else rows
    assert rows.shape.ndims == 1
    assert_capacity = tf.assert_less(
        rows, self._capacity, message='capacity exceeded')
    with tf.control_dependencies([assert_capacity]):
      assert_max_length = tf.assert_less_equal(
          length, self._max_length, message='max length exceeded')
    with tf.control_dependencies([assert_max_length]):
      replace_ops = tools.nested.map(
          lambda var, val: tf.scatter_update(var, rows, val),
          self._buffers, episodes, flatten=True)
    with tf.control_dependencies(replace_ops):
      return tf.scatter_update(self._length, rows, length)
866567
private void init(final Map<DistributedDataSetPartition, InputSplit[]> splitsPerPartition) {
    final Pair<InputSplit[], DistributedDataSetPartition[]>
                                      splitsAndPartitions = getSplitsAndPartitions(splitsPerPartition);
    final InputSplit[] splits = splitsAndPartitions.getFirst();
    final DistributedDataSetPartition[] partitions = splitsAndPartitions.getSecond();
    Validate.isTrue(splits.length == partitions.length);
    for (int splitNum = 0; splitNum < splits.length; splitNum++) {
      LOG.log(Level.FINE, "Processing split: " + splitNum);
      final InputSplit split = splits[splitNum];
      final NumberedSplit<InputSplit> numberedSplit = new NumberedSplit<>(split, splitNum,
          partitions[splitNum]);
      unallocatedSplits.add(numberedSplit);
      updateLocations(numberedSplit);
    }
    if (LOG.isLoggable(Level.FINE)) {
      for (final Map.Entry<String, BlockingQueue<NumberedSplit<InputSplit>>> locSplit : locationToSplits.entrySet()) {
        LOG.log(Level.FINE, locSplit.getKey() + ": " + locSplit.getValue().toString());
      }
    }
  }