Package org.apache.flink.runtime.state
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static KeyGroupRange
EMPTY_KEY_GROUP_RANGE
The empty key-group
-
Constructor Summary
Constructors Constructor Description KeyGroupRange(int startKeyGroup, int endKeyGroup)
Defines the range [startKeyGroup, endKeyGroup]
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(int keyGroup)
Checks whether or not a single key-group is contained in the range.boolean
equals(Object o)
int
getEndKeyGroup()
KeyGroupRange
getIntersection(KeyGroupRange other)
Create a range that represent the intersection between this range and the given range.int
getKeyGroupId(int idx)
Returns the id of the keygroup at the given index, where index in interval [0,KeyGroupsList.getNumberOfKeyGroups()
[.int
getNumberOfKeyGroups()
Returns the number of key group ids in the list.int
getStartKeyGroup()
int
hashCode()
Iterator<Integer>
iterator()
static KeyGroupRange
of(int startKeyGroup, int endKeyGroup)
Factory method that also handles creation of empty key-groups.String
prettyPrintInterval()
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
EMPTY_KEY_GROUP_RANGE
public static final KeyGroupRange EMPTY_KEY_GROUP_RANGE
The empty key-group
-
-
Method Detail
-
contains
public boolean contains(int keyGroup)
Checks whether or not a single key-group is contained in the range.- Specified by:
contains
in interfaceKeyGroupsList
- 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 interfaceKeyGroupsList
- 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 interfaceKeyGroupsList
- Parameters:
idx
- the index into the list- Returns:
- key group id at the given index
-
prettyPrintInterval
public String prettyPrintInterval()
-
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.
-
-