Interface ValueState<T>

Type Parameters:
T - The type of value being stored.
All Superinterfaces:
ReadableState<@Nullable T>, State

public interface ValueState<T> extends ReadableState<@Nullable T>, State
A ReadableState cell containing a single value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Read the current value, blocking until it is available.
    Indicate that the value will be read later.
    void
    write(T input)
    Set the value.

    Methods inherited from interface org.apache.beam.sdk.state.State

    clear
  • Method Details

    • write

      void write(T input)
      Set the value.
    • read

      @Nullable T read()
      Read the current value, blocking until it is available.

      If there will be many calls to ReadableState.read() for different state in short succession, you should first call ReadableState.readLater() for all of them so the reads can potentially be batched (depending on the underlying implementation}.

      The returned object should be independent of the underlying state. Any direct modification of the returned object should not modify state without going through the appropriate state interface, and modification to the state should not be mirrored in the returned object.

      Note that null will be returned if the value has never been written.

      Specified by:
      read in interface ReadableState<T>
    • readLater

      ValueState<T> readLater()
      Description copied from interface: ReadableState
      Indicate that the value will be read later.

      This allows an implementation to start an asynchronous prefetch or to include this state in the next batch of reads.

      Specified by:
      readLater in interface ReadableState<T>
      Returns:
      this for convenient chaining