Class TestStream<T>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.PTransform<PBegin,PCollection<T>>
-
- org.apache.beam.sdk.testing.TestStream<T>
-
- All Implemented Interfaces:
java.io.Serializable
,HasDisplayData
public final class TestStream<T> extends PTransform<PBegin,PCollection<T>>
A testing input that generates an unboundedPCollection
of elements, advancing the watermark and processing time as elements are emitted. After all of the specified elements are emitted, ceases to produce output.Each call to a
TestStream.Builder
method will only be reflected in the state of thePipeline
after each method before it has completed and no more progress can be made by thePipeline
. APipelineRunner
must ensure that no more progress can be made in thePipeline
before advancing the state of theTestStream
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TestStream.Builder<T>
An incompleteTestStream
.static class
TestStream.ElementEvent<T>
ATestStream.Event
that produces elements.static interface
TestStream.Event<T>
An event in aTestStream
.static class
TestStream.EventType
The types ofTestStream.Event
that are supported byTestStream
.static class
TestStream.ProcessingTimeEvent<T>
ATestStream.Event
that advances the processing time clock.static class
TestStream.TestStreamCoder<T>
Coder forTestStream
.static class
TestStream.WatermarkEvent<T>
ATestStream.Event
that advances the watermark.
-
Field Summary
-
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
name, resourceHints
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> TestStream.Builder<T>
create(Coder<T> coder)
Create a newTestStream.Builder
with no elements and watermark equal toBoundedWindow.TIMESTAMP_MIN_VALUE
.static TestStream.Builder<Row>
create(Schema schema)
static <T> TestStream.Builder<T>
create(Schema schema, TypeDescriptor<T> typeDescriptor, SerializableFunction<T,Row> toRowFunction, SerializableFunction<Row,T> fromRowFunction)
boolean
equals(@Nullable java.lang.Object other)
PCollection<T>
expand(PBegin input)
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.static <T> TestStream<T>
fromRawEvents(Coder<T> coder, java.util.List<TestStream.Event<T>> events)
For internal use only.java.util.List<TestStream.Event<T>>
getEvents()
Returns the sequence ofEvents
in thisTestStream
.Coder<T>
getValueCoder()
int
hashCode()
-
Methods inherited from class org.apache.beam.sdk.transforms.PTransform
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setResourceHints, toString, validate, validate
-
-
-
-
Method Detail
-
create
public static <T> TestStream.Builder<T> create(Coder<T> coder)
Create a newTestStream.Builder
with no elements and watermark equal toBoundedWindow.TIMESTAMP_MIN_VALUE
.
-
create
@Experimental(SCHEMAS) public static TestStream.Builder<Row> create(Schema schema)
-
create
@Experimental(SCHEMAS) public static <T> TestStream.Builder<T> create(Schema schema, TypeDescriptor<T> typeDescriptor, SerializableFunction<T,Row> toRowFunction, SerializableFunction<Row,T> fromRowFunction)
-
expand
public PCollection<T> expand(PBegin input)
Description copied from class:PTransform
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
method.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expand
in classPTransform<PBegin,PCollection<T>>
-
getEvents
public java.util.List<TestStream.Event<T>> getEvents()
-
fromRawEvents
@Internal public static <T> TestStream<T> fromRawEvents(Coder<T> coder, java.util.List<TestStream.Event<T>> events)
For internal use only. No backwards-compatibility guarantees.Builder a test stream directly from events. No validation is performed on watermark monotonicity, etc. This is assumed to be a previously-serialized
TestStream
transform that is correct by construction.
-
equals
public boolean equals(@Nullable java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-