You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "FiV0 (via GitHub)" <gi...@apache.org> on 2024/01/11 08:41:22 UTC

[I] [Java] Allocator `buffer` method no setting the capacity correctly. [arrow]

FiV0 opened a new issue, #39556:
URL: https://github.com/apache/arrow/issues/39556

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   The following snippet
   ```java
   package org.apache.arrow.vector;
   
   import org.apache.arrow.memory.ArrowBuf;
   import org.apache.arrow.memory.RootAllocator;
   import org.junit.jupiter.api.Test;
   
   
   public class BufferAllocatorOverAllocation {
   
       @Test
       void overallocation()  {
           RootAllocator allocator = new RootAllocator();
           ArrowBuf buf = allocator.buffer(9946);
   
           System.out.println(buf.capacity());
   
           buf.capacity(9946);
   
           System.out.println(buf.capacity());
   
       }
   
   }
   ```
   prints
   ```
   16384
   9946
   ```
   So without setting the capacity explicitly the allocator overallocates memory and also seems to set the capacity of the buffer to that. That is contrary to the docstring of the `buffer` method:
   ```
   Note that the buffer may technically be larger than the requested size for rounding purposes. However, the buffer's capacity will be set to the configured size.
   ```
   
   Tested against the `14.0.2` tag. 
   
   
   ### Component(s)
   
   Java


-- 
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: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Java] Allocator `buffer` method no setting the capacity correctly. [arrow]

Posted by "davisusanibar (via GitHub)" <gi...@apache.org>.
davisusanibar commented on issue #39556:
URL: https://github.com/apache/arrow/issues/39556#issuecomment-1895755214

   Thanks for opening this issue, @FiV0.
   
   The sentences are separated by dots, maybe this will be improved, but how I understand this is:
   
   `Note that the buffer may technically be larger than the requested size for rounding purposes. However, the buffer's capacity will be adjusted based on the configured size using the method properly (buffer.capacity).`
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Java] Allocator `buffer` method no setting the capacity correctly. [arrow]

Posted by "vibhatha (via GitHub)" <gi...@apache.org>.
vibhatha commented on issue #39556:
URL: https://github.com/apache/arrow/issues/39556#issuecomment-1893026879

   @FiV0 Did you look into the definition of `capacity` function [here](https://github.com/apache/arrow/blob/go/v14.0.2/java/memory/memory-core/src/main/java/org/apache/arrow/memory/ArrowBuf.java#L142-L161)?
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Java] Allocator `buffer` method no setting the capacity correctly. [arrow]

Posted by "FiV0 (via GitHub)" <gi...@apache.org>.
FiV0 commented on issue #39556:
URL: https://github.com/apache/arrow/issues/39556#issuecomment-1893355218

   @vibhatha The point of this ticket was for the `buffer` method for which (IMO) the docstring or implementation is wrong.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Java] Allocator `buffer` method no setting the capacity correctly. [arrow]

Posted by "FiV0 (via GitHub)" <gi...@apache.org>.
FiV0 commented on issue #39556:
URL: https://github.com/apache/arrow/issues/39556#issuecomment-1896505863

   @davisusanibar Then it's a misunderstanding on my part. Your docstring improvement than solves this ticket for me.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org