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 class
MemorySize.MemoryUnit
Enum which defines memory unit, mostly used to parse value from configuration file.
-
Field Summary
Fields Modifier and Type Field Description static MemorySize
MAX_VALUE
static MemorySize
ZERO
-
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 MemorySize
add(MemorySize that)
int
compareTo(MemorySize that)
MemorySize
divide(long by)
boolean
equals(Object obj)
long
getBytes()
Gets the memory size in bytes.long
getGibiBytes()
Gets the memory size in Gibibytes (= 1024 Mebibytes).long
getKibiBytes()
Gets the memory size in Kibibytes (= 1024 bytes).int
getMebiBytes()
Gets the memory size in Mebibytes (= 1024 Kibibytes).long
getTebiBytes()
Gets the memory size in Tebibytes (= 1024 Gibibytes).int
hashCode()
MemorySize
multiply(double multiplier)
static MemorySize
ofMebiBytes(long mebiBytes)
static MemorySize
parse(String text)
Parses the given string as as MemorySize.static MemorySize
parse(String text, MemorySize.MemoryUnit defaultUnit)
Parses the given string with a default unit.static long
parseBytes(String text)
Parses the given string as bytes.MemorySize
subtract(MemorySize that)
String
toHumanReadableString()
String
toString()
-
-
-
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:
compareTo
in 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.
-
-