@Internal public abstract class TupleComparatorBase<T> extends CompositeTypeComparator<T> implements Serializable
Modifier and Type | Field and Description |
---|---|
protected TypeComparator[] |
comparators
comparators for the key fields, in the same order as the key fields
|
protected Object[] |
deserializedFields1 |
protected Object[] |
deserializedFields2 |
static int[] |
HASH_SALT
A sequence of prime numbers to be used for salting the computed hash values.
|
protected boolean |
invertNormKey |
protected int[] |
keyPositions
key positions describe which fields are keys in what order
|
protected int |
normalizableKeyPrefixLen |
protected int[] |
normalizedKeyLengths |
protected int |
numLeadingNormalizableKeys |
protected TypeSerializer[] |
serializers
serializers to deserialize the first n fields for comparison
|
Modifier | Constructor and Description |
---|---|
|
TupleComparatorBase(int[] keyPositions,
TypeComparator<?>[] comparators,
TypeSerializer<?>[] serializers) |
protected |
TupleComparatorBase(TupleComparatorBase<T> toClone) |
Modifier and Type | Method and Description |
---|---|
int |
compareSerialized(DataInputView firstSource,
DataInputView secondSource)
Compares two records in serialized form.
|
int |
compareToReference(TypeComparator<T> referencedComparator)
This method compares the element that has been set as reference in this type accessor, to the
element set as reference in the given type accessor.
|
void |
getFlatComparator(List<TypeComparator> flatComparators) |
protected int[] |
getKeyPositions() |
int |
getNormalizeKeyLen()
Gets the number of bytes that the normalized key would maximally take.
|
protected void |
instantiateDeserializationUtils() |
boolean |
invertNormalizedKey()
Flag whether normalized key comparisons should be inverted key should be interpreted
inverted, i.e.
|
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.
|
protected void |
privateDuplicate(TupleComparatorBase<T> toClone) |
T |
readWithKeyDenormalization(T reuse,
DataInputView source)
Reads the record back while de-normalizing the key fields.
|
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.
|
void |
writeWithKeyNormalization(T record,
DataOutputView target)
Writes the record in such a fashion that all keys are normalizing and at the beginning of the serialized data.
|
getFlatComparators
compare, compareAgainstReference, duplicate, equalToReference, extractKeys, hash, putNormalizedKey, setReference, supportsCompareAgainstReference
protected int[] keyPositions
protected TypeComparator[] comparators
protected int[] normalizedKeyLengths
protected int numLeadingNormalizableKeys
protected int normalizableKeyPrefixLen
protected boolean invertNormKey
protected TypeSerializer[] serializers
protected transient Object[] deserializedFields1
protected transient Object[] deserializedFields2
public static final int[] HASH_SALT
public TupleComparatorBase(int[] keyPositions, TypeComparator<?>[] comparators, TypeSerializer<?>[] serializers)
protected TupleComparatorBase(TupleComparatorBase<T> toClone)
protected void privateDuplicate(TupleComparatorBase<T> toClone)
protected int[] getKeyPositions()
public void getFlatComparator(List<TypeComparator> flatComparators)
getFlatComparator
in class CompositeTypeComparator<T>
public int compareToReference(TypeComparator<T> referencedComparator)
TypeComparator
e1
and e2
via a comparator, this method can be used the
following way.
E e1 = ...;
E e2 = ...;
TypeComparator<E> acc1 = ...;
TypeComparator<E> acc2 = ...;
acc1.setReference(e1);
acc2.setReference(e2);
int comp = acc1.compareToReference(acc2);
The rational behind this method is that elements are typically compared using certain features that
are extracted from them, (such de-serializing as a subset of fields). When setting the
reference, this extraction happens. The extraction needs happen only once per element,
even though an element is typically compared to many other elements when establishing a
sorted order. The actual comparison performed by this method may be very cheap, as it
happens on the extracted features.compareToReference
in class TypeComparator<T>
referencedComparator
- The type accessors where the element for comparison has been set
as reference.referencedAccessors
is smaller
than the reference value of this type accessor; a value greater than zero, if it is larger;
zero, if both are equal.TypeComparator.setReference(Object)
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException
TypeComparator
Comparator.compare(Object, Object)
.
This method may de-serialize the records or compare them directly based on their binary representation.
compareSerialized
in class TypeComparator<T>
firstSource
- The input view containing the first record.secondSource
- The input view containing the second record.Comparator.compare(Object, Object)
.IOException
- Thrown, if any of the input views raised an exception when reading the records.Comparator.compare(Object, Object)
public boolean supportsNormalizedKey()
TypeComparator
supportsNormalizedKey
in class TypeComparator<T>
public int getNormalizeKeyLen()
TypeComparator
Integer
.MAX_VALUE is interpreted as infinite.getNormalizeKeyLen
in class TypeComparator<T>
public boolean isNormalizedKeyPrefixOnly(int keyBytes)
TypeComparator
isNormalizedKeyPrefixOnly
in class TypeComparator<T>
public boolean invertNormalizedKey()
TypeComparator
invertNormalizedKey
in class TypeComparator<T>
public boolean supportsSerializationWithKeyNormalization()
TypeComparator
supportsSerializationWithKeyNormalization
in class TypeComparator<T>
public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException
TypeComparator
#supportsSerializationWithKeyNormalization()
allows to check that.writeWithKeyNormalization
in class TypeComparator<T>
record
- The record object into which to read the record data.target
- The stream to which to write the data,IOException
TypeComparator.supportsSerializationWithKeyNormalization()
,
TypeComparator.readWithKeyDenormalization(Object, DataInputView)
,
NormalizableKey.copyNormalizedKey(MemorySegment, int, int)
public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException
TypeComparator
#supportsSerializationWithKeyNormalization()
method.readWithKeyDenormalization
in class TypeComparator<T>
reuse
- The reuse object into which to read the record data.source
- The stream from which to read the data,IOException
TypeComparator.supportsSerializationWithKeyNormalization()
,
TypeComparator.writeWithKeyNormalization(Object, DataOutputView)
,
NormalizableKey.copyNormalizedKey(MemorySegment, int, int)
protected final void instantiateDeserializationUtils()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.