/** * Does a full outer join of the values of this stream with the values having the same key from the other stream. * <p> * Note: The parallelism of this stream is carried forward to the joined stream. * </p> * * @param otherStream the other stream * @param valueJoiner the {@link ValueJoiner} * @param <R> the type of the values resulting from the join * @param <V1> the type of the values in the other stream * @return the new stream */ public <R, V1> PairStream<K, R> fullOuterJoin(PairStream<K, V1> otherStream, ValueJoiner<? super V, ? super V1, ? extends R> valueJoiner) { return partitionByKey() .joinPartition( otherStream.partitionByKey(), valueJoiner, JoinProcessor.JoinType.OUTER, JoinProcessor.JoinType.OUTER); }
/** * Join the values of this stream with the values having the same key from the other stream. * <p> * Note: The parallelism of this stream is carried forward to the joined stream. * </p> * * @param otherStream the other stream * @param valueJoiner the {@link ValueJoiner} * @param <R> the type of the values resulting from the join * @param <V1> the type of the values in the other stream * @return the new stream */ public <R, V1> PairStream<K, R> join(PairStream<K, V1> otherStream, ValueJoiner<? super V, ? super V1, ? extends R> valueJoiner) { return partitionByKey() .joinPartition( otherStream.partitionByKey(), valueJoiner, JoinProcessor.JoinType.INNER, JoinProcessor.JoinType.INNER); }
/** * Does a left outer join of the values of this stream with the values having the same key from the other stream. * <p> * Note: The parallelism of this stream is carried forward to the joined stream. * </p> * * @param otherStream the other stream * @param valueJoiner the {@link ValueJoiner} * @param <R> the type of the values resulting from the join * @param <V1> the type of the values in the other stream * @return the new stream */ public <R, V1> PairStream<K, R> leftOuterJoin(PairStream<K, V1> otherStream, ValueJoiner<? super V, ? super V1, ? extends R> valueJoiner) { return partitionByKey() .joinPartition( otherStream.partitionByKey(), valueJoiner, JoinProcessor.JoinType.OUTER, JoinProcessor.JoinType.INNER); }
/** * Does a right outer join of the values of this stream with the values having the same key from the other stream. * <p> * Note: The parallelism of this stream is carried forward to the joined stream. * </p> * * @param otherStream the other stream * @param valueJoiner the {@link ValueJoiner} * @param <R> the type of the values resulting from the join * @param <V1> the type of the values in the other stream * @return the new stream */ public <R, V1> PairStream<K, R> rightOuterJoin(PairStream<K, V1> otherStream, ValueJoiner<? super V, ? super V1, ? extends R> valueJoiner) { return partitionByKey() .joinPartition( otherStream.partitionByKey(), valueJoiner, JoinProcessor.JoinType.INNER, JoinProcessor.JoinType.OUTER); }
/** * Groups the values of this stream with the values having the same key from the other stream. * <p> * If stream1 has values - (k1, v1), (k2, v2), (k2, v3) <br/> and stream2 has values - (k1, x1), (k1, x2), (k3, x3) <br/> The the * co-grouped stream would contain - (k1, ([v1], [x1, x2]), (k2, ([v2, v3], [])), (k3, ([], [x3])) * </p> * <p> * Note: The parallelism of this stream is carried forward to the co-grouped stream. * </p> * * @param otherStream the other stream * @param <V1> the type of the values in the other stream * @return the new stream */ public <V1> PairStream<K, Pair<Iterable<V>, Iterable<V1>>> coGroupByKey(PairStream<K, V1> otherStream) { return partitionByKey().coGroupByKeyPartition(otherStream); }
/** * Returns a new stream where the values are grouped by the keys. * * @return the new stream */ public PairStream<K, Iterable<V>> groupByKey() { return partitionByKey().aggregatePartition(new MergeValues<>()); }
/** * Returns a new stream where the values that arrive within a window having the same key will be reduced by repeatedly applying the * reducer. * * @param reducer the reducer * @param window the window configuration * @return the new stream */ public PairStream<K, V> reduceByKeyAndWindow(Reducer<V> reducer, Window<?, ?> window) { return partitionByKey().window(window).reduceByKey(reducer); }
/** * Returns a new stream where the values are grouped by keys and the given window. The values that arrive within a window having the * same key will be merged together and returned as an Iterable of values mapped to the key. * * @param window the window configuration * @return the new stream */ public PairStream<K, Iterable<V>> groupByKeyAndWindow(Window<?, ?> window) { return partitionByKey().window(window).aggregatePartition(new MergeValues<>()); }