Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Many keywords in Odysseus Scripts supports or needs the definition of parameters. There is an existing parser class PreParserKeywordParameterHelper, that supports an easy definition and parsing of these parameters. The following code example shows, how define these parameters. There are two possibilities (with the name of the parameter or a short form without names). Note that if there are no names given, the position of the parameter is relevant. If the parameters are defined with names, the position is arbitrary.

Code Block
/// keyword with parameters and their names
#PARALLELIZATION (type=INTER_OPERATOR) (degree=2) (buffersize=10000000) (optimization=true) (threadedbuffer=true)
 
/// or definition without names
#PARALLELIZATION INTER_OPERATOR 2 10000000 true true

...

Info
titleInfo

By default the structure of the parameter string is validated through and regular expression. In this case the value of the parameter need to contain only a-z0-9 and underscores. If the value has a more complex structure it is possible to define a custom regular expression. In this case the instantiation of the parser is shown in the following code example. In this example it is needed to change the expression for the constant PATTERN_PAIRS.

Code Block
private static final String PATTERN_PAIRS = "((([a-zA-Z0-9_]+)|([(][a-zA-Z0-9_]+([:][a-zA-Z0-9_]+)+[)]))[,])"
			+ "*(([a-zA-Z0-9_]+)|([(][a-zA-Z0-9_]+([:][a-zA-Z0-9_]+)+[)]))";
private static final String PATTERN_WITH_ATTRIBUTESNAMES = "([(][a-zA-Z0-9_]+[=]"
			+ PATTERN_PAIRS
			+ "[)])([\\s][(][a-zA-Z0-9_]+[=]"
			+ PATTERN_PAIRS
			+ "[)])*";
private static final String PATTERN_WITHOUT_ATTRIBUTENAMES = "("
			+ PATTERN_PAIRS + ")([\\s]" + PATTERN_PAIRS + ")*";
private static final String PATTERN_KEYWORD = PATTERN_WITH_ATTRIBUTESNAMES
			+ "|" + PATTERN_WITHOUT_ATTRIBUTENAMES;
 
...
 
parameterHelper = PreParserKeywordParameterHelper.newInstance(InterOperatorParallelizationKeywordParameter.class, PATTERN_KEYWORD);