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

The following examples show how to use org.apache.flink.test.operators.util.CollectionDataSets#getStringDataSet() . 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: FlatMapITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonPassingFlatMap() throws Exception {
	/*
	 * Test non-passing flatmap
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> nonPassingFlatMapDs = ds.
			flatMap(new FlatMapper1());

	List<String> result = nonPassingFlatMapDs.collect();

	String expected = "\n";

	compareResultAsText(result, expected);
}
 
Example 2
Source File: FilterITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterBasicType() throws Exception {
	/*
	 * Test filter on basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> filterDs = ds.
			filter(new Filter5());
	List<String> result = filterDs.collect();

	String expected = "Hi\n" +
			"Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n";

	compareResultAsText(result, expected);
}
 
Example 3
Source File: FlatMapITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataDuplicatingFlatMap() throws Exception {
	/*
	 * Test data duplicating flatmap
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> duplicatingFlatMapDs = ds.
			flatMap(new FlatMapper2());

	List<String> result = duplicatingFlatMapDs.collect();

	String expected = "Hi\n" + "HI\n" +
			"Hello\n" + "HELLO\n" +
			"Hello world\n" + "HELLO WORLD\n" +
			"Hello world, how are you?\n" + "HELLO WORLD, HOW ARE YOU?\n" +
			"I am fine.\n" + "I AM FINE.\n" +
			"Luke Skywalker\n" + "LUKE SKYWALKER\n" +
			"Random comment\n" + "RANDOM COMMENT\n" +
			"LOL\n" + "LOL\n";

	compareResultAsText(result, expected);
}
 
Example 4
Source File: FlatMapITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonPassingFlatMap() throws Exception {
	/*
	 * Test non-passing flatmap
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> nonPassingFlatMapDs = ds.
			flatMap(new FlatMapper1());

	List<String> result = nonPassingFlatMapDs.collect();

	String expected = "\n";

	compareResultAsText(result, expected);
}
 
Example 5
Source File: MapITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testIdentityMapWithBasicType() throws Exception {
	/*
	 * Test identity map with basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> identityMapDs = ds.
			map(new Mapper1());

	List<String> result = identityMapDs.collect();

	String expected = "Hi\n" +
			"Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n" +
			"I am fine.\n" +
			"Luke Skywalker\n" +
			"Random comment\n" +
			"LOL\n";

	compareResultAsText(result, expected);
}
 
Example 6
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testStringSortingParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	ds.writeAsText(resultPath).sortLocalOutput("*", Order.ASCENDING).setParallelism(1);

	env.execute();

	String expected = "Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n" +
			"Hi\n" +
			"I am fine.\n" +
			"LOL\n" +
			"Luke Skywalker\n" +
			"Random comment\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 7
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testStringSortingParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	ds.writeAsText(resultPath).sortLocalOutput("*", Order.ASCENDING).setParallelism(1);

	env.execute();

	String expected = "Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n" +
			"Hi\n" +
			"I am fine.\n" +
			"LOL\n" +
			"Luke Skywalker\n" +
			"Random comment\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 8
Source File: FilterITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterBasicType() throws Exception {
	/*
	 * Test filter on basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> filterDs = ds.
			filter(new Filter5());
	List<String> result = filterDs.collect();

	String expected = "Hi\n" +
			"Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n";

	compareResultAsText(result, expected);
}
 
Example 9
Source File: FlatMapITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataDuplicatingFlatMap() throws Exception {
	/*
	 * Test data duplicating flatmap
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> duplicatingFlatMapDs = ds.
			flatMap(new FlatMapper2());

	List<String> result = duplicatingFlatMapDs.collect();

	String expected = "Hi\n" + "HI\n" +
			"Hello\n" + "HELLO\n" +
			"Hello world\n" + "HELLO WORLD\n" +
			"Hello world, how are you?\n" + "HELLO WORLD, HOW ARE YOU?\n" +
			"I am fine.\n" + "I AM FINE.\n" +
			"Luke Skywalker\n" + "LUKE SKYWALKER\n" +
			"Random comment\n" + "RANDOM COMMENT\n" +
			"LOL\n" + "LOL\n";

	compareResultAsText(result, expected);
}
 
Example 10
Source File: DistinctITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectnessOfDistinctOnAtomicWithSelectAllChar() throws Exception {
	/*
	 * check correctness of distinct on Strings, using Keys.ExpressionKeys.SELECT_ALL_CHAR
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> reduceDs = ds.union(ds).distinct("*");

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

	String expected = "I am fine.\n" +
			"Luke Skywalker\n" +
			"LOL\n" +
			"Hello world, how are you?\n" +
			"Hi\n" +
			"Hello world\n" +
			"Hello\n" +
			"Random comment\n";

	compareResultAsText(result, expected);
}
 
Example 11
Source File: MapITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testIdentityMapWithBasicType() throws Exception {
	/*
	 * Test identity map with basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> identityMapDs = ds.
			map(new Mapper1());

	List<String> result = identityMapDs.collect();

	String expected = "Hi\n" +
			"Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n" +
			"I am fine.\n" +
			"Luke Skywalker\n" +
			"Random comment\n" +
			"LOL\n";

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

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> reduceDs = ds.union(ds).distinct("*");

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

	String expected = "I am fine.\n" +
			"Luke Skywalker\n" +
			"LOL\n" +
			"Hello world, how are you?\n" +
			"Hi\n" +
			"Hello world\n" +
			"Hello\n" +
			"Random comment\n";

	compareResultAsText(result, expected);
}
 
Example 13
Source File: DataSinkITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testStringSortingParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	ds.writeAsText(resultPath).sortLocalOutput("*", Order.ASCENDING).setParallelism(1);

	env.execute();

	String expected = "Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n" +
			"Hi\n" +
			"I am fine.\n" +
			"LOL\n" +
			"Luke Skywalker\n" +
			"Random comment\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 14
Source File: FilterITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterBasicType() throws Exception {
	/*
	 * Test filter on basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> filterDs = ds.
			filter(new Filter5());
	List<String> result = filterDs.collect();

	String expected = "Hi\n" +
			"Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n";

	compareResultAsText(result, expected);
}
 
Example 15
Source File: FlatMapITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataDuplicatingFlatMap() throws Exception {
	/*
	 * Test data duplicating flatmap
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> duplicatingFlatMapDs = ds.
			flatMap(new FlatMapper2());

	List<String> result = duplicatingFlatMapDs.collect();

	String expected = "Hi\n" + "HI\n" +
			"Hello\n" + "HELLO\n" +
			"Hello world\n" + "HELLO WORLD\n" +
			"Hello world, how are you?\n" + "HELLO WORLD, HOW ARE YOU?\n" +
			"I am fine.\n" + "I AM FINE.\n" +
			"Luke Skywalker\n" + "LUKE SKYWALKER\n" +
			"Random comment\n" + "RANDOM COMMENT\n" +
			"LOL\n" + "LOL\n";

	compareResultAsText(result, expected);
}
 
Example 16
Source File: FlatMapITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonPassingFlatMap() throws Exception {
	/*
	 * Test non-passing flatmap
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> nonPassingFlatMapDs = ds.
			flatMap(new FlatMapper1());

	List<String> result = nonPassingFlatMapDs.collect();

	String expected = "\n";

	compareResultAsText(result, expected);
}
 
Example 17
Source File: MapITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testIdentityMapWithBasicType() throws Exception {
	/*
	 * Test identity map with basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> identityMapDs = ds.
			map(new Mapper1());

	List<String> result = identityMapDs.collect();

	String expected = "Hi\n" +
			"Hello\n" +
			"Hello world\n" +
			"Hello world, how are you?\n" +
			"I am fine.\n" +
			"Luke Skywalker\n" +
			"Random comment\n" +
			"LOL\n";

	compareResultAsText(result, expected);
}
 
Example 18
Source File: MapITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testRuntimeContextAndExecutionConfigParams() throws Exception {
	/*
	 * Test identity map with basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.getConfig().setNumberOfExecutionRetries(1000);
	env.getConfig().setTaskCancellationInterval(50000);

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> identityMapDs = ds.
		map(new RichMapFunction<String, String>() {
			@Override
			public String map(String value) throws Exception {
				Assert.assertTrue(1000 == getRuntimeContext().getExecutionConfig().getNumberOfExecutionRetries());
				Assert.assertTrue(50000 == getRuntimeContext().getExecutionConfig().getTaskCancellationInterval());
				return value;
			}
		});

	List<String> result = identityMapDs.collect();

	String expected = "Hi\n" +
		"Hello\n" +
		"Hello world\n" +
		"Hello world, how are you?\n" +
		"I am fine.\n" +
		"Luke Skywalker\n" +
		"Random comment\n" +
		"LOL\n";

	compareResultAsText(result, expected);
}
 
Example 19
Source File: MapITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testRuntimeContextAndExecutionConfigParams() throws Exception {
	/*
	 * Test identity map with basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.getConfig().setNumberOfExecutionRetries(1000);
	env.getConfig().setTaskCancellationInterval(50000);

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> identityMapDs = ds.
		map(new RichMapFunction<String, String>() {
			@Override
			public String map(String value) throws Exception {
				Assert.assertTrue(1000 == getRuntimeContext().getExecutionConfig().getNumberOfExecutionRetries());
				Assert.assertTrue(50000 == getRuntimeContext().getExecutionConfig().getTaskCancellationInterval());
				return value;
			}
		});

	List<String> result = identityMapDs.collect();

	String expected = "Hi\n" +
		"Hello\n" +
		"Hello world\n" +
		"Hello world, how are you?\n" +
		"I am fine.\n" +
		"Luke Skywalker\n" +
		"Random comment\n" +
		"LOL\n";

	compareResultAsText(result, expected);
}
 
Example 20
Source File: MapITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testRuntimeContextAndExecutionConfigParams() throws Exception {
	/*
	 * Test identity map with basic type
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.getConfig().setNumberOfExecutionRetries(1000);
	env.getConfig().setTaskCancellationInterval(50000);

	DataSet<String> ds = CollectionDataSets.getStringDataSet(env);
	DataSet<String> identityMapDs = ds.
		map(new RichMapFunction<String, String>() {
			@Override
			public String map(String value) throws Exception {
				Assert.assertTrue(1000 == getRuntimeContext().getExecutionConfig().getNumberOfExecutionRetries());
				Assert.assertTrue(50000 == getRuntimeContext().getExecutionConfig().getTaskCancellationInterval());
				return value;
			}
		});

	List<String> result = identityMapDs.collect();

	String expected = "Hi\n" +
		"Hello\n" +
		"Hello world\n" +
		"Hello world, how are you?\n" +
		"I am fine.\n" +
		"Luke Skywalker\n" +
		"Random comment\n" +
		"LOL\n";

	compareResultAsText(result, expected);
}