Package org.elasticsearch.common.bytes
Class ByteBufferReference
- java.lang.Object
-
- org.elasticsearch.common.bytes.BytesReference
-
- org.elasticsearch.common.bytes.ByteBufferReference
-
- All Implemented Interfaces:
java.lang.Comparable<BytesReference>
,ToXContent
,ToXContentFragment
public class ByteBufferReference extends BytesReference
This is aBytesReference
backed by aByteBuffer
. The byte buffer can either be a heap or direct byte buffer. The reference is composed of the space between theBuffer.position()
andBuffer.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
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
get(int index)
Returns the byte at the specified index.int
length()
The length.long
ramBytesUsed()
The amount of memory used by this BytesReferenceBytesReference
slice(int from, int length)
Slice the bytes from thefrom
index up tolength
.org.apache.lucene.util.BytesRef
toBytesRef()
This will return a bytes ref composed of the bytes.-
Methods inherited from class org.elasticsearch.common.bytes.BytesReference
bytes, compareTo, equals, fromByteBuffers, hashCode, iterator, streamInput, toByteBuffers, toBytes, toXContent, utf8ToString, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Method Detail
-
get
public byte get(int index)
Description copied from class:BytesReference
Returns the byte at the specified index. Need to be between 0 and length.- Specified by:
get
in classBytesReference
-
length
public int length()
Description copied from class:BytesReference
The length.- Specified by:
length
in classBytesReference
-
slice
public BytesReference slice(int from, int length)
Description copied from class:BytesReference
Slice the bytes from thefrom
index up tolength
.- Specified by:
slice
in classBytesReference
-
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.- Specified by:
toBytesRef
in classBytesReference
- Returns:
- the bytes ref
-
ramBytesUsed
public long ramBytesUsed()
Description copied from class:BytesReference
The amount of memory used by this BytesReference- Specified by:
ramBytesUsed
in classBytesReference
-
-