public UnsafeRow getAggregationBufferFromUnsafeRow(UnsafeRow unsafeGroupingKeyRow) {
        // Probe our map using the serialized key
        final BytesToBytesMap.Location loc = map.lookup(
                unsafeGroupingKeyRow.getBaseObject(),
                unsafeGroupingKeyRow.getBaseOffset(),
                unsafeGroupingKeyRow.getSizeInBytes());
        if (!loc.isDefined()) {
            // This is the first time that we've seen this grouping key, so we'll insert a copy of the
            // empty aggregation buffer into the map:
            boolean putSucceeded = loc.putNewKey(
                    unsafeGroupingKeyRow.getBaseObject(),
                    unsafeGroupingKeyRow.getBaseOffset(),
                    unsafeGroupingKeyRow.getSizeInBytes(),
                    emptyAggregationBuffer,
                    Platform.BYTE_ARRAY_OFFSET,
                    emptyAggregationBuffer.length
            );
            if (!putSucceeded) {
                return null;
            }
        }

        // Reset the pointer to point to the value that we just stored or looked up:
        final MemoryLocation address = loc.getValueAddress();
        currentAggregationBuffer.pointTo(
                address.getBaseObject(),
                address.getBaseOffset(),
                loc.getValueLength()
        );
        return currentAggregationBuffer;
    }
Return the aggregation buffer for the current group. For efficiency, all calls to this method
return the same object. If additional memory could not be allocated, then this method will
signal an error by returning null.
indexr-query-opt/src/main/java/org/apache/spark/sql/execution/UnsafeFixedWidthAggregationMap.java