本文整理汇总了Java中org.apache.flink.api.common.typeutils.CompositeType.getTypeAt方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeType.getTypeAt方法的具体用法?Java CompositeType.getTypeAt怎么用?Java CompositeType.getTypeAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.common.typeutils.CompositeType
的用法示例。
在下文中一共展示了CompositeType.getTypeAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSerializerTree
import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
private static <T> String getSerializerTree(TypeInformation<T> ti, int indent) {
String ret = "";
if (ti instanceof CompositeType) {
ret += StringUtils.repeat(' ', indent) + ti.getClass().getSimpleName() + "\n";
CompositeType<T> cti = (CompositeType<T>) ti;
String[] fieldNames = cti.getFieldNames();
for (int i = 0; i < cti.getArity(); i++) {
TypeInformation<?> fieldType = cti.getTypeAt(i);
ret += StringUtils.repeat(' ', indent + 2) + fieldNames[i] + ":" + getSerializerTree(fieldType, indent);
}
} else {
if (ti instanceof GenericTypeInfo) {
ret += StringUtils.repeat(' ', indent) + "GenericTypeInfo (" + ti.getTypeClass().getSimpleName() + ")\n";
ret += getGenericTypeTree(ti.getTypeClass(), indent + 4);
} else {
ret += StringUtils.repeat(' ', indent) + ti.toString() + "\n";
}
}
return ret;
}
示例2: getFieldTypes
import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
private <E> TypeInformation[] getFieldTypes(TypeInformation<E> typeInfo, int[] fieldIndexes, String[] fieldNames) {
TypeInformation[] fieldTypes;
if (isCompositeType()) {
CompositeType cType = (CompositeType) typeInfo;
if (fieldNames.length != cType.getArity()) {
// throw new IllegalArgumentException("Arity of type (" + cType.getFieldNames().length+ ") " +
// "not equal to number of field names " + fieldNames.length + ".");
LOGGER.warn("Arity of type (" + cType.getFieldNames().length + ") " +
"not equal to number of field names " + fieldNames.length + ".");
}
fieldTypes = new TypeInformation[fieldIndexes.length];
for (int i = 0; i < fieldIndexes.length; i++) {
fieldTypes[i] = cType.getTypeAt(fieldIndexes[i]);
}
} else if (isAtomicType()) {
if (fieldIndexes.length != 1 || fieldIndexes[0] != 0) {
throw new IllegalArgumentException(
"Non-composite input type may have only a single field and its index must be 0.");
}
fieldTypes = new TypeInformation[]{typeInfo};
} else {
throw new IllegalArgumentException(
"Illegal input type info"
);
}
return fieldTypes;
}
示例3: getFieldTypes
import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
private <E> TypeInformation[] getFieldTypes(TypeInformation<E> typeInfo, int[] fieldIndexes, String[] fieldNames) {
TypeInformation[] fieldTypes;
if (isCompositeType()) {
CompositeType cType = (CompositeType) typeInfo;
if (fieldNames.length != cType.getArity()) {
// throw new IllegalArgumentException("Arity of type (" + cType.getFieldNames().length+ ") " +
// "not equal to number of field names " + fieldNames.length + ".");
LOGGER.warn("Arity of type (" + cType.getFieldNames().length + ") " +
"not equal to number of field names " + fieldNames.length + ".");
}
fieldTypes = new TypeInformation[fieldIndexes.length];
for (int i = 0; i < fieldIndexes.length; i++) {
fieldTypes[i] = cType.getTypeAt(fieldIndexes[i]);
}
} else if (isAtomicType()) {
if (fieldIndexes.length != 1 || fieldIndexes[0] != 0) {
throw new IllegalArgumentException(
"Non-composite input type may have only a single field and its index must be 0.");
}
fieldTypes = new TypeInformation[]{typeInfo};
} else {
throw new IllegalArgumentException(
"Illegal input type info"
);
}
return fieldTypes;
}
示例4: getContainedGenericTypes
import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
/**
* Returns all GenericTypeInfos contained in a composite type.
*
* @param typeInfo {@link CompositeType}
*/
private static void getContainedGenericTypes(CompositeType<?> typeInfo, List<GenericTypeInfo<?>> target) {
for (int i = 0; i < typeInfo.getArity(); i++) {
TypeInformation<?> type = typeInfo.getTypeAt(i);
if (type instanceof CompositeType) {
getContainedGenericTypes((CompositeType<?>) type, target);
} else if (type instanceof GenericTypeInfo) {
if (!target.contains(type)) {
target.add((GenericTypeInfo<?>) type);
}
}
}
}
示例5: ExpressionKeys
import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
/**
* Create int-based (non-nested) field position keys on a tuple type.
*/
public ExpressionKeys(int[] keyPositions, TypeInformation<T> type, boolean allowEmpty) {
if (!type.isTupleType() || !(type instanceof CompositeType)) {
throw new InvalidProgramException("Specifying keys via field positions is only valid " +
"for tuple data types. Type: " + type);
}
if (type.getArity() == 0) {
throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity());
}
if (!allowEmpty && (keyPositions == null || keyPositions.length == 0)) {
throw new IllegalArgumentException("The grouping fields must not be empty.");
}
this.keyFields = new ArrayList<>();
if (keyPositions == null || keyPositions.length == 0) {
// use all tuple fields as key fields
keyPositions = createIncrIntArray(type.getArity());
} else {
rangeCheckFields(keyPositions, type.getArity() - 1);
}
checkArgument(keyPositions.length > 0, "Grouping fields can not be empty at this point");
// extract key field types
CompositeType<T> cType = (CompositeType<T>)type;
this.keyFields = new ArrayList<>(type.getTotalFields());
// for each key position, find all (nested) field types
String[] fieldNames = cType.getFieldNames();
this.originalKeyTypes = new TypeInformation<?>[keyPositions.length];
ArrayList<FlatFieldDescriptor> tmpList = new ArrayList<>();
for (int i = 0; i < keyPositions.length; i++) {
int keyPos = keyPositions[i];
tmpList.clear();
// get all flat fields
this.originalKeyTypes[i] = cType.getTypeAt(keyPos);
cType.getFlatFields(fieldNames[keyPos], 0, tmpList);
// check if fields are of key type
for(FlatFieldDescriptor ffd : tmpList) {
if(!ffd.getType().isKeyType()) {
throw new InvalidProgramException("This type (" + ffd.getType() + ") cannot be used as key.");
}
}
this.keyFields.addAll(tmpList);
}
}