Package org.apache.flink.configuration
Class MemorySize
- java.lang.Object
-
- org.apache.flink.configuration.MemorySize
-
- All Implemented Interfaces:
Serializable,Comparable<MemorySize>
@PublicEvolving public class MemorySize extends Object implements Serializable, Comparable<MemorySize>
MemorySize is a representation of a number of bytes, viewable in different units.Parsing
The size can be parsed from a text expression. If the expression is a pure number, the value will be interpreted as bytes.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMemorySize.MemoryUnitEnum which defines memory unit, mostly used to parse value from configuration file.
-
Field Summary
Fields Modifier and Type Field Description static MemorySizeMAX_VALUEstatic MemorySizeZERO
-
Constructor Summary
Constructors Constructor Description MemorySize(long bytes)Constructs a new MemorySize.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MemorySizeadd(MemorySize that)intcompareTo(MemorySize that)MemorySizedivide(long by)booleanequals(Object obj)longgetBytes()Gets the memory size in bytes.longgetGibiBytes()Gets the memory size in Gibibytes (= 1024 Mebibytes).longgetKibiBytes()Gets the memory size in Kibibytes (= 1024 bytes).intgetMebiBytes()Gets the memory size in Mebibytes (= 1024 Kibibytes).longgetTebiBytes()Gets the memory size in Tebibytes (= 1024 Gibibytes).inthashCode()MemorySizemultiply(double multiplier)static MemorySizeofMebiBytes(long mebiBytes)static MemorySizeparse(String text)Parses the given string as as MemorySize.static MemorySizeparse(String text, MemorySize.MemoryUnit defaultUnit)Parses the given string with a default unit.static longparseBytes(String text)Parses the given string as bytes.MemorySizesubtract(MemorySize that)StringtoHumanReadableString()StringtoString()
-
-
-
Field Detail
-
ZERO
public static final MemorySize ZERO
-
MAX_VALUE
public static final MemorySize MAX_VALUE
-
-
Method Detail
-
ofMebiBytes
public static MemorySize ofMebiBytes(long mebiBytes)
-
getBytes
public long getBytes()
Gets the memory size in bytes.
-
getKibiBytes
public long getKibiBytes()
Gets the memory size in Kibibytes (= 1024 bytes).
-
getMebiBytes
public int getMebiBytes()
Gets the memory size in Mebibytes (= 1024 Kibibytes).
-
getGibiBytes
public long getGibiBytes()
Gets the memory size in Gibibytes (= 1024 Mebibytes).
-
getTebiBytes
public long getTebiBytes()
Gets the memory size in Tebibytes (= 1024 Gibibytes).
-
toHumanReadableString
public String toHumanReadableString()
-
compareTo
public int compareTo(MemorySize that)
- Specified by:
compareToin interfaceComparable<MemorySize>
-
add
public MemorySize add(MemorySize that)
-
subtract
public MemorySize subtract(MemorySize that)
-
multiply
public MemorySize multiply(double multiplier)
-
divide
public MemorySize divide(long by)
-
parse
public static MemorySize parse(String text) throws IllegalArgumentException
Parses the given string as as MemorySize.- Parameters:
text- The string to parse- Returns:
- The parsed MemorySize
- Throws:
IllegalArgumentException- Thrown, if the expression cannot be parsed.
-
parse
public static MemorySize parse(String text, MemorySize.MemoryUnit defaultUnit) throws IllegalArgumentException
Parses the given string with a default unit.- Parameters:
text- The string to parse.defaultUnit- specify the default unit.- Returns:
- The parsed MemorySize.
- Throws:
IllegalArgumentException- Thrown, if the expression cannot be parsed.
-
parseBytes
public static long parseBytes(String text) throws IllegalArgumentException
Parses the given string as bytes. The supported expressions are listed underMemorySize.- Parameters:
text- The string to parse- Returns:
- The parsed size, in bytes.
- Throws:
IllegalArgumentException- Thrown, if the expression cannot be parsed.
-
-