Package org.apache.flink.util
Class MultipleParameterTool
- java.lang.Object
-
- org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters
-
- org.apache.flink.util.AbstractParameterTool
-
- org.apache.flink.util.MultipleParameterTool
-
- All Implemented Interfaces:
Serializable
,Cloneable
@PublicEvolving public class MultipleParameterTool extends AbstractParameterTool
This class provides simple utility methods for reading and parsing program arguments from different sources. Multiple values parameter in args could be supported. For example, --multi multiValue1 --multi multiValue2. IfMultipleParameterTool
object is used for GlobalJobParameters, the last one of multiple values will be used. Navigate totoMap()
for more information.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Collection<String>>
data
-
Fields inherited from class org.apache.flink.util.AbstractParameterTool
DEFAULT_UNDEFINED, defaultData, NO_VALUE_KEY, unrequestedParameters
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
clone()
boolean
equals(Object o)
static MultipleParameterTool
fromArgs(String[] args)
ReturnsMultipleParameterTool
for the given arguments.static MultipleParameterTool
fromMultiMap(Map<String,Collection<String>> multiMap)
ReturnsMultipleParameterTool
for the given multi map.String
get(String key)
Returns the String value for the given key.Collection<String>
getMultiParameter(String key)
Returns the Collection of String values for the given key.Collection<String>
getMultiParameterRequired(String key)
Returns the Collection of String values for the given key.int
getNumberOfParameters()
Returns number of parameters inParameterTool
.boolean
has(String value)
Check if value is set.int
hashCode()
MultipleParameterTool
mergeWith(MultipleParameterTool other)
Merges twoMultipleParameterTool
.Map<String,String>
toMap()
Convert UserConfig into aMap<String, String>
representation.Map<String,Collection<String>>
toMultiMap()
Return MultiMap of all the parameters processed byMultipleParameterTool
.-
Methods inherited from class org.apache.flink.util.AbstractParameterTool
addToDefaults, get, getBoolean, getBoolean, getByte, getByte, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getRequired, getShort, getShort, getUnrequestedParameters
-
-
-
-
Field Detail
-
data
protected final Map<String,Collection<String>> data
-
-
Method Detail
-
fromArgs
public static MultipleParameterTool fromArgs(String[] args)
ReturnsMultipleParameterTool
for the given arguments. The arguments are keys followed by values. Keys have to start with '-' or '--'Example arguments: --key1 value1 --key2 value2 -key3 value3 --multi multiValue1 --multi multiValue2
- Parameters:
args
- Input array arguments- Returns:
- A
MultipleParameterTool
-
fromMultiMap
public static MultipleParameterTool fromMultiMap(Map<String,Collection<String>> multiMap)
ReturnsMultipleParameterTool
for the given multi map.- Parameters:
multiMap
- A map of arguments. Key is String and value is a Collection.- Returns:
- A
MultipleParameterTool
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classExecutionConfig.GlobalJobParameters
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classExecutionConfig.GlobalJobParameters
-
getNumberOfParameters
public int getNumberOfParameters()
Returns number of parameters inParameterTool
.- Specified by:
getNumberOfParameters
in classAbstractParameterTool
-
get
public String get(String key)
Returns the String value for the given key. The value should only have one item. UsegetMultiParameter(String)
instead if want to get multiple values parameter. If the key does not exist it will return null.- Specified by:
get
in classAbstractParameterTool
-
has
public boolean has(String value)
Check if value is set.- Specified by:
has
in classAbstractParameterTool
-
getMultiParameter
public Collection<String> getMultiParameter(String key)
Returns the Collection of String values for the given key. If the key does not exist it will return null.
-
getMultiParameterRequired
public Collection<String> getMultiParameterRequired(String key)
Returns the Collection of String values for the given key. If the key does not exist it will throw aRuntimeException
.
-
toMultiMap
public Map<String,Collection<String>> toMultiMap()
Return MultiMap of all the parameters processed byMultipleParameterTool
.- Returns:
- MultiMap of the
MultipleParameterTool
. Key is String and Value is a Collection of String.
-
clone
protected Object clone() throws CloneNotSupportedException
- Specified by:
clone
in classAbstractParameterTool
- Throws:
CloneNotSupportedException
-
mergeWith
public MultipleParameterTool mergeWith(MultipleParameterTool other)
Merges twoMultipleParameterTool
.- Parameters:
other
- OtherMultipleParameterTool
object- Returns:
- The Merged
MultipleParameterTool
-
toMap
public Map<String,String> toMap()
Description copied from class:ExecutionConfig.GlobalJobParameters
Convert UserConfig into aMap<String, String>
representation. This can be used by the runtime, for example for presenting the user config in the web frontend.- Specified by:
toMap
in classAbstractParameterTool
- Returns:
- Key/Value representation of the UserConfig
-
-