java.lang.Object
org.elasticsearch.common.unit.ByteSizeValue
- All Implemented Interfaces:
Comparable<ByteSizeValue>,Writeable,ToXContent,ToXContentFragment
public class ByteSizeValue
extends Object
implements Writeable, Comparable<ByteSizeValue>, ToXContentFragment
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ByteSizeValuestatic final ByteSizeValuestatic final ByteSizeValueFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteSizeValueadd(ByteSizeValue x, ByteSizeValue y) intDeprecated.intcompareTo(ByteSizeValue other) booleanlonggetBytes()longgetGb()doublelonggetKb()doublelonggetMb()doublelonggetPb()doublelonggetTb()doubleinthashCode()static ByteSizeValuemin(ByteSizeValue x, ByteSizeValue y) static ByteSizeValueof(long size, ByteSizeUnit unit) static ByteSizeValueofBytes(long size) static ByteSizeValueofGb(long size) static ByteSizeValueofKb(long size) static ByteSizeValueofMb(long size) static ByteSizeValueofPb(long size) static ByteSizeValueofTb(long size) static ByteSizeValueparseBytesSizeValue(String sValue, String settingName) static ByteSizeValueparseBytesSizeValue(String sValue, ByteSizeValue defaultValue, String settingName) static ByteSizeValuereadFrom(StreamInput in) static ByteSizeValuetoString()toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
ZERO
-
ONE
-
MINUS_ONE
-
-
Method Details
-
of
- Parameters:
size- the number ofunits
-
ofBytes
-
ofKb
-
ofMb
-
ofGb
-
ofTb
-
ofPb
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
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
- Returns:
- a string representation of this value which is guaranteed to be
able to be parsed using
parseBytesSizeValue(String, ByteSizeValue, String). UnliketoString()this method will not output fractional or rounded values so this method should be preferred when serialising the value to JSON.
-
toString
-
parseBytesSizeValue
public static ByteSizeValue parseBytesSizeValue(String sValue, String settingName) throws ElasticsearchParseException - Throws:
ElasticsearchParseException
-
parseBytesSizeValue
public static ByteSizeValue parseBytesSizeValue(String sValue, ByteSizeValue defaultValue, String settingName) throws ElasticsearchParseException - Throws:
ElasticsearchParseException
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<ByteSizeValue>
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
add
- Returns:
- Constructs a
ByteSizeValuewith the bytes resulting from the addition of the arguments' bytes. Note that the resultingByteSizeUnitis bytes. - Throws:
IllegalArgumentException- if any of the arguments have -1 bytes
-
subtract
- Returns:
- Constructs a
ByteSizeValuewith the bytes resulting from the difference of the arguments' bytes. Note that the resultingByteSizeUnitis bytes. - Throws:
IllegalArgumentException- if any of the arguments or the result have -1 bytes
-
min
- Returns:
- Returns the lesser of the two given
ByteSizeValuearguments. In case of equality, the first argument is returned. - Throws:
IllegalArgumentException- if any of the arguments have -1 bytes
-