Class StreamingTranslator.StreamOutput<O>

  • Type Parameters:
    O - the output type
    Enclosing interface:
    StreamingTranslator<I,​O>

    public abstract static class StreamingTranslator.StreamOutput<O>
    extends java.lang.Object
    A StreamingTranslator.StreamOutput represents a streamable output type (either iterative or asynchronous).

    There are two modes for the StreamingTranslator.StreamOutput. When using it, you must choose one of the modes and can only access it once. Any other usage including trying both modes or trying one mode twice will result in an IllegalStateException.

    The first mode is the iterative mode which can be used by calling getIterativeOutput(), it returns a result that has an internal iterate method. When calling the iterating method, it will compute an additional part of the output.

    The second mode is asynchronous mode. Here, you can produce a mutable output object by calling getAsyncOutput(). Then, calling computeAsyncOutput() will synchronously compute the results and deposit them into the prepared output. This method works best with manual threading where the worker can return the template result to another thread and then continue to compute it.

    • Constructor Detail

      • StreamOutput

        public StreamOutput()
    • Method Detail

      • getAsyncOutput

        public final O getAsyncOutput()
        Returns a template object to be used with the async output.

        This should only be an empty data structure until computeAsyncOutput() is called.

        Returns:
        a template object to be used with the async output
      • computeAsyncOutput

        public final void computeAsyncOutput()
        Computes the actual value and stores it in the object returned earlier by getAsyncOutput().
      • computeAsyncOutputInternal

        protected abstract void computeAsyncOutputInternal​(O output)
        Performs the internal implementation of computeAsyncOutput().
        Parameters:
        output - the output object returned by the earlier call to getAsyncOutput().
      • getIterativeOutput

        public final O getIterativeOutput()
        Returns an iterative streamable output.
        Returns:
        an iterative streamable output