Package org.infinispan.commons.marshall
Class AdaptiveBufferSizePredictor
java.lang.Object
org.infinispan.commons.marshall.AdaptiveBufferSizePredictor
- All Implemented Interfaces:
BufferSizePredictor
The
BufferSizePredictor that automatically increases and
decreases the predicted buffer size on feed back.
It gradually increases the expected number of bytes if the previous buffer fully filled the allocated buffer. It gradually decreases the expected number of bytes if the read operation was not able to fill a certain amount of the allocated buffer two times consecutively. Otherwise, it keeps returning the same prediction. TODO: Object type hints could be useful at giving more type-specific predictions
- Since:
- 5.0
- Author:
- Trustin Lee, Galder ZamarreƱo
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new predictor with the default parameters.AdaptiveBufferSizePredictor(int minimum, int initial, int maximum) Creates a new predictor with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionintProvide the next buffer size taking in account the object to store in the buffer.voidrecordSize(int previousSize) Record the size of the of data in the last buffer used.
-
Constructor Details
-
AdaptiveBufferSizePredictor
public AdaptiveBufferSizePredictor()Creates a new predictor with the default parameters. With the default parameters, the expected buffer size starts from512, does not go down below16, and does not go up above65536. -
AdaptiveBufferSizePredictor
public AdaptiveBufferSizePredictor(int minimum, int initial, int maximum) Creates a new predictor with the specified parameters.- Parameters:
minimum- the inclusive lower bound of the expected buffer sizeinitial- the initial buffer size when no feed back was receivedmaximum- the inclusive upper bound of the expected buffer size
-
-
Method Details
-
nextSize
Description copied from interface:BufferSizePredictorProvide the next buffer size taking in account the object to store in the buffer.- Specified by:
nextSizein interfaceBufferSizePredictor- Parameters:
obj- instance that will be stored in the buffer- Returns:
- int representing the next predicted buffer size
-
recordSize
public void recordSize(int previousSize) Description copied from interface:BufferSizePredictorRecord the size of the of data in the last buffer used.- Specified by:
recordSizein interfaceBufferSizePredictor- Parameters:
previousSize- int representing the size of the last object buffered.
-