Class ObjectBuffer
java.lang.Object
tools.jackson.databind.util.ObjectBuffer
Helper class to use for constructing Object arrays by appending entries
to create arrays of various lengths (length that is not known a priori).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Object[]Reusable Object array, stored here after buffer has been released having been used previously.private LinkedNode<Object[]> private intNumber of total buffered entries in this buffer, counting all instances within linked list formed by following_head.private LinkedNode<Object[]> private static final intLet's limit maximum size of chunks we use; helps avoid excessive allocation overhead for huge data sets.private static final intAlso: let's expand by doubling up until 64k chunks (which is 16k entries for 32-bit machines) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidprotected void_reset()Object[]appendCompletedChunk(Object[] fullChunk) Method called to add a full Object array as a chunk buffered within this buffer, and to obtain a new array to fill.intMethod that can be used to check how many Objects have been buffered within this buffer.Object[]completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries) Method called to indicate that the buffering process is now complete; and to construct a combined exactly-sized result array.<T> T[]completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries, Class<T> componentType) Type-safe alternative tocompleteAndClearBuffer(Object[], int), to allow for constructing explicitly typed result array.voidcompleteAndClearBuffer(Object[] lastChunk, int lastChunkEntries, List<Object> resultList) intHelper method that can be used to check how much free capacity will this instance start with.Object[]Method called to start buffering process.Object[]resetAndStart(Object[] base, int count)
-
Field Details
-
SMALL_CHUNK
private static final int SMALL_CHUNKAlso: let's expand by doubling up until 64k chunks (which is 16k entries for 32-bit machines)- See Also:
-
MAX_CHUNK
private static final int MAX_CHUNKLet's limit maximum size of chunks we use; helps avoid excessive allocation overhead for huge data sets. For now, let's limit to quarter million entries, 1 meg chunks for 32-bit machines.- See Also:
-
_head
-
_tail
-
_size
private int _sizeNumber of total buffered entries in this buffer, counting all instances within linked list formed by following_head. -
_freeBuffer
Reusable Object array, stored here after buffer has been released having been used previously.
-
-
Constructor Details
-
ObjectBuffer
public ObjectBuffer()
-
-
Method Details
-
resetAndStart
Method called to start buffering process. Will ensure that the buffer is empty, and then return an object array to start chunking content on -
resetAndStart
-
appendCompletedChunk
Method called to add a full Object array as a chunk buffered within this buffer, and to obtain a new array to fill. Caller is not to use the array it gives; but to use the returned array for continued buffering.- Parameters:
fullChunk- Completed chunk that the caller is requesting to append to this buffer. It is generally chunk that was returned by an earlier call toresetAndStart()orappendCompletedChunk(Object[])(although this is not required or enforced)- Returns:
- New chunk buffer for caller to fill
-
completeAndClearBuffer
Method called to indicate that the buffering process is now complete; and to construct a combined exactly-sized result array. Additionally the buffer itself will be reset to reduce memory retention.Resulting array will be of generic
Object[]type: if a typed array is needed, use the method with additional type argument. -
completeAndClearBuffer
public <T> T[] completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries, Class<T> componentType) Type-safe alternative tocompleteAndClearBuffer(Object[], int), to allow for constructing explicitly typed result array.- Parameters:
componentType- Type of elements included in the buffer. Will be used for constructing the result array.
-
completeAndClearBuffer
-
initialCapacity
public int initialCapacity()Helper method that can be used to check how much free capacity will this instance start with. Can be used to choose the best instance to reuse, based on size of reusable object chunk buffer holds reference to. -
bufferedSize
public int bufferedSize()Method that can be used to check how many Objects have been buffered within this buffer. -
_reset
protected void _reset() -
_copyTo
-