org.apache.flink.api.common.operators.util.TestIOData Java Examples

The following examples show how to use org.apache.flink.api.common.operators.util.TestIOData. 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: GenericDataSourceBaseTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataSourcePlain() {
	try {
		TestNonRichInputFormat in = new TestNonRichInputFormat();
		GenericDataSourceBase<String, TestNonRichInputFormat> source =
				new GenericDataSourceBase<String, TestNonRichInputFormat>(
						in, new OperatorInformation<String>(BasicTypeInfo.STRING_TYPE_INFO), "testSource");

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		List<String> resultMutableSafe = source.executeOnCollections(null, executionConfig);

		in.reset();
		executionConfig.enableObjectReuse();
		List<String> resultRegular = source.executeOnCollections(null, executionConfig);
		assertEquals(asList(TestIOData.NAMES), resultMutableSafe);
		assertEquals(asList(TestIOData.NAMES), resultRegular);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #2
Source File: GenericDataSourceBaseTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataSourcePlain() {
	try {
		TestNonRichInputFormat in = new TestNonRichInputFormat();
		GenericDataSourceBase<String, TestNonRichInputFormat> source =
				new GenericDataSourceBase<String, TestNonRichInputFormat>(
						in, new OperatorInformation<String>(BasicTypeInfo.STRING_TYPE_INFO), "testSource");

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		List<String> resultMutableSafe = source.executeOnCollections(null, executionConfig);

		in.reset();
		executionConfig.enableObjectReuse();
		List<String> resultRegular = source.executeOnCollections(null, executionConfig);
		assertEquals(asList(TestIOData.NAMES), resultMutableSafe);
		assertEquals(asList(TestIOData.NAMES), resultRegular);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #3
Source File: GenericDataSourceBaseTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataSourcePlain() {
	try {
		TestNonRichInputFormat in = new TestNonRichInputFormat();
		GenericDataSourceBase<String, TestNonRichInputFormat> source =
				new GenericDataSourceBase<String, TestNonRichInputFormat>(
						in, new OperatorInformation<String>(BasicTypeInfo.STRING_TYPE_INFO), "testSource");

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		List<String> resultMutableSafe = source.executeOnCollections(null, executionConfig);

		in.reset();
		executionConfig.enableObjectReuse();
		List<String> resultRegular = source.executeOnCollections(null, executionConfig);
		assertEquals(asList(TestIOData.NAMES), resultMutableSafe);
		assertEquals(asList(TestIOData.NAMES), resultRegular);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #4
Source File: GenericDataSinkBaseTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSourcePlain() {
	try {
		TestNonRichOutputFormat out = new TestNonRichOutputFormat();
		GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>(
				out,
				new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)),
				"test_sink");
		sink.setInput(source);

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		in.reset();
		sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig);
		assertEquals(out.output, asList(TestIOData.NAMES));

		executionConfig.enableObjectReuse();
		out.clear();
		in.reset();
		sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig);
		assertEquals(out.output, asList(TestIOData.NAMES));
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #5
Source File: GenericDataSinkBaseTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSourceWithRuntimeContext() {
	try {
		TestRichOutputFormat out = new TestRichOutputFormat();
		GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>(
				out,
				new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)),
				"test_sink");
		sink.setInput(source);

		ExecutionConfig executionConfig = new ExecutionConfig();
		final HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
		final HashMap<String, Future<Path>> cpTasks = new HashMap<>();
		final TaskInfo taskInfo = new TaskInfo("test_sink", 1, 0, 1, 0);
		executionConfig.disableObjectReuse();
		in.reset();
		
		sink.executeOnCollections(asList(TestIOData.NAMES), new RuntimeUDFContext(
				taskInfo, null, executionConfig, cpTasks, accumulatorMap, new UnregisteredMetricsGroup()),
				executionConfig);
	
			assertEquals(out.output, asList(TestIOData.RICH_NAMES));

		executionConfig.enableObjectReuse();
		out.clear();
		in.reset();
		
		sink.executeOnCollections(asList(TestIOData.NAMES), new RuntimeUDFContext(
				taskInfo, null, executionConfig, cpTasks, accumulatorMap, new UnregisteredMetricsGroup()),
				executionConfig);
		assertEquals(out.output, asList(TestIOData.RICH_NAMES));
	} catch(Exception e){
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #6
Source File: GenericDataSinkBaseTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSourcePlain() {
	try {
		TestNonRichOutputFormat out = new TestNonRichOutputFormat();
		GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>(
				out,
				new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)),
				"test_sink");
		sink.setInput(source);

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		in.reset();
		sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig);
		assertEquals(out.output, asList(TestIOData.NAMES));

		executionConfig.enableObjectReuse();
		out.clear();
		in.reset();
		sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig);
		assertEquals(out.output, asList(TestIOData.NAMES));
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #7
Source File: GenericDataSinkBaseTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSourceWithRuntimeContext() {
	try {
		TestRichOutputFormat out = new TestRichOutputFormat();
		GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>(
				out,
				new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)),
				"test_sink");
		sink.setInput(source);

		ExecutionConfig executionConfig = new ExecutionConfig();
		final HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
		final HashMap<String, Future<Path>> cpTasks = new HashMap<>();
		final TaskInfo taskInfo = new TaskInfo("test_sink", 1, 0, 1, 0);
		executionConfig.disableObjectReuse();
		in.reset();
		
		sink.executeOnCollections(asList(TestIOData.NAMES), new RuntimeUDFContext(
				taskInfo, null, executionConfig, cpTasks, accumulatorMap, new UnregisteredMetricsGroup()),
				executionConfig);
	
			assertEquals(out.output, asList(TestIOData.RICH_NAMES));

		executionConfig.enableObjectReuse();
		out.clear();
		in.reset();
		
		sink.executeOnCollections(asList(TestIOData.NAMES), new RuntimeUDFContext(
				taskInfo, null, executionConfig, cpTasks, accumulatorMap, new UnregisteredMetricsGroup()),
				executionConfig);
		assertEquals(out.output, asList(TestIOData.RICH_NAMES));
	} catch(Exception e){
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #8
Source File: GenericDataSinkBaseTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSourcePlain() {
	try {
		TestNonRichOutputFormat out = new TestNonRichOutputFormat();
		GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>(
				out,
				new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)),
				"test_sink");
		sink.setInput(source);

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		in.reset();
		sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig);
		assertEquals(out.output, asList(TestIOData.NAMES));

		executionConfig.enableObjectReuse();
		out.clear();
		in.reset();
		sink.executeOnCollections(asList(TestIOData.NAMES), null, executionConfig);
		assertEquals(out.output, asList(TestIOData.NAMES));
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #9
Source File: GenericDataSinkBaseTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSourceWithRuntimeContext() {
	try {
		TestRichOutputFormat out = new TestRichOutputFormat();
		GenericDataSinkBase<String> sink = new GenericDataSinkBase<String>(
				out,
				new UnaryOperatorInformation<String, Nothing>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.getInfoFor(Nothing.class)),
				"test_sink");
		sink.setInput(source);

		ExecutionConfig executionConfig = new ExecutionConfig();
		final HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
		final HashMap<String, Future<Path>> cpTasks = new HashMap<>();
		final TaskInfo taskInfo = new TaskInfo("test_sink", 1, 0, 1, 0);
		executionConfig.disableObjectReuse();
		in.reset();
		
		sink.executeOnCollections(asList(TestIOData.NAMES), new RuntimeUDFContext(
				taskInfo, null, executionConfig, cpTasks, accumulatorMap, new UnregisteredMetricsGroup()),
				executionConfig);
	
			assertEquals(out.output, asList(TestIOData.RICH_NAMES));

		executionConfig.enableObjectReuse();
		out.clear();
		in.reset();
		
		sink.executeOnCollections(asList(TestIOData.NAMES), new RuntimeUDFContext(
				taskInfo, null, executionConfig, cpTasks, accumulatorMap, new UnregisteredMetricsGroup()),
				executionConfig);
		assertEquals(out.output, asList(TestIOData.RICH_NAMES));
	} catch(Exception e){
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #10
Source File: GenericDataSourceBaseTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testDataSourceWithRuntimeContext() {
	try {
		TestRichInputFormat in = new TestRichInputFormat();
		GenericDataSourceBase<String, TestRichInputFormat> source =
				new GenericDataSourceBase<String, TestRichInputFormat>(
						in, new OperatorInformation<String>(BasicTypeInfo.STRING_TYPE_INFO), "testSource");

		final HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
		final HashMap<String, Future<Path>> cpTasks = new HashMap<>();
		final TaskInfo taskInfo = new TaskInfo("test_source", 1, 0, 1, 0);

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		assertEquals(false, in.hasBeenClosed());
		assertEquals(false, in.hasBeenOpened());
		
		List<String> resultMutableSafe = source.executeOnCollections(
				new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks, accumulatorMap,
						new UnregisteredMetricsGroup()), executionConfig);
		
		assertEquals(true, in.hasBeenClosed());
		assertEquals(true, in.hasBeenOpened());

		in.reset();
		executionConfig.enableObjectReuse();
		assertEquals(false, in.hasBeenClosed());
		assertEquals(false, in.hasBeenOpened());
		
		List<String> resultRegular = source.executeOnCollections(
				new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks, accumulatorMap,
						new UnregisteredMetricsGroup()), executionConfig);
		
		assertEquals(true, in.hasBeenClosed());
		assertEquals(true, in.hasBeenOpened());

		assertEquals(asList(TestIOData.RICH_NAMES), resultMutableSafe);
		assertEquals(asList(TestIOData.RICH_NAMES), resultRegular);
	}
	catch(Exception e){
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #11
Source File: GenericDataSourceBaseTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testDataSourceWithRuntimeContext() {
	try {
		TestRichInputFormat in = new TestRichInputFormat();
		GenericDataSourceBase<String, TestRichInputFormat> source =
				new GenericDataSourceBase<String, TestRichInputFormat>(
						in, new OperatorInformation<String>(BasicTypeInfo.STRING_TYPE_INFO), "testSource");

		final HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
		final HashMap<String, Future<Path>> cpTasks = new HashMap<>();
		final TaskInfo taskInfo = new TaskInfo("test_source", 1, 0, 1, 0);

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		assertEquals(false, in.hasBeenClosed());
		assertEquals(false, in.hasBeenOpened());
		
		List<String> resultMutableSafe = source.executeOnCollections(
				new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks, accumulatorMap,
						new UnregisteredMetricsGroup()), executionConfig);
		
		assertEquals(true, in.hasBeenClosed());
		assertEquals(true, in.hasBeenOpened());

		in.reset();
		executionConfig.enableObjectReuse();
		assertEquals(false, in.hasBeenClosed());
		assertEquals(false, in.hasBeenOpened());
		
		List<String> resultRegular = source.executeOnCollections(
				new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks, accumulatorMap,
						new UnregisteredMetricsGroup()), executionConfig);
		
		assertEquals(true, in.hasBeenClosed());
		assertEquals(true, in.hasBeenOpened());

		assertEquals(asList(TestIOData.RICH_NAMES), resultMutableSafe);
		assertEquals(asList(TestIOData.RICH_NAMES), resultRegular);
	}
	catch(Exception e){
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #12
Source File: GenericDataSourceBaseTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testDataSourceWithRuntimeContext() {
	try {
		TestRichInputFormat in = new TestRichInputFormat();
		GenericDataSourceBase<String, TestRichInputFormat> source =
				new GenericDataSourceBase<String, TestRichInputFormat>(
						in, new OperatorInformation<String>(BasicTypeInfo.STRING_TYPE_INFO), "testSource");

		final HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
		final HashMap<String, Future<Path>> cpTasks = new HashMap<>();
		final TaskInfo taskInfo = new TaskInfo("test_source", 1, 0, 1, 0);

		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		assertEquals(false, in.hasBeenClosed());
		assertEquals(false, in.hasBeenOpened());
		
		List<String> resultMutableSafe = source.executeOnCollections(
				new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks, accumulatorMap,
						new UnregisteredMetricsGroup()), executionConfig);
		
		assertEquals(true, in.hasBeenClosed());
		assertEquals(true, in.hasBeenOpened());

		in.reset();
		executionConfig.enableObjectReuse();
		assertEquals(false, in.hasBeenClosed());
		assertEquals(false, in.hasBeenOpened());
		
		List<String> resultRegular = source.executeOnCollections(
				new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks, accumulatorMap,
						new UnregisteredMetricsGroup()), executionConfig);
		
		assertEquals(true, in.hasBeenClosed());
		assertEquals(true, in.hasBeenOpened());

		assertEquals(asList(TestIOData.RICH_NAMES), resultMutableSafe);
		assertEquals(asList(TestIOData.RICH_NAMES), resultRegular);
	}
	catch(Exception e){
		e.printStackTrace();
		fail(e.getMessage());
	}
}