PA: updates to run spilling with minimum required memory.

With this change, we can run partitioned aggs at the minimum required memory. This
value is a constant thats based on the io block size and fanout.

Change-Id: I8555c5216fa14d1ea66dcbcbeff266e2a754a012
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4209
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
IMPALA-1211: Query should be unregistered if SetResultCache returns error status

Otherwise, the query will hang around until the session or connection is
closed.  Enhance a test so that this is regression tested.

While I'm here, some minor cleanup: hoist out some code that's sprinkled
between the return_val writes to make it more obvious what the code is doing.

Change-Id: I594e583c4e10f12c3f9b920ea4d44e5da7df3558
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4211
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins