Package org.elasticsearch.common.bytes
Class BytesArray
java.lang.Object
org.elasticsearch.common.bytes.AbstractBytesReference
org.elasticsearch.common.bytes.BytesArray
- All Implemented Interfaces:
Comparable<BytesReference>
,BytesReference
,org.elasticsearch.xcontent.ToXContent
,org.elasticsearch.xcontent.ToXContentFragment
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params
-
Field Summary
FieldsFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionBytesArray
(byte[] bytes) BytesArray
(byte[] bytes, int offset, int length) BytesArray
(String bytes) BytesArray
(org.apache.lucene.util.BytesRef bytesRef) BytesArray
(org.apache.lucene.util.BytesRef bytesRef, boolean deepCopy) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
array()
int
boolean
byte
get
(int index) Returns the byte at the specified index.boolean
hasArray()
int
hashCode()
int
indexOf
(byte marker, int from) Finds the index of the first occurrence of the given marker between within the given bounds.int
length()
The length.long
The amount of memory used by this BytesReferenceslice
(int from, int length) Slice the bytes from thefrom
index up tolength
.A stream input of the bytes.org.apache.lucene.util.BytesRef
Converts to Lucene BytesRef.void
writeTo
(OutputStream os) Writes the bytes directly to the output stream.Methods inherited from class org.elasticsearch.common.bytes.AbstractBytesReference
compareTo, getInt, iterator, toXContent, utf8ToString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
EMPTY
-
-
Constructor Details
-
BytesArray
-
BytesArray
public BytesArray(org.apache.lucene.util.BytesRef bytesRef) -
BytesArray
public BytesArray(org.apache.lucene.util.BytesRef bytesRef, boolean deepCopy) -
BytesArray
public BytesArray(byte[] bytes) -
BytesArray
public BytesArray(byte[] bytes, int offset, int length)
-
-
Method Details
-
get
public byte get(int index) Description copied from interface:BytesReference
Returns the byte at the specified index. Need to be between 0 and length. -
indexOf
public int indexOf(byte marker, int from) Description copied from interface:BytesReference
Finds the index of the first occurrence of the given marker between within the given bounds.- Specified by:
indexOf
in interfaceBytesReference
- Overrides:
indexOf
in classAbstractBytesReference
- Parameters:
marker
- marker byte to searchfrom
- lower bound for the index to check (inclusive)- Returns:
- first index of the marker or
-1
if not found
-
length
public int length()Description copied from interface:BytesReference
The length. -
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractBytesReference
-
equals
- Overrides:
equals
in classAbstractBytesReference
-
slice
Description copied from interface:BytesReference
Slice the bytes from thefrom
index up tolength
. -
hasArray
public boolean hasArray()- Returns:
true
if this instance is backed by a byte array
-
array
public byte[] array()- Returns:
- backing byte array for this instance
-
arrayOffset
public int arrayOffset()- Returns:
- offset of the first byte of this instance in the backing byte array
-
toBytesRef
public org.apache.lucene.util.BytesRef toBytesRef()Description copied from interface:BytesReference
Converts to Lucene BytesRef. -
ramBytesUsed
public long ramBytesUsed()Description copied from interface:BytesReference
The amount of memory used by this BytesReference -
streamInput
Description copied from interface:BytesReference
A stream input of the bytes.- Specified by:
streamInput
in interfaceBytesReference
- Overrides:
streamInput
in classAbstractBytesReference
-
writeTo
Description copied from interface:BytesReference
Writes the bytes directly to the output stream.- Specified by:
writeTo
in interfaceBytesReference
- Overrides:
writeTo
in classAbstractBytesReference
- Throws:
IOException
-