The sliding function is used when you want to have windows to be of a length different than what you slide by. Also sliding is more preferable in such a situation rather than grouping.
The Sliding function results in an RDD from grouping items of its parent RDD in fixed size block by passing window over them. A window operator is defined by two parameters:-
- WindowDuration - the length of the window
- SlideDuration - the interval at which the window will slide or move forward
The Signature for the sliding function is as follows:
def sliding(n: Int, step: Int = 1): Repr[immutable.Seq[Out]]