Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.util

public final Class ObjectBuffer

extends Object
Class Inheritance
Imports
java.lang.reflect.Array, java.util.List

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

Modifier and TypeField and Description
private Object[]
_freeBuffer

Reusable Object array, stored here after buffer has been released having been used previously.

private LinkedNode<Object[]>
private int
_size

Number of total buffered entries in this buffer, counting all instances within linked list formed by following _head.

private LinkedNode<Object[]>
private static final int
MAX_CHUNK

Let's limit maximum size of chunks we use; helps avoid excessive allocation overhead for huge data sets.

private static final int
SMALL_CHUNK

Also: let's expand by doubling up until 64k chunks (which is 16k entries for 32-bit machines)

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final void
_copyTo(Object resultArray, int totalSize, Object[] lastChunk, int lastChunkEntries)

protected void
public Object[]

Returns:

New chunk buffer for caller to fill
appendCompletedChunk
(Object[]
Completed chunk that the caller is requesting to append to this buffer. It is generally chunk that was returned by an earlier call to resetAndStart or appendCompletedChunk (although this is not required or enforced)
fullChunk
)

Method called to add a full Object array as a chunk buffered within this buffer, and to obtain a new array to fill.

public int
bufferedSize()

Method that can be used to check how many Objects have been buffered within this buffer.

public 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.

public <T> T[]
completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries, Class<T>
Type of elements included in the buffer. Will be used for constructing the result array.
componentType
)

Type-safe alternative to completeAndClearBuffer(Object[], int), to allow for constructing explicitly typed result array.

public void
completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries, List<Object> resultList)

public int
initialCapacity()

Helper method that can be used to check how much free capacity will this instance start with.

public Object[]
resetAndStart()

Method called to start buffering process.

public Object[]
resetAndStart(Object[] base, int count)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_freeBufferback to summary
private Object[] _freeBuffer

Reusable Object array, stored here after buffer has been released having been used previously.

_headback to summary
private LinkedNode<Object[]> _head
_sizeback to summary
private int _size

Number of total buffered entries in this buffer, counting all instances within linked list formed by following _head.

_tailback to summary
private LinkedNode<Object[]> _tail
MAX_CHUNKback to summary
private static final int MAX_CHUNK

Let'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.

SMALL_CHUNKback to summary
private static final int SMALL_CHUNK

Also: let's expand by doubling up until 64k chunks (which is 16k entries for 32-bit machines)

Constructor Detail

ObjectBufferback to summary
public ObjectBuffer()

Method Detail

_copyToback to summary
protected final void _copyTo(Object resultArray, int totalSize, Object[] lastChunk, int lastChunkEntries)
_resetback to summary
protected void _reset()
appendCompletedChunkback to summary
public 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. Caller is not to use the array it gives; but to use the returned array for continued buffering.

Parameters
fullChunk:Object[]

Completed chunk that the caller is requesting to append to this buffer. It is generally chunk that was returned by an earlier call to resetAndStart or appendCompletedChunk (although this is not required or enforced)

Returns:Object[]

New chunk buffer for caller to fill

bufferedSizeback to summary
public int bufferedSize()

Method that can be used to check how many Objects have been buffered within this buffer.

completeAndClearBufferback to summary
public 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. 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.

completeAndClearBufferback to summary
public <T> T[] completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries, Class<T> componentType)

Type-safe alternative to completeAndClearBuffer(Object[], int), to allow for constructing explicitly typed result array.

Parameters
componentType:Class<T>

Type of elements included in the buffer. Will be used for constructing the result array.

completeAndClearBufferback to summary
public void completeAndClearBuffer(Object[] lastChunk, int lastChunkEntries, List<Object> resultList)
initialCapacityback to summary
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.

resetAndStartback to summary
public Object[] 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

resetAndStartback to summary
public Object[] resetAndStart(Object[] base, int count)
Since
2.9