A method and system for processing a data stream are described. The method executes, until the occurrence of a cut condition, a map function from a set of query processing steps to generate map results for a first portion of the data stream, executes a reduce function from the set of query processing steps to generate history-sensitive data from the map results, and rewinds the set of query processing steps, without termination of processing. The history-sensitive data is maintained for a second execution of the map function and reduce function on a second portion of the data stream.