org.apache.flink.types.NullFieldException Java Examples

The following examples show how to use org.apache.flink.types.NullFieldException. 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-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 #2
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
	int i = 0;
	try {
		for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
			int len = this.normalizedKeyLengths[i];
			len = numBytes >= len ? len : numBytes;
			this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
			numBytes -= len;
			offset += len;
		}
	} catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	} catch (NullPointerException npex) {
		throw new NullKeyFieldException(this.keyPositions[i]);
	}
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
Source File: TupleComparator.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
	int i = 0;
	try {
		for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
			int len = this.normalizedKeyLengths[i];
			len = numBytes >= len ? len : numBytes;
			this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
			numBytes -= len;
			offset += len;
		}
	} catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	} catch (NullPointerException npex) {
		throw new NullKeyFieldException(this.keyPositions[i]);
	}
}
 
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: TupleComparator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
	int i = 0;
	try {
		for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
			int len = this.normalizedKeyLengths[i];
			len = numBytes >= len ? len : numBytes;
			this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
			numBytes -= len;
			offset += len;
		}
	} catch (NullFieldException nfex) {
		throw new NullKeyFieldException(nfex);
	} catch (NullPointerException npex) {
		throw new NullKeyFieldException(this.keyPositions[i]);
	}
}
 
Example #13
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 #14
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 #15
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 #16
Source File: Tuple2Test.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test(expected = NullFieldException.class)
public void testGetFieldNotNull() {
	Tuple2<String, Integer> tuple = new Tuple2<>("Test case", null);

	Assert.assertEquals("Test case", tuple.getFieldNotNull(0));
	tuple.getFieldNotNull(1);
}
 
Example #17
Source File: Tuple.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
 *
 * @param pos The position of the field, zero indexed.
 * @return The field at the specified position.
 * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
 * @throws NullFieldException Thrown, if the field at pos is null.
 */
public <T> T getFieldNotNull(int pos){
	T field = getField(pos);
	if (field != null) {
		return field;
	} else {
		throw new NullFieldException(pos);
	}
}
 
Example #18
Source File: TupleSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(T value, DataOutputView target) throws IOException {
	for (int i = 0; i < arity; i++) {
		Object o = value.getField(i);
		try {
			fieldSerializers[i].serialize(o, target);
		} catch (NullPointerException npex) {
			throw new NullFieldException(i, npex);
		}
	}
}
 
Example #19
Source File: Tuple.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
 *
 * @param pos The position of the field, zero indexed.
 * @return The field at the specified position.
 * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
 * @throws NullFieldException Thrown, if the field at pos is null.
 */
public <T> T getFieldNotNull(int pos){
	T field = getField(pos);
	if (field != null) {
		return field;
	} else {
		throw new NullFieldException(pos);
	}
}
 
Example #20
Source File: Tuple2Test.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = NullFieldException.class)
public void testGetFieldNotNull() {
	Tuple2<String, Integer> tuple = new Tuple2<>("Test case", null);

	Assert.assertEquals("Test case", tuple.getFieldNotNull(0));
	tuple.getFieldNotNull(1);
}
 
Example #21
Source File: TupleSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(T value, DataOutputView target) throws IOException {
	for (int i = 0; i < arity; i++) {
		Object o = value.getField(i);
		try {
			fieldSerializers[i].serialize(o, target);
		} catch (NullPointerException npex) {
			throw new NullFieldException(i, npex);
		}
	}
}
 
Example #22
Source File: TupleSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(T value, DataOutputView target) throws IOException {
	for (int i = 0; i < arity; i++) {
		Object o = value.getField(i);
		try {
			fieldSerializers[i].serialize(o, target);
		} catch (NullPointerException npex) {
			throw new NullFieldException(i, npex);
		}
	}
}
 
Example #23
Source File: Tuple.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
 *
 * @param pos The position of the field, zero indexed.
 * @return The field at the specified position.
 * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
 * @throws NullFieldException Thrown, if the field at pos is null.
 */
public <T> T getFieldNotNull(int pos){
	T field = getField(pos);
	if (field != null) {
		return field;
	} else {
		throw new NullFieldException(pos);
	}
}
 
Example #24
Source File: Tuple2Test.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = NullFieldException.class)
public void testGetFieldNotNull() {
	Tuple2<String, Integer> tuple = new Tuple2<>("Test case", null);

	Assert.assertEquals("Test case", tuple.getFieldNotNull(0));
	tuple.getFieldNotNull(1);
}