Package org.opensearch.common.bytes
Class ReleasableBytesReference
java.lang.Object
org.opensearch.common.bytes.ReleasableBytesReference
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Comparable<org.opensearch.core.common.bytes.BytesReference>
,org.opensearch.common.lease.Releasable
,org.opensearch.core.common.bytes.BytesReference
,org.opensearch.core.xcontent.ToXContent
,org.opensearch.core.xcontent.ToXContentFragment
public final class ReleasableBytesReference
extends Object
implements org.opensearch.common.lease.Releasable, org.opensearch.core.common.bytes.BytesReference
An extension to
BytesReference
that requires releasing its content. This
class exists to make it explicit when a bytes reference needs to be released, and when not.- Opensearch.internal:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params
-
Field Summary
FieldsFields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionReleasableBytesReference
(org.opensearch.core.common.bytes.BytesReference delegate, org.opensearch.common.lease.Releasable releasable) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
int
compareTo
(org.opensearch.core.common.bytes.BytesReference o) boolean
byte
get
(int index) int
getInt
(int index) int
hashCode()
int
indexOf
(byte marker, int from) boolean
org.apache.lucene.util.BytesRefIterator
iterator()
int
length()
long
int
refCount()
retain()
retainedSlice
(int from, int length) org.opensearch.core.common.bytes.BytesReference
slice
(int from, int length) org.opensearch.core.common.io.stream.StreamInput
org.apache.lucene.util.BytesRef
org.opensearch.core.xcontent.XContentBuilder
toXContent
(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) static ReleasableBytesReference
wrap
(org.opensearch.core.common.bytes.BytesReference reference) void
writeTo
(OutputStream os)
-
Field Details
-
NO_OP
public static final org.opensearch.common.lease.Releasable NO_OP
-
-
Constructor Details
-
ReleasableBytesReference
public ReleasableBytesReference(org.opensearch.core.common.bytes.BytesReference delegate, org.opensearch.common.lease.Releasable releasable)
-
-
Method Details
-
wrap
public static ReleasableBytesReference wrap(org.opensearch.core.common.bytes.BytesReference reference) -
refCount
public int refCount() -
retain
-
retainedSlice
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.opensearch.common.lease.Releasable
-
get
public byte get(int index) - Specified by:
get
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
getInt
public int getInt(int index) - Specified by:
getInt
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
indexOf
public int indexOf(byte marker, int from) - Specified by:
indexOf
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
length
public int length()- Specified by:
length
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
slice
public org.opensearch.core.common.bytes.BytesReference slice(int from, int length) - Specified by:
slice
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
streamInput
- Specified by:
streamInput
in interfaceorg.opensearch.core.common.bytes.BytesReference
- Throws:
IOException
-
writeTo
- Specified by:
writeTo
in interfaceorg.opensearch.core.common.bytes.BytesReference
- Throws:
IOException
-
utf8ToString
- Specified by:
utf8ToString
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
toBytesRef
public org.apache.lucene.util.BytesRef toBytesRef()- Specified by:
toBytesRef
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
iterator
public org.apache.lucene.util.BytesRefIterator iterator()- Specified by:
iterator
in interfaceorg.opensearch.core.common.bytes.BytesReference
-
compareTo
public int compareTo(org.opensearch.core.common.bytes.BytesReference o) - Specified by:
compareTo
in interfaceComparable<org.opensearch.core.common.bytes.BytesReference>
-
toXContent
public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceorg.opensearch.core.xcontent.ToXContent
- Throws:
IOException
-
isFragment
public boolean isFragment()- Specified by:
isFragment
in interfaceorg.opensearch.core.xcontent.ToXContent
- Specified by:
isFragment
in interfaceorg.opensearch.core.xcontent.ToXContentFragment
-
equals
-
hashCode
public int hashCode()
-