Search in sources :

Example 1 with Nothing

use of org.apache.flink.types.Nothing in project flink by apache.

the class GenericDataSinkBaseTest method testDataSourceWithRuntimeContext.

@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());
    }
}
Also used : Accumulator(org.apache.flink.api.common.accumulators.Accumulator) UnregisteredMetricsGroup(org.apache.flink.metrics.groups.UnregisteredMetricsGroup) HashMap(java.util.HashMap) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) Nothing(org.apache.flink.types.Nothing) TaskInfo(org.apache.flink.api.common.TaskInfo) RuntimeUDFContext(org.apache.flink.api.common.functions.util.RuntimeUDFContext) Future(java.util.concurrent.Future) TestRichOutputFormat(org.apache.flink.api.common.operators.util.TestRichOutputFormat) Test(org.junit.Test)

Example 2 with Nothing

use of org.apache.flink.types.Nothing in project flink by apache.

the class GenericDataSinkBaseTest method testDataSourcePlain.

@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());
    }
}
Also used : TestNonRichOutputFormat(org.apache.flink.api.common.operators.util.TestNonRichOutputFormat) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) Nothing(org.apache.flink.types.Nothing) Test(org.junit.Test)

Aggregations

ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2 Nothing (org.apache.flink.types.Nothing)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Future (java.util.concurrent.Future)1 TaskInfo (org.apache.flink.api.common.TaskInfo)1 Accumulator (org.apache.flink.api.common.accumulators.Accumulator)1 RuntimeUDFContext (org.apache.flink.api.common.functions.util.RuntimeUDFContext)1 TestNonRichOutputFormat (org.apache.flink.api.common.operators.util.TestNonRichOutputFormat)1 TestRichOutputFormat (org.apache.flink.api.common.operators.util.TestRichOutputFormat)1 UnregisteredMetricsGroup (org.apache.flink.metrics.groups.UnregisteredMetricsGroup)1