Class ShortComparator
- java.lang.Object
-
- org.apache.flink.api.common.typeutils.TypeComparator<T>
-
- org.apache.flink.api.common.typeutils.base.BasicTypeComparator<Short>
-
- org.apache.flink.api.common.typeutils.base.ShortComparator
-
- All Implemented Interfaces:
Serializable
@Internal public final class ShortComparator extends BasicTypeComparator<Short>
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.flink.api.common.typeutils.base.BasicTypeComparator
ascendingComparison
-
-
Constructor Summary
Constructors Constructor Description ShortComparator(boolean ascending)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareSerialized(DataInputView firstSource, DataInputView secondSource)
Compares two records in serialized form.ShortComparator
duplicate()
Creates a copy of this class.int
getNormalizeKeyLen()
Gets the number of bytes that the normalized key would maximally take.boolean
isNormalizedKeyPrefixOnly(int keyBytes)
Checks, whether the given number of bytes for a normalized is only a prefix to determine the order of elements of the data type for which this comparator provides the comparison methods.void
putNormalizedKey(Short value, MemorySegment target, int offset, int numBytes)
Writes a normalized key for the given record into the target byte array, starting at the specified position and writing exactly the given number of bytes.boolean
supportsNormalizedKey()
Checks whether the data type supports the creation of a normalized key for comparison.-
Methods inherited from class org.apache.flink.api.common.typeutils.base.BasicTypeComparator
compare, compareToReference, equalToReference, extractKeys, getFlatComparators, hash, invertNormalizedKey, readWithKeyDenormalization, setReference, supportsSerializationWithKeyNormalization, writeWithKeyNormalization
-
Methods inherited from class org.apache.flink.api.common.typeutils.TypeComparator
compareAgainstReference, supportsCompareAgainstReference
-
-
-
-
Method Detail
-
compareSerialized
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException
Description copied from class:TypeComparator
Compares two records in serialized form. The return value indicates the order of the two in the same way as defined byComparator.compare(Object, Object)
.This method may de-serialize the records or compare them directly based on their binary representation.
- Specified by:
compareSerialized
in classTypeComparator<Short>
- Parameters:
firstSource
- The input view containing the first record.secondSource
- The input view containing the second record.- Returns:
- An integer defining the oder among the objects in the same way as
Comparator.compare(Object, Object)
. - Throws:
IOException
- Thrown, if any of the input views raised an exception when reading the records.- See Also:
Comparator.compare(Object, Object)
-
supportsNormalizedKey
public boolean supportsNormalizedKey()
Description copied from class:TypeComparator
Checks whether the data type supports the creation of a normalized key for comparison.- Specified by:
supportsNormalizedKey
in classTypeComparator<Short>
- Returns:
- True, if the data type supports the creation of a normalized key for comparison, false otherwise.
-
getNormalizeKeyLen
public int getNormalizeKeyLen()
Description copied from class:TypeComparator
Gets the number of bytes that the normalized key would maximally take. A value ofInteger
.MAX_VALUE is interpreted as infinite.- Specified by:
getNormalizeKeyLen
in classTypeComparator<Short>
- Returns:
- The number of bytes that the normalized key would maximally take.
-
isNormalizedKeyPrefixOnly
public boolean isNormalizedKeyPrefixOnly(int keyBytes)
Description copied from class:TypeComparator
Checks, whether the given number of bytes for a normalized is only a prefix to determine the order of elements of the data type for which this comparator provides the comparison methods. For example, if the data type is ordered with respect to an integer value it contains, then this method would return true, if the number of key bytes is smaller than four.- Specified by:
isNormalizedKeyPrefixOnly
in classTypeComparator<Short>
- Returns:
- True, if the given number of bytes is only a prefix, false otherwise.
-
putNormalizedKey
public void putNormalizedKey(Short value, MemorySegment target, int offset, int numBytes)
Description copied from class:TypeComparator
Writes a normalized key for the given record into the target byte array, starting at the specified position and writing exactly the given number of bytes. Note that the comparison of the bytes is treating the bytes as unsigned bytes:int byteI = bytes[i] & 0xFF;
If the meaningful part of the normalized key takes less than the given number of bytes, then it must be padded. Padding is typically required for variable length data types, such as strings. The padding uses a special character, either
0
or0xff
, depending on whether shorter values are sorted to the beginning or the end.This method is similar to
NormalizableKey.copyNormalizedKey(MemorySegment, int, int)
. In the case that multiple fields of a record contribute to the normalized key, it is crucial that the fields align on the byte field, i.e. that every field always takes up the exact same number of bytes.- Specified by:
putNormalizedKey
in classTypeComparator<Short>
- Parameters:
value
- The record for which to create the normalized key.target
- The byte array into which to write the normalized key bytes.offset
- The offset in the byte array, where to start writing the normalized key bytes.numBytes
- The number of bytes to be written exactly.- See Also:
NormalizableKey.copyNormalizedKey(MemorySegment, int, int)
-
duplicate
public ShortComparator duplicate()
Description copied from class:TypeComparator
Creates a copy of this class. The copy must be deep such that no state set in the copy affects this instance of the comparator class.- Specified by:
duplicate
in classTypeComparator<Short>
- Returns:
- A deep copy of this comparator instance.
-
-