本文整理汇总了Java中org.apache.flink.api.java.DataSet.distinct方法的典型用法代码示例。如果您正苦于以下问题:Java DataSet.distinct方法的具体用法?Java DataSet.distinct怎么用?Java DataSet.distinct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.java.DataSet
的用法示例。
在下文中一共展示了DataSet.distinct方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCorrectnessOfDistinctOnAtomic
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testCorrectnessOfDistinctOnAtomic() throws Exception {
/*
* check correctness of distinct on Integers
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Integer> ds = CollectionDataSets.getIntegerDataSet(env);
DataSet<Integer> reduceDs = ds.distinct();
List<Integer> result = reduceDs.collect();
String expected = "1\n2\n3\n4\n5";
compareResultAsText(result, expected);
}
示例2: testDistinctByKeySelector1
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
@SuppressWarnings("serial")
public void testDistinctByKeySelector1() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
this.customTypeData.add(new CustomType());
try {
DataSet<CustomType> customDs = env.fromCollection(customTypeData);
// should work
customDs.distinct(
new KeySelector<DistinctOperatorTest.CustomType, Long>() {
@Override
public Long getKey(CustomType value) {
return value.myLong;
}
});
} catch (Exception e) {
Assert.fail();
}
}
示例3: testDistinctByKeyFields1
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testDistinctByKeyFields1() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
try {
tupleDs.distinct(0);
} catch (Exception e) {
Assert.fail();
}
}
示例4: testDistinctByKeyFields2
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = InvalidProgramException.class)
public void testDistinctByKeyFields2() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Long> longDs = env.fromCollection(emptyLongData, BasicTypeInfo.LONG_TYPE_INFO);
// should not work: distinct on basic type
longDs.distinct(0);
}
示例5: testDistinctByKeyFields4
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testDistinctByKeyFields4() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
tupleDs.distinct();
}
示例6: testDistinctByKeyFields6
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = IndexOutOfBoundsException.class)
public void testDistinctByKeyFields6() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should not work, negative field position
tupleDs.distinct(-1);
}
示例7: testDistinctByKeyFields7
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testDistinctByKeyFields7(){
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Long> longDs = env.fromCollection(emptyLongData, BasicTypeInfo.LONG_TYPE_INFO);
// should work
try {
longDs.distinct("*");
} catch (Exception e){
Assert.fail();
}
}
示例8: testDistinctByKeyIndices1
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testDistinctByKeyIndices1() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
try {
DataSet<Long> longDs = env.fromCollection(emptyLongData, BasicTypeInfo.LONG_TYPE_INFO);
// should work
longDs.distinct();
} catch (Exception e) {
Assert.fail();
}
}
示例9: testDistinctOnNotKeyDataType
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = InvalidProgramException.class)
public void testDistinctOnNotKeyDataType() throws Exception {
/*
* should not work. NotComparable data type cannot be used as key
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
NotComparable a = new NotComparable();
List<NotComparable> l = new ArrayList<NotComparable>();
l.add(a);
DataSet<NotComparable> ds = env.fromCollection(l);
DataSet<NotComparable> reduceDs = ds.distinct();
}
示例10: testDistinctOnNotKeyDataTypeOnSelectAllChar
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = InvalidProgramException.class)
public void testDistinctOnNotKeyDataTypeOnSelectAllChar() throws Exception {
/*
* should not work. NotComparable data type cannot be used as key
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
NotComparable a = new NotComparable();
List<NotComparable> l = new ArrayList<NotComparable>();
l.add(a);
DataSet<NotComparable> ds = env.fromCollection(l);
DataSet<NotComparable> reduceDs = ds.distinct("*");
}
示例11: testDistinctByKeyFields3
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test(expected = InvalidProgramException.class)
public void testDistinctByKeyFields3() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
this.customTypeData.add(new CustomType());
DataSet<CustomType> customDs = env.fromCollection(customTypeData);
// should not work: distinct on custom type
customDs.distinct(0);
}
示例12: testDistinctByKeyFields5
import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testDistinctByKeyFields5() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
this.customTypeData.add(new CustomType());
DataSet<CustomType> customDs = env.fromCollection(customTypeData);
// should work
customDs.distinct();
}