Class BigDecComparator
- java.lang.Object
-
- org.apache.flink.api.common.typeutils.TypeComparator<T>
-
- org.apache.flink.api.common.typeutils.base.BasicTypeComparator<BigDecimal>
-
- org.apache.flink.api.common.typeutils.base.BigDecComparator
-
- All Implemented Interfaces:
Serializable
@Internal public final class BigDecComparator extends BasicTypeComparator<BigDecimal>
Comparator for comparing BigDecimal values. Does not support null values.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.flink.api.common.typeutils.base.BasicTypeComparator
ascendingComparison
-
-
Constructor Summary
Constructors Constructor Description BigDecComparator(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.BigDecComparator
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(BigDecimal record, MemorySegment target, int offset, int len)
Adds a normalized key containing a normalized order of magnitude of the given record. 2 bits determine the sign (negative, zero, positive), 33 bits determine the magnitude.boolean
supportsNormalizedKey()
Checks whether the data type supports the creation of a normalized key for comparison.boolean
supportsSerializationWithKeyNormalization()
Check whether this comparator supports to serialize the record in a format that replaces its keys by a normalized key.-
Methods inherited from class org.apache.flink.api.common.typeutils.base.BasicTypeComparator
compare, compareToReference, equalToReference, extractKeys, getFlatComparators, hash, invertNormalizedKey, readWithKeyDenormalization, setReference, 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<BigDecimal>
- 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<BigDecimal>
- Returns:
- True, if the data type supports the creation of a normalized key for comparison, false otherwise.
-
supportsSerializationWithKeyNormalization
public boolean supportsSerializationWithKeyNormalization()
Description copied from class:TypeComparator
Check whether this comparator supports to serialize the record in a format that replaces its keys by a normalized key.- Overrides:
supportsSerializationWithKeyNormalization
in classBasicTypeComparator<BigDecimal>
- Returns:
- True, if the comparator supports that specific form of serialization, false if not.
-
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<BigDecimal>
- 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<BigDecimal>
- Returns:
- True, if the given number of bytes is only a prefix, false otherwise.
-
putNormalizedKey
public void putNormalizedKey(BigDecimal record, MemorySegment target, int offset, int len)
Adds a normalized key containing a normalized order of magnitude of the given record. 2 bits determine the sign (negative, zero, positive), 33 bits determine the magnitude. This method adds at most 5 bytes that contain information.- Specified by:
putNormalizedKey
in classTypeComparator<BigDecimal>
- Parameters:
record
- 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.len
- The number of bytes to be written exactly.- See Also:
NormalizableKey.copyNormalizedKey(MemorySegment, int, int)
-
duplicate
public BigDecComparator 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<BigDecimal>
- Returns:
- A deep copy of this comparator instance.
-
-