joosthooz opened a new pull request #12089:
URL: https://github.com/apache/arrow/pull/12089


   Targets https://issues.apache.org/jira/browse/ARROW-9285
   If a kernel uses preallocated memory allocation 
(`MemAllocation::PREALLOCATE`), it should not create new buffers. This code 
aims to check for this.
   Questions/TODO;
   - If the check triggers an abort by using `DCHECK_*`, it is not possible to 
test whether a misbehaving kernel is detected. I added an example test with a 
misbehaving kernel, but for that to work the check should throw an Error that 
the test can then check for using `ASSERT_RAISES_WITH_MESSAGE`
   - Should the check only happen for output buffers? Now it also checks the 
input batches
   - Scalar kernels have a field `preallocate_contiguous_`, but there might be 
additional cases where this check could be useful? For example if 
`validity_preallocated_` is true, we could check if there aren't any newly 
created validity buffers. But the current `AddBuffersToSet()` code does not 
support this.
   - Vector kernels do not have such a field, but may still pre-allocate their 
memory. Now I just use the condition `(kernel_->mem_allocation == 
MemAllocation::PREALLOCATE)` but I don't know if that is the right way to go. 
Because the VectorExecutor calls `ComputeDataPreallocate` on that condition, 
but it never calls `PrepareOutput` so I don't know where the allocation 
actually happens for Vector kernels.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to