本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
}
}
示例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);
}
示例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.");
}
示例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.");
}
示例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.");
}
示例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();
}
}
示例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();
}
示例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;
}
示例13: isAtomicType
import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
public boolean isAtomicType() {
return typeInfo instanceof AtomicType;
}
示例14: isAtomicType
import org.apache.flink.api.common.typeinfo.AtomicType; //导入依赖的package包/类
public boolean isAtomicType() {
return typeInfo instanceof AtomicType;
}
示例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);
}