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. IfMultipleParameterToolobject 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 Objectclone()booleanequals(Object o)static MultipleParameterToolfromArgs(String[] args)ReturnsMultipleParameterToolfor the given arguments.static MultipleParameterToolfromMultiMap(Map<String,Collection<String>> multiMap)ReturnsMultipleParameterToolfor the given multi map.Stringget(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.intgetNumberOfParameters()Returns number of parameters inParameterTool.booleanhas(String value)Check if value is set.inthashCode()MultipleParameterToolmergeWith(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)
ReturnsMultipleParameterToolfor 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)
ReturnsMultipleParameterToolfor 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:
equalsin classExecutionConfig.GlobalJobParameters
-
hashCode
public int hashCode()
- Overrides:
hashCodein classExecutionConfig.GlobalJobParameters
-
getNumberOfParameters
public int getNumberOfParameters()
Returns number of parameters inParameterTool.- Specified by:
getNumberOfParametersin 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:
getin classAbstractParameterTool
-
has
public boolean has(String value)
Check if value is set.- Specified by:
hasin 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:
clonein classAbstractParameterTool- Throws:
CloneNotSupportedException
-
mergeWith
public MultipleParameterTool mergeWith(MultipleParameterTool other)
Merges twoMultipleParameterTool.- Parameters:
other- OtherMultipleParameterToolobject- Returns:
- The Merged
MultipleParameterTool
-
toMap
public Map<String,String> toMap()
Description copied from class:ExecutionConfig.GlobalJobParametersConvert 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:
toMapin classAbstractParameterTool- Returns:
- Key/Value representation of the UserConfig
-
-