Now we can inject a re-allocation DrillBuf to UDF. It's applicable to most of UDF usage cases. But there's some situation that does not work out.
If I want to implement an aggregation UDF , every group key has an aggregated bitmap which needs to be held as a DrillBuf. Then the current injected DrillBuf will not solve this perfectly. Holding all the value bitmap memory into one DrillBuf will not only have the Integer.MAX_VALUE memory space limitation , but also not good performance as we need to always replace the old one , lots of memory copying.
As BufferManager will finally be closed by the FragmentContext, it's safe to inject it to the UDF to be used by the users to allocate they wanted number of sized DrillBufs.