org.apache.flink.types.KeyFieldOutOfBoundsException Java Examples

The following examples show how to use org.apache.flink.types.KeyFieldOutOfBoundsException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void setReference(T toCompare) {
	int i = 0;
	try {
		for (; i < this.keyPositions.length; i++) {
			this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
		}
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #2
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@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]);
	}
}
 
Example #3
Source File: TupleComparatorBase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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]);
	}
}
 
Example #4
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equalToReference(Row candidate) {
	int i = 0;
	try {
		for (; i < keyPositions.length; i++) {
			TypeComparator<Object> comparator = comparators[i];
			Object element = candidate.getField(keyPositions[i]);   // element can be null
			// check if reference is not equal
			if (!comparator.equalToReference(element)) {
				return false;
			}
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
	return true;
}
 
Example #5
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(Row first, Row second) {
	int i = 0;
	try {
		for (; i < keyPositions.length; i++) {
			int keyPos = keyPositions[i];
			TypeComparator<Object> comparator = comparators[i];
			Object firstElement = first.getField(keyPos);   // element can be null
			Object secondElement = second.getField(keyPos); // element can be null

			int cmp = comparator.compare(firstElement, secondElement);
			if (cmp != 0) {
				return cmp;
			}
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
	return 0;
}
 
Example #7
Source File: RecordComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public int hash(Record object) {
	int i = 0;
	try {
		int code = 0;
		for (; i < this.keyFields.length; i++) {
			code ^= object.getField(this.keyFields[i], this.transientKeyHolders[i]).hashCode();
			code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
		}
		return code;
	}
	catch (NullPointerException npex) {
		throw new NullKeyFieldException(this.keyFields[i]);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(this.keyFields[i]);
	}
}
 
Example #8
Source File: TupleComparatorBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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]);
	}
}
 
Example #9
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public int hash(T value) {
	int i = 0;
	try {
		int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
		for (i = 1; i < this.keyPositions.length; i++) {
			code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
			code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
		}
		return code;
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #10
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public int hash(Row record) {
	int code = 0;
	int i = 0;

	try {
		for (; i < keyPositions.length; i++) {
			code *= TupleComparatorBase.HASH_SALT[i & 0x1F];
			Object element = record.getField(keyPositions[i]); // element can be null
			code += comparators[i].hash(element);
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}

	return code;
}
 
Example #11
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean equalToReference(T candidate) {
	int i = 0;
	try {
		for (; i < this.keyPositions.length; i++) {
			if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
				return false;
			}
		}
		return true;
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #12
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@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]);
	}
}
 
Example #13
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public int hash(Row record) {
	int code = 0;
	int i = 0;

	try {
		for (; i < keyPositions.length; i++) {
			code *= TupleComparatorBase.HASH_SALT[i & 0x1F];
			Object element = record.getField(keyPositions[i]); // element can be null
			code += comparators[i].hash(element);
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}

	return code;
}
 
Example #14
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equalToReference(Row candidate) {
	int i = 0;
	try {
		for (; i < keyPositions.length; i++) {
			TypeComparator<Object> comparator = comparators[i];
			Object element = candidate.getField(keyPositions[i]);   // element can be null
			// check if reference is not equal
			if (!comparator.equalToReference(element)) {
				return false;
			}
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
	return true;
}
 
Example #15
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #16
Source File: RowComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(Row first, Row second) {
	int i = 0;
	try {
		for (; i < keyPositions.length; i++) {
			int keyPos = keyPositions[i];
			TypeComparator<Object> comparator = comparators[i];
			Object firstElement = first.getField(keyPos);   // element can be null
			Object secondElement = second.getField(keyPos); // element can be null

			int cmp = comparator.compare(firstElement, secondElement);
			if (cmp != 0) {
				return cmp;
			}
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
	return 0;
}
 
Example #17
Source File: RecordComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public int hash(Record object) {
	int i = 0;
	try {
		int code = 0;
		for (; i < this.keyFields.length; i++) {
			code ^= object.getField(this.keyFields[i], this.transientKeyHolders[i]).hashCode();
			code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
		}
		return code;
	}
	catch (NullPointerException npex) {
		throw new NullKeyFieldException(this.keyFields[i]);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(this.keyFields[i]);
	}
}
 
Example #18
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void setReference(T toCompare) {
	int i = 0;
	try {
		for (; i < this.keyPositions.length; i++) {
			this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
		}
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #19
Source File: TupleComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public int hash(T value) {
	int i = 0;
	try {
		int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
		for (i = 1; i < this.keyPositions.length; i++) {
			code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
			code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
		}
		return code;
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #20
Source File: TupleComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void setReference(T toCompare) {
	int i = 0;
	try {
		for (; i < this.keyPositions.length; i++) {
			this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
		}
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #21
Source File: TupleComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean equalToReference(T candidate) {
	int i = 0;
	try {
		for (; i < this.keyPositions.length; i++) {
			if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
				return false;
			}
		}
		return true;
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #22
Source File: TupleComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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]);
	}
}
 
Example #23
Source File: RowComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public int hash(Row record) {
	int code = 0;
	int i = 0;

	try {
		for (; i < keyPositions.length; i++) {
			code *= TupleComparatorBase.HASH_SALT[i & 0x1F];
			Object element = record.getField(keyPositions[i]); // element can be null
			code += comparators[i].hash(element);
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}

	return code;
}
 
Example #24
Source File: RowComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equalToReference(Row candidate) {
	int i = 0;
	try {
		for (; i < keyPositions.length; i++) {
			TypeComparator<Object> comparator = comparators[i];
			Object element = candidate.getField(keyPositions[i]);   // element can be null
			// check if reference is not equal
			if (!comparator.equalToReference(element)) {
				return false;
			}
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
	return true;
}
 
Example #25
Source File: RowComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #26
Source File: RowComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(Row first, Row second) {
	int i = 0;
	try {
		for (; i < keyPositions.length; i++) {
			int keyPos = keyPositions[i];
			TypeComparator<Object> comparator = comparators[i];
			Object firstElement = first.getField(keyPos);   // element can be null
			Object secondElement = second.getField(keyPos); // element can be null

			int cmp = comparator.compare(firstElement, secondElement);
			if (cmp != 0) {
				return cmp;
			}
		}
	} catch (IndexOutOfBoundsException e) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
	return 0;
}
 
Example #27
Source File: RecordComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public int hash(Record object) {
	int i = 0;
	try {
		int code = 0;
		for (; i < this.keyFields.length; i++) {
			code ^= object.getField(this.keyFields[i], this.transientKeyHolders[i]).hashCode();
			code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
		}
		return code;
	}
	catch (NullPointerException npex) {
		throw new NullKeyFieldException(this.keyFields[i]);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(this.keyFields[i]);
	}
}
 
Example #28
Source File: TupleComparatorBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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]);
	}
}
 
Example #29
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public int hash(T value) {
	int i = 0;
	try {
		int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
		for (i = 1; i < this.keyPositions.length; i++) {
			code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
			code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
		}
		return code;
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}
 
Example #30
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean equalToReference(T candidate) {
	int i = 0;
	try {
		for (; i < this.keyPositions.length; i++) {
			if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
				return false;
			}
		}
		return true;
	}
	catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	}
	catch (IndexOutOfBoundsException iobex) {
		throw new KeyFieldOutOfBoundsException(keyPositions[i]);
	}
}