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


Java AtomicType类代码示例

本文整理汇总了Java中org.apache.flink.api.common.typeinfo.AtomicType的典型用法代码示例。如果您正苦于以下问题:Java AtomicType类的具体用法?Java AtomicType怎么用?Java AtomicType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AtomicType类属于org.apache.flink.api.common.typeinfo包,在下文中一共展示了AtomicType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildComparatorFor

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> TypeComparator<T> buildComparatorFor(int input, ExecutionConfig executionConfig, TypeInformation<T> typeInformation) {
	TypeComparator<T> comparator;
	if (typeInformation instanceof AtomicType) {
		comparator = ((AtomicType<T>) typeInformation).createComparator(true, executionConfig);
	} else if (typeInformation instanceof CompositeType) {
		int[] keyPositions = getKeyColumns(input);
		boolean[] orders = new boolean[keyPositions.length];
		Arrays.fill(orders, true);

		comparator = ((CompositeType<T>) typeInformation).createComparator(keyPositions, orders, 0, executionConfig);
	} else {
		throw new RuntimeException("Type information for input of type " + typeInformation.getClass()
				.getCanonicalName() + " is not supported. Could not generate a comparator.");
	}
	return comparator;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:OuterJoinOperatorBase.java

示例2: executeOnCollections

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
@Override
protected List<IN> executeOnCollections(List<IN> inputData, RuntimeContext runtimeContext, ExecutionConfig executionConfig) {

	TypeInformation<IN> inputType = getInput().getOperatorInfo().getOutputType();

	int[] sortColumns = this.partitionOrdering.getFieldPositions();
	boolean[] sortOrderings = this.partitionOrdering.getFieldSortDirections();

	final TypeComparator<IN> sortComparator;
	if (inputType instanceof CompositeType) {
		sortComparator = ((CompositeType<IN>) inputType).createComparator(sortColumns, sortOrderings, 0, executionConfig);
	} else if (inputType instanceof AtomicType) {
		sortComparator = ((AtomicType) inputType).createComparator(sortOrderings[0], executionConfig);
	} else {
		throw new UnsupportedOperationException("Partition sorting does not support type "+inputType+" yet.");
	}

	Collections.sort(inputData, new Comparator<IN>() {
		@Override
		public int compare(IN o1, IN o2) {
			return sortComparator.compare(o1, o2);
		}
	});

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

示例3: createComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> TypeComparatorFactory<?> createComparator(TypeInformation<T> typeInfo, FieldList keys, boolean[] sortOrder) {
	
	TypeComparator<T> comparator;
	if (typeInfo instanceof CompositeType) {
		comparator = ((CompositeType<T>) typeInfo).createComparator(keys.toArray(), sortOrder, 0, executionConfig);
	}
	else if (typeInfo instanceof AtomicType) {
		// handle grouping of atomic types
		comparator = ((AtomicType<T>) typeInfo).createComparator(sortOrder[0], executionConfig);
	}
	else {
		throw new RuntimeException("Unrecognized type: " + typeInfo);
	}

	return new RuntimeComparatorFactory<T>(comparator);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:JavaApiPostPass.java

示例4: createComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
private static <T> TypeComparatorFactory<?> createComparator(TypeInformation<T> typeInfo, FieldList keys, boolean[] sortOrder, ExecutionConfig executionConfig) {

		TypeComparator<T> comparator;
		if (typeInfo instanceof CompositeType) {
			comparator = ((CompositeType<T>) typeInfo).createComparator(keys.toArray(), sortOrder, 0, executionConfig);
		}
		else if (typeInfo instanceof AtomicType) {
			// handle grouping of atomic types
			comparator = ((AtomicType<T>) typeInfo).createComparator(sortOrder[0], executionConfig);
		}
		else {
			throw new RuntimeException("Unrecognized type: " + typeInfo);
		}

		return new RuntimeComparatorFactory<>(comparator);
	}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:Utils.java

示例5: createComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
@Override
public TypeComparator<Comparable> createComparator(boolean sortOrderAscending, ExecutionConfig config) {

	if(this.fieldTypeInfo != null) {
		TypeComparator<Comparable> fieldComparator = ((AtomicType)fieldTypeInfo).createComparator(sortOrderAscending, config);
		return new WrappingFieldComparator(fieldComparator, sortOrderAscending, Comparable.class);
	}
	else {
		TypeSerializer<Comparable> serializer = this.createSerializer(config);
		if (this.fieldComparator == null) {
			return new FieldComparator(sortOrderAscending, serializer, Comparable.class);
		} else {
			return new CustomFieldComparator(sortOrderAscending, this.fieldComparator, this.createSerializer(config));
		}
	}
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:17,代码来源:FieldTypeInfo.java

示例6: createComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
private static <T> TypeComparatorFactory<?> createComparator(TypeInformation<T> typeInfo, FieldList keys, boolean[] sortOrder) {
	
	TypeComparator<T> comparator;
	if (typeInfo instanceof CompositeType) {
		comparator = ((CompositeType<T>) typeInfo).createComparator(keys.toArray(), sortOrder, 0);
	}
	else if (typeInfo instanceof AtomicType) {
		// handle grouping of atomic types
		throw new UnsupportedOperationException("Grouping on atomic types is currently not implemented. " + typeInfo);
	}
	else {
		throw new RuntimeException("Unrecognized type: " + typeInfo);
	}

	return new RuntimeComparatorFactory<T>(comparator);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:17,代码来源:JavaApiPostPass.java

示例7: getTypeComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> TypeComparator<T> getTypeComparator(ExecutionConfig executionConfig, TypeInformation<T> inputType, int[] inputKeys, boolean[] inputSortDirections) {
	if (inputType instanceof CompositeType) {
		return ((CompositeType<T>) inputType).createComparator(inputKeys, inputSortDirections, 0, executionConfig);
	} else if (inputType instanceof AtomicType) {
		return ((AtomicType<T>) inputType).createComparator(inputSortDirections[0], executionConfig);
	}

	throw new InvalidProgramException("Input type of coGroup must be one of composite types or atomic types.");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:CoGroupOperatorBase.java

示例8: getTypeComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
private TypeComparator<IN> getTypeComparator(TypeInformation<IN> typeInfo, int[] sortColumns, boolean[] sortOrderings, ExecutionConfig executionConfig) {
	if (typeInfo instanceof CompositeType) {
		return ((CompositeType<IN>) typeInfo).createComparator(sortColumns, sortOrderings, 0, executionConfig);
	} else if (typeInfo instanceof AtomicType) {
		return ((AtomicType<IN>) typeInfo).createComparator(sortOrderings[0], executionConfig);
	}

	throw new InvalidProgramException("Input type of GroupCombine must be one of composite types or atomic types.");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:GroupCombineOperatorBase.java

示例9: getTypeComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
private TypeComparator<IN> getTypeComparator(TypeInformation<IN> typeInfo, int[] sortColumns, boolean[] sortOrderings, ExecutionConfig executionConfig) {
	if (typeInfo instanceof CompositeType) {
		return ((CompositeType<IN>) typeInfo).createComparator(sortColumns, sortOrderings, 0, executionConfig);
	} else if (typeInfo instanceof AtomicType) {
		return ((AtomicType<IN>) typeInfo).createComparator(sortOrderings[0], executionConfig);
	}

	throw new InvalidProgramException("Input type of GroupReduce must be one of composite types or atomic types.");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:GroupReduceOperatorBase.java

示例10: addAllFields

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
/**
 * Recursively add all fields in this tuple type. We need this in particular to get all
 * the types.
 * @param keyId
 * @param keyFields
 */
public void addAllFields(int startKeyId, List<FlatFieldDescriptor> keyFields) {
	for(int i = 0; i < this.getArity(); i++) {
		TypeInformation<?> type = this.types[i];
		if(type instanceof AtomicType) {
			keyFields.add(new FlatFieldDescriptor(startKeyId, type));
		} else if(type instanceof TupleTypeInfoBase<?>) {
			TupleTypeInfoBase<?> ttb = (TupleTypeInfoBase<?>) type;
			ttb.addAllFields(startKeyId, keyFields);
		}
		startKeyId += type.getTotalFields();
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:19,代码来源:TupleTypeInfoBase.java

示例11: createComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
/**
 * Generic implementation of the comparator creation. Composite types are supplying the infrastructure
 * to create the actual comparators
 * @return
 */
public TypeComparator<T> createComparator(int[] logicalKeyFields, boolean[] orders, int logicalFieldOffset) {
	initializeNewComparator(logicalKeyFields.length);
	
	for(int logicalKeyFieldIndex = 0; logicalKeyFieldIndex < logicalKeyFields.length; logicalKeyFieldIndex++) {
		int logicalKeyField = logicalKeyFields[logicalKeyFieldIndex];
		int logicalField = logicalFieldOffset; // this is the global/logical field number
		for(int localFieldId = 0; localFieldId < this.getArity(); localFieldId++) {
			TypeInformation<?> localFieldType = this.getTypeAt(localFieldId);
			
			if(localFieldType instanceof AtomicType && logicalField == logicalKeyField) {
				// we found an atomic key --> create comparator
				addCompareField(localFieldId, ((AtomicType<?>) localFieldType).createComparator(orders[logicalKeyFieldIndex]) );
			} else if(localFieldType instanceof CompositeType  && // must be a composite type
					( logicalField <= logicalKeyField //check if keyField can be at or behind the current logicalField
					&& logicalKeyField <= logicalField + (localFieldType.getTotalFields() - 1) ) // check if logical field + lookahead could contain our key
					) {
				// we found a compositeType that is containing the logicalKeyField we are looking for --> create comparator
				addCompareField(localFieldId, ((CompositeType<?>) localFieldType).createComparator(new int[] {logicalKeyField}, new boolean[] {orders[logicalKeyFieldIndex]}, logicalField));
			}
			
			// maintain logicalField
			if(localFieldType instanceof CompositeType) {
				// we need to subtract 1 because we are not accounting for the local field (not accessible for the user)
				logicalField += localFieldType.getTotalFields() - 1;
			}
			logicalField++;
		}
	}
	return getNewComparator();
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:36,代码来源:CompositeType.java

示例12: FlatFieldDescriptor

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
public FlatFieldDescriptor(int keyPosition, TypeInformation<?> type) {
	if( !(type instanceof AtomicType)) {
		throw new IllegalArgumentException("A flattened field can only be an atomic type");
	}
	this.keyPosition = keyPosition;
	this.type = type;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:8,代码来源:CompositeType.java

示例13: isAtomicType

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
public boolean isAtomicType() {
	return typeInfo instanceof AtomicType;
}
 
开发者ID:haoch,项目名称:flink-siddhi,代码行数:4,代码来源:StreamSchema.java

示例14: isAtomicType

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
public boolean isAtomicType() {
    return typeInfo instanceof AtomicType;
}
 
开发者ID:apache,项目名称:bahir-flink,代码行数:4,代码来源:StreamSchema.java

示例15: createComparator

import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
/**
 * Generic implementation of the comparator creation. Composite types are supplying the infrastructure
 * to create the actual comparators
 * @return The comparator
 */
@PublicEvolving
public TypeComparator<T> createComparator(int[] logicalKeyFields, boolean[] orders, int logicalFieldOffset, ExecutionConfig config) {

	TypeComparatorBuilder<T> builder = createTypeComparatorBuilder();

	builder.initializeTypeComparatorBuilder(logicalKeyFields.length);

	for (int logicalKeyFieldIndex = 0; logicalKeyFieldIndex < logicalKeyFields.length; logicalKeyFieldIndex++) {
		int logicalKeyField = logicalKeyFields[logicalKeyFieldIndex];
		int logicalField = logicalFieldOffset; // this is the global/logical field number
		boolean comparatorAdded = false;

		for (int localFieldId = 0; localFieldId < this.getArity() && logicalField <= logicalKeyField && !comparatorAdded; localFieldId++) {
			TypeInformation<?> localFieldType = this.getTypeAt(localFieldId);
			
			if (localFieldType instanceof AtomicType && logicalField == logicalKeyField) {
				// we found an atomic key --> create comparator
				builder.addComparatorField(
					localFieldId,
					((AtomicType<?>) localFieldType).createComparator(
						orders[logicalKeyFieldIndex],
						config));

				comparatorAdded = true;
			}
			// must be composite type and check that the logicalKeyField is within the bounds
			// of the composite type's logical fields
			else if (localFieldType instanceof CompositeType &&
				logicalField <= logicalKeyField &&
				logicalKeyField <= logicalField + (localFieldType.getTotalFields() - 1)) {
				// we found a compositeType that is containing the logicalKeyField we are looking for --> create comparator
				builder.addComparatorField(
					localFieldId,
					((CompositeType<?>) localFieldType).createComparator(
						new int[]{logicalKeyField},
						new boolean[]{orders[logicalKeyFieldIndex]},
						logicalField,
						config)
				);

				comparatorAdded = true;
			}

			if (localFieldType instanceof CompositeType) {
				// we need to subtract 1 because we are not accounting for the local field (not accessible for the user)
				logicalField += localFieldType.getTotalFields() - 1;
			}
			
			logicalField++;
		}

		if (!comparatorAdded) {
			throw new IllegalArgumentException("Could not add a comparator for the logical" +
				"key field index " + logicalKeyFieldIndex + ".");
		}
	}

	return builder.createTypeComparator(config);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:65,代码来源:CompositeType.java


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