Class ByteSizeValue

java.lang.Object
org.elasticsearch.common.unit.ByteSizeValue
All Implemented Interfaces:
java.lang.Comparable<ByteSizeValue>, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public class ByteSizeValue
extends java.lang.Object
implements Writeable, java.lang.Comparable<ByteSizeValue>, org.elasticsearch.common.xcontent.ToXContentFragment
  • Field Details

  • Constructor Details

    • ByteSizeValue

      public ByteSizeValue​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
    • ByteSizeValue

      public ByteSizeValue​(long bytes)
    • ByteSizeValue

      public ByteSizeValue​(long size, ByteSizeUnit unit)
  • Method Details

    • ofBytes

      public static ByteSizeValue ofBytes​(long size)
    • ofKb

      public static ByteSizeValue ofKb​(long size)
    • ofMb

      public static ByteSizeValue ofMb​(long size)
    • ofGb

      public static ByteSizeValue ofGb​(long size)
    • ofTb

      public static ByteSizeValue ofTb​(long size)
    • ofPb

      public static ByteSizeValue ofPb​(long size)
    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • bytesAsInt

      @Deprecated public int bytesAsInt()
      Deprecated.
    • getBytes

      public long getBytes()
    • getKb

      public long getKb()
    • getMb

      public long getMb()
    • getGb

      public long getGb()
    • getTb

      public long getTb()
    • getPb

      public long getPb()
    • getKbFrac

      public double getKbFrac()
    • getMbFrac

      public double getMbFrac()
    • getGbFrac

      public double getGbFrac()
    • getTbFrac

      public double getTbFrac()
    • getPbFrac

      public double getPbFrac()
    • getStringRep

      public java.lang.String getStringRep()
      Returns:
      a string representation of this value which is guaranteed to be able to be parsed using parseBytesSizeValue(String, ByteSizeValue, String). Unlike toString() this method will not output fractional or rounded values so this method should be preferred when serialising the value to JSON.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • parseBytesSizeValue

      public static ByteSizeValue parseBytesSizeValue​(java.lang.String sValue, java.lang.String settingName) throws ElasticsearchParseException
      Throws:
      ElasticsearchParseException
    • parseBytesSizeValue

      public static ByteSizeValue parseBytesSizeValue​(java.lang.String sValue, ByteSizeValue defaultValue, java.lang.String settingName) throws ElasticsearchParseException
      Throws:
      ElasticsearchParseException
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • compareTo

      public int compareTo​(ByteSizeValue other)
      Specified by:
      compareTo in interface java.lang.Comparable<ByteSizeValue>
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException