Hey all,

I'm currently working a lot on the UDF static code analyzer. But I have a general question about Semantic Properties which might be also interesting for other users.

How is the ForwardedFields annotation interpreted for UDF functions with Iterables?

An example can be found in: org.apache.flink.examples.java.graph.EnumTrianglesBasic.TriadBuilder

Does this mean that each call of "collect" must happen in the same order than the call of "next"? But this is not the case in the example above. Or does the annotation only refer to the first iterator element?

Other examples:

@ForwardedFields("*") // CORRECT?
public static class GroupReduce1 implements GroupReduceFunction<Tuple2<Long, Long>,Tuple2<Long, Long>> {
        @Override
        public void reduce(Iterable<Tuple2<Long, Long>> values,
                Collector<Tuple2<Long, Long>> out) throws Exception {
            out.collect(values.iterator().next());
        }
    }

@ForwardedFields("*") // NOT CORRECT?
public static class GroupReduce3 implements GroupReduceFunction<Tuple2<Long, Long>,Tuple2<Long, Long>> {
        @Override
        public void reduce(Iterable<Tuple2<Long, Long>> values,
                Collector<Tuple2<Long, Long>> out) throws Exception {
            Iterator<Tuple2<Long, Long>> it = values.iterator();
            while (it.hasNext()) {
                Tuple2<Long,Long> t = it.next();
                if (t.f0 == 42) {
                    out.collect(t);
                }
            }
        }
    }

Thanks in advance.

Regards,
Timo

Reply via email to