本文整理了Java中org.apache.flink.api.java.operators.UnsortedGrouping.maxBy()
方法的一些代码示例,展示了UnsortedGrouping.maxBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UnsortedGrouping.maxBy()
方法的具体详情如下:
包路径:org.apache.flink.api.java.operators.UnsortedGrouping
类名称:UnsortedGrouping
方法名:maxBy
[英]Applies a special case of a reduce transformation (maxBy) on a grouped DataSet.
The transformation consecutively calls a ReduceFunctionuntil only a single element remains which is the result of the transformation. A ReduceFunction combines two elements into one new element of the same type.
[中]在分组数据集上应用reduce转换(maxBy)的特殊情况。
转换连续调用reduceFunction,直到只剩下一个元素,这是转换的结果。ReduceFunction将两个元素组合成一个相同类型的新元素。
代码示例来源:origin: apache/flink
/**
* This test validates that an InvalidProgramException is thrown when maxBy
* is used on a custom data type.
*/
@Test(expected = InvalidProgramException.class)
public void testCustomKeyFieldsGrouping() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
this.customTypeData.add(new CustomType());
UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0);
// should not work: groups on custom type
groupDs.maxBy(0);
}
代码示例来源:origin: apache/flink
/**
* This test validates that an index which is out of bounds throws an
* IndexOutOfBoundsException.
*/
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping3() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);
// should not work, key out of tuple bounds
groupDs.maxBy(1, 2, 3, 4, -1);
}
代码示例来源:origin: apache/flink
/**
* This test validates that an index which is out of bounds throws an
* IndexOutOfBoundsException.
*/
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping2() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);
// should not work, key out of tuple bounds
groupDs.maxBy(-1);
}
代码示例来源:origin: apache/flink
/**
* This test validates that an index which is out of bounds throws an
* IndexOutOfBoundsException.
*/
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping1() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);
// should not work, key out of tuple bounds
groupDs.maxBy(5);
}
代码示例来源:origin: apache/flink
/**
* This test validates that no exceptions is thrown when an empty grouping
* calls maxBy().
*/
@Test
public void testMaxByKeyFieldsGrouping() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);
// should work
try {
groupDs.maxBy(4, 0, 1, 2, 3);
} catch (Exception e) {
Assert.fail();
}
}
代码示例来源:origin: seznam/euphoria
trendsParams.getRankThreshold()))
.groupBy(0)
.maxBy(2)
.setParallelism(1);
内容来源于网络,如有侵权,请联系作者删除!