当前位置: 首页>>代码示例>>Java>>正文


Java CompositeType.createComparator方法代码示例

本文整理汇总了Java中org.apache.flink.api.common.typeutils.CompositeType.createComparator方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeType.createComparator方法的具体用法?Java CompositeType.createComparator怎么用?Java CompositeType.createComparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.api.common.typeutils.CompositeType的用法示例。


在下文中一共展示了CompositeType.createComparator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectorForKeys

import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
public static <X> KeySelector<X, Tuple> getSelectorForKeys(Keys<X> keys, TypeInformation<X> typeInfo, ExecutionConfig executionConfig) {
	if (!(typeInfo instanceof CompositeType)) {
		throw new InvalidTypesException(
				"This key operation requires a composite type such as Tuples, POJOs, or Case Classes.");
	}

	CompositeType<X> compositeType = (CompositeType<X>) typeInfo;

	int[] logicalKeyPositions = keys.computeLogicalKeyPositions();
	int numKeyFields = logicalKeyPositions.length;

	TypeInformation<?>[] typeInfos = keys.getKeyFieldTypes();
	// use ascending order here, the code paths for that are usually a slight bit faster
	boolean[] orders = new boolean[numKeyFields];
	for (int i = 0; i < numKeyFields; i++) {
		orders[i] = true;
	}

	TypeComparator<X> comparator = compositeType.createComparator(logicalKeyPositions, orders, 0, executionConfig);
	return new ComparableKeySelector<>(comparator, numKeyFields, new TupleTypeInfo<>(typeInfos));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:KeySelectorUtil.java

示例2: getSelectorForOneKey

import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
public static <X, K> KeySelector<X, K> getSelectorForOneKey(
		Keys<X> keys, Partitioner<K> partitioner, TypeInformation<X> typeInfo, ExecutionConfig executionConfig) {
	if (!(typeInfo instanceof CompositeType)) {
		throw new InvalidTypesException(
				"This key operation requires a composite type such as Tuples, POJOs, case classes, etc");
	}
	if (partitioner != null) {
		keys.validateCustomPartitioner(partitioner, null);
	}

	CompositeType<X> compositeType = (CompositeType<X>) typeInfo;
	int[] logicalKeyPositions = keys.computeLogicalKeyPositions();
	if (logicalKeyPositions.length != 1) {
		throw new IllegalArgumentException("There must be exactly 1 key specified");
	}

	TypeComparator<X> comparator = compositeType.createComparator(
			logicalKeyPositions, new boolean[] { true }, 0, executionConfig);
	return new OneKeySelector<>(comparator);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:KeySelectorUtil.java

示例3: createComparator

import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
@Override
protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) {
	Assert.assertTrue(type instanceof CompositeType);
	CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type;
	ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType);
	boolean[] orders = new boolean[keys.getNumberOfKeyFields()];
	Arrays.fill(orders, ascending);
	return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:PojoSubclassComparatorTest.java

示例4: PojoFieldAccessor

import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
PojoFieldAccessor(String field, TypeInformation<R> type, ExecutionConfig config) {
	if (!(type instanceof CompositeType<?>)) {
		throw new IllegalArgumentException(
				"Key expressions are only supported on POJO types and Tuples. "
						+ "A type is considered a POJO if all its fields are public, or have both getters and setters defined");
	}

	@SuppressWarnings("unchecked")
	CompositeType<R> cType = (CompositeType<R>) type;

	if(field.contains(".")) {
		throw new IllegalArgumentException("The Pojo field accessor currently doesn't support nested POJOs");
	}

	List<CompositeType.FlatFieldDescriptor> fieldDescriptors = cType.getFlatFields(field);

	int logicalKeyPosition = fieldDescriptors.get(0).getPosition();
	this.fieldType = fieldDescriptors.get(0).getType();

	if (cType instanceof PojoTypeInfo) {
		comparator = (PojoComparator<R>) cType.createComparator(
				new int[] { logicalKeyPosition }, new boolean[] { false }, 0, config);
	} else {
		throw new IllegalArgumentException(
				"Key expressions are only supported on POJO types. "
						+ "A type is considered a POJO if all its fields are public, or have both getters and setters defined");
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:29,代码来源:FieldAccessor.java

示例5: createComparator

import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
@Override
protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) {
	Assert.assertTrue(type instanceof CompositeType);
	CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type;
	ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType);
	boolean[] orders = new boolean[keys.getNumberOfKeyFields()];
	Arrays.fill(orders, ascending);
	return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:10,代码来源:PojoComparatorTest.java


注:本文中的org.apache.flink.api.common.typeutils.CompositeType.createComparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。