Package org.apache.flink.runtime.util
Class NonReusingKeyGroupedIterator<E>
- java.lang.Object
-
- org.apache.flink.runtime.util.NonReusingKeyGroupedIterator<E>
-
- All Implemented Interfaces:
KeyGroupedIterator<E>
public final class NonReusingKeyGroupedIterator<E> extends Object implements KeyGroupedIterator<E>
The key grouped iterator returns a key and all values that share the same key.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
NonReusingKeyGroupedIterator.ValuesIterator
-
Constructor Summary
Constructors Constructor Description NonReusingKeyGroupedIterator(MutableObjectIterator<E> iterator, TypeComparator<E> comparator)
Initializes the KeyGroupedIterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeComparator<E>
getComparatorWithCurrentReference()
E
getCurrent()
NonReusingKeyGroupedIterator.ValuesIterator
getValues()
Returns an iterator over all values that belong to the current key.boolean
nextKey()
Moves the iterator to the next key.
-
-
-
Constructor Detail
-
NonReusingKeyGroupedIterator
public NonReusingKeyGroupedIterator(MutableObjectIterator<E> iterator, TypeComparator<E> comparator)
Initializes the KeyGroupedIterator. It requires an iterator which returns its result sorted by the key fields.- Parameters:
iterator
- An iterator over records, which are sorted by the key fields, in any order.comparator
- The comparator for the data type iterated over.
-
-
Method Detail
-
nextKey
public boolean nextKey() throws IOException
Moves the iterator to the next key. This method may skip any values that have not yet been returned by the iterator created by thegetValues()
method. Hence, if called multiple times it "removes" key groups.- Specified by:
nextKey
in interfaceKeyGroupedIterator<E>
- Returns:
- true, if the input iterator has an other group of records with the same key.
- Throws:
IOException
-
getCurrent
public E getCurrent()
- Specified by:
getCurrent
in interfaceKeyGroupedIterator<E>
-
getComparatorWithCurrentReference
public TypeComparator<E> getComparatorWithCurrentReference()
-
getValues
public NonReusingKeyGroupedIterator.ValuesIterator getValues()
Returns an iterator over all values that belong to the current key. The iterator is initiallynull
(before the first call tonextKey()
and after all keys are consumed. In general, this method returns always a non-null value, if a previous call tonextKey()
returntrue
.- Specified by:
getValues
in interfaceKeyGroupedIterator<E>
- Returns:
- Iterator over all values that belong to the current key.
-
-