Package org.elasticsearch.common.bytes
Class ByteBufferReference
java.lang.Object
org.elasticsearch.common.bytes.AbstractBytesReference
org.elasticsearch.common.bytes.ByteBufferReference
- All Implemented Interfaces:
java.lang.Comparable<BytesReference>,BytesReference,ToXContent,ToXContentFragment
public class ByteBufferReference extends AbstractBytesReference
This is a
BytesReference backed by a ByteBuffer. The byte buffer can either be a heap or
direct byte buffer. The reference is composed of the space between the Buffer.position() and
Buffer.limit() at construction time. If the position or limit of the underlying byte buffer is
changed, those changes will not be reflected in this reference. Any changes to the underlying data in the
byte buffer will be reflected in this reference.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params -
Field Summary
-
Method Summary
Modifier and Type Method Description byteget(int index)Returns the byte at the specified index.intgetInt(int index)Returns the integer read from the 4 bytes (BE) starting at the given index.intlength()The length.longramBytesUsed()The amount of memory used by this BytesReferenceBytesReferenceslice(int from, int length)Slice the bytes from thefromindex up tolength.org.apache.lucene.util.BytesReftoBytesRef()This will return a bytes ref composed of the bytes.Methods inherited from class org.elasticsearch.common.bytes.AbstractBytesReference
compareTo, equals, hashCode, indexOf, iterator, streamInput, toXContent, utf8ToString, writeTo
-
Method Details
-
get
public byte get(int index)Description copied from interface:BytesReferenceReturns the byte at the specified index. Need to be between 0 and length. -
getInt
public int getInt(int index)Description copied from interface:BytesReferenceReturns the integer read from the 4 bytes (BE) starting at the given index.- Specified by:
getIntin interfaceBytesReference- Overrides:
getIntin classAbstractBytesReference
-
length
public int length()Description copied from interface:BytesReferenceThe length. -
slice
Description copied from interface:BytesReferenceSlice the bytes from thefromindex up tolength. -
toBytesRef
public org.apache.lucene.util.BytesRef toBytesRef()This will return a bytes ref composed of the bytes. If this is a direct byte buffer, the bytes will have to be copied.- Returns:
- the bytes ref
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:BytesReferenceThe amount of memory used by this BytesReference
-