elasticsearch/elasticsearch — pull request #6477 by colings86 (2014-06-12 10:08:45+00:00)
Title: Aggregations: Delegation of nextReader calls

Currently aggregations subscribe to setNextReader calls in AggregationContext. When a new reader is used all reader aware objects are notified of the new reader. With deferred aggregations children aggregations of a breath-first aggregation do not require to be notified of reader changes until the replay stage. Also, at the replay stage only the child aggregations of the breath-first aggregation need to be notified, we should not be notifying all the other aggregations of the new reader.

To solve this the calls for setNextReader are now handled by each aggregation so it can notify its child aggregations and any other ReaderContextAware objects (e.g. ValueSources) of the new reader at the relevant time.

The same idea has also been applied to the setScorer and setTopReader calls for Aggregators and ValueSources.