Skip to content

Commit 9a04e25

Browse files
committed
GH-141: Correct capacity behavior in BufferAllocator.buffer docstrings
1 parent ce1f3d7 commit 9a04e25

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

memory/memory-core/src/main/java/org/apache/arrow/memory/ArrowBuf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public long capacity() {
136136
/**
137137
* Adjusts the capacity of this buffer. Size increases are NOT supported.
138138
*
139-
* @param newCapacity Must be in in the range [0, length).
139+
* @param newCapacity Must be in the range [0, length).
140140
*/
141141
public synchronized ArrowBuf capacity(long newCapacity) {
142142

memory/memory-core/src/main/java/org/apache/arrow/memory/BufferAllocator.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
public interface BufferAllocator extends AutoCloseable {
2626

2727
/**
28-
* Allocate a new or reused buffer of the provided size. Note that the buffer may technically be
29-
* larger than the requested size for rounding purposes. However, the buffer's capacity will be
30-
* set to the configured size.
28+
* Allocate a new or reused buffer of the provided size. The buffer may be larger than the
29+
* requested size for rounding purposes (e.g. to a power of two), and the buffer's capacity will
30+
* reflect the actual allocated size. Use {@link ArrowBuf#capacity(long)} to set the capacity to
31+
* the requested size if needed.
3132
*
3233
* @param size The size in bytes.
3334
* @return a new ArrowBuf, or null if the request can't be satisfied
@@ -36,9 +37,10 @@ public interface BufferAllocator extends AutoCloseable {
3637
ArrowBuf buffer(long size);
3738

3839
/**
39-
* Allocate a new or reused buffer of the provided size. Note that the buffer may technically be
40-
* larger than the requested size for rounding purposes. However, the buffer's capacity will be
41-
* set to the configured size.
40+
* Allocate a new or reused buffer of the provided size. The buffer may be larger than the
41+
* requested size for rounding purposes (e.g. to a power of two), and the buffer's capacity will
42+
* reflect the actual allocated size. Use {@link ArrowBuf#capacity(long)} to set the capacity to
43+
* the requested size if needed.
4244
*
4345
* @param size The size in bytes.
4446
* @param manager A buffer manager to manage reallocation.

0 commit comments

Comments
 (0)