public static Set < Annotation > readDualConstantAnnotations ( Class < ? > udfClass ) { // get readSet annotation from stub ConstantFieldsFirst constantSet1 = udfClass . getAnnotation ( ConstantFieldsFirst . class ) ; ConstantFieldsSecond constantSet2 = udfClass . getAnnotation ( ConstantFieldsSecond . class ) ; // get readSet annotation from stub ConstantFieldsFirstExcept notConstantSet1 = udfClass . getAnnotation ( ConstantFieldsFirstExcept . class ) ; ConstantFieldsSecondExcept notConstantSet2 = udfClass . getAnnotation ( ConstantFieldsSecondExcept . class ) ; ReadFieldsFirst readfieldSet1 = udfClass . getAnnotation ( ReadFieldsFirst . class ) ; ReadFieldsSecond readfieldSet2 = udfClass . getAnnotation ( ReadFieldsSecond . class ) ; if ( notConstantSet1 != null && constantSet1 != null ) { throw new InvalidProgramException ( "Either " + ConstantFieldsFirst . class . getSimpleName ( ) + " or " + ConstantFieldsFirstExcept . class . getSimpleName ( ) + " can be annotated to a function, not both." ) ; } if ( constantSet2 != null && notConstantSet2 != null ) { throw new InvalidProgramException ( "Either " + ConstantFieldsSecond . class . getSimpleName ( ) + " or " + ConstantFieldsSecondExcept . class . getSimpleName ( ) + " can be annotated to a function, not both." ) ; } Set < Annotation > result = null ; if ( notConstantSet2 != null ) { result = new HashSet < Annotation > ( ) ; result . add ( notConstantSet2 ) ; } if ( constantSet2 != null ) { result = new HashSet < Annotation > ( ) ; result . add ( constantSet2 ) ; } if ( readfieldSet2 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( readfieldSet2 ) ; } if ( notConstantSet1 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( notConstantSet1 ) ; } if ( constantSet1 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( constantSet1 ) ; } if ( readfieldSet1 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( readfieldSet1 ) ; } return result ; }
Reads the annotations of a user defined function with two inputs and returns semantic properties according to the constant fields annotated .