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


Java TupleTypeInfo.getArity方法代码示例

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

	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:SelectByMinFunction.java

示例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.");
		}

	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:SelectByMaxFunction.java

示例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());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:CsvReader.java


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