本文整理汇总了Java中org.apache.flink.api.common.operators.Ordering.appendOrdering方法的典型用法代码示例。如果您正苦于以下问题:Java Ordering.appendOrdering方法的具体用法?Java Ordering.appendOrdering怎么用?Java Ordering.appendOrdering使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.common.operators.Ordering
的用法示例。
在下文中一共展示了Ordering.appendOrdering方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: testRangePartitioningErased
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testRangePartitioningErased() {
SingleInputSemanticProperties sProp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[]{"1;2"}, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(3, LongValue.class, Order.DESCENDING);
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(6, ByteValue.class, Order.DESCENDING);
RequestedGlobalProperties rgProps = new RequestedGlobalProperties();
rgProps.setRangePartitioned(o);
RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0);
assertNull(filtered);
}
示例3: 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);
}
示例4: 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());
}
示例5: testRangePartitioningErased
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testRangePartitioningErased() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[]{"1;5"}, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(5, LongValue.class, Order.DESCENDING);
o.appendOrdering(2, StringValue.class, Order.ASCENDING);
GlobalProperties gprops = new GlobalProperties();
gprops.setRangePartitioned(o);
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
assertEquals(PartitioningProperty.RANDOM_PARTITIONED, result.getPartitioning());
assertNull(result.getPartitioningOrdering());
assertNull(result.getPartitioningFields());
}
示例6: translateToDataFlowWithKeyExtractor
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
private <K> org.apache.flink.api.common.operators.SingleInputOperator<?, T, ?> translateToDataFlowWithKeyExtractor(
Operator<T> input, Keys.SelectorFunctionKeys<T, K> keys, Order order, String name) {
TypeInformation<Tuple2<K, T>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
Keys.ExpressionKeys<Tuple2<K, T>> newKey = new Keys.ExpressionKeys<>(0, typeInfoWithKey);
Operator<Tuple2<K, T>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
int[] sortKeyPositions = newKey.computeLogicalKeyPositions();
Ordering partitionOrdering = new Ordering();
for (int keyPosition : sortKeyPositions) {
partitionOrdering.appendOrdering(keyPosition, null, order);
}
// distinguish between partition types
UnaryOperatorInformation<Tuple2<K, T>, Tuple2<K, T>> operatorInfo = new UnaryOperatorInformation<>(typeInfoWithKey, typeInfoWithKey);
SortPartitionOperatorBase<Tuple2<K, T>> noop = new SortPartitionOperatorBase<>(operatorInfo, partitionOrdering, name);
noop.setInput(keyedInput);
if (this.getParallelism() < 0) {
// use parallelism of input if not explicitly specified
noop.setParallelism(input.getParallelism());
} else {
// use explicitly specified parallelism
noop.setParallelism(this.getParallelism());
}
return KeyFunctions.appendKeyRemover(noop, keys);
}
示例7: translateToDataFlow
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
protected GenericDataSinkBase<T> translateToDataFlow(Operator<T> input) {
// select the name (or create a default one)
String name = this.name != null ? this.name : this.format.toString();
GenericDataSinkBase<T> sink = new GenericDataSinkBase<>(this.format, new UnaryOperatorInformation<>(this.type, new NothingTypeInfo()), name);
// set input
sink.setInput(input);
// set parameters
if (this.parameters != null) {
sink.getParameters().addAll(this.parameters);
}
// set parallelism
if (this.parallelism > 0) {
// use specified parallelism
sink.setParallelism(this.parallelism);
} else {
// if no parallelism has been specified, use parallelism of input operator to enable chaining
sink.setParallelism(input.getParallelism());
}
if (this.sortKeyPositions != null) {
// configure output sorting
Ordering ordering = new Ordering();
for (int i = 0; i < this.sortKeyPositions.length; i++) {
ordering.appendOrdering(this.sortKeyPositions[i], null, this.sortOrders[i]);
}
sink.setLocalOrder(ordering);
}
return sink;
}
示例8: getGroupOrdering
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
protected Ordering getGroupOrdering() {
Ordering o = new Ordering();
for (int i = 0; i < this.groupSortKeyPositions.length; i++) {
o.appendOrdering(this.groupSortKeyPositions[i], null, this.groupSortOrders[i]);
}
return o;
}
示例9: createOrdering
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
public static Ordering createOrdering(FieldList fields, boolean[] directions) {
final Ordering o = new Ordering();
for (int i = 0; i < fields.size(); i++) {
o.appendOrdering(fields.get(i), null, directions == null || directions[i] ? Order.ASCENDING : Order.DESCENDING);
}
return o;
}
示例10: testOrderPreserved1
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testOrderPreserved1() {
SingleInputSemanticProperties sProps = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[]{"1;4;6"}, 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);
assertNotNull(filtered);
assertNotNull(filtered.getOrdering());
assertEquals(3, filtered.getOrdering().getNumberOfFields());
assertEquals(4, filtered.getOrdering().getFieldNumber(0).intValue());
assertEquals(1, filtered.getOrdering().getFieldNumber(1).intValue());
assertEquals(6, filtered.getOrdering().getFieldNumber(2).intValue());
assertEquals(LongValue.class, filtered.getOrdering().getType(0));
assertEquals(IntValue.class, filtered.getOrdering().getType(1));
assertEquals(ByteValue.class, filtered.getOrdering().getType(2));
assertEquals(Order.DESCENDING, filtered.getOrdering().getOrder(0));
assertEquals(Order.ASCENDING, filtered.getOrdering().getOrder(1));
assertEquals(Order.DESCENDING, filtered.getOrdering().getOrder(2));
assertNull(filtered.getGroupedFields());
}
示例11: testSortingPreserved1
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testSortingPreserved1() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[]{"0;2;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(3, gFields.size());
assertTrue(gFields.contains(0));
assertTrue(gFields.contains(2));
assertTrue(gFields.contains(5));
assertNotNull(order);
assertEquals(3, order.getNumberOfFields());
assertEquals(2, order.getFieldNumber(0).intValue());
assertEquals(0, order.getFieldNumber(1).intValue());
assertEquals(5, order.getFieldNumber(2).intValue());
assertEquals(Order.ASCENDING, order.getOrder(0));
assertEquals(Order.DESCENDING, order.getOrder(1));
assertEquals(Order.DESCENDING, order.getOrder(2));
assertEquals(IntValue.class, order.getType(0));
assertEquals(StringValue.class, order.getType(1));
assertEquals(LongValue.class, order.getType(2));
assertNull(filtered.getUniqueFields());
}
示例12: testSortingPreserved2
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testSortingPreserved2() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[]{"0->3;2->7;5->1"}, 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(3, gFields.size());
assertTrue(gFields.contains(3));
assertTrue(gFields.contains(7));
assertTrue(gFields.contains(1));
assertNotNull(order);
assertEquals(3, order.getNumberOfFields());
assertEquals(7, order.getFieldNumber(0).intValue());
assertEquals(3, order.getFieldNumber(1).intValue());
assertEquals(1, order.getFieldNumber(2).intValue());
assertEquals(Order.ASCENDING, order.getOrder(0));
assertEquals(Order.DESCENDING, order.getOrder(1));
assertEquals(Order.DESCENDING, order.getOrder(2));
assertEquals(IntValue.class, order.getType(0));
assertEquals(StringValue.class, order.getType(1));
assertEquals(LongValue.class, order.getType(2));
assertNull(filtered.getUniqueFields());
}
示例13: testSortingPreserved3
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testSortingPreserved3() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[]{"0;2"}, 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(2, gFields.size());
assertTrue(gFields.contains(0));
assertTrue(gFields.contains(2));
assertNotNull(order);
assertEquals(2, order.getNumberOfFields());
assertEquals(2, order.getFieldNumber(0).intValue());
assertEquals(0, order.getFieldNumber(1).intValue());
assertEquals(Order.ASCENDING, order.getOrder(0));
assertEquals(Order.DESCENDING, order.getOrder(1));
assertEquals(IntValue.class, order.getType(0));
assertEquals(StringValue.class, order.getType(1));
assertNull(filtered.getUniqueFields());
}
示例14: testRangePartitioningPreserved3
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testRangePartitioningPreserved3() {
SingleInputSemanticProperties sProp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[]{"7->3;1->1;2->6"}, null, null, tupleInfo, tupleInfo);
DataDistribution dd = new MockDistribution();
Ordering o = new Ordering();
o.appendOrdering(3, LongValue.class, Order.DESCENDING);
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(6, ByteValue.class, Order.DESCENDING);
RequestedGlobalProperties rgProps = new RequestedGlobalProperties();
rgProps.setRangePartitioned(o, dd);
RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0);
assertNotNull(filtered);
assertEquals(PartitioningProperty.RANGE_PARTITIONED, filtered.getPartitioning());
assertNotNull(filtered.getOrdering());
assertEquals(3, filtered.getOrdering().getNumberOfFields());
assertEquals(7, filtered.getOrdering().getFieldNumber(0).intValue());
assertEquals(1, filtered.getOrdering().getFieldNumber(1).intValue());
assertEquals(2, filtered.getOrdering().getFieldNumber(2).intValue());
assertEquals(LongValue.class, filtered.getOrdering().getType(0));
assertEquals(IntValue.class, filtered.getOrdering().getType(1));
assertEquals(ByteValue.class, filtered.getOrdering().getType(2));
assertEquals(Order.DESCENDING, filtered.getOrdering().getOrder(0));
assertEquals(Order.ASCENDING, filtered.getOrdering().getOrder(1));
assertEquals(Order.DESCENDING, filtered.getOrdering().getOrder(2));
assertNotNull(filtered.getDataDistribution());
assertEquals(dd, filtered.getDataDistribution());
assertNull(filtered.getPartitionedFields());
assertNull(filtered.getCustomPartitioner());
}
示例15: testRangePartitioningPreserved1
import org.apache.flink.api.common.operators.Ordering; //导入方法依赖的package包/类
@Test
public void testRangePartitioningPreserved1() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[]{"1;2;5"}, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(5, LongValue.class, Order.DESCENDING);
o.appendOrdering(2, StringValue.class, Order.ASCENDING);
GlobalProperties gprops = new GlobalProperties();
gprops.setRangePartitioned(o);
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
assertEquals(PartitioningProperty.RANGE_PARTITIONED, result.getPartitioning());
FieldList pFields = result.getPartitioningFields();
assertEquals(3, pFields.size());
assertEquals(1, pFields.get(0).intValue());
assertEquals(5, pFields.get(1).intValue());
assertEquals(2, pFields.get(2).intValue());
Ordering pOrder = result.getPartitioningOrdering();
assertEquals(3, pOrder.getNumberOfFields());
assertEquals(1, pOrder.getFieldNumber(0).intValue());
assertEquals(5, pOrder.getFieldNumber(1).intValue());
assertEquals(2, pOrder.getFieldNumber(2).intValue());
assertEquals(Order.ASCENDING, pOrder.getOrder(0));
assertEquals(Order.DESCENDING, pOrder.getOrder(1));
assertEquals(Order.ASCENDING, pOrder.getOrder(2));
assertEquals(IntValue.class, pOrder.getType(0));
assertEquals(LongValue.class, pOrder.getType(1));
assertEquals(StringValue.class, pOrder.getType(2));
}