io.ray.streaming.api.stream.DataStreamSource Maven / Gradle / Ivy
package io.ray.streaming.api.stream;
import io.ray.streaming.api.context.StreamingContext;
import io.ray.streaming.api.function.impl.SourceFunction;
import io.ray.streaming.api.function.internal.CollectionSourceFunction;
import io.ray.streaming.operator.impl.SourceOperatorImpl;
import java.util.Collection;
/**
* Represents a source of the DataStream.
*
* @param The type of StreamSource data.
*/
public class DataStreamSource extends DataStream implements StreamSource {
private DataStreamSource(StreamingContext streamingContext, SourceFunction sourceFunction) {
super(streamingContext, new SourceOperatorImpl<>(sourceFunction));
}
public static DataStreamSource fromSource(
StreamingContext context, SourceFunction sourceFunction) {
return new DataStreamSource<>(context, sourceFunction);
}
/**
* Build a DataStreamSource source from a collection.
*
* @param context Stream context.
* @param values A collection of values.
* @param The type of source data.
* @return A DataStreamSource.
*/
public static DataStreamSource fromCollection(
StreamingContext context, Collection values) {
return new DataStreamSource<>(context, new CollectionSourceFunction<>(values));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy