Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/11274#issuecomment-186356444
  
    This is generated code for Q55:
    ```
    select i_brand_id brand_id, i_brand brand,
        sum(ss_ext_sales_price) ext_price
     from date_dim, store_sales, item
     where d_date_sk = ss_sold_date_sk
        and ss_item_sk = i_item_sk
        and i_manager_id=28
        and d_moy=11
        and d_year=1999
     group by i_brand, i_brand_id
     order by ext_price desc, brand_id
     limit 100
    ```
    
    ```
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * Project [i_brand_id#188,i_item_sk#181,i_brand#189]
    /* 008 */ +- Filter (i_manager_id#201 = 28)
    /* 009 */ +- INPUT
    /* 010 */ */
    /* 011 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 012 */   private Object[] references;
    /* 013 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
filter_numOutputRows;
    /* 014 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue filter_metricValue;
    /* 015 */   private UnsafeRow project_result;
    /* 016 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder project_holder;
    /* 017 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter 
project_rowWriter;
    /* 018 */
    /* 019 */   public GeneratedIterator(Object[] references) {
    /* 020 */     this.references = references;
    /* 021 */     this.filter_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[0];
    /* 022 */     filter_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
filter_numOutputRows.localValue();
    /* 023 */     project_result = new UnsafeRow(3);
    /* 024 */     this.project_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(project_result, 
32);
    /* 025 */     this.project_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(project_holder,
 3);
    /* 026 */   }
    /* 027 */
    /* 028 */   protected void processNext() throws java.io.IOException {
    /* 029 */     /*** PRODUCE: Project 
[i_brand_id#188,i_item_sk#181,i_brand#189] */
    /* 030 */
    /* 031 */     /*** PRODUCE: Filter (i_manager_id#201 = 28) */
    /* 032 */
    /* 033 */     /*** PRODUCE: INPUT */
    /* 034 */
    /* 035 */     while (!shouldStop() && input.hasNext()) {
    /* 036 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 037 */       /*** CONSUME: Filter (i_manager_id#201 = 28) */
    /* 038 */       /* input[3, int] */
    /* 039 */       boolean inputadapter_isNull3 = inputadapter_row.isNullAt(3);
    /* 040 */       int inputadapter_value3 = inputadapter_isNull3 ? -1 : 
(inputadapter_row.getInt(3));
    /* 041 */
    /* 042 */       /* (input[3, int] = 28) */
    /* 043 */       boolean filter_isNull = true;
    /* 044 */       boolean filter_value = false;
    /* 045 */
    /* 046 */       if (!inputadapter_isNull3) {
    /* 047 */         filter_isNull = false; // resultCode could change 
nullability.
    /* 048 */         filter_value = inputadapter_value3 == 28;
    /* 049 */
    /* 050 */       }
    /* 051 */       if (!(!filter_isNull && filter_value)) continue;
    /* 052 */       filter_metricValue.add(1);
    /* 053 */
    /* 054 */       /*** CONSUME: Project 
[i_brand_id#188,i_item_sk#181,i_brand#189] */
    /* 055 */       /* input[0, int] */
    /* 056 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 057 */       int inputadapter_value = inputadapter_isNull ? -1 : 
(inputadapter_row.getInt(0));
    /* 058 */       /* input[1, int] */
    /* 059 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 060 */       int inputadapter_value1 = inputadapter_isNull1 ? -1 : 
(inputadapter_row.getInt(1));
    /* 061 */       /* input[2, string] */
    /* 062 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 063 */       UTF8String inputadapter_value2 = inputadapter_isNull2 ? 
null : (inputadapter_row.getUTF8String(2));
    /* 064 */
    /* 065 */       project_holder.reset();
    /* 066 */
    /* 067 */       project_rowWriter.zeroOutNullBytes();
    /* 068 */
    /* 069 */       if (inputadapter_isNull) {
    /* 070 */         project_rowWriter.setNullAt(0);
    /* 071 */       } else {
    /* 072 */         project_rowWriter.write(0, inputadapter_value);
    /* 073 */       }
    /* 074 */
    /* 075 */       if (inputadapter_isNull1) {
    /* 076 */         project_rowWriter.setNullAt(1);
    /* 077 */       } else {
    /* 078 */         project_rowWriter.write(1, inputadapter_value1);
    /* 079 */       }
    /* 080 */
    /* 081 */       if (inputadapter_isNull2) {
    /* 082 */         project_rowWriter.setNullAt(2);
    /* 083 */       } else {
    /* 084 */         project_rowWriter.write(2, inputadapter_value2);
    /* 085 */       }
    /* 086 */       project_result.setTotalSize(project_holder.totalSize());
    /* 087 */       currentRows.add(project_result.copy());
    /* 088 */     }
    /* 089 */   }
    /* 090 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * Project [d_date_sk#141]
    /* 008 */ +- Filter ((d_moy#149 = 11) && (d_year#147 = 1999))
    /* 009 */ +- INPUT
    /* 010 */ */
    /* 011 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 012 */   private Object[] references;
    /* 013 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
filter_numOutputRows;
    /* 014 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue filter_metricValue;
    /* 015 */   private UnsafeRow project_result;
    /* 016 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder project_holder;
    /* 017 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter 
project_rowWriter;
    /* 018 */
    /* 019 */   public GeneratedIterator(Object[] references) {
    /* 020 */     this.references = references;
    /* 021 */     this.filter_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[0];
    /* 022 */     filter_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
filter_numOutputRows.localValue();
    /* 023 */     project_result = new UnsafeRow(1);
    /* 024 */     this.project_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(project_result, 
0);
    /* 025 */     this.project_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(project_holder,
 1);
    /* 026 */   }
    /* 027 */
    /* 028 */   protected void processNext() throws java.io.IOException {
    /* 029 */     /*** PRODUCE: Project [d_date_sk#141] */
    /* 030 */
    /* 031 */     /*** PRODUCE: Filter ((d_moy#149 = 11) && (d_year#147 = 
1999)) */
    /* 032 */
    /* 033 */     /*** PRODUCE: INPUT */
    /* 034 */
    /* 035 */     while (!shouldStop() && input.hasNext()) {
    /* 036 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 037 */       /*** CONSUME: Filter ((d_moy#149 = 11) && (d_year#147 = 
1999)) */
    /* 038 */       /* input[1, int] */
    /* 039 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 040 */       int inputadapter_value1 = inputadapter_isNull1 ? -1 : 
(inputadapter_row.getInt(1));
    /* 041 */       /* input[2, int] */
    /* 042 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 043 */       int inputadapter_value2 = inputadapter_isNull2 ? -1 : 
(inputadapter_row.getInt(2));
    /* 044 */
    /* 045 */       /* ((input[1, int] = 11) && (input[2, int] = 1999)) */
    /* 046 */       /* (input[1, int] = 11) */
    /* 047 */       boolean filter_isNull1 = true;
    /* 048 */       boolean filter_value1 = false;
    /* 049 */
    /* 050 */       if (!inputadapter_isNull1) {
    /* 051 */         filter_isNull1 = false; // resultCode could change 
nullability.
    /* 052 */         filter_value1 = inputadapter_value1 == 11;
    /* 053 */
    /* 054 */       }
    /* 055 */       boolean filter_isNull = false;
    /* 056 */       boolean filter_value = false;
    /* 057 */
    /* 058 */       if (!filter_isNull1 && !filter_value1) {
    /* 059 */       } else {
    /* 060 */         /* (input[2, int] = 1999) */
    /* 061 */         boolean filter_isNull4 = true;
    /* 062 */         boolean filter_value4 = false;
    /* 063 */
    /* 064 */         if (!inputadapter_isNull2) {
    /* 065 */           filter_isNull4 = false; // resultCode could change 
nullability.
    /* 066 */           filter_value4 = inputadapter_value2 == 1999;
    /* 067 */
    /* 068 */         }
    /* 069 */         if (!filter_isNull4 && !filter_value4) {
    /* 070 */         } else if (!filter_isNull1 && !filter_isNull4) {
    /* 071 */           filter_value = true;
    /* 072 */         } else {
    /* 073 */           filter_isNull = true;
    /* 074 */         }
    /* 075 */       }
    /* 076 */       if (!(!filter_isNull && filter_value)) continue;
    /* 077 */       filter_metricValue.add(1);
    /* 078 */
    /* 079 */       /*** CONSUME: Project [d_date_sk#141] */
    /* 080 */       /* input[0, int] */
    /* 081 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 082 */       int inputadapter_value = inputadapter_isNull ? -1 : 
(inputadapter_row.getInt(0));
    /* 083 */
    /* 084 */       project_rowWriter.zeroOutNullBytes();
    /* 085 */
    /* 086 */       if (inputadapter_isNull) {
    /* 087 */         project_rowWriter.setNullAt(0);
    /* 088 */       } else {
    /* 089 */         project_rowWriter.write(0, inputadapter_value);
    /* 090 */       }
    /* 091 */       currentRows.add(project_result.copy());
    /* 092 */     }
    /* 093 */   }
    /* 094 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Final,isDistinct=false)],
 output=[brand_id#438,brand#439,ext_price#440])
    /* 008 */ +- INPUT
    /* 009 */ */
    /* 010 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 011 */   private Object[] references;
    /* 012 */   private boolean agg_initAgg;
    /* 013 */   private 
org.apache.spark.sql.execution.aggregate.TungstenAggregate agg_plan;
    /* 014 */   private 
org.apache.spark.sql.execution.UnsafeFixedWidthAggregationMap agg_hashMap;
    /* 015 */   private org.apache.spark.sql.execution.UnsafeKVExternalSorter 
agg_sorter;
    /* 016 */   private org.apache.spark.unsafe.KVIterator agg_mapIter;
    /* 017 */   private UnsafeRow agg_result;
    /* 018 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder agg_holder;
    /* 019 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter agg_rowWriter;
    /* 020 */   private UnsafeRow agg_result1;
    /* 021 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder agg_holder1;
    /* 022 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter 
agg_rowWriter1;
    /* 023 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
agg_numOutputRows;
    /* 024 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue agg_metricValue;
    /* 025 */
    /* 026 */   public GeneratedIterator(Object[] references) {
    /* 027 */     this.references = references;
    /* 028 */     agg_initAgg = false;
    /* 029 */     this.agg_plan = 
(org.apache.spark.sql.execution.aggregate.TungstenAggregate) references[0];
    /* 030 */     agg_hashMap = agg_plan.createHashMap();
    /* 031 */
    /* 032 */     agg_result = new UnsafeRow(2);
    /* 033 */     this.agg_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(agg_result, 32);
    /* 034 */     this.agg_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(agg_holder, 
2);
    /* 035 */     agg_result1 = new UnsafeRow(3);
    /* 036 */     this.agg_holder1 = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(agg_result1, 32);
    /* 037 */     this.agg_rowWriter1 = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(agg_holder1, 
3);
    /* 038 */     this.agg_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[1];
    /* 039 */     agg_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
agg_numOutputRows.localValue();
    /* 040 */   }
    /* 041 */
    /* 042 */   private void agg_doAggregateWithKeys() throws 
java.io.IOException {
    /* 043 */     /*** PRODUCE: INPUT */
    /* 044 */
    /* 045 */     while (!shouldStop() && input.hasNext()) {
    /* 046 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 047 */       /*** CONSUME: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Final,isDistinct=false)],
 output=[brand_id#438,brand#439,ext_price#440]) */
    /* 048 */       /* input[0, string] */
    /* 049 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 050 */       UTF8String inputadapter_value = inputadapter_isNull ? null 
: (inputadapter_row.getUTF8String(0));
    /* 051 */       /* input[1, int] */
    /* 052 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 053 */       int inputadapter_value1 = inputadapter_isNull1 ? -1 : 
(inputadapter_row.getInt(1));
    /* 054 */       /* input[2, bigint] */
    /* 055 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 056 */       long inputadapter_value2 = inputadapter_isNull2 ? -1L : 
(inputadapter_row.getLong(2));
    /* 057 */
    /* 058 */       // generate grouping key
    /* 059 */       agg_holder.reset();
    /* 060 */
    /* 061 */       agg_rowWriter.zeroOutNullBytes();
    /* 062 */
    /* 063 */       if (inputadapter_isNull) {
    /* 064 */         agg_rowWriter.setNullAt(0);
    /* 065 */       } else {
    /* 066 */         agg_rowWriter.write(0, inputadapter_value);
    /* 067 */       }
    /* 068 */
    /* 069 */       if (inputadapter_isNull1) {
    /* 070 */         agg_rowWriter.setNullAt(1);
    /* 071 */       } else {
    /* 072 */         agg_rowWriter.write(1, inputadapter_value1);
    /* 073 */       }
    /* 074 */       agg_result.setTotalSize(agg_holder.totalSize());
    /* 075 */       /* hash(input[0, string],input[1, int],42) */
    /* 076 */       int agg_value2 = 42;
    /* 077 */
    /* 078 */       if (!inputadapter_isNull) {
    /* 079 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashUnsafeBytes(inputadapter_value.getBaseObject(),
 inputadapter_value.getBaseOffset(), inputadapter_value.numBytes(), agg_value2);
    /* 080 */       }
    /* 081 */
    /* 082 */       if (!inputadapter_isNull1) {
    /* 083 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashInt(inputadapter_value1, 
agg_value2);
    /* 084 */       }
    /* 085 */       UnsafeRow agg_aggBuffer = null;
    /* 086 */       if (true) {
    /* 087 */         // try to get the buffer from hash map
    /* 088 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 089 */       }
    /* 090 */       if (agg_aggBuffer == null) {
    /* 091 */         if (agg_sorter == null) {
    /* 092 */           agg_sorter = 
agg_hashMap.destructAndCreateExternalSorter();
    /* 093 */         } else {
    /* 094 */           
agg_sorter.merge(agg_hashMap.destructAndCreateExternalSorter());
    /* 095 */         }
    /* 096 */
    /* 097 */         // the hash map had be spilled, it should have enough 
memory now,
    /* 098 */         // try  to allocate buffer again.
    /* 099 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 100 */         if (agg_aggBuffer == null) {
    /* 101 */           // failed to allocate the first page
    /* 102 */           throw new OutOfMemoryError("No enough memory for 
aggregation");
    /* 103 */         }
    /* 104 */       }
    /* 105 */
    /* 106 */       // evaluate aggregate function
    /* 107 */       /* coalesce((coalesce(input[0, bigint],cast(0 as bigint)) + 
input[3, bigint]),input[0, bigint]) */
    /* 108 */       /* (coalesce(input[0, bigint],cast(0 as bigint)) + input[3, 
bigint]) */
    /* 109 */       boolean agg_isNull6 = true;
    /* 110 */       long agg_value6 = -1L;
    /* 111 */       /* coalesce(input[0, bigint],cast(0 as bigint)) */
    /* 112 */       /* input[0, bigint] */
    /* 113 */       boolean agg_isNull8 = agg_aggBuffer.isNullAt(0);
    /* 114 */       long agg_value8 = agg_isNull8 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 115 */       boolean agg_isNull7 = agg_isNull8;
    /* 116 */       long agg_value7 = agg_value8;
    /* 117 */
    /* 118 */       if (agg_isNull7) {
    /* 119 */         /* cast(0 as bigint) */
    /* 120 */         boolean agg_isNull9 = false;
    /* 121 */         long agg_value9 = -1L;
    /* 122 */         if (!false) {
    /* 123 */           agg_value9 = (long) 0;
    /* 124 */         }
    /* 125 */         if (!agg_isNull9) {
    /* 126 */           agg_isNull7 = false;
    /* 127 */           agg_value7 = agg_value9;
    /* 128 */         }
    /* 129 */       }
    /* 130 */
    /* 131 */       if (!inputadapter_isNull2) {
    /* 132 */         agg_isNull6 = false; // resultCode could change 
nullability.
    /* 133 */         agg_value6 = agg_value7 + inputadapter_value2;
    /* 134 */
    /* 135 */       }
    /* 136 */       boolean agg_isNull5 = agg_isNull6;
    /* 137 */       long agg_value5 = agg_value6;
    /* 138 */
    /* 139 */       if (agg_isNull5) {
    /* 140 */         /* input[0, bigint] */
    /* 141 */         boolean agg_isNull12 = agg_aggBuffer.isNullAt(0);
    /* 142 */         long agg_value12 = agg_isNull12 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 143 */         if (!agg_isNull12) {
    /* 144 */           agg_isNull5 = false;
    /* 145 */           agg_value5 = agg_value12;
    /* 146 */         }
    /* 147 */       }
    /* 148 */       // update aggregate buffer
    /* 149 */       if (!agg_isNull5) {
    /* 150 */         agg_aggBuffer.setLong(0, agg_value5);
    /* 151 */       } else {
    /* 152 */         agg_aggBuffer.setNullAt(0);
    /* 153 */       }
    /* 154 */     }
    /* 155 */
    /* 156 */     agg_mapIter = agg_plan.finishAggregate(agg_hashMap, 
agg_sorter);
    /* 157 */   }
    /* 158 */
    /* 159 */   protected void processNext() throws java.io.IOException {
    /* 160 */     /*** PRODUCE: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Final,isDistinct=false)],
 output=[brand_id#438,brand#439,ext_price#440]) */
    /* 161 */
    /* 162 */     if (!agg_initAgg) {
    /* 163 */       agg_initAgg = true;
    /* 164 */       agg_doAggregateWithKeys();
    /* 165 */     }
    /* 166 */
    /* 167 */     // output the result
    /* 168 */     while (agg_mapIter.next()) {
    /* 169 */       agg_metricValue.add(1);
    /* 170 */       UnsafeRow agg_aggKey = (UnsafeRow) agg_mapIter.getKey();
    /* 171 */       UnsafeRow agg_aggBuffer1 = (UnsafeRow) 
agg_mapIter.getValue();
    /* 172 */
    /* 173 */       /* input[0, string] */
    /* 174 */       boolean agg_isNull13 = agg_aggKey.isNullAt(0);
    /* 175 */       UTF8String agg_value13 = agg_isNull13 ? null : 
(agg_aggKey.getUTF8String(0));
    /* 176 */       /* input[1, int] */
    /* 177 */       boolean agg_isNull14 = agg_aggKey.isNullAt(1);
    /* 178 */       int agg_value14 = agg_isNull14 ? -1 : 
(agg_aggKey.getInt(1));
    /* 179 */       /* input[0, bigint] */
    /* 180 */       boolean agg_isNull15 = agg_aggBuffer1.isNullAt(0);
    /* 181 */       long agg_value15 = agg_isNull15 ? -1L : 
(agg_aggBuffer1.getLong(0));
    /* 182 */
    /* 183 */       /* MakeDecimal(input[2, bigint],17,2) */
    /* 184 */       boolean agg_isNull19 = agg_isNull15;
    /* 185 */       Decimal agg_value19 = null;
    /* 186 */
    /* 187 */       if (!agg_isNull15) {
    /* 188 */         agg_value19 = (new Decimal()).setOrNull(agg_value15, 17, 
2);
    /* 189 */         agg_isNull19 = agg_value19 == null;
    /* 190 */
    /* 191 */       }
    /* 192 */       agg_holder1.reset();
    /* 193 */
    /* 194 */       agg_rowWriter1.zeroOutNullBytes();
    /* 195 */
    /* 196 */       if (agg_isNull14) {
    /* 197 */         agg_rowWriter1.setNullAt(0);
    /* 198 */       } else {
    /* 199 */         agg_rowWriter1.write(0, agg_value14);
    /* 200 */       }
    /* 201 */
    /* 202 */       if (agg_isNull13) {
    /* 203 */         agg_rowWriter1.setNullAt(1);
    /* 204 */       } else {
    /* 205 */         agg_rowWriter1.write(1, agg_value13);
    /* 206 */       }
    /* 207 */
    /* 208 */       if (agg_isNull19) {
    /* 209 */         agg_rowWriter1.setNullAt(2);
    /* 210 */       } else {
    /* 211 */         agg_rowWriter1.write(2, agg_value19, 17, 2);
    /* 212 */       }
    /* 213 */       agg_result1.setTotalSize(agg_holder1.totalSize());
    /* 214 */       currentRows.add(agg_result1.copy());
    /* 215 */
    /* 216 */       if (shouldStop()) return;
    /* 217 */     }
    /* 218 */
    /* 219 */     agg_mapIter.close();
    /* 220 */     if (agg_sorter == null) {
    /* 221 */       agg_hashMap.free();
    /* 222 */     }
    /* 223 */   }
    /* 224 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Partial,isDistinct=false)],
 output=[i_brand#189,i_brand_id#188,sum#445L])
    /* 008 */ +- Project [i_brand#189,i_brand_id#188,ss_ext_sales_price#295]
    /* 009 */ +- BroadcastHashJoin [ss_item_sk#282], [i_item_sk#181], Inner, 
BuildRight, None
    /* 010 */ :- Project [ss_item_sk#282,ss_ext_sales_price#295]
    /* 011 */ :  +- BroadcastHashJoin [d_date_sk#141], [ss_sold_date_sk#280], 
Inner, BuildLeft, None
    /* 012 */ :     :- INPUT
    /* 013 */ :     +- INPUT
    /* 014 */ +- INPUT
    /* 015 */ */
    /* 016 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 017 */   private Object[] references;
    /* 018 */   private boolean agg_initAgg;
    /* 019 */   private 
org.apache.spark.sql.execution.aggregate.TungstenAggregate agg_plan;
    /* 020 */   private 
org.apache.spark.sql.execution.UnsafeFixedWidthAggregationMap agg_hashMap;
    /* 021 */   private org.apache.spark.sql.execution.UnsafeKVExternalSorter 
agg_sorter;
    /* 022 */   private org.apache.spark.unsafe.KVIterator agg_mapIter;
    /* 023 */   private org.apache.spark.broadcast.TorrentBroadcast 
join_broadcast;
    /* 024 */   private org.apache.spark.sql.execution.joins.LongArrayRelation 
join_relation;
    /* 025 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
join_numOutputRows;
    /* 026 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue join_metricValue;
    /* 027 */   private org.apache.spark.broadcast.TorrentBroadcast 
join_broadcast1;
    /* 028 */   private 
org.apache.spark.sql.execution.joins.UniqueLongHashedRelation join_relation1;
    /* 029 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
join_numOutputRows1;
    /* 030 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue join_metricValue1;
    /* 031 */   private UnsafeRow agg_result;
    /* 032 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder agg_holder;
    /* 033 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter agg_rowWriter;
    /* 034 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowJoiner 
agg_unsafeRowJoiner;
    /* 035 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
agg_numOutputRows;
    /* 036 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue agg_metricValue;
    /* 037 */
    /* 038 */   public GeneratedIterator(Object[] references) {
    /* 039 */     this.references = references;
    /* 040 */     agg_initAgg = false;
    /* 041 */     this.agg_plan = 
(org.apache.spark.sql.execution.aggregate.TungstenAggregate) references[0];
    /* 042 */     agg_hashMap = agg_plan.createHashMap();
    /* 043 */
    /* 044 */     this.join_broadcast = 
(org.apache.spark.broadcast.TorrentBroadcast) references[1];
    /* 045 */
    /* 046 */     join_relation = 
(org.apache.spark.sql.execution.joins.LongArrayRelation) join_broadcast.value();
    /* 047 */     incPeakExecutionMemory(join_relation.getMemorySize());
    /* 048 */
    /* 049 */     this.join_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[2];
    /* 050 */     join_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
join_numOutputRows.localValue();
    /* 051 */     this.join_broadcast1 = 
(org.apache.spark.broadcast.TorrentBroadcast) references[3];
    /* 052 */
    /* 053 */     join_relation1 = 
(org.apache.spark.sql.execution.joins.UniqueLongHashedRelation) 
join_broadcast1.value();
    /* 054 */     incPeakExecutionMemory(join_relation1.getMemorySize());
    /* 055 */
    /* 056 */     this.join_numOutputRows1 = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[4];
    /* 057 */     join_metricValue1 = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
join_numOutputRows1.localValue();
    /* 058 */     agg_result = new UnsafeRow(2);
    /* 059 */     this.agg_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(agg_result, 32);
    /* 060 */     this.agg_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(agg_holder, 
2);
    /* 061 */     agg_unsafeRowJoiner = agg_plan.createUnsafeJoiner();
    /* 062 */     this.agg_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[5];
    /* 063 */     agg_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
agg_numOutputRows.localValue();
    /* 064 */   }
    /* 065 */
    /* 066 */   private void agg_doAggregateWithKeys() throws 
java.io.IOException {
    /* 067 */     /*** PRODUCE: Project 
[i_brand#189,i_brand_id#188,ss_ext_sales_price#295] */
    /* 068 */
    /* 069 */     /*** PRODUCE: BroadcastHashJoin [ss_item_sk#282], 
[i_item_sk#181], Inner, BuildRight, None */
    /* 070 */
    /* 071 */     /*** PRODUCE: Project [ss_item_sk#282,ss_ext_sales_price#295] 
*/
    /* 072 */
    /* 073 */     /*** PRODUCE: BroadcastHashJoin [d_date_sk#141], 
[ss_sold_date_sk#280], Inner, BuildLeft, None */
    /* 074 */
    /* 075 */     /*** PRODUCE: INPUT */
    /* 076 */
    /* 077 */     while (!shouldStop() && input.hasNext()) {
    /* 078 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 079 */       /*** CONSUME: BroadcastHashJoin [d_date_sk#141], 
[ss_sold_date_sk#280], Inner, BuildLeft, None */
    /* 080 */       /* input[2, int] */
    /* 081 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 082 */       int inputadapter_value2 = inputadapter_isNull2 ? -1 : 
(inputadapter_row.getInt(2));
    /* 083 */
    /* 084 */       // generate join key for stream side
    /* 085 */       /* cast(input[2, int] as bigint) */
    /* 086 */       boolean join_isNull = inputadapter_isNull2;
    /* 087 */       long join_value = -1L;
    /* 088 */       if (!inputadapter_isNull2) {
    /* 089 */         join_value = (long) inputadapter_value2;
    /* 090 */       }
    /* 091 */       // find matches from HashedRelation
    /* 092 */       UnsafeRow join_matched = join_isNull ? null: 
(UnsafeRow)join_relation.getValue(join_value);
    /* 093 */       if (join_matched == null) continue;
    /* 094 */
    /* 095 */       join_metricValue.add(1);
    /* 096 */
    /* 097 */       /*** CONSUME: Project 
[ss_item_sk#282,ss_ext_sales_price#295] */
    /* 098 */       /* input[0, int] */
    /* 099 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 100 */       int inputadapter_value = inputadapter_isNull ? -1 : 
(inputadapter_row.getInt(0));
    /* 101 */       /* input[1, decimal(7,2)] */
    /* 102 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 103 */       Decimal inputadapter_value1 = inputadapter_isNull1 ? null : 
(inputadapter_row.getDecimal(1, 7, 2));
    /* 104 */
    /* 105 */       /*** CONSUME: BroadcastHashJoin [ss_item_sk#282], 
[i_item_sk#181], Inner, BuildRight, None */
    /* 106 */
    /* 107 */       // generate join key for stream side
    /* 108 */       /* cast(input[0, int] as bigint) */
    /* 109 */       boolean join_isNull3 = inputadapter_isNull;
    /* 110 */       long join_value3 = -1L;
    /* 111 */       if (!inputadapter_isNull) {
    /* 112 */         join_value3 = (long) inputadapter_value;
    /* 113 */       }
    /* 114 */       // find matches from HashedRelation
    /* 115 */       UnsafeRow join_matched1 = join_isNull3 ? null: 
(UnsafeRow)join_relation1.getValue(join_value3);
    /* 116 */       if (join_matched1 == null) continue;
    /* 117 */
    /* 118 */       join_metricValue1.add(1);
    /* 119 */
    /* 120 */       /*** CONSUME: Project 
[i_brand#189,i_brand_id#188,ss_ext_sales_price#295] */
    /* 121 */       /* input[0, int] */
    /* 122 */       boolean join_isNull5 = join_matched1.isNullAt(0);
    /* 123 */       int join_value5 = join_isNull5 ? -1 : 
(join_matched1.getInt(0));
    /* 124 */       /* input[2, string] */
    /* 125 */       boolean join_isNull7 = join_matched1.isNullAt(2);
    /* 126 */       UTF8String join_value7 = join_isNull7 ? null : 
(join_matched1.getUTF8String(2));
    /* 127 */
    /* 128 */       /*** CONSUME: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Partial,isDistinct=false)],
 output=[i_brand#189,i_brand_id#188,sum#445L]) */
    /* 129 */
    /* 130 */       // generate grouping key
    /* 131 */       agg_holder.reset();
    /* 132 */
    /* 133 */       agg_rowWriter.zeroOutNullBytes();
    /* 134 */
    /* 135 */       if (join_isNull7) {
    /* 136 */         agg_rowWriter.setNullAt(0);
    /* 137 */       } else {
    /* 138 */         agg_rowWriter.write(0, join_value7);
    /* 139 */       }
    /* 140 */
    /* 141 */       if (join_isNull5) {
    /* 142 */         agg_rowWriter.setNullAt(1);
    /* 143 */       } else {
    /* 144 */         agg_rowWriter.write(1, join_value5);
    /* 145 */       }
    /* 146 */       agg_result.setTotalSize(agg_holder.totalSize());
    /* 147 */       /* hash(input[0, string],input[1, int],42) */
    /* 148 */       int agg_value2 = 42;
    /* 149 */
    /* 150 */       if (!join_isNull7) {
    /* 151 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashUnsafeBytes(join_value7.getBaseObject(),
 join_value7.getBaseOffset(), join_value7.numBytes(), agg_value2);
    /* 152 */       }
    /* 153 */
    /* 154 */       if (!join_isNull5) {
    /* 155 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashInt(join_value5, agg_value2);
    /* 156 */       }
    /* 157 */       UnsafeRow agg_aggBuffer = null;
    /* 158 */       if (true) {
    /* 159 */         // try to get the buffer from hash map
    /* 160 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 161 */       }
    /* 162 */       if (agg_aggBuffer == null) {
    /* 163 */         if (agg_sorter == null) {
    /* 164 */           agg_sorter = 
agg_hashMap.destructAndCreateExternalSorter();
    /* 165 */         } else {
    /* 166 */           
agg_sorter.merge(agg_hashMap.destructAndCreateExternalSorter());
    /* 167 */         }
    /* 168 */
    /* 169 */         // the hash map had be spilled, it should have enough 
memory now,
    /* 170 */         // try  to allocate buffer again.
    /* 171 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 172 */         if (agg_aggBuffer == null) {
    /* 173 */           // failed to allocate the first page
    /* 174 */           throw new OutOfMemoryError("No enough memory for 
aggregation");
    /* 175 */         }
    /* 176 */       }
    /* 177 */
    /* 178 */       // evaluate aggregate function
    /* 179 */       /* coalesce((coalesce(input[0, bigint],cast(0 as bigint)) + 
cast(UnscaledValue(input[3, decimal(7,2)]) as bigint)),input[0, bigint]) */
    /* 180 */       /* (coalesce(input[0, bigint],cast(0 as bigint)) + 
cast(UnscaledValue(input[3, decimal(7,2)]) as bigint)) */
    /* 181 */       boolean agg_isNull6 = true;
    /* 182 */       long agg_value6 = -1L;
    /* 183 */       /* coalesce(input[0, bigint],cast(0 as bigint)) */
    /* 184 */       /* input[0, bigint] */
    /* 185 */       boolean agg_isNull8 = agg_aggBuffer.isNullAt(0);
    /* 186 */       long agg_value8 = agg_isNull8 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 187 */       boolean agg_isNull7 = agg_isNull8;
    /* 188 */       long agg_value7 = agg_value8;
    /* 189 */
    /* 190 */       if (agg_isNull7) {
    /* 191 */         /* cast(0 as bigint) */
    /* 192 */         boolean agg_isNull9 = false;
    /* 193 */         long agg_value9 = -1L;
    /* 194 */         if (!false) {
    /* 195 */           agg_value9 = (long) 0;
    /* 196 */         }
    /* 197 */         if (!agg_isNull9) {
    /* 198 */           agg_isNull7 = false;
    /* 199 */           agg_value7 = agg_value9;
    /* 200 */         }
    /* 201 */       }
    /* 202 */       /* cast(UnscaledValue(input[3, decimal(7,2)]) as bigint) */
    /* 203 */       /* UnscaledValue(input[3, decimal(7,2)]) */
    /* 204 */       boolean agg_isNull12 = inputadapter_isNull1;
    /* 205 */       long agg_value12 = -1L;
    /* 206 */
    /* 207 */       if (!inputadapter_isNull1) {
    /* 208 */         agg_value12 = inputadapter_value1.toUnscaledLong();
    /* 209 */       }
    /* 210 */       boolean agg_isNull11 = agg_isNull12;
    /* 211 */       long agg_value11 = -1L;
    /* 212 */       if (!agg_isNull12) {
    /* 213 */         agg_value11 = agg_value12;
    /* 214 */       }
    /* 215 */       if (!agg_isNull11) {
    /* 216 */         agg_isNull6 = false; // resultCode could change 
nullability.
    /* 217 */         agg_value6 = agg_value7 + agg_value11;
    /* 218 */
    /* 219 */       }
    /* 220 */       boolean agg_isNull5 = agg_isNull6;
    /* 221 */       long agg_value5 = agg_value6;
    /* 222 */
    /* 223 */       if (agg_isNull5) {
    /* 224 */         /* input[0, bigint] */
    /* 225 */         boolean agg_isNull14 = agg_aggBuffer.isNullAt(0);
    /* 226 */         long agg_value14 = agg_isNull14 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 227 */         if (!agg_isNull14) {
    /* 228 */           agg_isNull5 = false;
    /* 229 */           agg_value5 = agg_value14;
    /* 230 */         }
    /* 231 */       }
    /* 232 */       // update aggregate buffer
    /* 233 */       if (!agg_isNull5) {
    /* 234 */         agg_aggBuffer.setLong(0, agg_value5);
    /* 235 */       } else {
    /* 236 */         agg_aggBuffer.setNullAt(0);
    /* 237 */       }
    /* 238 */     }
    /* 239 */
    /* 240 */     agg_mapIter = agg_plan.finishAggregate(agg_hashMap, 
agg_sorter);
    /* 241 */   }
    /* 242 */
    /* 243 */   protected void processNext() throws java.io.IOException {
    /* 244 */     /*** PRODUCE: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Partial,isDistinct=false)],
 output=[i_brand#189,i_brand_id#188,sum#445L]) */
    /* 245 */
    /* 246 */     if (!agg_initAgg) {
    /* 247 */       agg_initAgg = true;
    /* 248 */       agg_doAggregateWithKeys();
    /* 249 */     }
    /* 250 */
    /* 251 */     // output the result
    /* 252 */     while (agg_mapIter.next()) {
    /* 253 */       agg_metricValue.add(1);
    /* 254 */       UnsafeRow agg_aggKey = (UnsafeRow) agg_mapIter.getKey();
    /* 255 */       UnsafeRow agg_aggBuffer1 = (UnsafeRow) 
agg_mapIter.getValue();
    /* 256 */
    /* 257 */       UnsafeRow agg_resultRow = 
agg_unsafeRowJoiner.join(agg_aggKey, agg_aggBuffer1);
    /* 258 */
    /* 259 */       currentRows.add(agg_resultRow.copy());
    /* 260 */
    /* 261 */       if (shouldStop()) return;
    /* 262 */     }
    /* 263 */
    /* 264 */     agg_mapIter.close();
    /* 265 */     if (agg_sorter == null) {
    /* 266 */       agg_hashMap.free();
    /* 267 */     }
    /* 268 */   }
    /* 269 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * Project [i_brand_id#188,i_item_sk#181,i_brand#189]
    /* 008 */ +- Filter (i_manager_id#201 = 28)
    /* 009 */ +- INPUT
    /* 010 */ */
    /* 011 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 012 */   private Object[] references;
    /* 013 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
filter_numOutputRows;
    /* 014 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue filter_metricValue;
    /* 015 */   private UnsafeRow project_result;
    /* 016 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder project_holder;
    /* 017 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter 
project_rowWriter;
    /* 018 */
    /* 019 */   public GeneratedIterator(Object[] references) {
    /* 020 */     this.references = references;
    /* 021 */     this.filter_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[0];
    /* 022 */     filter_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
filter_numOutputRows.localValue();
    /* 023 */     project_result = new UnsafeRow(3);
    /* 024 */     this.project_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(project_result, 
32);
    /* 025 */     this.project_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(project_holder,
 3);
    /* 026 */   }
    /* 027 */
    /* 028 */   protected void processNext() throws java.io.IOException {
    /* 029 */     /*** PRODUCE: Project 
[i_brand_id#188,i_item_sk#181,i_brand#189] */
    /* 030 */
    /* 031 */     /*** PRODUCE: Filter (i_manager_id#201 = 28) */
    /* 032 */
    /* 033 */     /*** PRODUCE: INPUT */
    /* 034 */
    /* 035 */     while (!shouldStop() && input.hasNext()) {
    /* 036 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 037 */       /*** CONSUME: Filter (i_manager_id#201 = 28) */
    /* 038 */       /* input[3, int] */
    /* 039 */       boolean inputadapter_isNull3 = inputadapter_row.isNullAt(3);
    /* 040 */       int inputadapter_value3 = inputadapter_isNull3 ? -1 : 
(inputadapter_row.getInt(3));
    /* 041 */
    /* 042 */       /* (input[3, int] = 28) */
    /* 043 */       boolean filter_isNull = true;
    /* 044 */       boolean filter_value = false;
    /* 045 */
    /* 046 */       if (!inputadapter_isNull3) {
    /* 047 */         filter_isNull = false; // resultCode could change 
nullability.
    /* 048 */         filter_value = inputadapter_value3 == 28;
    /* 049 */
    /* 050 */       }
    /* 051 */       if (!(!filter_isNull && filter_value)) continue;
    /* 052 */       filter_metricValue.add(1);
    /* 053 */
    /* 054 */       /*** CONSUME: Project 
[i_brand_id#188,i_item_sk#181,i_brand#189] */
    /* 055 */       /* input[0, int] */
    /* 056 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 057 */       int inputadapter_value = inputadapter_isNull ? -1 : 
(inputadapter_row.getInt(0));
    /* 058 */       /* input[1, int] */
    /* 059 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 060 */       int inputadapter_value1 = inputadapter_isNull1 ? -1 : 
(inputadapter_row.getInt(1));
    /* 061 */       /* input[2, string] */
    /* 062 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 063 */       UTF8String inputadapter_value2 = inputadapter_isNull2 ? 
null : (inputadapter_row.getUTF8String(2));
    /* 064 */
    /* 065 */       project_holder.reset();
    /* 066 */
    /* 067 */       project_rowWriter.zeroOutNullBytes();
    /* 068 */
    /* 069 */       if (inputadapter_isNull) {
    /* 070 */         project_rowWriter.setNullAt(0);
    /* 071 */       } else {
    /* 072 */         project_rowWriter.write(0, inputadapter_value);
    /* 073 */       }
    /* 074 */
    /* 075 */       if (inputadapter_isNull1) {
    /* 076 */         project_rowWriter.setNullAt(1);
    /* 077 */       } else {
    /* 078 */         project_rowWriter.write(1, inputadapter_value1);
    /* 079 */       }
    /* 080 */
    /* 081 */       if (inputadapter_isNull2) {
    /* 082 */         project_rowWriter.setNullAt(2);
    /* 083 */       } else {
    /* 084 */         project_rowWriter.write(2, inputadapter_value2);
    /* 085 */       }
    /* 086 */       project_result.setTotalSize(project_holder.totalSize());
    /* 087 */       currentRows.add(project_result.copy());
    /* 088 */     }
    /* 089 */   }
    /* 090 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * Project [d_date_sk#141]
    /* 008 */ +- Filter ((d_moy#149 = 11) && (d_year#147 = 1999))
    /* 009 */ +- INPUT
    /* 010 */ */
    /* 011 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 012 */   private Object[] references;
    /* 013 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
filter_numOutputRows;
    /* 014 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue filter_metricValue;
    /* 015 */   private UnsafeRow project_result;
    /* 016 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder project_holder;
    /* 017 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter 
project_rowWriter;
    /* 018 */
    /* 019 */   public GeneratedIterator(Object[] references) {
    /* 020 */     this.references = references;
    /* 021 */     this.filter_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[0];
    /* 022 */     filter_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
filter_numOutputRows.localValue();
    /* 023 */     project_result = new UnsafeRow(1);
    /* 024 */     this.project_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(project_result, 
0);
    /* 025 */     this.project_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(project_holder,
 1);
    /* 026 */   }
    /* 027 */
    /* 028 */   protected void processNext() throws java.io.IOException {
    /* 029 */     /*** PRODUCE: Project [d_date_sk#141] */
    /* 030 */
    /* 031 */     /*** PRODUCE: Filter ((d_moy#149 = 11) && (d_year#147 = 
1999)) */
    /* 032 */
    /* 033 */     /*** PRODUCE: INPUT */
    /* 034 */
    /* 035 */     while (!shouldStop() && input.hasNext()) {
    /* 036 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 037 */       /*** CONSUME: Filter ((d_moy#149 = 11) && (d_year#147 = 
1999)) */
    /* 038 */       /* input[1, int] */
    /* 039 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 040 */       int inputadapter_value1 = inputadapter_isNull1 ? -1 : 
(inputadapter_row.getInt(1));
    /* 041 */       /* input[2, int] */
    /* 042 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 043 */       int inputadapter_value2 = inputadapter_isNull2 ? -1 : 
(inputadapter_row.getInt(2));
    /* 044 */
    /* 045 */       /* ((input[1, int] = 11) && (input[2, int] = 1999)) */
    /* 046 */       /* (input[1, int] = 11) */
    /* 047 */       boolean filter_isNull1 = true;
    /* 048 */       boolean filter_value1 = false;
    /* 049 */
    /* 050 */       if (!inputadapter_isNull1) {
    /* 051 */         filter_isNull1 = false; // resultCode could change 
nullability.
    /* 052 */         filter_value1 = inputadapter_value1 == 11;
    /* 053 */
    /* 054 */       }
    /* 055 */       boolean filter_isNull = false;
    /* 056 */       boolean filter_value = false;
    /* 057 */
    /* 058 */       if (!filter_isNull1 && !filter_value1) {
    /* 059 */       } else {
    /* 060 */         /* (input[2, int] = 1999) */
    /* 061 */         boolean filter_isNull4 = true;
    /* 062 */         boolean filter_value4 = false;
    /* 063 */
    /* 064 */         if (!inputadapter_isNull2) {
    /* 065 */           filter_isNull4 = false; // resultCode could change 
nullability.
    /* 066 */           filter_value4 = inputadapter_value2 == 1999;
    /* 067 */
    /* 068 */         }
    /* 069 */         if (!filter_isNull4 && !filter_value4) {
    /* 070 */         } else if (!filter_isNull1 && !filter_isNull4) {
    /* 071 */           filter_value = true;
    /* 072 */         } else {
    /* 073 */           filter_isNull = true;
    /* 074 */         }
    /* 075 */       }
    /* 076 */       if (!(!filter_isNull && filter_value)) continue;
    /* 077 */       filter_metricValue.add(1);
    /* 078 */
    /* 079 */       /*** CONSUME: Project [d_date_sk#141] */
    /* 080 */       /* input[0, int] */
    /* 081 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 082 */       int inputadapter_value = inputadapter_isNull ? -1 : 
(inputadapter_row.getInt(0));
    /* 083 */
    /* 084 */       project_rowWriter.zeroOutNullBytes();
    /* 085 */
    /* 086 */       if (inputadapter_isNull) {
    /* 087 */         project_rowWriter.setNullAt(0);
    /* 088 */       } else {
    /* 089 */         project_rowWriter.write(0, inputadapter_value);
    /* 090 */       }
    /* 091 */       currentRows.add(project_result.copy());
    /* 092 */     }
    /* 093 */   }
    /* 094 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Final,isDistinct=false)],
 output=[brand_id#446,brand#447,ext_price#448])
    /* 008 */ +- INPUT
    /* 009 */ */
    /* 010 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 011 */   private Object[] references;
    /* 012 */   private boolean agg_initAgg;
    /* 013 */   private 
org.apache.spark.sql.execution.aggregate.TungstenAggregate agg_plan;
    /* 014 */   private 
org.apache.spark.sql.execution.UnsafeFixedWidthAggregationMap agg_hashMap;
    /* 015 */   private org.apache.spark.sql.execution.UnsafeKVExternalSorter 
agg_sorter;
    /* 016 */   private org.apache.spark.unsafe.KVIterator agg_mapIter;
    /* 017 */   private UnsafeRow agg_result;
    /* 018 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder agg_holder;
    /* 019 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter agg_rowWriter;
    /* 020 */   private UnsafeRow agg_result1;
    /* 021 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder agg_holder1;
    /* 022 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter 
agg_rowWriter1;
    /* 023 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
agg_numOutputRows;
    /* 024 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue agg_metricValue;
    /* 025 */
    /* 026 */   public GeneratedIterator(Object[] references) {
    /* 027 */     this.references = references;
    /* 028 */     agg_initAgg = false;
    /* 029 */     this.agg_plan = 
(org.apache.spark.sql.execution.aggregate.TungstenAggregate) references[0];
    /* 030 */     agg_hashMap = agg_plan.createHashMap();
    /* 031 */
    /* 032 */     agg_result = new UnsafeRow(2);
    /* 033 */     this.agg_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(agg_result, 32);
    /* 034 */     this.agg_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(agg_holder, 
2);
    /* 035 */     agg_result1 = new UnsafeRow(3);
    /* 036 */     this.agg_holder1 = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(agg_result1, 32);
    /* 037 */     this.agg_rowWriter1 = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(agg_holder1, 
3);
    /* 038 */     this.agg_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[1];
    /* 039 */     agg_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
agg_numOutputRows.localValue();
    /* 040 */   }
    /* 041 */
    /* 042 */   private void agg_doAggregateWithKeys() throws 
java.io.IOException {
    /* 043 */     /*** PRODUCE: INPUT */
    /* 044 */
    /* 045 */     while (!shouldStop() && input.hasNext()) {
    /* 046 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 047 */       /*** CONSUME: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Final,isDistinct=false)],
 output=[brand_id#446,brand#447,ext_price#448]) */
    /* 048 */       /* input[0, string] */
    /* 049 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 050 */       UTF8String inputadapter_value = inputadapter_isNull ? null 
: (inputadapter_row.getUTF8String(0));
    /* 051 */       /* input[1, int] */
    /* 052 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 053 */       int inputadapter_value1 = inputadapter_isNull1 ? -1 : 
(inputadapter_row.getInt(1));
    /* 054 */       /* input[2, bigint] */
    /* 055 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 056 */       long inputadapter_value2 = inputadapter_isNull2 ? -1L : 
(inputadapter_row.getLong(2));
    /* 057 */
    /* 058 */       // generate grouping key
    /* 059 */       agg_holder.reset();
    /* 060 */
    /* 061 */       agg_rowWriter.zeroOutNullBytes();
    /* 062 */
    /* 063 */       if (inputadapter_isNull) {
    /* 064 */         agg_rowWriter.setNullAt(0);
    /* 065 */       } else {
    /* 066 */         agg_rowWriter.write(0, inputadapter_value);
    /* 067 */       }
    /* 068 */
    /* 069 */       if (inputadapter_isNull1) {
    /* 070 */         agg_rowWriter.setNullAt(1);
    /* 071 */       } else {
    /* 072 */         agg_rowWriter.write(1, inputadapter_value1);
    /* 073 */       }
    /* 074 */       agg_result.setTotalSize(agg_holder.totalSize());
    /* 075 */       /* hash(input[0, string],input[1, int],42) */
    /* 076 */       int agg_value2 = 42;
    /* 077 */
    /* 078 */       if (!inputadapter_isNull) {
    /* 079 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashUnsafeBytes(inputadapter_value.getBaseObject(),
 inputadapter_value.getBaseOffset(), inputadapter_value.numBytes(), agg_value2);
    /* 080 */       }
    /* 081 */
    /* 082 */       if (!inputadapter_isNull1) {
    /* 083 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashInt(inputadapter_value1, 
agg_value2);
    /* 084 */       }
    /* 085 */       UnsafeRow agg_aggBuffer = null;
    /* 086 */       if (true) {
    /* 087 */         // try to get the buffer from hash map
    /* 088 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 089 */       }
    /* 090 */       if (agg_aggBuffer == null) {
    /* 091 */         if (agg_sorter == null) {
    /* 092 */           agg_sorter = 
agg_hashMap.destructAndCreateExternalSorter();
    /* 093 */         } else {
    /* 094 */           
agg_sorter.merge(agg_hashMap.destructAndCreateExternalSorter());
    /* 095 */         }
    /* 096 */
    /* 097 */         // the hash map had be spilled, it should have enough 
memory now,
    /* 098 */         // try  to allocate buffer again.
    /* 099 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 100 */         if (agg_aggBuffer == null) {
    /* 101 */           // failed to allocate the first page
    /* 102 */           throw new OutOfMemoryError("No enough memory for 
aggregation");
    /* 103 */         }
    /* 104 */       }
    /* 105 */
    /* 106 */       // evaluate aggregate function
    /* 107 */       /* coalesce((coalesce(input[0, bigint],cast(0 as bigint)) + 
input[3, bigint]),input[0, bigint]) */
    /* 108 */       /* (coalesce(input[0, bigint],cast(0 as bigint)) + input[3, 
bigint]) */
    /* 109 */       boolean agg_isNull6 = true;
    /* 110 */       long agg_value6 = -1L;
    /* 111 */       /* coalesce(input[0, bigint],cast(0 as bigint)) */
    /* 112 */       /* input[0, bigint] */
    /* 113 */       boolean agg_isNull8 = agg_aggBuffer.isNullAt(0);
    /* 114 */       long agg_value8 = agg_isNull8 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 115 */       boolean agg_isNull7 = agg_isNull8;
    /* 116 */       long agg_value7 = agg_value8;
    /* 117 */
    /* 118 */       if (agg_isNull7) {
    /* 119 */         /* cast(0 as bigint) */
    /* 120 */         boolean agg_isNull9 = false;
    /* 121 */         long agg_value9 = -1L;
    /* 122 */         if (!false) {
    /* 123 */           agg_value9 = (long) 0;
    /* 124 */         }
    /* 125 */         if (!agg_isNull9) {
    /* 126 */           agg_isNull7 = false;
    /* 127 */           agg_value7 = agg_value9;
    /* 128 */         }
    /* 129 */       }
    /* 130 */
    /* 131 */       if (!inputadapter_isNull2) {
    /* 132 */         agg_isNull6 = false; // resultCode could change 
nullability.
    /* 133 */         agg_value6 = agg_value7 + inputadapter_value2;
    /* 134 */
    /* 135 */       }
    /* 136 */       boolean agg_isNull5 = agg_isNull6;
    /* 137 */       long agg_value5 = agg_value6;
    /* 138 */
    /* 139 */       if (agg_isNull5) {
    /* 140 */         /* input[0, bigint] */
    /* 141 */         boolean agg_isNull12 = agg_aggBuffer.isNullAt(0);
    /* 142 */         long agg_value12 = agg_isNull12 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 143 */         if (!agg_isNull12) {
    /* 144 */           agg_isNull5 = false;
    /* 145 */           agg_value5 = agg_value12;
    /* 146 */         }
    /* 147 */       }
    /* 148 */       // update aggregate buffer
    /* 149 */       if (!agg_isNull5) {
    /* 150 */         agg_aggBuffer.setLong(0, agg_value5);
    /* 151 */       } else {
    /* 152 */         agg_aggBuffer.setNullAt(0);
    /* 153 */       }
    /* 154 */     }
    /* 155 */
    /* 156 */     agg_mapIter = agg_plan.finishAggregate(agg_hashMap, 
agg_sorter);
    /* 157 */   }
    /* 158 */
    /* 159 */   protected void processNext() throws java.io.IOException {
    /* 160 */     /*** PRODUCE: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Final,isDistinct=false)],
 output=[brand_id#446,brand#447,ext_price#448]) */
    /* 161 */
    /* 162 */     if (!agg_initAgg) {
    /* 163 */       agg_initAgg = true;
    /* 164 */       agg_doAggregateWithKeys();
    /* 165 */     }
    /* 166 */
    /* 167 */     // output the result
    /* 168 */     while (agg_mapIter.next()) {
    /* 169 */       agg_metricValue.add(1);
    /* 170 */       UnsafeRow agg_aggKey = (UnsafeRow) agg_mapIter.getKey();
    /* 171 */       UnsafeRow agg_aggBuffer1 = (UnsafeRow) 
agg_mapIter.getValue();
    /* 172 */
    /* 173 */       /* input[0, string] */
    /* 174 */       boolean agg_isNull13 = agg_aggKey.isNullAt(0);
    /* 175 */       UTF8String agg_value13 = agg_isNull13 ? null : 
(agg_aggKey.getUTF8String(0));
    /* 176 */       /* input[1, int] */
    /* 177 */       boolean agg_isNull14 = agg_aggKey.isNullAt(1);
    /* 178 */       int agg_value14 = agg_isNull14 ? -1 : 
(agg_aggKey.getInt(1));
    /* 179 */       /* input[0, bigint] */
    /* 180 */       boolean agg_isNull15 = agg_aggBuffer1.isNullAt(0);
    /* 181 */       long agg_value15 = agg_isNull15 ? -1L : 
(agg_aggBuffer1.getLong(0));
    /* 182 */
    /* 183 */       /* MakeDecimal(input[2, bigint],17,2) */
    /* 184 */       boolean agg_isNull19 = agg_isNull15;
    /* 185 */       Decimal agg_value19 = null;
    /* 186 */
    /* 187 */       if (!agg_isNull15) {
    /* 188 */         agg_value19 = (new Decimal()).setOrNull(agg_value15, 17, 
2);
    /* 189 */         agg_isNull19 = agg_value19 == null;
    /* 190 */
    /* 191 */       }
    /* 192 */       agg_holder1.reset();
    /* 193 */
    /* 194 */       agg_rowWriter1.zeroOutNullBytes();
    /* 195 */
    /* 196 */       if (agg_isNull14) {
    /* 197 */         agg_rowWriter1.setNullAt(0);
    /* 198 */       } else {
    /* 199 */         agg_rowWriter1.write(0, agg_value14);
    /* 200 */       }
    /* 201 */
    /* 202 */       if (agg_isNull13) {
    /* 203 */         agg_rowWriter1.setNullAt(1);
    /* 204 */       } else {
    /* 205 */         agg_rowWriter1.write(1, agg_value13);
    /* 206 */       }
    /* 207 */
    /* 208 */       if (agg_isNull19) {
    /* 209 */         agg_rowWriter1.setNullAt(2);
    /* 210 */       } else {
    /* 211 */         agg_rowWriter1.write(2, agg_value19, 17, 2);
    /* 212 */       }
    /* 213 */       agg_result1.setTotalSize(agg_holder1.totalSize());
    /* 214 */       currentRows.add(agg_result1.copy());
    /* 215 */
    /* 216 */       if (shouldStop()) return;
    /* 217 */     }
    /* 218 */
    /* 219 */     agg_mapIter.close();
    /* 220 */     if (agg_sorter == null) {
    /* 221 */       agg_hashMap.free();
    /* 222 */     }
    /* 223 */   }
    /* 224 */ }
    
    /* 001 */
    /* 002 */ public Object generate(Object[] references) {
    /* 003 */   return new GeneratedIterator(references);
    /* 004 */ }
    /* 005 */
    /* 006 */ /** Codegened pipeline for:
    /* 007 */ * TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Partial,isDistinct=false)],
 output=[i_brand#189,i_brand_id#188,sum#453L])
    /* 008 */ +- Project [i_brand#189,i_brand_id#188,ss_ext_sales_price#295]
    /* 009 */ +- BroadcastHashJoin [ss_item_sk#282], [i_item_sk#181], Inner, 
BuildRight, None
    /* 010 */ :- Project [ss_item_sk#282,ss_ext_sales_price#295]
    /* 011 */ :  +- BroadcastHashJoin [d_date_sk#141], [ss_sold_date_sk#280], 
Inner, BuildLeft, None
    /* 012 */ :     :- INPUT
    /* 013 */ :     +- INPUT
    /* 014 */ +- INPUT
    /* 015 */ */
    /* 016 */ class GeneratedIterator extends 
org.apache.spark.sql.execution.BufferedRowIterator {
    /* 017 */   private Object[] references;
    /* 018 */   private boolean agg_initAgg;
    /* 019 */   private 
org.apache.spark.sql.execution.aggregate.TungstenAggregate agg_plan;
    /* 020 */   private 
org.apache.spark.sql.execution.UnsafeFixedWidthAggregationMap agg_hashMap;
    /* 021 */   private org.apache.spark.sql.execution.UnsafeKVExternalSorter 
agg_sorter;
    /* 022 */   private org.apache.spark.unsafe.KVIterator agg_mapIter;
    /* 023 */   private org.apache.spark.broadcast.TorrentBroadcast 
join_broadcast;
    /* 024 */   private org.apache.spark.sql.execution.joins.LongArrayRelation 
join_relation;
    /* 025 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
join_numOutputRows;
    /* 026 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue join_metricValue;
    /* 027 */   private org.apache.spark.broadcast.TorrentBroadcast 
join_broadcast1;
    /* 028 */   private 
org.apache.spark.sql.execution.joins.UniqueLongHashedRelation join_relation1;
    /* 029 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
join_numOutputRows1;
    /* 030 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue join_metricValue1;
    /* 031 */   private UnsafeRow agg_result;
    /* 032 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder agg_holder;
    /* 033 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter agg_rowWriter;
    /* 034 */   private 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowJoiner 
agg_unsafeRowJoiner;
    /* 035 */   private org.apache.spark.sql.execution.metric.LongSQLMetric 
agg_numOutputRows;
    /* 036 */   private 
org.apache.spark.sql.execution.metric.LongSQLMetricValue agg_metricValue;
    /* 037 */
    /* 038 */   public GeneratedIterator(Object[] references) {
    /* 039 */     this.references = references;
    /* 040 */     agg_initAgg = false;
    /* 041 */     this.agg_plan = 
(org.apache.spark.sql.execution.aggregate.TungstenAggregate) references[0];
    /* 042 */     agg_hashMap = agg_plan.createHashMap();
    /* 043 */
    /* 044 */     this.join_broadcast = 
(org.apache.spark.broadcast.TorrentBroadcast) references[1];
    /* 045 */
    /* 046 */     join_relation = 
(org.apache.spark.sql.execution.joins.LongArrayRelation) join_broadcast.value();
    /* 047 */     incPeakExecutionMemory(join_relation.getMemorySize());
    /* 048 */
    /* 049 */     this.join_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[2];
    /* 050 */     join_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
join_numOutputRows.localValue();
    /* 051 */     this.join_broadcast1 = 
(org.apache.spark.broadcast.TorrentBroadcast) references[3];
    /* 052 */
    /* 053 */     join_relation1 = 
(org.apache.spark.sql.execution.joins.UniqueLongHashedRelation) 
join_broadcast1.value();
    /* 054 */     incPeakExecutionMemory(join_relation1.getMemorySize());
    /* 055 */
    /* 056 */     this.join_numOutputRows1 = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[4];
    /* 057 */     join_metricValue1 = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
join_numOutputRows1.localValue();
    /* 058 */     agg_result = new UnsafeRow(2);
    /* 059 */     this.agg_holder = new 
org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(agg_result, 32);
    /* 060 */     this.agg_rowWriter = new 
org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(agg_holder, 
2);
    /* 061 */     agg_unsafeRowJoiner = agg_plan.createUnsafeJoiner();
    /* 062 */     this.agg_numOutputRows = 
(org.apache.spark.sql.execution.metric.LongSQLMetric) references[5];
    /* 063 */     agg_metricValue = 
(org.apache.spark.sql.execution.metric.LongSQLMetricValue) 
agg_numOutputRows.localValue();
    /* 064 */   }
    /* 065 */
    /* 066 */   private void agg_doAggregateWithKeys() throws 
java.io.IOException {
    /* 067 */     /*** PRODUCE: Project 
[i_brand#189,i_brand_id#188,ss_ext_sales_price#295] */
    /* 068 */
    /* 069 */     /*** PRODUCE: BroadcastHashJoin [ss_item_sk#282], 
[i_item_sk#181], Inner, BuildRight, None */
    /* 070 */
    /* 071 */     /*** PRODUCE: Project [ss_item_sk#282,ss_ext_sales_price#295] 
*/
    /* 072 */
    /* 073 */     /*** PRODUCE: BroadcastHashJoin [d_date_sk#141], 
[ss_sold_date_sk#280], Inner, BuildLeft, None */
    /* 074 */
    /* 075 */     /*** PRODUCE: INPUT */
    /* 076 */
    /* 077 */     while (!shouldStop() && input.hasNext()) {
    /* 078 */       InternalRow inputadapter_row = (InternalRow) input.next();
    /* 079 */       /*** CONSUME: BroadcastHashJoin [d_date_sk#141], 
[ss_sold_date_sk#280], Inner, BuildLeft, None */
    /* 080 */       /* input[2, int] */
    /* 081 */       boolean inputadapter_isNull2 = inputadapter_row.isNullAt(2);
    /* 082 */       int inputadapter_value2 = inputadapter_isNull2 ? -1 : 
(inputadapter_row.getInt(2));
    /* 083 */
    /* 084 */       // generate join key for stream side
    /* 085 */       /* cast(input[2, int] as bigint) */
    /* 086 */       boolean join_isNull = inputadapter_isNull2;
    /* 087 */       long join_value = -1L;
    /* 088 */       if (!inputadapter_isNull2) {
    /* 089 */         join_value = (long) inputadapter_value2;
    /* 090 */       }
    /* 091 */       // find matches from HashedRelation
    /* 092 */       UnsafeRow join_matched = join_isNull ? null: 
(UnsafeRow)join_relation.getValue(join_value);
    /* 093 */       if (join_matched == null) continue;
    /* 094 */
    /* 095 */       join_metricValue.add(1);
    /* 096 */
    /* 097 */       /*** CONSUME: Project 
[ss_item_sk#282,ss_ext_sales_price#295] */
    /* 098 */       /* input[0, int] */
    /* 099 */       boolean inputadapter_isNull = inputadapter_row.isNullAt(0);
    /* 100 */       int inputadapter_value = inputadapter_isNull ? -1 : 
(inputadapter_row.getInt(0));
    /* 101 */       /* input[1, decimal(7,2)] */
    /* 102 */       boolean inputadapter_isNull1 = inputadapter_row.isNullAt(1);
    /* 103 */       Decimal inputadapter_value1 = inputadapter_isNull1 ? null : 
(inputadapter_row.getDecimal(1, 7, 2));
    /* 104 */
    /* 105 */       /*** CONSUME: BroadcastHashJoin [ss_item_sk#282], 
[i_item_sk#181], Inner, BuildRight, None */
    /* 106 */
    /* 107 */       // generate join key for stream side
    /* 108 */       /* cast(input[0, int] as bigint) */
    /* 109 */       boolean join_isNull3 = inputadapter_isNull;
    /* 110 */       long join_value3 = -1L;
    /* 111 */       if (!inputadapter_isNull) {
    /* 112 */         join_value3 = (long) inputadapter_value;
    /* 113 */       }
    /* 114 */       // find matches from HashedRelation
    /* 115 */       UnsafeRow join_matched1 = join_isNull3 ? null: 
(UnsafeRow)join_relation1.getValue(join_value3);
    /* 116 */       if (join_matched1 == null) continue;
    /* 117 */
    /* 118 */       join_metricValue1.add(1);
    /* 119 */
    /* 120 */       /*** CONSUME: Project 
[i_brand#189,i_brand_id#188,ss_ext_sales_price#295] */
    /* 121 */       /* input[0, int] */
    /* 122 */       boolean join_isNull5 = join_matched1.isNullAt(0);
    /* 123 */       int join_value5 = join_isNull5 ? -1 : 
(join_matched1.getInt(0));
    /* 124 */       /* input[2, string] */
    /* 125 */       boolean join_isNull7 = join_matched1.isNullAt(2);
    /* 126 */       UTF8String join_value7 = join_isNull7 ? null : 
(join_matched1.getUTF8String(2));
    /* 127 */
    /* 128 */       /*** CONSUME: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Partial,isDistinct=false)],
 output=[i_brand#189,i_brand_id#188,sum#453L]) */
    /* 129 */
    /* 130 */       // generate grouping key
    /* 131 */       agg_holder.reset();
    /* 132 */
    /* 133 */       agg_rowWriter.zeroOutNullBytes();
    /* 134 */
    /* 135 */       if (join_isNull7) {
    /* 136 */         agg_rowWriter.setNullAt(0);
    /* 137 */       } else {
    /* 138 */         agg_rowWriter.write(0, join_value7);
    /* 139 */       }
    /* 140 */
    /* 141 */       if (join_isNull5) {
    /* 142 */         agg_rowWriter.setNullAt(1);
    /* 143 */       } else {
    /* 144 */         agg_rowWriter.write(1, join_value5);
    /* 145 */       }
    /* 146 */       agg_result.setTotalSize(agg_holder.totalSize());
    /* 147 */       /* hash(input[0, string],input[1, int],42) */
    /* 148 */       int agg_value2 = 42;
    /* 149 */
    /* 150 */       if (!join_isNull7) {
    /* 151 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashUnsafeBytes(join_value7.getBaseObject(),
 join_value7.getBaseOffset(), join_value7.numBytes(), agg_value2);
    /* 152 */       }
    /* 153 */
    /* 154 */       if (!join_isNull5) {
    /* 155 */         agg_value2 = 
org.apache.spark.unsafe.hash.Murmur3_x86_32.hashInt(join_value5, agg_value2);
    /* 156 */       }
    /* 157 */       UnsafeRow agg_aggBuffer = null;
    /* 158 */       if (true) {
    /* 159 */         // try to get the buffer from hash map
    /* 160 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 161 */       }
    /* 162 */       if (agg_aggBuffer == null) {
    /* 163 */         if (agg_sorter == null) {
    /* 164 */           agg_sorter = 
agg_hashMap.destructAndCreateExternalSorter();
    /* 165 */         } else {
    /* 166 */           
agg_sorter.merge(agg_hashMap.destructAndCreateExternalSorter());
    /* 167 */         }
    /* 168 */
    /* 169 */         // the hash map had be spilled, it should have enough 
memory now,
    /* 170 */         // try  to allocate buffer again.
    /* 171 */         agg_aggBuffer = 
agg_hashMap.getAggregationBufferFromUnsafeRow(agg_result, agg_value2);
    /* 172 */         if (agg_aggBuffer == null) {
    /* 173 */           // failed to allocate the first page
    /* 174 */           throw new OutOfMemoryError("No enough memory for 
aggregation");
    /* 175 */         }
    /* 176 */       }
    /* 177 */
    /* 178 */       // evaluate aggregate function
    /* 179 */       /* coalesce((coalesce(input[0, bigint],cast(0 as bigint)) + 
cast(UnscaledValue(input[3, decimal(7,2)]) as bigint)),input[0, bigint]) */
    /* 180 */       /* (coalesce(input[0, bigint],cast(0 as bigint)) + 
cast(UnscaledValue(input[3, decimal(7,2)]) as bigint)) */
    /* 181 */       boolean agg_isNull6 = true;
    /* 182 */       long agg_value6 = -1L;
    /* 183 */       /* coalesce(input[0, bigint],cast(0 as bigint)) */
    /* 184 */       /* input[0, bigint] */
    /* 185 */       boolean agg_isNull8 = agg_aggBuffer.isNullAt(0);
    /* 186 */       long agg_value8 = agg_isNull8 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 187 */       boolean agg_isNull7 = agg_isNull8;
    /* 188 */       long agg_value7 = agg_value8;
    /* 189 */
    /* 190 */       if (agg_isNull7) {
    /* 191 */         /* cast(0 as bigint) */
    /* 192 */         boolean agg_isNull9 = false;
    /* 193 */         long agg_value9 = -1L;
    /* 194 */         if (!false) {
    /* 195 */           agg_value9 = (long) 0;
    /* 196 */         }
    /* 197 */         if (!agg_isNull9) {
    /* 198 */           agg_isNull7 = false;
    /* 199 */           agg_value7 = agg_value9;
    /* 200 */         }
    /* 201 */       }
    /* 202 */       /* cast(UnscaledValue(input[3, decimal(7,2)]) as bigint) */
    /* 203 */       /* UnscaledValue(input[3, decimal(7,2)]) */
    /* 204 */       boolean agg_isNull12 = inputadapter_isNull1;
    /* 205 */       long agg_value12 = -1L;
    /* 206 */
    /* 207 */       if (!inputadapter_isNull1) {
    /* 208 */         agg_value12 = inputadapter_value1.toUnscaledLong();
    /* 209 */       }
    /* 210 */       boolean agg_isNull11 = agg_isNull12;
    /* 211 */       long agg_value11 = -1L;
    /* 212 */       if (!agg_isNull12) {
    /* 213 */         agg_value11 = agg_value12;
    /* 214 */       }
    /* 215 */       if (!agg_isNull11) {
    /* 216 */         agg_isNull6 = false; // resultCode could change 
nullability.
    /* 217 */         agg_value6 = agg_value7 + agg_value11;
    /* 218 */
    /* 219 */       }
    /* 220 */       boolean agg_isNull5 = agg_isNull6;
    /* 221 */       long agg_value5 = agg_value6;
    /* 222 */
    /* 223 */       if (agg_isNull5) {
    /* 224 */         /* input[0, bigint] */
    /* 225 */         boolean agg_isNull14 = agg_aggBuffer.isNullAt(0);
    /* 226 */         long agg_value14 = agg_isNull14 ? -1L : 
(agg_aggBuffer.getLong(0));
    /* 227 */         if (!agg_isNull14) {
    /* 228 */           agg_isNull5 = false;
    /* 229 */           agg_value5 = agg_value14;
    /* 230 */         }
    /* 231 */       }
    /* 232 */       // update aggregate buffer
    /* 233 */       if (!agg_isNull5) {
    /* 234 */         agg_aggBuffer.setLong(0, agg_value5);
    /* 235 */       } else {
    /* 236 */         agg_aggBuffer.setNullAt(0);
    /* 237 */       }
    /* 238 */     }
    /* 239 */
    /* 240 */     agg_mapIter = agg_plan.finishAggregate(agg_hashMap, 
agg_sorter);
    /* 241 */   }
    /* 242 */
    /* 243 */   protected void processNext() throws java.io.IOException {
    /* 244 */     /*** PRODUCE: 
TungstenAggregate(key=[i_brand#189,i_brand_id#188], 
functions=[(sum(UnscaledValue(ss_ext_sales_price#295)),mode=Partial,isDistinct=false)],
 output=[i_brand#189,i_brand_id#188,sum#453L]) */
    /* 245 */
    /* 246 */     if (!agg_initAgg) {
    /* 247 */       agg_initAgg = true;
    /* 248 */       agg_doAggregateWithKeys();
    /* 249 */     }
    /* 250 */
    /* 251 */     // output the result
    /* 252 */     while (agg_mapIter.next()) {
    /* 253 */       agg_metricValue.add(1);
    /* 254 */       UnsafeRow agg_aggKey = (UnsafeRow) agg_mapIter.getKey();
    /* 255 */       UnsafeRow agg_aggBuffer1 = (UnsafeRow) 
agg_mapIter.getValue();
    /* 256 */
    /* 257 */       UnsafeRow agg_resultRow = 
agg_unsafeRowJoiner.join(agg_aggKey, agg_aggBuffer1);
    /* 258 */
    /* 259 */       currentRows.add(agg_resultRow.copy());
    /* 260 */
    /* 261 */       if (shouldStop()) return;
    /* 262 */     }
    /* 263 */
    /* 264 */     agg_mapIter.close();
    /* 265 */     if (agg_sorter == null) {
    /* 266 */       agg_hashMap.free();
    /* 267 */     }
    /* 268 */   }
    /* 269 */ }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to