Search in sources :

Example 6 with SessionWindowTimeGapExtractor

use of org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor in project flink by apache.

the class DynamicProcessingTimeSessionWindowsTest method testMergeCoveringWindow.

@Test
public void testMergeCoveringWindow() {
    MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
    SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class);
    when(extractor.extract(any())).thenReturn(5000L);
    DynamicProcessingTimeSessionWindows assigner = DynamicProcessingTimeSessionWindows.withDynamicGap(extractor);
    assigner.mergeWindows(Lists.newArrayList(new TimeWindow(1, 1), new TimeWindow(0, 2), new TimeWindow(4, 7), new TimeWindow(5, 6)), callback);
    verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(1, 1), new TimeWindow(0, 2))), eq(new TimeWindow(0, 2)));
    verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(5, 6), new TimeWindow(4, 7))), eq(new TimeWindow(4, 7)));
    verify(callback, times(2)).merge(anyCollection(), Matchers.anyObject());
}
Also used : DynamicProcessingTimeSessionWindows(org.apache.flink.streaming.api.windowing.assigners.DynamicProcessingTimeSessionWindows) MergingWindowAssigner(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) SessionWindowTimeGapExtractor(org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor) Test(org.junit.Test)

Example 7 with SessionWindowTimeGapExtractor

use of org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor in project flink by apache.

the class DynamicProcessingTimeSessionWindowsTest method testMergeSingleWindow.

@Test
public void testMergeSingleWindow() {
    MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
    SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class);
    when(extractor.extract(any())).thenReturn(5000L);
    DynamicProcessingTimeSessionWindows assigner = DynamicProcessingTimeSessionWindows.withDynamicGap(extractor);
    assigner.mergeWindows(Lists.newArrayList(new TimeWindow(0, 1)), callback);
    verify(callback, never()).merge(anyCollection(), Matchers.anyObject());
}
Also used : DynamicProcessingTimeSessionWindows(org.apache.flink.streaming.api.windowing.assigners.DynamicProcessingTimeSessionWindows) MergingWindowAssigner(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) SessionWindowTimeGapExtractor(org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor) Test(org.junit.Test)

Example 8 with SessionWindowTimeGapExtractor

use of org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor in project flink by apache.

the class DynamicProcessingTimeSessionWindowsTest method testMergeConsecutiveWindows.

@Test
public void testMergeConsecutiveWindows() {
    MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
    SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class);
    when(extractor.extract(any())).thenReturn(5000L);
    DynamicProcessingTimeSessionWindows assigner = DynamicProcessingTimeSessionWindows.withDynamicGap(extractor);
    assigner.mergeWindows(Lists.newArrayList(new TimeWindow(0, 1), new TimeWindow(1, 2), new TimeWindow(2, 3), new TimeWindow(4, 5), new TimeWindow(5, 6)), callback);
    verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(0, 1), new TimeWindow(1, 2), new TimeWindow(2, 3))), eq(new TimeWindow(0, 3)));
    verify(callback, times(1)).merge((Collection<TimeWindow>) argThat(containsInAnyOrder(new TimeWindow(4, 5), new TimeWindow(5, 6))), eq(new TimeWindow(4, 6)));
    verify(callback, times(2)).merge(anyCollection(), Matchers.anyObject());
}
Also used : DynamicProcessingTimeSessionWindows(org.apache.flink.streaming.api.windowing.assigners.DynamicProcessingTimeSessionWindows) MergingWindowAssigner(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) SessionWindowTimeGapExtractor(org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor) Test(org.junit.Test)

Example 9 with SessionWindowTimeGapExtractor

use of org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor in project flink by apache.

the class DynamicEventTimeSessionWindowsTest method testMergeSinglePointWindow.

@Test
public void testMergeSinglePointWindow() {
    MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
    SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class);
    when(extractor.extract(any())).thenReturn(5000L);
    DynamicEventTimeSessionWindows assigner = DynamicEventTimeSessionWindows.withDynamicGap(extractor);
    assigner.mergeWindows(Lists.newArrayList(new TimeWindow(0, 0)), callback);
    verify(callback, never()).merge(anyCollection(), Matchers.anyObject());
}
Also used : DynamicEventTimeSessionWindows(org.apache.flink.streaming.api.windowing.assigners.DynamicEventTimeSessionWindows) MergingWindowAssigner(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) SessionWindowTimeGapExtractor(org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor) Test(org.junit.Test)

Example 10 with SessionWindowTimeGapExtractor

use of org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor in project flink by apache.

the class DynamicEventTimeSessionWindowsTest method testMergeSingleWindow.

@Test
public void testMergeSingleWindow() {
    MergingWindowAssigner.MergeCallback callback = mock(MergingWindowAssigner.MergeCallback.class);
    SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class);
    when(extractor.extract(any())).thenReturn(5000L);
    DynamicEventTimeSessionWindows assigner = DynamicEventTimeSessionWindows.withDynamicGap(extractor);
    assigner.mergeWindows(Lists.newArrayList(new TimeWindow(0, 1)), callback);
    verify(callback, never()).merge(anyCollection(), Matchers.anyObject());
}
Also used : DynamicEventTimeSessionWindows(org.apache.flink.streaming.api.windowing.assigners.DynamicEventTimeSessionWindows) MergingWindowAssigner(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) SessionWindowTimeGapExtractor(org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor) Test(org.junit.Test)

Aggregations

SessionWindowTimeGapExtractor (org.apache.flink.streaming.api.windowing.assigners.SessionWindowTimeGapExtractor)12 Test (org.junit.Test)12 MergingWindowAssigner (org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner)10 TimeWindow (org.apache.flink.streaming.api.windowing.windows.TimeWindow)10 DynamicEventTimeSessionWindows (org.apache.flink.streaming.api.windowing.assigners.DynamicEventTimeSessionWindows)6 DynamicProcessingTimeSessionWindows (org.apache.flink.streaming.api.windowing.assigners.DynamicProcessingTimeSessionWindows)6 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2 WindowAssigner (org.apache.flink.streaming.api.windowing.assigners.WindowAssigner)2 EventTimeTrigger (org.apache.flink.streaming.api.windowing.triggers.EventTimeTrigger)1 ProcessingTimeTrigger (org.apache.flink.streaming.api.windowing.triggers.ProcessingTimeTrigger)1