@Public public class ParameterTool extends org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters implements Serializable, Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,String> |
data |
protected static String |
DEFAULT_UNDEFINED |
protected HashMap<String,String> |
defaultData |
protected static String |
NO_VALUE_KEY |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToDefaults(String key,
String value) |
protected Object |
clone() |
void |
createPropertiesFile(String pathToFile)
Create a properties file with all the known parameters (call after the last get*() call).
|
void |
createPropertiesFile(String pathToFile,
boolean overwrite)
Create a properties file with all the known parameters (call after the last get*() call).
|
static ParameterTool |
fromArgs(String[] args)
Returns
ParameterTool for the given arguments. |
static ParameterTool |
fromGenericOptionsParser(String[] args)
Returns
ParameterTool for the arguments parsed by GenericOptionsParser |
static ParameterTool |
fromMap(Map<String,String> map)
Returns
ParameterTool for the given map |
static ParameterTool |
fromPropertiesFile(String path)
Returns
ParameterTool for the given Properties file |
static ParameterTool |
fromSystemProperties()
Returns
ParameterTool from the system properties. |
String |
get(String key)
Returns the String value for the given key.
|
String |
get(String key,
String defaultValue)
Returns the String value for the given key.
|
boolean |
getBoolean(String key)
Returns the Boolean value for the given key.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the Boolean value for the given key.
|
byte |
getByte(String key)
Returns the Byte value for the given key.
|
byte |
getByte(String key,
byte defaultValue)
Returns the Byte value for the given key.
|
org.apache.flink.configuration.Configuration |
getConfiguration()
Returns a
Configuration object from this ParameterTool |
double |
getDouble(String key)
Returns the Double value for the given key.
|
double |
getDouble(String key,
double defaultValue)
Returns the Double value for the given key.
|
float |
getFloat(String key)
Returns the Float value for the given key.
|
float |
getFloat(String key,
float defaultValue)
Returns the Float value for the given key.
|
int |
getInt(String key)
Returns the Integer value for the given key.
|
int |
getInt(String key,
int defaultValue)
Returns the Integer value for the given key.
|
long |
getLong(String key)
Returns the Long value for the given key.
|
long |
getLong(String key,
long defaultValue)
Returns the Long value for the given key.
|
int |
getNumberOfParameters()
Returns number of parameters in
ParameterTool. |
Properties |
getProperties()
Returns a
Properties object from this ParameterTool |
String |
getRequired(String key)
Returns the String value for the given key.
|
short |
getShort(String key)
Returns the Short value for the given key.
|
short |
getShort(String key,
short defaultValue)
Returns the Short value for the given key.
|
boolean |
has(String value)
Check if value is set.
|
ParameterTool |
mergeWith(ParameterTool other)
Merges two
ParameterTool |
Map<String,String> |
toMap() |
protected static String NO_VALUE_KEY
protected static String DEFAULT_UNDEFINED
public static ParameterTool fromArgs(String[] args)
ParameterTool 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
args - Input array argumentsParameterToolpublic static ParameterTool fromPropertiesFile(String path) throws IOException
ParameterTool for the given Properties filepath - Path to the properties fileParameterToolIOException - If the file does not existPropertiespublic static ParameterTool fromMap(Map<String,String> map)
ParameterTool for the given mapmap - A map of arguments. Both Key and Value have to be StringsParameterToolpublic static ParameterTool fromSystemProperties()
ParameterTool from the system properties.
Example on how to pass system properties:
-Dkey1=value1 -Dkey2=value2ParameterTool@PublicEvolving public static ParameterTool fromGenericOptionsParser(String[] args) throws IOException
ParameterTool for the arguments parsed by GenericOptionsParserargs - Input array arguments. It should be parsable by GenericOptionsParserParameterToolIOException - If arguments cannot be parsed by GenericOptionsParserGenericOptionsParserpublic int getNumberOfParameters()
ParameterTool.public String get(String key)
public String getRequired(String key)
RuntimeException.public String get(String key, String defaultValue)
public boolean has(String value)
public int getInt(String key)
public int getInt(String key, int defaultValue)
public long getLong(String key)
public long getLong(String key, long defaultValue)
public float getFloat(String key)
public float getFloat(String key, float defaultValue)
public double getDouble(String key)
public double getDouble(String key, double defaultValue)
public boolean getBoolean(String key)
public boolean getBoolean(String key, boolean defaultValue)
public short getShort(String key)
public short getShort(String key, short defaultValue)
public byte getByte(String key)
public byte getByte(String key, byte defaultValue)
public org.apache.flink.configuration.Configuration getConfiguration()
Configuration object from this ParameterToolConfigurationpublic Properties getProperties()
Properties object from this ParameterToolPropertiespublic void createPropertiesFile(String pathToFile) throws IOException
pathToFile - Location of the default properties file.IOExceptionpublic void createPropertiesFile(String pathToFile, boolean overwrite) throws IOException
pathToFile - Location of the default properties file.overwrite - Boolean flag indicating whether or not to overwrite the fileIOException - If overwrite is not allowed and the file existsprotected Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic ParameterTool mergeWith(ParameterTool other)
ParameterToolother - Other ParameterTool objectParameterToolCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.