public class FunctionAnnotation extends Object
\@ConstantFields({"0->0,1", "1->2"}) public class MyMapper extends FlatMapFunction, Tuple3 > { public void flatMap(Tuple3 value, Collector > out) { value.f2 = value.f1 value.f1 = value.f0; out.collect(value); } }
All annotations takes String arrays. The Strings represent the source and destination fields. The transition is represented by the arrow "->". Fields are described by their tuple position (and later also the names of the fields in the objects). The left hand side of the arrow always describes the fields in the input value(s), i.e. the value that is passed as a parameter to the function call, or the values obtained from the input iterator. The right hand side of the arrow describes the field in the value returned from the function. If the right hand side is omitted, the a field is assumed to stay exactly the same, i.e. the field itself is unmodified, rather than that the value is placed into another field.
It is very important to follow a conservative strategy when specifying constant fields. Only fields that are always constant (regardless of value, stub call, etc.) to the output may be declared as such! Otherwise, the correct execution of a program can not be guaranteed. So if in doubt, do not add a field to this set.
Be aware that some annotations should only be used for functions with as single input
(RichMapFunction
, RichReduceFunction
) and some only for stubs with two inputs
(RichCrossFunction
, RichFlatJoinFunction
, RichCoGroupFunction
).
Modifier and Type | Class and Description |
---|---|
static interface |
FunctionAnnotation.ConstantFields
This annotation declares that a function leaves certain fields of its input values unmodified and
only "forwards" or "copies" them to the return value.
|
static interface |
FunctionAnnotation.ConstantFieldsExcept
This annotation declares that a function changes certain fields of its input values, while leaving all
others unmodified and in place in the return value.
|
static interface |
FunctionAnnotation.ConstantFieldsFirst
This annotation declares that a function leaves certain fields of its first input values unmodified and
only "forwards" or "copies" them to the return value.
|
static interface |
FunctionAnnotation.ConstantFieldsFirstExcept
This annotation declares that a function changes certain fields of its first input value, while leaving all
others unmodified and in place in the return value.
|
static interface |
FunctionAnnotation.ConstantFieldsSecond
This annotation declares that a function leaves certain fields of its second input values unmodified and
only "forwards" or "copies" them to the return value.
|
static interface |
FunctionAnnotation.ConstantFieldsSecondExcept
This annotation declares that a function changes certain fields of its second input value, while leaving all
others unmodified and in place in the return value.
|
static interface |
FunctionAnnotation.ReadFields
Specifies the fields of the input value of a user-defined that are accessed in the code.
|
static interface |
FunctionAnnotation.ReadFieldsFirst
Specifies the fields of the second input value of a user-defined that are accessed in the code.
|
static interface |
FunctionAnnotation.ReadFieldsSecond
Specifies the fields of the first input value of a user-defined that are accessed in the code.
|
Modifier and Type | Method and Description |
---|---|
static Set<Annotation> |
readDualConstantAnnotations(Class<?> udfClass)
Reads the annotations of a user defined function with two inputs and returns semantic properties according to the constant fields annotated.
|
static Set<Annotation> |
readSingleConstantAnnotations(Class<?> udfClass)
Reads the annotations of a user defined function with one input and returns semantic properties according to the constant fields annotated.
|
public static Set<Annotation> readSingleConstantAnnotations(Class<?> udfClass)
udfClass
- The user defined function, represented by its class.public static Set<Annotation> readDualConstantAnnotations(Class<?> udfClass)
udfClass
- The user defined function, represented by its class.Copyright © 2015 The Apache Software Foundation. All rights reserved.