Class InputSelection

  • All Implemented Interfaces:
    Serializable

    @PublicEvolving
    public final class InputSelection
    extends Object
    implements Serializable
    Describe the input selection that stream operators want to read records.
    See Also:
    Serialized Form
    • Field Detail

      • ALL

        public static final InputSelection ALL
        The InputSelection instance which indicates to select all inputs.
      • FIRST

        public static final InputSelection FIRST
        The InputSelection instance which indicates to select the first input.
      • SECOND

        public static final InputSelection SECOND
        The InputSelection instance which indicates to select the second input.
    • Method Detail

      • getInputMask

        public long getInputMask()
      • isInputSelected

        public boolean isInputSelected​(int inputId)
        Tests if the input specified by inputId is selected.
        Parameters:
        inputId - The input id, see the description of inputId in InputSelection.Builder.select(int).
        Returns:
        true if the input is selected, false otherwise.
      • areAllInputsSelected

        public boolean areAllInputsSelected()
        Tests if all inputs are selected.
        Returns:
        true if the input mask equals -1, false otherwise.
      • fairSelectNextIndexOutOf2

        public int fairSelectNextIndexOutOf2​(int availableInputsMask,
                                             int lastReadInputIndex)
        Fairly select one of the two inputs for reading. When inputMask includes two inputs and both inputs are available, alternately select one of them. Otherwise, select the available one of inputMask, or return NONE_AVAILABLE to indicate no input is selected.

        Note that this supports only two inputs for performance reasons.

        Parameters:
        availableInputsMask - The mask of all available inputs.
        lastReadInputIndex - The index of last read input.
        Returns:
        the index of the input for reading or NONE_AVAILABLE (if inputMask is empty or the inputs in inputMask are unavailable).
      • fairSelectNextIndexOutOf2

        public static int fairSelectNextIndexOutOf2​(int selectionMask,
                                                    int availableInputsMask,
                                                    int lastReadInputIndex)
        Fairly select one of the two inputs for reading. When inputMask includes two inputs and both inputs are available, alternately select one of them. Otherwise, select the available one of inputMask, or return NONE_AVAILABLE to indicate no input is selected.

        Note that this supports only two inputs for performance reasons.

        Parameters:
        selectionMask - The mask of inputs that are selected. Note -1 for this is interpreted as all of the 32 inputs are available.
        availableInputsMask - The mask of all available inputs.
        lastReadInputIndex - The index of last read input.
        Returns:
        the index of the input for reading or NONE_AVAILABLE (if inputMask is empty or the inputs in inputMask are unavailable).
      • fairSelectNextIndex

        public int fairSelectNextIndex​(long availableInputsMask,
                                       int lastReadInputIndex)
        Fairly select one of the available inputs for reading.
        Parameters:
        availableInputsMask - The mask of all available inputs. Note -1 for this is interpreted as all of the 32 inputs are available.
        lastReadInputIndex - The index of last read input.
        Returns:
        the index of the input for reading or NONE_AVAILABLE (if inputMask is empty or the inputs in inputMask are unavailable).
      • fairSelectNextIndex

        public static int fairSelectNextIndex​(long inputMask,
                                              long availableInputsMask,
                                              int lastReadInputIndex)
        Fairly select one of the available inputs for reading.
        Parameters:
        inputMask - The mask of inputs that are selected. Note -1 for this is interpreted as all of the 32 inputs are available.
        availableInputsMask - The mask of all available inputs. Note -1 for this is interpreted as all of the 32 inputs are available.
        lastReadInputIndex - The index of last read input.
        Returns:
        the index of the input for reading or NONE_AVAILABLE (if inputMask is empty or the inputs in inputMask are unavailable).