本文整理汇总了Java中org.apache.flink.api.java.typeutils.TupleTypeInfo.getArity方法的典型用法代码示例。如果您正苦于以下问题:Java TupleTypeInfo.getArity方法的具体用法?Java TupleTypeInfo.getArity怎么用?Java TupleTypeInfo.getArity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.java.typeutils.TupleTypeInfo
的用法示例。
在下文中一共展示了TupleTypeInfo.getArity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SelectByMinFunction
import org.apache.flink.api.java.typeutils.TupleTypeInfo; //导入方法依赖的package包/类
/**
* Constructor which is overwriting the default constructor.
* @param type Types of tuple whether to check if given fields are key types.
* @param fields Array of integers which are used as key for comparison. The order of indexes
* is regarded in the reduce function. First index has highest priority and last index has
* least priority.
*/
public SelectByMinFunction(TupleTypeInfo<T> type, int... fields) {
this.fields = fields;
// Check correctness of each position
for (int field : fields) {
// Is field inside array
if (field < 0 || field >= type.getArity()) {
throw new java.lang.IndexOutOfBoundsException(
"MinReduceFunction field position " + field + " is out of range.");
}
// Check whether type is comparable
if (!type.getTypeAt(field).isKeyType()) {
throw new java.lang.IllegalArgumentException(
"MinReduceFunction supports only key(Comparable) types.");
}
}
}
示例2: SelectByMaxFunction
import org.apache.flink.api.java.typeutils.TupleTypeInfo; //导入方法依赖的package包/类
/**
* Constructor which is overwriting the default constructor.
* @param type Types of tuple whether to check if given fields are key types.
* @param fields Array of integers which are used as key for comparison. The order of indexes
* is regarded in the reduce function. First index has highest priority and last index has
* least priority.
*/
public SelectByMaxFunction(TupleTypeInfo<T> type, int... fields) {
this.fields = fields;
// Check correctness of each position
for (int field : fields) {
// Is field inside array
if (field < 0 || field >= type.getArity()) {
throw new IndexOutOfBoundsException(
"MinReduceFunction field position " + field + " is out of range.");
}
// Check whether type is comparable
if (!type.getTypeAt(field).isKeyType()) {
throw new java.lang.IllegalArgumentException(
"MinReduceFunction supports only key(Comparable) types.");
}
}
}
示例3: tupleType
import org.apache.flink.api.java.typeutils.TupleTypeInfo; //导入方法依赖的package包/类
/**
* Configures the reader to read the CSV data and parse it to the given type. The type must be a subclass of
* {@link Tuple}. The type information for the fields is obtained from the type class. The type
* consequently needs to specify all generic field types of the tuple.
*
* @param targetType The class of the target type, needs to be a subclass of Tuple.
* @return The DataSet representing the parsed CSV data.
*/
public <T extends Tuple> DataSource<T> tupleType(Class<T> targetType) {
Preconditions.checkNotNull(targetType, "The target type class must not be null.");
if (!Tuple.class.isAssignableFrom(targetType)) {
throw new IllegalArgumentException("The target type must be a subclass of " + Tuple.class.getName());
}
@SuppressWarnings("unchecked")
TupleTypeInfo<T> typeInfo = (TupleTypeInfo<T>) TypeExtractor.createTypeInfo(targetType);
CsvInputFormat<T> inputFormat = new TupleCsvInputFormat<T>(path, this.lineDelimiter, this.fieldDelimiter, typeInfo, this.includedMask);
Class<?>[] classes = new Class<?>[typeInfo.getArity()];
for (int i = 0; i < typeInfo.getArity(); i++) {
classes[i] = typeInfo.getTypeAt(i).getTypeClass();
}
configureInputFormat(inputFormat);
return new DataSource<T>(executionContext, inputFormat, typeInfo, Utils.getCallLocationName());
}