Class StreamRecord<T>
- java.lang.Object
-
- org.apache.flink.streaming.runtime.streamrecord.StreamElement
-
- org.apache.flink.streaming.runtime.streamrecord.StreamRecord<T>
-
- Type Parameters:
T- The type encapsulated with the stream record.
@Internal public final class StreamRecord<T> extends StreamElement
One value in a data stream. This stores the value and an optional associated timestamp.
-
-
Constructor Summary
Constructors Constructor Description StreamRecord(T value)Creates a new StreamRecord.StreamRecord(T value, long timestamp)Creates a new StreamRecord wrapping the given value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamRecord<T>copy(T valueCopy)Creates a copy of this stream record.voidcopyTo(T valueCopy, StreamRecord<T> target)Copies this record into the new stream record.booleanequals(Object o)voideraseTimestamp()longgetTimestamp()Returns the timestamp associated with this stream value in milliseconds.TgetValue()Returns the value wrapped in this stream value.inthashCode()booleanhasTimestamp()Checks whether this record has a timestamp.<X> StreamRecord<X>replace(X element)Replace the currently stored value by the given new value.<X> StreamRecord<X>replace(X value, long timestamp)Replace the currently stored value by the given new value and the currently stored timestamp with the new timestamp.voidsetTimestamp(long timestamp)StringtoString()-
Methods inherited from class org.apache.flink.streaming.runtime.streamrecord.StreamElement
asLatencyMarker, asRecord, asRecordAttributes, asWatermark, asWatermarkStatus, isLatencyMarker, isRecord, isRecordAttributes, isWatermark, isWatermarkStatus
-
-
-
-
Constructor Detail
-
StreamRecord
public StreamRecord(T value)
Creates a new StreamRecord. The record does not have a timestamp.
-
StreamRecord
public StreamRecord(T value, long timestamp)
Creates a new StreamRecord wrapping the given value. The timestamp is set to the given timestamp.- Parameters:
value- The value to wrap in thisStreamRecordtimestamp- The timestamp in milliseconds
-
-
Method Detail
-
getValue
public T getValue()
Returns the value wrapped in this stream value.
-
getTimestamp
public long getTimestamp()
Returns the timestamp associated with this stream value in milliseconds.
-
hasTimestamp
public boolean hasTimestamp()
Checks whether this record has a timestamp.- Returns:
- True if the record has a timestamp, false if not.
-
replace
public <X> StreamRecord<X> replace(X element)
Replace the currently stored value by the given new value. This returns a StreamElement with the generic type parameter that matches the new value while keeping the old timestamp.- Parameters:
element- Element to set in this stream value- Returns:
- Returns the StreamElement with replaced value
-
replace
public <X> StreamRecord<X> replace(X value, long timestamp)
Replace the currently stored value by the given new value and the currently stored timestamp with the new timestamp. This returns a StreamElement with the generic type parameter that matches the new value.- Parameters:
value- The new value to wrap in this StreamRecordtimestamp- The new timestamp in milliseconds- Returns:
- Returns the StreamElement with replaced value
-
setTimestamp
public void setTimestamp(long timestamp)
-
eraseTimestamp
public void eraseTimestamp()
-
copy
public StreamRecord<T> copy(T valueCopy)
Creates a copy of this stream record. Uses the copied value as the value for the new record, i.e., only copies timestamp fields.
-
copyTo
public void copyTo(T valueCopy, StreamRecord<T> target)
Copies this record into the new stream record. Uses the copied value as the value for the new record, i.e., only copies timestamp fields.
-
-