Class 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 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 this StreamRecord
        timestamp - 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 StreamRecord
        timestamp - 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object