Search in sources :

Example 6 with InternalIterableWindowFunction

use of org.apache.flink.streaming.runtime.operators.windowing.functions.InternalIterableWindowFunction in project flink by apache.

the class InternalWindowFunctionTest method testInternalIterableWindowFunction.

@SuppressWarnings("unchecked")
@Test
public void testInternalIterableWindowFunction() throws Exception {
    WindowFunctionMock mock = mock(WindowFunctionMock.class);
    InternalIterableWindowFunction<Long, String, Long, TimeWindow> windowFunction = new InternalIterableWindowFunction<>(mock);
    // check setOutputType
    TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
    ExecutionConfig execConf = new ExecutionConfig();
    execConf.setParallelism(42);
    StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
    verify(mock).setOutputType(stringType, execConf);
    // check open
    Configuration config = new Configuration();
    windowFunction.open(config);
    verify(mock).open(config);
    // check setRuntimeContext
    RuntimeContext rCtx = mock(RuntimeContext.class);
    windowFunction.setRuntimeContext(rCtx);
    verify(mock).setRuntimeContext(rCtx);
    // check apply
    TimeWindow w = mock(TimeWindow.class);
    Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
    Collector<String> c = (Collector<String>) mock(Collector.class);
    windowFunction.apply(42L, w, i, c);
    verify(mock).apply(eq(42L), eq(w), eq(i), eq(c));
    // check close
    windowFunction.close();
    verify(mock).close();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) InternalIterableWindowFunction(org.apache.flink.streaming.runtime.operators.windowing.functions.InternalIterableWindowFunction) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) Collector(org.apache.flink.util.Collector) RuntimeContext(org.apache.flink.api.common.functions.RuntimeContext) Test(org.junit.Test)

Aggregations

InternalIterableWindowFunction (org.apache.flink.streaming.runtime.operators.windowing.functions.InternalIterableWindowFunction)6 RichFunction (org.apache.flink.api.common.functions.RichFunction)5 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)5 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)5 InternalSingleValueWindowFunction (org.apache.flink.streaming.runtime.operators.windowing.functions.InternalSingleValueWindowFunction)5 StreamElementSerializer (org.apache.flink.streaming.runtime.streamrecord.StreamElementSerializer)5 StreamRecord (org.apache.flink.streaming.runtime.streamrecord.StreamRecord)5 PublicEvolving (org.apache.flink.annotation.PublicEvolving)2 FoldingStateDescriptor (org.apache.flink.api.common.state.FoldingStateDescriptor)2 ReducingStateDescriptor (org.apache.flink.api.common.state.ReducingStateDescriptor)2 MergingWindowAssigner (org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner)2 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 RuntimeContext (org.apache.flink.api.common.functions.RuntimeContext)1 AggregatingStateDescriptor (org.apache.flink.api.common.state.AggregatingStateDescriptor)1 Configuration (org.apache.flink.configuration.Configuration)1 BaseAlignedWindowAssigner (org.apache.flink.streaming.api.windowing.assigners.BaseAlignedWindowAssigner)1 TimeWindow (org.apache.flink.streaming.api.windowing.windows.TimeWindow)1 Collector (org.apache.flink.util.Collector)1 Test (org.junit.Test)1