io.ray.streaming.api.stream.UnionStream Maven / Gradle / Ivy
package io.ray.streaming.api.stream;
import io.ray.streaming.operator.impl.UnionOperator;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a union DataStream.
*
* This stream does not create a physical operation, it only affects how upstream data are
* connected to downstream data.
*
* @param The type of union data.
*/
public class UnionStream extends DataStream {
private List> unionStreams;
public UnionStream(DataStream input, List> streams) {
// Union stream does not create a physical operation, so we don't have to set partition
// function for it.
super(input, new UnionOperator());
this.unionStreams = new ArrayList<>();
streams.forEach(this::addStream);
}
void addStream(DataStream stream) {
if (stream instanceof UnionStream) {
this.unionStreams.addAll(((UnionStream) stream).getUnionStreams());
} else {
this.unionStreams.add(stream);
}
}
public List> getUnionStreams() {
return unionStreams;
}
}