本文整理汇总了Java中org.apache.flink.api.common.operators.Ordering类的典型用法代码示例。如果您正苦于以下问题:Java Ordering类的具体用法?Java Ordering怎么用?Java Ordering使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ordering类属于org.apache.flink.api.common.operators包,在下文中一共展示了Ordering类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateSelectorFunctionSortedReducer
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <IN, OUT, K1, K2> PlanUnwrappingSortedReduceGroupOperator<IN, OUT, K1, K2> translateSelectorFunctionSortedReducer(
SelectorFunctionKeys<IN, ?> rawGroupingKey,
SelectorFunctionKeys<IN, ?> rawSortingKey,
Ordering groupOrdering,
GroupReduceFunction<IN, OUT> function,
TypeInformation<OUT> outputType,
String name,
Operator<IN> input,
boolean combinable) {
final SelectorFunctionKeys<IN, K1> groupingKey = (SelectorFunctionKeys<IN, K1>) rawGroupingKey;
final SelectorFunctionKeys<IN, K2> sortingKey = (SelectorFunctionKeys<IN, K2>) rawSortingKey;
TypeInformation<Tuple3<K1, K2, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(groupingKey, sortingKey);
Operator<Tuple3<K1, K2, IN>> inputWithKey = KeyFunctions.appendKeyExtractor(input, groupingKey, sortingKey);
PlanUnwrappingSortedReduceGroupOperator<IN, OUT, K1, K2> reducer =
new PlanUnwrappingSortedReduceGroupOperator<>(
function, groupingKey, sortingKey, name, outputType, typeInfoWithKey, combinable);
reducer.setInput(inputWithKey);
reducer.setGroupOrder(groupOrdering);
return reducer;
}
示例2: computeOrdering
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
private static <T> Ordering computeOrdering(Keys<T> pKeys, Order[] orders) {
Ordering ordering = new Ordering();
final int[] logicalKeyPositions = pKeys.computeLogicalKeyPositions();
if (orders == null) {
for (int key : logicalKeyPositions) {
ordering.appendOrdering(key, null, Order.ASCENDING);
}
} else {
final TypeInformation<?>[] originalKeyFieldTypes = pKeys.getOriginalKeyFieldTypes();
int index = 0;
for (int i = 0; i < originalKeyFieldTypes.length; i++) {
final int typeTotalFields = originalKeyFieldTypes[i].getTotalFields();
for (int j = index; j < index + typeTotalFields; j++) {
ordering.appendOrdering(logicalKeyPositions[j], null, orders[i]);
}
index += typeTotalFields;
}
}
return ordering;
}
示例3: translateSelectorFunctionPartitioner
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T, K> org.apache.flink.api.common.operators.SingleInputOperator<?, T, ?> translateSelectorFunctionPartitioner(
SelectorFunctionKeys<T, ?> rawKeys,
PartitionMethod pMethod,
String name,
Operator<T> input,
int partitionDop,
Partitioner<?> customPartitioner,
Order[] orders) {
final SelectorFunctionKeys<T, K> keys = (SelectorFunctionKeys<T, K>) rawKeys;
TypeInformation<Tuple2<K, T>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
Operator<Tuple2<K, T>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
PartitionOperatorBase<Tuple2<K, T>> keyedPartitionedInput =
new PartitionOperatorBase<>(new UnaryOperatorInformation<>(typeInfoWithKey, typeInfoWithKey), pMethod, new int[]{0}, name);
keyedPartitionedInput.setInput(keyedInput);
keyedPartitionedInput.setCustomPartitioner(customPartitioner);
keyedPartitionedInput.setParallelism(partitionDop);
keyedPartitionedInput.setOrdering(new Ordering(0, null, orders != null ? orders[0] : Order.ASCENDING));
return KeyFunctions.appendKeyRemover(keyedPartitionedInput, keys);
}
示例4: translateSelectorFunctionSortedReducer
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <IN, OUT, K1, K2> PlanUnwrappingSortedGroupCombineOperator<IN, OUT, K1, K2> translateSelectorFunctionSortedReducer(
SelectorFunctionKeys<IN, ?> rawGroupingKey,
SelectorFunctionKeys<IN, ?> rawSortingKeys,
Ordering groupOrder,
GroupCombineFunction<IN, OUT> function,
TypeInformation<OUT> outputType,
String name,
Operator<IN> input) {
final SelectorFunctionKeys<IN, K1> groupingKey = (SelectorFunctionKeys<IN, K1>) rawGroupingKey;
final SelectorFunctionKeys<IN, K2> sortingKey = (SelectorFunctionKeys<IN, K2>) rawSortingKeys;
TypeInformation<Tuple3<K1, K2, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(groupingKey, sortingKey);
Operator<Tuple3<K1, K2, IN>> inputWithKey = KeyFunctions.appendKeyExtractor(input, groupingKey, sortingKey);
PlanUnwrappingSortedGroupCombineOperator<IN, OUT, K1, K2> reducer =
new PlanUnwrappingSortedGroupCombineOperator<>(function, groupingKey, sortingKey, name, outputType, typeInfoWithKey);
reducer.setInput(inputWithKey);
reducer.setGroupOrder(groupOrder);
return reducer;
}
示例5: checkSameOrdering
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
protected boolean checkSameOrdering(GlobalProperties produced1, GlobalProperties produced2, int numRelevantFields) {
Ordering prod1 = produced1.getPartitioningOrdering();
Ordering prod2 = produced2.getPartitioningOrdering();
if (prod1 == null || prod2 == null) {
throw new CompilerException("The given properties do not meet this operators requirements.");
}
// check that order of fields is equivalent
if (!checkEquivalentFieldPositionsInKeyFields(
prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
return false;
}
// check that both inputs have the same directions of order
for (int i = 0; i < numRelevantFields; i++) {
if (prod1.getOrder(i) != prod2.getOrder(i)) {
return false;
}
}
return true;
}
示例6: GroupReduceWithCombineProperties
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
public GroupReduceWithCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
super(groupKeys);
// if we have an additional ordering, construct the ordering to have primarily the grouping fields
if (additionalOrderKeys != null) {
this.ordering = new Ordering();
for (Integer key : this.keyList) {
this.ordering.appendOrdering(key, null, Order.ANY);
}
// and next the additional order fields
for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
Integer field = additionalOrderKeys.getFieldNumber(i);
Order order = additionalOrderKeys.getOrder(i);
this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
}
} else {
this.ordering = null;
}
this.customPartitioner = customPartitioner;
}
示例7: GroupReduceProperties
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
public GroupReduceProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
super(groupKeys);
// if we have an additional ordering, construct the ordering to have primarily the grouping fields
if (additionalOrderKeys != null) {
this.ordering = new Ordering();
for (Integer key : this.keyList) {
this.ordering.appendOrdering(key, null, Order.ANY);
}
// and next the additional order fields
for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
Integer field = additionalOrderKeys.getFieldNumber(i);
Order order = additionalOrderKeys.getOrder(i);
this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
}
}
else {
this.ordering = null;
}
this.customPartitioner = customPartitioner;
}
示例8: GroupCombineProperties
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
public GroupCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys) {
super(groupKeys);
// if we have an additional ordering, construct the ordering to have primarily the grouping fields
this.ordering = new Ordering();
for (Integer key : this.keyList) {
this.ordering.appendOrdering(key, null, Order.ANY);
}
// and next the additional order fields
if (additionalOrderKeys != null) {
for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
Integer field = additionalOrderKeys.getFieldNumber(i);
Order order = additionalOrderKeys.getOrder(i);
this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
}
}
}
示例9: areCoFulfilled
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@Override
public boolean areCoFulfilled(RequestedLocalProperties requested1, RequestedLocalProperties requested2,
LocalProperties produced1, LocalProperties produced2) {
int numRelevantFields = this.keys1.size();
Ordering prod1 = produced1.getOrdering();
Ordering prod2 = produced2.getOrdering();
if (prod1 == null || prod2 == null || prod1.getNumberOfFields() < numRelevantFields
|| prod2.getNumberOfFields() < numRelevantFields) {
throw new CompilerException("The given properties do not meet this operators requirements.");
}
for (int i = 0; i < numRelevantFields; i++) {
if (prod1.getOrder(i) != prod2.getOrder(i)) {
return false;
}
}
return true;
}
示例10: initializeDataProperties
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
private List<OperatorDescriptorDual> initializeDataProperties() {
Ordering groupOrder1 = null;
Ordering groupOrder2 = null;
CoGroupRawOperatorBase<?, ?, ?, ?> cgc = getOperator();
groupOrder1 = cgc.getGroupOrderForInputOne();
groupOrder2 = cgc.getGroupOrderForInputTwo();
if (groupOrder1 != null && groupOrder1.getNumberOfFields() == 0) {
groupOrder1 = null;
}
if (groupOrder2 != null && groupOrder2.getNumberOfFields() == 0) {
groupOrder2 = null;
}
return Collections.<OperatorDescriptorDual>singletonList(new CoGroupRawDescriptor(this.keys1, this.keys2, groupOrder1, groupOrder2));
}
示例11: computeInterestingPropertiesForInputs
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@Override
public void computeInterestingPropertiesForInputs(CostEstimator estimator) {
final InterestingProperties iProps = new InterestingProperties();
{
final RequestedGlobalProperties partitioningProps = new RequestedGlobalProperties();
iProps.addGlobalProperties(partitioningProps);
}
{
final Ordering localOrder = getOperator().getLocalOrder();
final RequestedLocalProperties orderProps = new RequestedLocalProperties();
if (localOrder != null) {
orderProps.setOrdering(localOrder);
}
iProps.addLocalProperties(orderProps);
}
this.input.setInterestingProperties(iProps);
}
示例12: initializeDataProperties
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
private List<OperatorDescriptorDual> initializeDataProperties(Partitioner<?> customPartitioner) {
Ordering groupOrder1 = null;
Ordering groupOrder2 = null;
CoGroupOperatorBase<?, ?, ?, ?> cgc = getOperator();
groupOrder1 = cgc.getGroupOrderForInputOne();
groupOrder2 = cgc.getGroupOrderForInputTwo();
if (groupOrder1 != null && groupOrder1.getNumberOfFields() == 0) {
groupOrder1 = null;
}
if (groupOrder2 != null && groupOrder2.getNumberOfFields() == 0) {
groupOrder2 = null;
}
CoGroupDescriptor descr = new CoGroupDescriptor(this.keys1, this.keys2, groupOrder1, groupOrder2);
if (customPartitioner != null) {
descr.setCustomPartitioner(customPartitioner);
}
return Collections.<OperatorDescriptorDual>singletonList(descr);
}
示例13: testOrderErased
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@Test
public void testOrderErased() {
SingleInputSemanticProperties sProps = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[]{"1; 4"}, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(4, LongValue.class, Order.DESCENDING);
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(6, ByteValue.class, Order.DESCENDING);
RequestedLocalProperties rlProp = new RequestedLocalProperties();
rlProp.setOrdering(o);
RequestedLocalProperties filtered = rlProp.filterBySemanticProperties(sProps, 0);
assertNull(filtered);
}
示例14: testSortingPreserved4
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@Test
public void testSortingPreserved4() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[]{"2->7;5"}, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(2, IntValue.class, Order.ASCENDING);
o.appendOrdering(0, StringValue.class, Order.DESCENDING);
o.appendOrdering(5, LongValue.class, Order.DESCENDING);
LocalProperties lProps = LocalProperties.forOrdering(o);
LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
FieldList gFields = filtered.getGroupedFields();
Ordering order = filtered.getOrdering();
assertNotNull(gFields);
assertEquals(1, gFields.size());
assertTrue(gFields.contains(7));
assertNotNull(order);
assertEquals(1, order.getNumberOfFields());
assertEquals(7, order.getFieldNumber(0).intValue());
assertEquals(Order.ASCENDING, order.getOrder(0));
assertEquals(IntValue.class, order.getType(0));
assertNull(filtered.getUniqueFields());
}
示例15: testSortingErased
import org.apache.flink.api.common.operators.Ordering; //导入依赖的package包/类
@Test
public void testSortingErased() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[]{"0;5"}, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(2, IntValue.class, Order.ASCENDING);
o.appendOrdering(0, StringValue.class, Order.DESCENDING);
o.appendOrdering(5, LongValue.class, Order.DESCENDING);
LocalProperties lProps = LocalProperties.forOrdering(o);
LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
FieldList gFields = filtered.getGroupedFields();
Ordering order = filtered.getOrdering();
assertNull(gFields);
assertNull(order);
assertNull(filtered.getUniqueFields());
}