Class SingleRunOperation<Original,​E,​R,​S extends BaseStream<R,​S>,​S2 extends S>

  • Type Parameters:
    Original - original stream type
    E - type of the output of the function
    R - type of the stream entries
    S - type of the stream itself
    All Implemented Interfaces:
    SegmentAwareOperation, TerminalOperation<Original,​E>

    public class SingleRunOperation<Original,​E,​R,​S extends BaseStream<R,​S>,​S2 extends S>
    extends BaseTerminalOperation<Original>
    implements TerminalOperation<Original,​E>
    Runs the provided function once only and returns the result. This is useful for operations that can be performed and its result is still valid even when a segment is lost.
    • Method Detail

      • lostSegment

        public boolean lostSegment​(boolean stopIfLost)
        Description copied from interface: SegmentAwareOperation
        This method will be invoked when the operation is known to be performing on a given set of segments and this node no longer owns 1 or many of them. Returns whether the lost segment affected the results or not. If stopIfLost is true then doneWithOperation will not be invoked as it would normally.
        Specified by:
        lostSegment in interface SegmentAwareOperation
        Parameters:
        stopIfLost - argument to tell the operation that if this segment affects that it should not perform any more operations if possible as all segments have been lost.
        Returns:
        whether or not this operation was affected by the loss of segments
      • performOperation

        public E performOperation()
        Description copied from interface: TerminalOperation
        Actually runs the terminal operation returning the result from the operation
        Specified by:
        performOperation in interface TerminalOperation<Original,​E>
        Returns:
        the value retrieved for the operation
      • getFunction

        public Function<? super S2,​? extends E> getFunction()