Class DeltaIterationBase<ST,​WT>

  • All Implemented Interfaces:
    IterationOperator, Visitable<Operator<?>>

    @Internal
    public class DeltaIterationBase<ST,​WT>
    extends DualInputOperator<ST,​WT,​ST,​AbstractRichFunction>
    implements IterationOperator
    A DeltaIteration is similar to a BulkIterationBase, but maintains state across the individual iteration steps. The state is called the solution set, can be obtained via getSolutionSet(), and be accessed by joining (or CoGrouping) with it. The solution set is updated by producing a delta for it, which is merged into the solution set at the end of each iteration step.

    The delta iteration must be closed by setting a delta for the solution set (setSolutionSetDelta(org.apache.flink.api.common.operators.Operator)) and the new workset (the data set that will be fed back, setNextWorkset(org.apache.flink.api.common.operators.Operator)). The DeltaIteration itself represents the result after the iteration has terminated. Delta iterations terminate when the feed back data set (the workset) is empty. In addition, a maximum number of steps is given as a fall back termination guard.

    Elements in the solution set are uniquely identified by a key. When merging the solution set delta, contained elements with the same key are replaced.

    This class is a subclass of DualInputOperator. The solution set is considered the first input, the workset is considered the second input.

    • Method Detail

      • getSolutionSetKeyFields

        public int[] getSolutionSetKeyFields()
      • setMaximumNumberOfIterations

        public void setMaximumNumberOfIterations​(int maxIterations)
      • getMaximumNumberOfIterations

        public int getMaximumNumberOfIterations()
      • getSolutionSet

        public Operator<ST> getSolutionSet()
        Gets the contract that represents the solution set for the step function.
        Returns:
        The solution set for the step function.
      • getWorkset

        public Operator<WT> getWorkset()
        Gets the contract that represents the workset for the step function.
        Returns:
        The workset for the step function.
      • setNextWorkset

        public void setNextWorkset​(Operator<WT> result)
        Sets the contract of the step function that represents the next workset. This contract is considered one of the two sinks of the step function (the other one being the solution set delta).
        Parameters:
        result - The contract representing the next workset.
      • getNextWorkset

        public Operator<WT> getNextWorkset()
        Gets the contract that has been set as the next workset.
        Returns:
        The contract that has been set as the next workset.
      • setSolutionSetDelta

        public void setSolutionSetDelta​(Operator<ST> delta)
        Sets the contract of the step function that represents the solution set delta. This contract is considered one of the two sinks of the step function (the other one being the next workset).
        Parameters:
        delta - The contract representing the solution set delta.
      • getSolutionSetDelta

        public Operator<ST> getSolutionSetDelta()
        Gets the contract that has been set as the solution set delta.
        Returns:
        The contract that has been set as the solution set delta.
      • getInitialSolutionSet

        public Operator<ST> getInitialSolutionSet()
        Returns the initial solution set input, or null, if none is set.
        Returns:
        The iteration's initial solution set input.
      • getInitialWorkset

        public Operator<WT> getInitialWorkset()
        Returns the initial workset input, or null, if none is set.
        Returns:
        The iteration's workset input.
      • setInitialSolutionSet

        public void setInitialSolutionSet​(Operator<ST> input)
        Sets the given input as the initial solution set.
        Parameters:
        input - The contract to set the initial solution set.
      • setInitialWorkset

        public void setInitialWorkset​(Operator<WT> input)
        Sets the given input as the initial workset.
        Parameters:
        input - The contract to set as the initial workset.
      • setSolutionSetUnManaged

        public void setSolutionSetUnManaged​(boolean solutionSetUnManaged)
        Sets whether to keep the solution set in managed memory (safe against heap exhaustion) or unmanaged memory (objects on heap).
        Parameters:
        solutionSetUnManaged - True to keep the solution set in unmanaged memory, false to keep it in managed memory.
        See Also:
        isSolutionSetUnManaged()
      • isSolutionSetUnManaged

        public boolean isSolutionSetUnManaged()
        gets whether the solution set is in managed or unmanaged memory.
        Returns:
        True, if the solution set is in unmanaged memory (object heap), false if in managed memory.
        See Also:
        setSolutionSetUnManaged(boolean)