Package org.elasticsearch.nio
Class InboundChannelBuffer
java.lang.Object
org.elasticsearch.nio.InboundChannelBuffer
- All Implemented Interfaces:
AutoCloseable
This is a channel byte buffer composed internally of 16kb pages. When an entire message has been read
and consumed, the
release(long) method releases the bytes from the head of the buffer and closes
the pages internally. If more space is needed at the end of the buffer ensureCapacity(long) can
be called and the buffer will expand using the supplier provided.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InboundChannelBuffervoidclose()voidensureCapacity(long requiredCapacity) longlonggetIndex()longvoidincrementIndex(long delta) voidrelease(long bytesToRelease) This method will release bytes from the head of this buffer.Page[]sliceAndRetainPagesTo(long to) This method will return an array ofPagerepresenting the bytes from the beginning of this buffer up through the index argument that was passed.sliceBuffersFrom(long from) This method will return an array ofByteBufferrepresenting the bytes from the index passed through the end of this buffer.sliceBuffersTo(long to) This method will return an array ofByteBufferrepresenting the bytes from the beginning of this buffer up through the index argument that was passed.
-
Field Details
-
PAGE_SIZE
public static final int PAGE_SIZE- See Also:
-
-
Constructor Details
-
InboundChannelBuffer
-
-
Method Details
-
allocatingInstance
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
ensureCapacity
public void ensureCapacity(long requiredCapacity) -
release
public void release(long bytesToRelease) This method will release bytes from the head of this buffer. If you release bytes past the current index the index is truncated to zero.- Parameters:
bytesToRelease- number of bytes to drop
-
sliceBuffersTo
This method will return an array ofByteBufferrepresenting the bytes from the beginning of this buffer up through the index argument that was passed. The buffers will be duplicates of the internal buffers, so any modifications to the markersBuffer.position(),Buffer.limit(), etc will not modify the this class.- Parameters:
to- the index to slice up to- Returns:
- the byte buffers
-
sliceAndRetainPagesTo
This method will return an array ofPagerepresenting the bytes from the beginning of this buffer up through the index argument that was passed. The pages and buffers will be duplicates of the internal components, so any modifications to the markersBuffer.position(),Buffer.limit(), etc will not modify the this class. Additionally, this will internally retain the underlying pages, so the pages returned by this method must be closed.- Parameters:
to- the index to slice up to- Returns:
- the pages
-
sliceBuffersFrom
This method will return an array ofByteBufferrepresenting the bytes from the index passed through the end of this buffer. The buffers will be duplicates of the internal buffers, so any modifications to the markersBuffer.position(),Buffer.limit(), etc will not modify the this class.- Parameters:
from- the index to slice from- Returns:
- the byte buffers
-
incrementIndex
public void incrementIndex(long delta) -
getIndex
public long getIndex() -
getCapacity
public long getCapacity() -
getRemaining
public long getRemaining()
-