Improvements to aggregation framework

Benchmarks show a 10-30% performance gain

Benchmarks (master):
                          count_agg ::    3.606 cpu ms :: in  1.5M,  12.9MB,    416M/s,  3.49GB/s :: out     1,  1.02KB,     277/s,   284KB/s
                     double_sum_agg ::   26.284 cpu ms :: in  1.5M,  12.9MB,   57.1M/s,   490MB/s :: out     1,  1.02KB,      38/s,  38.9KB/s
                           hash_agg ::  148.530 cpu ms :: in  1.5M,  23.4MB,   10.1M/s,   157MB/s :: out     3,  1.09KB,      20/s,  7.35KB/s
                   predicate_filter ::   73.680 cpu ms :: in  1.5M,  12.9MB,   20.4M/s,   175MB/s :: out 1.29M,  11.3MB,   17.5M/s,   153MB/s
                         raw_stream ::    3.631 cpu ms :: in  1.5M,  12.9MB,    413M/s,  3.46GB/s :: out  1.5M,  12.9MB,    413M/s,  3.46GB/s
                             top100 ::   27.935 cpu ms :: in  1.5M,  12.9MB,   53.7M/s,   461MB/s :: out   100,   1.8KB,   3.58K/s,  64.3KB/s
             in_memory_orderby_1.5M :: 1504.026 cpu ms :: in  1.5M,  50.1MB,    997K/s,  33.3MB/s :: out  1.5M,  28.6MB,    997K/s,    19MB/s
                         hash_build ::  320.783 cpu ms :: in  1.5M,  25.8MB,   4.68M/s,  80.3MB/s :: out  1.5M,  25.8MB,   4.68M/s,  80.3MB/s
                          hash_join :: 1235.543 cpu ms :: in    6M,   103MB,   4.86M/s,  83.4MB/s :: out    6M,   229MB,   4.86M/s,   185MB/s
                hash_build_and_join :: 1611.270 cpu ms :: in  7.5M,   129MB,   4.66M/s,  79.9MB/s :: out    6M,   229MB,   3.72M/s,   142MB/s
                  hand_tpch_query_1 :: 2710.860 cpu ms :: in    6M,   458MB,   2.21M/s,   169MB/s :: out     4,  7.45KB,       1/s,  2.75KB/s
                  hand_tpch_query_6 ::  273.196 cpu ms :: in    6M,   271MB,     22M/s,   992MB/s :: out     1,  1.02KB,       3/s,  3.75KB/s
    sql_groupby_agg_with_arithmetic ::  931.339 cpu ms :: in    6M,   145MB,   6.44M/s,   156MB/s :: out     2,  1.08KB,       2/s,  1.16KB/s
                      sql_count_agg ::    5.100 cpu ms :: in  1.5M,  12.9MB,    294M/s,  2.47GB/s :: out     1,  1.02KB,     196/s,   201KB/s
                 sql_double_sum_agg ::   27.523 cpu ms :: in  1.5M,  12.9MB,   54.5M/s,   468MB/s :: out     1,  1.02KB,      36/s,  37.2KB/s
              sql_count_with_filter ::   66.517 cpu ms :: in  1.5M,  8.59MB,   22.6M/s,   129MB/s :: out     1,  1.02KB,      15/s,  15.4KB/s
                    sql_groupby_agg ::  148.829 cpu ms :: in  1.5M,  23.4MB,   10.1M/s,   157MB/s :: out     3,  1.09KB,      20/s,  7.33KB/s
               sql_predicate_filter ::   32.651 cpu ms :: in  1.5M,  12.9MB,   45.9M/s,   394MB/s :: out 1.29M,  11.3MB,   39.5M/s,   345MB/s
                     sql_raw_stream ::    4.794 cpu ms :: in  1.5M,  12.9MB,    313M/s,  2.62GB/s :: out  1.5M,  12.9MB,    313M/s,  2.62GB/s
                        sql_top_100 ::   28.930 cpu ms :: in  1.5M,  12.9MB,   51.8M/s,   445MB/s :: out   100,   1.8KB,   3.45K/s,  62.1KB/s
                      sql_hash_join :: 2799.406 cpu ms :: in  7.5M,   129MB,   2.68M/s,    46MB/s :: out    6M,   229MB,   2.14M/s,  81.8MB/s
            sql_join_with_predicate ::  588.991 cpu ms :: in  7.5M,   116MB,   12.7M/s,   197MB/s :: out     1,  1.02KB,       1/s,  1.74KB/s
                  sql_varbinary_max ::  246.238 cpu ms :: in    6M,  97.3MB,   24.4M/s,   395MB/s :: out     1,     57B,       4/s,    231B/s
                 sql_distinct_multi ::  188.266 cpu ms :: in  1.5M,  39.2MB,   7.97M/s,   208MB/s :: out     5,  1.16KB,      26/s,  6.14KB/s
                sql_distinct_single ::   85.986 cpu ms :: in  1.5M,  12.9MB,   17.4M/s,   150MB/s :: out     1,  1.02KB,      11/s,  11.9KB/s
                   sql_tpch_query_1 :: 2749.494 cpu ms :: in    6M,   458MB,   2.18M/s,   167MB/s :: out     4,  8.49KB,       1/s,  3.09KB/s
                   sql_tpch_query_6 ::  211.896 cpu ms :: in    6M,   271MB,   28.3M/s,  1.25GB/s :: out     1,  1.02KB,       4/s,  4.83KB/s
                           sql_like :: 2945.558 cpu ms :: in    6M,   270MB,   2.04M/s,  91.8MB/s :: out 1.15M,  10.9MB,    389K/s,   3.7MB/s
                             sql_in ::   49.545 cpu ms :: in    6M,  51.5MB,    121M/s,  1.02GB/s :: out    25,  1.21KB,     504/s,  24.4KB/s
                    sql_semijoin_in :: 1040.881 cpu ms :: in  7.5M,  64.4MB,   7.21M/s,  61.9MB/s :: out    3M,  27.5MB,   2.88M/s,  26.4MB/s
                    sql_regexp_like :: 2288.169 cpu ms :: in  1.5M,  76.6MB,    656K/s,  33.5MB/s :: out     1,  1.02KB,       0/s,    458B/s
         sql_approx_percentile_long ::  560.223 cpu ms :: in  1.5M,  12.9MB,   2.68M/s,    23MB/s :: out     1,  1.02KB,       1/s,  1.83KB/s
                   sql_between_long ::   31.808 cpu ms :: in  1.5M,  12.9MB,   47.2M/s,   405MB/s :: out     1,  1.02KB,      31/s,  32.2KB/s
                 stat_long_variance ::   23.990 cpu ms :: in  1.5M,  12.9MB,   62.5M/s,   537MB/s :: out     1,  1.02KB,      41/s,  42.7KB/s
             stat_long_variance_pop ::   23.977 cpu ms :: in  1.5M,  12.9MB,   62.6M/s,   537MB/s :: out     1,  1.02KB,      41/s,  42.7KB/s
               stat_double_variance ::   20.221 cpu ms :: in  1.5M,  12.9MB,   74.2M/s,   637MB/s :: out     1,  1.02KB,      49/s,  50.6KB/s
           stat_double_variance_pop ::   20.209 cpu ms :: in  1.5M,  12.9MB,   74.2M/s,   637MB/s :: out     1,  1.02KB,      49/s,  50.6KB/s
                   stat_long_stddev ::   23.884 cpu ms :: in  1.5M,  12.9MB,   62.8M/s,   539MB/s :: out     1,  1.02KB,      41/s,  42.8KB/s
               stat_long_stddev_pop ::   23.878 cpu ms :: in  1.5M,  12.9MB,   62.8M/s,   539MB/s :: out     1,  1.02KB,      41/s,  42.9KB/s
                 stat_double_stddev ::   20.006 cpu ms :: in  1.5M,  12.9MB,     75M/s,   644MB/s :: out     1,  1.02KB,      49/s,  51.2KB/s
             stat_double_stddev_pop ::   20.205 cpu ms :: in  1.5M,  12.9MB,   74.2M/s,   637MB/s :: out     1,  1.02KB,      49/s,  50.7KB/s
     sql_approx_count_distinct_long ::   24.346 cpu ms :: in  1.5M,  12.9MB,   61.6M/s,   529MB/s :: out     1,  1.02KB,      41/s,    42KB/s
   sql_approx_count_distinct_double ::   26.044 cpu ms :: in  1.5M,  12.9MB,   57.6M/s,   494MB/s :: out     1,  1.02KB,      38/s,  39.3KB/s
Jul 21, 2014 11:57:50 AM io.airlift.log.Logger info
sql_approx_count_distinct_varbinary ::   75.750 cpu ms :: in  1.5M,  21.5MB,   19.8M/s,   283MB/s :: out     1,  1.02KB,      13/s,  13.5KB/s


Benchmarks on my branch:
                          count_agg ::    3.584 cpu ms :: in  1.5M,  12.9MB,    418M/s,  3.51GB/s :: out     1,  1.02KB,     278/s,   286KB/s
                     double_sum_agg ::   18.778 cpu ms :: in  1.5M,  12.9MB,   79.9M/s,   686MB/s :: out     1,  1.02KB,      53/s,  54.5KB/s
                           hash_agg ::  136.159 cpu ms :: in  1.5M,  23.4MB,     11M/s,   172MB/s :: out     3,  1.09KB,      22/s,  8.02KB/s
                   predicate_filter ::   71.093 cpu ms :: in  1.5M,  12.9MB,   21.1M/s,   181MB/s :: out 1.29M,  11.3MB,   18.1M/s,   158MB/s
                         raw_stream ::    3.500 cpu ms :: in  1.5M,  12.9MB,    429M/s,  3.59GB/s :: out  1.5M,  12.9MB,    429M/s,  3.59GB/s
                             top100 ::   28.027 cpu ms :: in  1.5M,  12.9MB,   53.5M/s,   459MB/s :: out   100,   1.8KB,   3.57K/s,  64.1KB/s
             in_memory_orderby_1.5M :: 1469.982 cpu ms :: in  1.5M,  50.1MB,   1.02M/s,  34.1MB/s :: out  1.5M,  28.6MB,   1.02M/s,  19.5MB/s
                         hash_build ::  330.285 cpu ms :: in  1.5M,  25.8MB,   4.54M/s,    78MB/s :: out  1.5M,  25.8MB,   4.54M/s,    78MB/s
                          hash_join :: 1260.090 cpu ms :: in    6M,   103MB,   4.76M/s,  81.8MB/s :: out    6M,   229MB,   4.76M/s,   182MB/s
                hash_build_and_join :: 1607.804 cpu ms :: in  7.5M,   129MB,   4.67M/s,  80.1MB/s :: out    6M,   229MB,   3.73M/s,   142MB/s
                  hand_tpch_query_1 :: 2544.824 cpu ms :: in    6M,   458MB,   2.36M/s,   180MB/s :: out     4,  7.45KB,       1/s,  2.92KB/s
                  hand_tpch_query_6 ::  276.046 cpu ms :: in    6M,   271MB,   21.7M/s,   982MB/s :: out     1,  1.02KB,       3/s,  3.71KB/s
    sql_groupby_agg_with_arithmetic ::  867.701 cpu ms :: in    6M,   145MB,   6.92M/s,   167MB/s :: out     2,  1.08KB,       2/s,  1.24KB/s
                      sql_count_agg ::    4.525 cpu ms :: in  1.5M,  12.9MB,    332M/s,  2.78GB/s :: out     1,  1.02KB,     221/s,   226KB/s
                 sql_double_sum_agg ::   19.782 cpu ms :: in  1.5M,  12.9MB,   75.8M/s,   651MB/s :: out     1,  1.02KB,      50/s,  51.7KB/s
              sql_count_with_filter ::   63.298 cpu ms :: in  1.5M,  8.59MB,   23.7M/s,   136MB/s :: out     1,  1.02KB,      15/s,  16.2KB/s
                    sql_groupby_agg ::  138.630 cpu ms :: in  1.5M,  23.4MB,   10.8M/s,   169MB/s :: out     3,  1.09KB,      21/s,  7.88KB/s
               sql_predicate_filter ::   27.900 cpu ms :: in  1.5M,  12.9MB,   53.8M/s,   462MB/s :: out 1.29M,  11.3MB,   46.2M/s,   404MB/s
                     sql_raw_stream ::    4.854 cpu ms :: in  1.5M,  12.9MB,    309M/s,  2.59GB/s :: out  1.5M,  12.9MB,    309M/s,  2.59GB/s
                        sql_top_100 ::   27.996 cpu ms :: in  1.5M,  12.9MB,   53.6M/s,   460MB/s :: out   100,   1.8KB,   3.57K/s,  64.2KB/s
                      sql_hash_join :: 2751.243 cpu ms :: in  7.5M,   129MB,   2.73M/s,  46.8MB/s :: out    6M,   229MB,   2.18M/s,  83.2MB/s
            sql_join_with_predicate ::  577.633 cpu ms :: in  7.5M,   116MB,     13M/s,   201MB/s :: out     1,  1.02KB,       1/s,  1.77KB/s
                  sql_varbinary_max ::  213.180 cpu ms :: in    6M,  97.3MB,   28.2M/s,   457MB/s :: out     1,     57B,       4/s,    267B/s
                 sql_distinct_multi ::  164.355 cpu ms :: in  1.5M,  39.2MB,   9.13M/s,   239MB/s :: out     5,  1.16KB,      30/s,  7.03KB/s
                sql_distinct_single ::   85.907 cpu ms :: in  1.5M,  12.9MB,   17.5M/s,   150MB/s :: out     1,  1.02KB,      11/s,  11.9KB/s
                   sql_tpch_query_1 :: 2580.721 cpu ms :: in    6M,   458MB,   2.33M/s,   178MB/s :: out     4,  8.49KB,       1/s,  3.29KB/s
                   sql_tpch_query_6 ::  206.511 cpu ms :: in    6M,   271MB,   29.1M/s,  1.28GB/s :: out     1,  1.02KB,       4/s,  4.96KB/s
                           sql_like :: 2841.709 cpu ms :: in    6M,   270MB,   2.11M/s,  95.2MB/s :: out 1.15M,  10.9MB,    404K/s,  3.83MB/s
                             sql_in ::   48.315 cpu ms :: in    6M,  51.5MB,    124M/s,  1.04GB/s :: out    25,  1.21KB,     517/s,  25.1KB/s
                    sql_semijoin_in :: 1024.990 cpu ms :: in  7.5M,  64.4MB,   7.32M/s,  62.8MB/s :: out    3M,  27.5MB,   2.93M/s,  26.8MB/s
                    sql_regexp_like :: 2268.136 cpu ms :: in  1.5M,  76.6MB,    661K/s,  33.8MB/s :: out     1,  1.02KB,       0/s,    462B/s
         sql_approx_percentile_long ::  576.011 cpu ms :: in  1.5M,  12.9MB,    2.6M/s,  22.4MB/s :: out     1,  1.02KB,       1/s,  1.78KB/s
                   sql_between_long ::   31.243 cpu ms :: in  1.5M,  12.9MB,     48M/s,   412MB/s :: out     1,  1.02KB,      32/s,  32.8KB/s
                 stat_long_variance ::   23.549 cpu ms :: in  1.5M,  12.9MB,   63.7M/s,   547MB/s :: out     1,  1.02KB,      42/s,  43.5KB/s
             stat_long_variance_pop ::   23.575 cpu ms :: in  1.5M,  12.9MB,   63.6M/s,   546MB/s :: out     1,  1.02KB,      42/s,  43.4KB/s
               stat_double_variance ::   19.829 cpu ms :: in  1.5M,  12.9MB,   75.6M/s,   649MB/s :: out     1,  1.02KB,      50/s,  51.6KB/s
           stat_double_variance_pop ::   20.099 cpu ms :: in  1.5M,  12.9MB,   74.6M/s,   641MB/s :: out     1,  1.02KB,      49/s,  50.9KB/s
                   stat_long_stddev ::   23.630 cpu ms :: in  1.5M,  12.9MB,   63.5M/s,   545MB/s :: out     1,  1.02KB,      42/s,  43.3KB/s
               stat_long_stddev_pop ::   23.619 cpu ms :: in  1.5M,  12.9MB,   63.5M/s,   545MB/s :: out     1,  1.02KB,      42/s,  43.3KB/s
                 stat_double_stddev ::   19.740 cpu ms :: in  1.5M,  12.9MB,     76M/s,   652MB/s :: out     1,  1.02KB,      50/s,  51.8KB/s
             stat_double_stddev_pop ::   19.748 cpu ms :: in  1.5M,  12.9MB,     76M/s,   652MB/s :: out     1,  1.02KB,      50/s,  51.8KB/s
     sql_approx_count_distinct_long ::   23.760 cpu ms :: in  1.5M,  12.9MB,   63.1M/s,   542MB/s :: out     1,  1.02KB,      42/s,  43.1KB/s
   sql_approx_count_distinct_double ::   25.405 cpu ms :: in  1.5M,  12.9MB,     59M/s,   507MB/s :: out     1,  1.02KB,      39/s,  40.3KB/s
sql_approx_count_distinct_varbinary ::   74.604 cpu ms :: in  1.5M,  21.5MB,   20.1M/s,   288MB/s :: out     1,  1.02KB,      13/s,  13.7KB/s