/** * This method merges n time series into one according to the following strategy: * The timestamps are merged; the resulting sequence is the union of the given ones. * On each timestamp, the new value is computed by reducing the given operator to * the vector of values at that time stamp. * Typical operators are min, max, sum, avg. * * @param input an iterable of time series to be merged * @param op the operator to be applied * @param <T> type of timestamps * @param <V> type of values * @return iterator of merged timeValuePairs */ public static <T extends Comparable<T>, V> Iterator<Pair<T, V>> merge(Iterable<Iterator<Pair<T, V>>> input, BinaryOperator<V> op) { return map(merge(input), (Pair<T, List<V>> p) -> pairOf(p.getFirst(), reduce(asIterator(p.getSecond()), weakBinaryOperator(op)))); }
/** * This method merges n time series into one according to the following strategy: * The timestamps are merged; the resulting sequence is the union of the given ones. * On each timestamp, the new value is computed by reducing the given operator to * the vector of values at that time stamp. * Typical operators are min, max, sum, avg. * * @param input an iterable of time series to be merged * @param op the operator to be applied * @param <T> type of timestamps * @param <V> type of values * @return iterator of merged timeValuePairs */ public static <T extends Comparable<T>, V> Iterator<Pair<T, V>> merge(Iterable<Iterator<Pair<T, V>>> input, BinaryOperator<V> op) { return map(merge(input), (Pair<T, List<V>> p) -> pairOf(p.getFirst(), reduce(asIterator(p.getSecond()), weakBinaryOperator(op)))); }