From 111bbd97a845803ae2fd8bbf24c0314e1d209bf0 Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Fri, 7 Aug 2020 12:04:55 -0400 Subject: [PATCH] Add Table.sliding wrapper for SlidingWindow --- faust/tables/table.py | 9 +++++++++ faust/types/tables.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/faust/tables/table.py b/faust/tables/table.py index 3ec323082..80d997e94 100644 --- a/faust/tables/table.py +++ b/faust/tables/table.py @@ -37,6 +37,15 @@ def hopping(self, size: Seconds, step: Seconds, key_index=key_index, ) + def sliding(self, before: Seconds, after: Seconds, + expires: Seconds = None, + key_index: bool = False) -> 'WindowWrapperT': + """Wrap table in a sliding window.""" + return self.using_window( + windows.SlidingWindow(before, after, expires), + key_index=key_index, + ) + def tumbling(self, size: Seconds, expires: Seconds = None, key_index: bool = False) -> WindowWrapperT: diff --git a/faust/types/tables.py b/faust/types/tables.py index 39c9a8cf3..e324f5f02 100644 --- a/faust/types/tables.py +++ b/faust/types/tables.py @@ -203,6 +203,12 @@ def hopping(self, size: Seconds, step: Seconds, key_index: bool = False) -> 'WindowWrapperT': ... + @abc.abstractmethod + def sliding(self, before: Seconds, after: Seconds, + expires: Seconds = None, + key_index: bool = False) -> 'WindowWrapperT': + ... + @abc.abstractmethod def tumbling(self, size: Seconds, expires: Seconds = None,