org.apache.flink.api.java.typeutils.runtime.RowComparator Java Examples

The following examples show how to use org.apache.flink.api.java.typeutils.runtime.RowComparator. 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: RowTypeInfo.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public TypeComparator<Row> createTypeComparator(ExecutionConfig config) {
	checkState(
		fieldComparators.size() > 0,
		"No field comparators were defined for the TupleTypeComparatorBuilder."
	);

	checkState(
		logicalKeyFields.size() > 0,
		"No key fields were defined for the TupleTypeComparatorBuilder."
	);

	checkState(
		fieldComparators.size() == logicalKeyFields.size(),
		"The number of field comparators and key fields is not equal."
	);

	final int maxKey = Collections.max(logicalKeyFields);

	checkState(
		maxKey >= 0,
		"The maximum key field must be greater or equal than 0."
	);

	TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1];

	for (int i = 0; i <= maxKey; i++) {
		fieldSerializers[i] = types[i].createSerializer(config);
	}

	int[] keyPositions = new int[logicalKeyFields.size()];
	for (int i = 0; i < keyPositions.length; i++) {
		keyPositions[i] = logicalKeyFields.get(i);
	}

	TypeComparator[] comparators = new TypeComparator[fieldComparators.size()];
	for (int i = 0; i < fieldComparators.size(); i++) {
		comparators[i] = fieldComparators.get(i);
	}

	//noinspection unchecked
	return new RowComparator(
		getArity(),
		keyPositions,
		comparators,
		(TypeSerializer<Object>[]) fieldSerializers,
		comparatorOrders);
}
 
Example #2
Source File: RowTypeInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TypeComparator<Row> createTypeComparator(ExecutionConfig config) {
	checkState(
		fieldComparators.size() > 0,
		"No field comparators were defined for the TupleTypeComparatorBuilder."
	);

	checkState(
		logicalKeyFields.size() > 0,
		"No key fields were defined for the TupleTypeComparatorBuilder."
	);

	checkState(
		fieldComparators.size() == logicalKeyFields.size(),
		"The number of field comparators and key fields is not equal."
	);

	final int maxKey = Collections.max(logicalKeyFields);

	checkState(
		maxKey >= 0,
		"The maximum key field must be greater or equal than 0."
	);

	TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1];

	for (int i = 0; i <= maxKey; i++) {
		fieldSerializers[i] = types[i].createSerializer(config);
	}

	int[] keyPositions = new int[logicalKeyFields.size()];
	for (int i = 0; i < keyPositions.length; i++) {
		keyPositions[i] = logicalKeyFields.get(i);
	}

	TypeComparator[] comparators = new TypeComparator[fieldComparators.size()];
	for (int i = 0; i < fieldComparators.size(); i++) {
		comparators[i] = fieldComparators.get(i);
	}

	//noinspection unchecked
	return new RowComparator(
		getArity(),
		keyPositions,
		comparators,
		(TypeSerializer<Object>[]) fieldSerializers,
		comparatorOrders);
}
 
Example #3
Source File: RowTypeInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TypeComparator<Row> createTypeComparator(ExecutionConfig config) {
	checkState(
		fieldComparators.size() > 0,
		"No field comparators were defined for the TupleTypeComparatorBuilder."
	);

	checkState(
		logicalKeyFields.size() > 0,
		"No key fields were defined for the TupleTypeComparatorBuilder."
	);

	checkState(
		fieldComparators.size() == logicalKeyFields.size(),
		"The number of field comparators and key fields is not equal."
	);

	final int maxKey = Collections.max(logicalKeyFields);

	checkState(
		maxKey >= 0,
		"The maximum key field must be greater or equal than 0."
	);

	TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1];

	for (int i = 0; i <= maxKey; i++) {
		fieldSerializers[i] = types[i].createSerializer(config);
	}

	int[] keyPositions = new int[logicalKeyFields.size()];
	for (int i = 0; i < keyPositions.length; i++) {
		keyPositions[i] = logicalKeyFields.get(i);
	}

	TypeComparator[] comparators = new TypeComparator[fieldComparators.size()];
	for (int i = 0; i < fieldComparators.size(); i++) {
		comparators[i] = fieldComparators.get(i);
	}

	//noinspection unchecked
	return new RowComparator(
		getArity(),
		keyPositions,
		comparators,
		(TypeSerializer<Object>[]) fieldSerializers,
		comparatorOrders);
}