Class KeyGroupRange

java.lang.Object
org.apache.flink.runtime.state.KeyGroupRange
All Implemented Interfaces:
Serializable, Iterable<Integer>, KeyGroupsList

public class KeyGroupRange extends Object implements KeyGroupsList, Serializable
This class defines a range of key-group indexes. Key-groups are the granularity into which the keyspace of a job is partitioned for keyed state-handling in state backends. The boundaries of the range are inclusive.
See Also:
  • Field Details

    • EMPTY_KEY_GROUP_RANGE

      public static final KeyGroupRange EMPTY_KEY_GROUP_RANGE
      The empty key-group
  • Constructor Details

    • KeyGroupRange

      public KeyGroupRange(int startKeyGroup, int endKeyGroup)
      Defines the range [startKeyGroup, endKeyGroup]
      Parameters:
      startKeyGroup - start of the range (inclusive)
      endKeyGroup - end of the range (inclusive)
  • Method Details

    • contains

      public boolean contains(int keyGroup)
      Checks whether or not a single key-group is contained in the range.
      Specified by:
      contains in interface KeyGroupsList
      Parameters:
      keyGroup - Key-group to check for inclusion.
      Returns:
      True, only if the key-group is in the range.
    • getIntersection

      public KeyGroupRange getIntersection(KeyGroupRange other)
      Create a range that represent the intersection between this range and the given range.
      Parameters:
      other - A KeyGroupRange to intersect.
      Returns:
      Key-group range that is the intersection between this and the given key-group range.
    • getNumberOfKeyGroups

      public int getNumberOfKeyGroups()
      Description copied from interface: KeyGroupsList
      Returns the number of key group ids in the list.
      Specified by:
      getNumberOfKeyGroups in interface KeyGroupsList
      Returns:
      The number of key-groups in the range
    • getStartKeyGroup

      public int getStartKeyGroup()
      Returns:
      The first key-group in the range.
    • getEndKeyGroup

      public int getEndKeyGroup()
      Returns:
      The last key-group in the range.
    • getKeyGroupId

      public int getKeyGroupId(int idx)
      Description copied from interface: KeyGroupsList
      Returns the id of the keygroup at the given index, where index in interval [0, KeyGroupsList.getNumberOfKeyGroups()[.
      Specified by:
      getKeyGroupId in interface KeyGroupsList
      Parameters:
      idx - the index into the list
      Returns:
      key group id at the given index
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • prettyPrintInterval

      public String prettyPrintInterval()
    • iterator

      public Iterator<Integer> iterator()
      Specified by:
      iterator in interface Iterable<Integer>
    • of

      public static KeyGroupRange of(int startKeyGroup, int endKeyGroup)
      Factory method that also handles creation of empty key-groups.
      Parameters:
      startKeyGroup - start of the range (inclusive)
      endKeyGroup - end of the range (inclusive)
      Returns:
      the key-group from start to end or an empty key-group range.