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

    Fields
    Modifier and Type
    Field
    Description
    static final org.opensearch.common.lease.Releasable
     

    Fields inherited from interface org.opensearch.core.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReleasableBytesReference(org.opensearch.core.common.bytes.BytesReference delegate, org.opensearch.common.lease.Releasable releasable)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    int
    compareTo(org.opensearch.core.common.bytes.BytesReference o)
     
    boolean
     
    byte
    get(int index)
     
    int
    getInt(int index)
     
    int
     
    int
    indexOf(byte marker, int from)
     
    boolean
     
    org.apache.lucene.util.BytesRefIterator
     
    int
     
    long
     
    int
     
     
    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)
     
     
    wrap(org.opensearch.core.common.bytes.BytesReference reference)
     
    void
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • 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

      public ReleasableBytesReference retain()
    • retainedSlice

      public ReleasableBytesReference retainedSlice(int from, int length)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.opensearch.common.lease.Releasable
    • get

      public byte get(int index)
      Specified by:
      get in interface org.opensearch.core.common.bytes.BytesReference
    • getInt

      public int getInt(int index)
      Specified by:
      getInt in interface org.opensearch.core.common.bytes.BytesReference
    • indexOf

      public int indexOf(byte marker, int from)
      Specified by:
      indexOf in interface org.opensearch.core.common.bytes.BytesReference
    • length

      public int length()
      Specified by:
      length in interface org.opensearch.core.common.bytes.BytesReference
    • slice

      public org.opensearch.core.common.bytes.BytesReference slice(int from, int length)
      Specified by:
      slice in interface org.opensearch.core.common.bytes.BytesReference
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.opensearch.core.common.bytes.BytesReference
    • streamInput

      public org.opensearch.core.common.io.stream.StreamInput streamInput() throws IOException
      Specified by:
      streamInput in interface org.opensearch.core.common.bytes.BytesReference
      Throws:
      IOException
    • writeTo

      public void writeTo(OutputStream os) throws IOException
      Specified by:
      writeTo in interface org.opensearch.core.common.bytes.BytesReference
      Throws:
      IOException
    • utf8ToString

      public String utf8ToString()
      Specified by:
      utf8ToString in interface org.opensearch.core.common.bytes.BytesReference
    • toBytesRef

      public org.apache.lucene.util.BytesRef toBytesRef()
      Specified by:
      toBytesRef in interface org.opensearch.core.common.bytes.BytesReference
    • iterator

      public org.apache.lucene.util.BytesRefIterator iterator()
      Specified by:
      iterator in interface org.opensearch.core.common.bytes.BytesReference
    • compareTo

      public int compareTo(org.opensearch.core.common.bytes.BytesReference o)
      Specified by:
      compareTo in interface Comparable<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 interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • isFragment

      public boolean isFragment()
      Specified by:
      isFragment in interface org.opensearch.core.xcontent.ToXContent
      Specified by:
      isFragment in interface org.opensearch.core.xcontent.ToXContentFragment
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object