You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Benjamin Wilhelm <be...@knime.com> on 2020/10/15 11:08:47 UTC
[Java] ArrowBuf bounds checking in getBytes/setBytes
Hi all,
I have a very specific question about the `ArrowBuf` implementation in
the Java project.
There is this constant `BOUNDS_CHECKING_ENABLED` which enables/disables
checking of the bounds when accessing the buffer. However, the
`getBytes` and `setBytes` implementations ignore this constant and
always check the bounds. What is the reason for this? Wouldn't it make
sense if each method respects this constant?
Thank you!
Benjamin Wilhelm
Re: [Java] ArrowBuf bounds checking in getBytes/setBytes
Posted by Benjamin Wilhelm <be...@knime.com>.
Thank you Liya,
I will try to implement some benchmarks to see how much it impacts the
performance for different numbers of bytes set each time. If I find
enough evidence that bounds checking can hurt the performance I will
open a PR.
Best,
Benjamin Wilhelm
On 15.10.20 14:07, Fan Liya wrote:
> Hi Benjamin,
>
> Nice catch!
>
> The code has been like this for quite some time.
> I think one reason is that the 'setBytes' and 'getBytes' APIs
> support manipulating data in large batches, so it is less
> performance-critical.
>
> IMO, it is reasonable to respect the constant to improve performance.
>
> Best,
> Liya Fan
>
>
>
> On Thu, Oct 15, 2020 at 7:09 PM Benjamin Wilhelm <be...@knime.com>
> wrote:
>
>> Hi all,
>>
>> I have a very specific question about the `ArrowBuf` implementation in
>> the Java project.
>> There is this constant `BOUNDS_CHECKING_ENABLED` which enables/disables
>> checking of the bounds when accessing the buffer. However, the
>> `getBytes` and `setBytes` implementations ignore this constant and
>> always check the bounds. What is the reason for this? Wouldn't it make
>> sense if each method respects this constant?
>>
>> Thank you!
>> Benjamin Wilhelm
>>
>
Re: [Java] ArrowBuf bounds checking in getBytes/setBytes
Posted by Fan Liya <li...@gmail.com>.
Hi Benjamin,
Nice catch!
The code has been like this for quite some time.
I think one reason is that the 'setBytes' and 'getBytes' APIs
support manipulating data in large batches, so it is less
performance-critical.
IMO, it is reasonable to respect the constant to improve performance.
Best,
Liya Fan
On Thu, Oct 15, 2020 at 7:09 PM Benjamin Wilhelm <be...@knime.com>
wrote:
> Hi all,
>
> I have a very specific question about the `ArrowBuf` implementation in
> the Java project.
> There is this constant `BOUNDS_CHECKING_ENABLED` which enables/disables
> checking of the bounds when accessing the buffer. However, the
> `getBytes` and `setBytes` implementations ignore this constant and
> always check the bounds. What is the reason for this? Wouldn't it make
> sense if each method respects this constant?
>
> Thank you!
> Benjamin Wilhelm
>