hpcc-systems/HPCC-Platform — pull request #1899 by ghalliday (2012-03-19 10:42:08+00:00)
Title: Fix problems with global optimizer

Previously the optimizer was based on a merging transformer - which
transforms each expression in the tree once for each context it is used
in. This was because selectors can have ambiguous meanings depending
on the context they were used.

However the optimizer also relies on couning the number of active
references to each dataset, and if an expression is transformed more
than once those counts are no longer valid. Instead this now
transforms and then calls updateOrphanedSelectors() to ensure the
expressions are only updated once.

That function required fixing to cope with sqnormidx2 and other
examples that implicitly access fields of the parent dataset
(a fairly unusual situation.)

Signed-off-by: Gavin Halliday