Package io.airlift.units
Class DataSize
java.lang.Object
io.airlift.units.DataSize
- All Implemented Interfaces:
Comparable<DataSize>
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintconvertTo(DataSize.Unit unit) Deprecated.Useto(Unit)instead.Deprecated.Usesuccinct()instead.booleangetUnit()doublegetValue()Deprecated.UsetoBytes()instead to avoid floating point precision semanticsdoublegetValue(DataSize.Unit unit) Deprecated.UsetoBytes()instead to avoid floating point precision semanticsinthashCode()static DataSizeof(long size, DataSize.Unit unit) Creates aDataSizeinstance with the provided quantity of the providedDataSize.Unit.static DataSizeofBytes(long bytes) longroundTo(DataSize.Unit unit) Deprecated.UsetoBytes()instead.succinct()static DataSizesuccinctBytes(long bytes) PreferofBytes(long)when conversion to the most 'succinct' unit is not necessary or desirablestatic DataSizesuccinctDataSize(double size, DataSize.Unit unit) Deprecated.usesuccinctBytes(long)instead, double values are impreciseto(DataSize.Unit unit) longtoBytes()toString()static DataSize
-
Constructor Details
-
DataSize
Deprecated.Useof(long, Unit)instead. The imprecise nature of using doubles for DataSize is deprecated for removal
-
-
Method Details
-
of
Creates aDataSizeinstance with the provided quantity of the providedDataSize.Unit. This value is immediately converted to bytes which might overflow.- Parameters:
size- The quantity of the supplied unitunit- The unit to use as the default unit for the constructed instance and to convert the size to bytes- Throws:
IllegalArgumentException- If the provided size would overflow a long value when converting to bytes
-
ofBytes
-
succinctBytes
PreferofBytes(long)when conversion to the most 'succinct' unit is not necessary or desirable -
succinctDataSize
Deprecated.usesuccinctBytes(long)instead, double values are imprecisePreferof(long, Unit)when conversion to the most 'succinct' unit is not necessary or desirable. Otherwise, usesuccinctBytes(long)since it will not incur rounding and loss of precision. -
toBytes
public long toBytes() -
getValue
Deprecated.UsetoBytes()instead to avoid floating point precision semantics -
getUnit
-
getValue
Deprecated.UsetoBytes()instead to avoid floating point precision semantics -
roundTo
Deprecated.UsetoBytes()instead. This method uses floating point semantics to compute the rounded value which can yield to unexpected loss of precision beyond the intended rounding -
convertTo
Deprecated.Useto(Unit)instead. No conversion occurs when calling this method, only the unit used for the default string representation is changed. This has no effect on the unit used during JSON serialization -
to
-
succinct
-
convertToMostSuccinctDataSize
Deprecated.Usesuccinct()instead. No conversion occurs when calling this method, only the unit used for the default string representation is changed. This has no effect on the unit used during JSON serialization -
toBytesValueString
-
toString
-
valueOf
- Throws:
IllegalArgumentException
-
compareTo
- Specified by:
compareToin interfaceComparable<DataSize>
-
equals
-
hashCode
public int hashCode()
-
of(long, Unit)instead.