/** * Emits a (reduce) group row, made from the key (copied in at the beginning of the group) and * the row aggregation buffers values * @param agg * @param buffer * @throws HiveException */ private void writeGroupRow(VectorAggregationBufferRow agg, DataOutputBuffer buffer) throws HiveException { int colNum = outputKeyLength; // Start after group keys. final int batchIndex = outputBatch.size; for (int i = 0; i < aggregators.length; ++i) { aggregators[i].assignRowColumn(outputBatch, batchIndex, colNum++, agg.getAggregationBuffer(i)); } ++outputBatch.size; if (outputBatch.size == VectorizedRowBatch.DEFAULT_SIZE) { flushOutput(); buffer.reset(); } }
/** * Emits a single row, made from the key and the row aggregation buffers values * kw is null if keyExpressions.length is 0 * @param kw * @param agg * @throws HiveException */ private void writeSingleRow(VectorHashKeyWrapperBase kw, VectorAggregationBufferRow agg) throws HiveException { int colNum = 0; final int batchIndex = outputBatch.size; // Output keys and aggregates into the output batch. for (int i = 0; i < outputKeyLength; ++i) { keyWrappersBatch.assignRowColumn(outputBatch, batchIndex, colNum++, kw); } for (int i = 0; i < aggregators.length; ++i) { aggregators[i].assignRowColumn(outputBatch, batchIndex, colNum++, agg.getAggregationBuffer(i)); } ++outputBatch.size; if (outputBatch.size == VectorizedRowBatch.DEFAULT_SIZE) { flushOutput(); } }
VectorAggregateExpression.AggregationBuffer aggregationBuffer = vectorAggregationBufferRow.getAggregationBuffer(0); vecAggrExpr.assignRowColumn(outputBatch, outputBatch.size++, 0, aggregationBuffer);