本文整理汇总了Java中org.apache.flink.api.common.typeutils.CompositeType.getArity方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeType.getArity方法的具体用法?Java CompositeType.getArity怎么用?Java CompositeType.getArity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.common.typeutils.CompositeType
的用法示例。
在下文中一共展示了CompositeType.getArity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProjectionPropertiesSingle
import org.apache.flink.api.common.typeutils.CompositeType; //导入方法依赖的package包/类
public static SingleInputSemanticProperties createProjectionPropertiesSingle(int[] fields, CompositeType<?> inType) {
Character.isJavaIdentifierStart(1);
SingleInputSemanticProperties ssp = new SingleInputSemanticProperties();
int[] sourceOffsets = new int[inType.getArity()];
sourceOffsets[0] = 0;
for (int i = 1; i < inType.getArity(); i++) {
sourceOffsets[i] = inType.getTypeAt(i - 1).getTotalFields() + sourceOffsets[i - 1];
}
int targetOffset = 0;
for (int i = 0; i < fields.length; i++) {
int sourceOffset = sourceOffsets[fields[i]];
int numFieldsToCopy = inType.getTypeAt(fields[i]).getTotalFields();
for (int j = 0; j < numFieldsToCopy; j++) {
ssp.addForwardedField(sourceOffset + j, targetOffset + j);
}
targetOffset += numFieldsToCopy;
}
return ssp;
}
示例2: 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;
}
示例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: 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;
}
示例5: 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);
}
}
}
}