Search in sources :

Example 1 with NonForwardedFieldsFirst

use of org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst in project flink by apache.

the class SemanticPropUtil method getSemanticPropsDual.

public static DualInputSemanticProperties getSemanticPropsDual(Set<Annotation> set, TypeInformation<?> inType1, TypeInformation<?> inType2, TypeInformation<?> outType) {
    if (set == null) {
        return null;
    }
    Iterator<Annotation> it = set.iterator();
    String[] forwardedFirst = null;
    String[] forwardedSecond = null;
    String[] nonForwardedFirst = null;
    String[] nonForwardedSecond = null;
    String[] readFirst = null;
    String[] readSecond = null;
    while (it.hasNext()) {
        Annotation ann = it.next();
        if (ann instanceof ForwardedFieldsFirst) {
            forwardedFirst = ((ForwardedFieldsFirst) ann).value();
        } else if (ann instanceof ForwardedFieldsSecond) {
            forwardedSecond = ((ForwardedFieldsSecond) ann).value();
        } else if (ann instanceof NonForwardedFieldsFirst) {
            nonForwardedFirst = ((NonForwardedFieldsFirst) ann).value();
        } else if (ann instanceof NonForwardedFieldsSecond) {
            nonForwardedSecond = ((NonForwardedFieldsSecond) ann).value();
        } else if (ann instanceof ReadFieldsFirst) {
            readFirst = ((ReadFieldsFirst) ann).value();
        } else if (ann instanceof ReadFieldsSecond) {
            readSecond = ((ReadFieldsSecond) ann).value();
        } else if (ann instanceof ForwardedFields || ann instanceof NonForwardedFields || ann instanceof ReadFields) {
            throw new InvalidSemanticAnnotationException("Annotation " + ann.getClass() + " invalid for dual input function.");
        }
    }
    if (forwardedFirst != null || nonForwardedFirst != null || readFirst != null || forwardedSecond != null || nonForwardedSecond != null || readSecond != null) {
        DualInputSemanticProperties result = new DualInputSemanticProperties();
        getSemanticPropsDualFromString(result, forwardedFirst, forwardedSecond, nonForwardedFirst, nonForwardedSecond, readFirst, readSecond, inType1, inType2, outType);
        return result;
    }
    return null;
}
Also used : NonForwardedFields(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFields) ForwardedFields(org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields) DualInputSemanticProperties(org.apache.flink.api.common.operators.DualInputSemanticProperties) Annotation(java.lang.annotation.Annotation) ReadFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsFirst) ForwardedFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsSecond) NonForwardedFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsSecond) NonForwardedFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst) ForwardedFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsFirst) NonForwardedFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst) NonForwardedFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsSecond) NonForwardedFields(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFields) InvalidSemanticAnnotationException(org.apache.flink.api.common.operators.SemanticProperties.InvalidSemanticAnnotationException) ReadFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsSecond) ReadFields(org.apache.flink.api.java.functions.FunctionAnnotation.ReadFields)

Example 2 with NonForwardedFieldsFirst

use of org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst in project flink by apache.

the class SemanticPropUtil method getSemanticPropsSingle.

public static SingleInputSemanticProperties getSemanticPropsSingle(Set<Annotation> set, TypeInformation<?> inType, TypeInformation<?> outType) {
    if (set == null) {
        return null;
    }
    Iterator<Annotation> it = set.iterator();
    String[] forwarded = null;
    String[] nonForwarded = null;
    String[] read = null;
    while (it.hasNext()) {
        Annotation ann = it.next();
        if (ann instanceof ForwardedFields) {
            forwarded = ((ForwardedFields) ann).value();
        } else if (ann instanceof NonForwardedFields) {
            nonForwarded = ((NonForwardedFields) ann).value();
        } else if (ann instanceof ReadFields) {
            read = ((ReadFields) ann).value();
        } else if (ann instanceof ForwardedFieldsFirst || ann instanceof ForwardedFieldsSecond || ann instanceof NonForwardedFieldsFirst || ann instanceof NonForwardedFieldsSecond || ann instanceof ReadFieldsFirst || ann instanceof ReadFieldsSecond) {
            throw new InvalidSemanticAnnotationException("Annotation " + ann.getClass() + " invalid for single input function.");
        }
    }
    if (forwarded != null || nonForwarded != null || read != null) {
        SingleInputSemanticProperties result = new SingleInputSemanticProperties();
        getSemanticPropsSingleFromString(result, forwarded, nonForwarded, read, inType, outType);
        return result;
    }
    return null;
}
Also used : NonForwardedFields(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFields) ForwardedFields(org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields) Annotation(java.lang.annotation.Annotation) ReadFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsFirst) ForwardedFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsSecond) NonForwardedFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsSecond) NonForwardedFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst) ForwardedFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsFirst) NonForwardedFieldsFirst(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst) NonForwardedFields(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFields) NonForwardedFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsSecond) InvalidSemanticAnnotationException(org.apache.flink.api.common.operators.SemanticProperties.InvalidSemanticAnnotationException) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) ReadFields(org.apache.flink.api.java.functions.FunctionAnnotation.ReadFields) ReadFieldsSecond(org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsSecond)

Aggregations

Annotation (java.lang.annotation.Annotation)2 InvalidSemanticAnnotationException (org.apache.flink.api.common.operators.SemanticProperties.InvalidSemanticAnnotationException)2 ForwardedFields (org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields)2 ForwardedFieldsFirst (org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsFirst)2 ForwardedFieldsSecond (org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsSecond)2 NonForwardedFields (org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFields)2 NonForwardedFieldsFirst (org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsFirst)2 NonForwardedFieldsSecond (org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFieldsSecond)2 ReadFields (org.apache.flink.api.java.functions.FunctionAnnotation.ReadFields)2 ReadFieldsFirst (org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsFirst)2 ReadFieldsSecond (org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsSecond)2 DualInputSemanticProperties (org.apache.flink.api.common.operators.DualInputSemanticProperties)1 SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)1