Class HumanReadableBytes
- java.lang.Object
-
- org.apache.druid.java.util.common.HumanReadableBytes
-
public class HumanReadableBytes extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHumanReadableBytes.UnitSystem
-
Field Summary
Fields Modifier and Type Field Description static HumanReadableBytesZERO
-
Constructor Summary
Constructors Constructor Description HumanReadableBytes(long bytes)HumanReadableBytes(String bytes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object thatObj)static Stringformat(long bytes, long precision, HumanReadableBytes.UnitSystem unitSystem)Returns a human-readable string version of input valuelonggetBytes()intgetBytesInInt()inthashCode()static longparse(String number)static longparse(String number, long nullValue)parse the case-insensitive string number, which is either:StringtoString()static HumanReadableBytesvalueOf(int bytes)static HumanReadableBytesvalueOf(long bytes)
-
-
-
Field Detail
-
ZERO
public static final HumanReadableBytes ZERO
-
-
Constructor Detail
-
HumanReadableBytes
public HumanReadableBytes(String bytes)
-
HumanReadableBytes
public HumanReadableBytes(long bytes)
-
-
Method Detail
-
getBytes
public long getBytes()
-
getBytesInInt
public int getBytesInInt()
-
valueOf
public static HumanReadableBytes valueOf(int bytes)
-
valueOf
public static HumanReadableBytes valueOf(long bytes)
-
parse
public static long parse(String number)
-
parse
public static long parse(String number, long nullValue)
parse the case-insensitive string number, which is either:a number string
or
a number string with a suffix which indicates the unit the of number the unit must be one of following k - kilobyte = 1000 m - megabyte = 1,000,000 g - gigabyte = 1,000,000,000 t - terabyte = 1,000,000,000,000 p - petabyte = 1,000,000,000,000,000 Ki(B) - kilo binary byte = 1024 Mi(B) - mega binary byte = 1024*1204 Gi(B) - giga binary byte = 1024*1024*1024 Ti(B) - tera binary byte = 1024*1024*1024*1024 Pi(B) - peta binary byte = 1024*1024*1024*1024*1024
- Parameters:
nullValue- to be returned when given number is null or empty- Returns:
- nullValue if input is null or empty value of number
- Throws:
IAE- if the input is invalid
-
format
public static String format(long bytes, long precision, HumanReadableBytes.UnitSystem unitSystem)
Returns a human-readable string version of input value- Parameters:
bytes- input value. Negative value is also allowedprecision- [0,3]unitSystem- which unit system is adopted to format the input value, seeHumanReadableBytes.UnitSystem
-
-