[
https://issues.apache.org/jira/browse/DRILL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13876899#comment-13876899
]
John Morris commented on DRILL-336:
-----------------------------------
Here is a revised API for extending the memory manager. The new API makes use
of the existing interfaces, although with a slightly different interpretation.
ByteBuffer buf = allocator.newDirectBuffer(min, max);
Allocate a direct buffer with capacity between min and max.
Formerly, max was an upper bound on resizing the buffer.
Now, max is an opportunistic value - give us that much if convenient.
buf.capacity(newSize);
As before, resize the buffer to the new size and preserve the old data.
The new version will
- efficiently "trim" a buffer to a smaller size for "normal"
allocations.
- throw a "TooMuchCopying" exception when resizing requires
copying more than a page of data.
- Correctly resize the buffer, even if the exception is thrown.
The "TooMuchCopying" exception is more a warning than an error. It signals an
inefficient use of the capacity(newSize) method. Whether the exception is
thrown or not, the buffer will be resized correctly.
> Extend off heap memory manager to support growing vectors
> ---------------------------------------------------------
>
> Key: DRILL-336
> URL: https://issues.apache.org/jira/browse/DRILL-336
> Project: Apache Drill
> Issue Type: Improvement
> Affects Versions: 1.0.0-milestone-2
> Reporter: John Morris
>
> Add the following interfaces to the bufferl memory manager:
> ptr = alloc(size, min, max) - allocate a block with given size, but
> with a total capacity between
> min+max.
> trim(ptr) - free up extra capacity, so current size is the capacity
> Rationale: It isn't always possible to anticipate the size of a vector. When
> creating a new vector, one strategy is to over-allocate the vector and then
> trim the size once the vector is complete. These routines allow us to
> implement this strategy.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)