use of org.apache.flink.types.KeyFieldOutOfBoundsException in project flink by apache.
the class RowComparator method hash.
@Override
public int hash(Row record) {
int code = 0;
int i = 0;
try {
for (; i < keyPositions.length; i++) {
code *= TupleComparatorBase.HASH_SALT[i & 0x1F];
// element can be null
Object element = record.getField(keyPositions[i]);
code += comparators[i].hash(element);
}
} catch (IndexOutOfBoundsException e) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
return code;
}
use of org.apache.flink.types.KeyFieldOutOfBoundsException in project flink by apache.
the class TupleComparator method compare.
@SuppressWarnings("unchecked")
@Override
public int compare(T first, T second) {
int i = 0;
try {
for (; i < keyPositions.length; i++) {
int keyPos = keyPositions[i];
int cmp = comparators[i].compare(first.getFieldNotNull(keyPos), second.getFieldNotNull(keyPos));
if (cmp != 0) {
return cmp;
}
}
return 0;
} catch (NullFieldException nfex) {
throw new NullKeyFieldException(nfex);
} catch (IndexOutOfBoundsException iobex) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
}
use of org.apache.flink.types.KeyFieldOutOfBoundsException in project flink by apache.
the class TupleComparatorBase method compareToReference.
// --------------------------------------------------------------------------------------------
// Comparator Methods
// --------------------------------------------------------------------------------------------
@Override
public int compareToReference(TypeComparator<T> referencedComparator) {
TupleComparatorBase<T> other = (TupleComparatorBase<T>) referencedComparator;
int i = 0;
try {
for (; i < this.keyPositions.length; i++) {
@SuppressWarnings("unchecked") int cmp = this.comparators[i].compareToReference(other.comparators[i]);
if (cmp != 0) {
return cmp;
}
}
return 0;
} catch (NullPointerException npex) {
throw new NullKeyFieldException(keyPositions[i]);
} catch (IndexOutOfBoundsException iobex) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
}
use of org.apache.flink.types.KeyFieldOutOfBoundsException in project flink by apache.
the class RowComparator method compareToReference.
@Override
public int compareToReference(TypeComparator<Row> referencedComparator) {
RowComparator other = (RowComparator) referencedComparator;
int i = 0;
try {
for (; i < keyPositions.length; i++) {
int cmp = comparators[i].compareToReference(other.comparators[i]);
if (cmp != 0) {
return cmp;
}
}
} catch (IndexOutOfBoundsException e) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
return 0;
}
use of org.apache.flink.types.KeyFieldOutOfBoundsException in project flink by apache.
the class RowComparator method equalToReference.
@Override
public boolean equalToReference(Row candidate) {
int i = 0;
try {
for (; i < keyPositions.length; i++) {
TypeComparator<Object> comparator = comparators[i];
// element can be null
Object element = candidate.getField(keyPositions[i]);
// check if reference is not equal
if (!comparator.equalToReference(element)) {
return false;
}
}
} catch (IndexOutOfBoundsException e) {
throw new KeyFieldOutOfBoundsException(keyPositions[i]);
}
return true;
}
Aggregations