Java Code Examples for org.apache.flink.test.operators.util.CollectionDataSets#getDuplicatePojoDataSet()

The following examples show how to use org.apache.flink.test.operators.util.CollectionDataSets#getDuplicatePojoDataSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistinctITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfDistinctOnPojos() throws Exception {
	/*
	 * check correctness of distinct on Pojos
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Integer> reduceDs = ds.distinct("nestedPojo.longNumber").map(new Mapper2());

	List<Integer> result = reduceDs.collect();

	String expected = "10000\n20000\n30000\n";

	compareResultAsText(result, expected);
}
 
Example 2
Source File: DistinctITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDistinctOnFullPojo() throws Exception {
	/*
	 * distinct on full Pojo
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Integer> reduceDs = ds.distinct().map(new Mapper1());

	List<Integer> result = reduceDs.collect();

	String expected = "10000\n20000\n30000\n";

	compareResultAsText(result, expected);
}
 
Example 3
Source File: PartitionITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testHashPartitionWithKeyExpression() throws Exception {
	/*
	 * Test hash partition with key expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Long> uniqLongs = ds
			.partitionByHash("nestedPojo.longNumber").setParallelism(4)
			.mapPartition(new UniqueNestedPojoLongMapper());
	List<Long> result = uniqLongs.collect();

	String expected = "10000\n" +
			"20000\n" +
			"30000\n";

	compareResultAsText(result, expected);
}
 
Example 4
Source File: PartitionITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testRangePartitionWithKeyExpression() throws Exception {
	/*
	 * Test range partition with key expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Long> uniqLongs = ds
		.partitionByRange("nestedPojo.longNumber").setParallelism(4)
		.mapPartition(new UniqueNestedPojoLongMapper());
	List<Long> result = uniqLongs.collect();

	String expected = "10000\n" +
		"20000\n" +
		"30000\n";

	compareResultAsText(result, expected);
}
 
Example 5
Source File: DistinctITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfDistinctOnPojos() throws Exception {
	/*
	 * check correctness of distinct on Pojos
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Integer> reduceDs = ds.distinct("nestedPojo.longNumber").map(new Mapper2());

	List<Integer> result = reduceDs.collect();

	String expected = "10000\n20000\n30000\n";

	compareResultAsText(result, expected);
}
 
Example 6
Source File: DistinctITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDistinctOnFullPojo() throws Exception {
	/*
	 * distinct on full Pojo
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Integer> reduceDs = ds.distinct().map(new Mapper1());

	List<Integer> result = reduceDs.collect();

	String expected = "10000\n20000\n30000\n";

	compareResultAsText(result, expected);
}
 
Example 7
Source File: PartitionITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testHashPartitionWithKeyExpression() throws Exception {
	/*
	 * Test hash partition with key expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Long> uniqLongs = ds
			.partitionByHash("nestedPojo.longNumber").setParallelism(4)
			.mapPartition(new UniqueNestedPojoLongMapper());
	List<Long> result = uniqLongs.collect();

	String expected = "10000\n" +
			"20000\n" +
			"30000\n";

	compareResultAsText(result, expected);
}
 
Example 8
Source File: PartitionITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testRangePartitionWithKeyExpression() throws Exception {
	/*
	 * Test range partition with key expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Long> uniqLongs = ds
		.partitionByRange("nestedPojo.longNumber").setParallelism(4)
		.mapPartition(new UniqueNestedPojoLongMapper());
	List<Long> result = uniqLongs.collect();

	String expected = "10000\n" +
		"20000\n" +
		"30000\n";

	compareResultAsText(result, expected);
}
 
Example 9
Source File: DistinctITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfDistinctOnPojos() throws Exception {
	/*
	 * check correctness of distinct on Pojos
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Integer> reduceDs = ds.distinct("nestedPojo.longNumber").map(new Mapper2());

	List<Integer> result = reduceDs.collect();

	String expected = "10000\n20000\n30000\n";

	compareResultAsText(result, expected);
}
 
Example 10
Source File: DistinctITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDistinctOnFullPojo() throws Exception {
	/*
	 * distinct on full Pojo
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Integer> reduceDs = ds.distinct().map(new Mapper1());

	List<Integer> result = reduceDs.collect();

	String expected = "10000\n20000\n30000\n";

	compareResultAsText(result, expected);
}
 
Example 11
Source File: PartitionITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testHashPartitionWithKeyExpression() throws Exception {
	/*
	 * Test hash partition with key expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Long> uniqLongs = ds
			.partitionByHash("nestedPojo.longNumber").setParallelism(4)
			.mapPartition(new UniqueNestedPojoLongMapper());
	List<Long> result = uniqLongs.collect();

	String expected = "10000\n" +
			"20000\n" +
			"30000\n";

	compareResultAsText(result, expected);
}
 
Example 12
Source File: PartitionITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testRangePartitionWithKeyExpression() throws Exception {
	/*
	 * Test range partition with key expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getDuplicatePojoDataSet(env);
	DataSet<Long> uniqLongs = ds
		.partitionByRange("nestedPojo.longNumber").setParallelism(4)
		.mapPartition(new UniqueNestedPojoLongMapper());
	List<Long> result = uniqLongs.collect();

	String expected = "10000\n" +
		"20000\n" +
		"30000\n";

	compareResultAsText(result, expected);
}