当前位置: 首页>>代码示例>>Java>>正文


Java DataSet.distinct方法代码示例

本文整理汇总了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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:DistinctITCase.java

示例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();
	}

}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:DistinctOperatorTest.java

示例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();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:DistinctOperatorTest.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:DistinctOperatorTest.java

示例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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:DistinctOperatorTest.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:DistinctOperatorTest.java

示例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();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:DistinctOperatorTest.java

示例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();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:DistinctOperatorTest.java

示例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();

}
 
开发者ID:axbaretto,项目名称:flink,代码行数:16,代码来源:DistinctOperatorTest.java

示例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("*");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:DistinctOperatorTest.java

示例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);

}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:DistinctOperatorTest.java

示例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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:DistinctOperatorTest.java


注:本文中的org.apache.flink.api.java.DataSet.distinct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。