本文整理汇总了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));
}
示例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);
}
示例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());
}
示例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");
}
}
示例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);
}