cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Compare current to previous document in stream

kmiesse
Contributor

If I want to compare two consecutive documents in an ordered stream (compare the current to the previous or next), is the best way to do that with array indexing functions in mappers/conditionals?

5 REPLIES 5

Hereโ€™s what I was thinking.

The GroupByN snap will group each 2 consecutive documents into a single document. Note this will group the first and second, third and fourth, and so on, but not the first and second, second and third, third and fourth. If you wanted to do a more complex grouping like the latter, youโ€™d probably have to muck around with adding an index and joining.

From there, the example is pretty simple and shows how to use the Mapper to do some basic operations on the data.

Hopefully this is helpful.

group-comparison-example_2020_04_21.slp (4.8 KB)