@FunctionAnnotation.ForwardedFieldsFirst("0->4;1;1->3") @FunctionAnnotation.ForwardedFieldsSecond("2;4->0") @FunctionAnnotation.ReadFieldsFirst("0;2;4") @FunctionAnnotation.ReadFieldsSecond("1;3") private static class DummyTestJoinFunction1 implements JoinFunction<Tuple5<Integer, Long, String, Long, Integer>, Tuple5<Integer, Long, String, Long, Integer>, Tuple5<Integer, Long, String, Long, Integer>> { @Override public Tuple5<Integer, Long, String, Long, Integer> join( Tuple5<Integer, Long, String, Long, Integer> first, Tuple5<Integer, Long, String, Long, Integer> second) throws Exception { return new Tuple5<Integer, Long, String, Long, Integer>(); } }
@FunctionAnnotation.ForwardedFieldsSecond("*") private static final class UpdateComponentIdMatchMirrored implements FlatJoinFunction<Tuple2<Long, Long>, Tuple2<Long, Long>, Tuple2<Long, Long>> { private static final long serialVersionUID = 1L; @Override public void join( Tuple2<Long, Long> current, Tuple2<Long, Long> candidate, Collector<Tuple2<Long, Long>> out) throws Exception { if (candidate.f1 < current.f1) { out.collect(candidate); } } } }
@SuppressWarnings("serial") @ForwardedFieldsFirst("*->f0") @ForwardedFieldsSecond("f1->f1") private static final class AppendVertexState<K, VV, Message> implements JoinFunction<Vertex<K, VV>, Tuple2<K, Either<NullValue, Message>>, Tuple2<Vertex<K, VV>, Either<NullValue, Message>>> { private Tuple2<Vertex<K, VV>, Either<NullValue, Message>> outTuple = new Tuple2<>(); public Tuple2<Vertex<K, VV>, Either<NullValue, Message>> join( Vertex<K, VV> vertex, Tuple2<K, Either<NullValue, Message>> message) { outTuple.f0 = vertex; outTuple.f1 = message.f1; return outTuple; } }
@FunctionAnnotation.ForwardedFieldsFirst("0->4;1;1->3") @FunctionAnnotation.ForwardedFieldsSecond("2;4->0") @FunctionAnnotation.ReadFieldsFirst("0;2;4") @FunctionAnnotation.ReadFieldsSecond("1;3") private static class DummyTestCoGroupFunction1 implements CoGroupFunction<Tuple5<Integer, Long, String, Long, Integer>, Tuple5<Integer, Long, String, Long, Integer>, Tuple5<Integer, Long, String, Long, Integer>> { @Override public void coGroup(Iterable<Tuple5<Integer, Long, String, Long, Integer>> first, Iterable<Tuple5<Integer, Long, String, Long, Integer>> second, Collector<Tuple5<Integer, Long, String, Long, Integer>> out) throws Exception { } }
/** * UDF that joins a (Vertex-ID, Component-ID) pair that represents the current component that * a vertex is associated with, with a (Source-Vertex-ID, Target-VertexID) edge. The function * produces a (Target-vertex-ID, Component-ID) pair. */ @ForwardedFieldsFirst("f1->f1") @ForwardedFieldsSecond("f1->f0") public static final class NeighborWithComponentIDJoin implements JoinFunction<Tuple2<Long, Long>, Tuple2<Long, Long>, Tuple2<Long, Long>> { @Override public Tuple2<Long, Long> join(Tuple2<Long, Long> vertexWithComponent, Tuple2<Long, Long> edge) { return new Tuple2<Long, Long>(edge.f1, vertexWithComponent.f1); } }
@ForwardedFieldsFirst("*->0") @ForwardedFieldsSecond("*->1") @Internal private static final class DefaultFlatJoinFunction<T1, T2> extends RichFlatJoinFunction<T1, T2, Tuple2<T1, T2>> { private static final long serialVersionUID = 1L; private final Tuple2<T1, T2> outTuple = new Tuple2<>(); @Override public void join(T1 first, T2 second, Collector<Tuple2<T1, T2>> out) throws Exception { outTuple.f0 = first; outTuple.f1 = second; out.collect(outTuple); } }
@ForwardedFieldsSecond("f1") private static final class ProjectVertexWithNeighborValueJoin<K, VV, EV> implements FlatJoinFunction<Edge<K, EV>, Vertex<K, VV>, Tuple2<K, VV>> { private int fieldPosition; public ProjectVertexWithNeighborValueJoin(int position) { this.fieldPosition = position; } @SuppressWarnings("unchecked") public void join(Edge<K, EV> edge, Vertex<K, VV> otherVertex, Collector<Tuple2<K, VV>> out) { out.collect(new Tuple2<>((K) edge.getField(fieldPosition), otherVertex.getValue())); } }
@ForwardedFieldsFirst("f1->f1") @ForwardedFieldsSecond("f1->f0") private static class Join1 implements JoinFunction<Tuple2<Long, Long>, Tuple2<Long, Long>, Tuple2<Long, Long>> { @Override public Tuple2<Long, Long> join(Tuple2<Long, Long> vertexWithComponent, Tuple2<Long, Long> edge) { return new Tuple2<Long, Long>(edge.f1, vertexWithComponent.f1); } }
@SuppressWarnings("serial") @ForwardedFieldsSecond({"f0"}) private static final class ProjectKeyWithNeighborIN<K, VV, EV> implements FlatJoinFunction< Vertex<K, VV>, Edge<K, EV>, Tuple2<K, Neighbor<VV, EV>>> { public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getSource(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }
@ForwardedFieldsFirst("f0; f1; f2; f3->f4") @ForwardedFieldsSecond("f1->f3") private static final class ProjectEdgeWithVertexValues<K, VV, EV> implements FlatJoinFunction<Tuple4<K, K, VV, EV>, Vertex<K, VV>, Triplet<K, VV, EV>> { @Override public void join(Tuple4<K, K, VV, EV> tripletWithSrcValSet, Vertex<K, VV> vertex, Collector<Triplet<K, VV, EV>> collector) throws Exception { collector.collect(new Triplet<>(tripletWithSrcValSet.f0, tripletWithSrcValSet.f1, tripletWithSrcValSet.f2, vertex.getValue(), tripletWithSrcValSet.f3)); } }
@ForwardedFieldsFirst("f1->f2") @ForwardedFieldsSecond("f0; f1; f2->f3") private static final class ProjectEdgeWithSrcValue<K, VV, EV> implements FlatJoinFunction<Vertex<K, VV>, Edge<K, EV>, Tuple4<K, K, VV, EV>> { @Override public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple4<K, K, VV, EV>> collector) throws Exception { collector.collect(new Tuple4<>(edge.getSource(), edge.getTarget(), vertex.getValue(), edge.getValue())); } }
@ForwardedFieldsFirst("f0->f0") @ForwardedFieldsSecond("f0->f0") private static class DummyCoGroupFunction implements CoGroupFunction<Tuple2<Long, Long>, Tuple2<Long, Long>, Tuple2<Long, Long>> { @Override public void coGroup(Iterable<Tuple2<Long, Long>> first, Iterable<Tuple2<Long, Long>> second, Collector<Tuple2<Long, Long>> out) throws Exception { // won't be executed } } }
@ForwardedFieldsSecond("f0; f1; f2") private static final class ProjectEdgeToBeRemoved<K, VV, EV> implements JoinFunction<Vertex<K, VV>, Edge<K, EV>, Edge<K, EV>> { @Override public Edge<K, EV> join(Vertex<K, VV> vertex, Edge<K, EV> edge) throws Exception { return edge; } }
@ForwardedFieldsSecond("f0; f1; f2") private static final class JoinVerticesWithEdgesOnSrc<K, VV, EV> implements JoinFunction<Vertex<K, VV>, Edge<K, EV>, Edge<K, EV>> { @Override public Edge<K, EV> join(Vertex<K, VV> vertex, Edge<K, EV> edge) throws Exception { return edge; } }
@ForwardedFieldsSecond("1->2") private static class ForwardedSecondAnnotationJoin<X> implements JoinFunction<Tuple2<X, X>, Tuple2<X, X>, Tuple3<X, X, X>> { @Override public Tuple3<X, X, X> join(Tuple2<X, X> first, Tuple2<X, X> second) throws Exception { return null; } }
@ForwardedFieldsFirst("f1->f1") @ForwardedFieldsSecond("f1->f0") private static final class NeighborWithComponentIDJoin implements JoinFunction<Tuple2<Long, Long>, Tuple2<Long, Long>, Tuple2<Long, Long>> { @Override public Tuple2<Long, Long> join(Tuple2<Long, Long> vertexWithComponent, Tuple2<Long, Long> edge) { return new Tuple2<Long, Long>(edge.f1, vertexWithComponent.f1); } }
@ForwardedFieldsFirst("f0; f2->f1") @ForwardedFieldsSecond("*->f2") private static final class ProjectEdgeWithNeighbor<K, VV, EV> implements FlatJoinFunction< Tuple3<K, K, Edge<K, EV>>, Vertex<K, VV>, Tuple3<K, Edge<K, EV>, Vertex<K, VV>>> { public void join(Tuple3<K, K, Edge<K, EV>> keysWithEdge, Vertex<K, VV> neighbor, Collector<Tuple3<K, Edge<K, EV>, Vertex<K, VV>>> out) { out.collect(new Tuple3<>(keysWithEdge.f0, keysWithEdge.f2, neighbor)); } }
@ForwardedFieldsFirst("f0") @ForwardedFieldsSecond("f1") private static final class ProjectNeighborValue<K, VV, EV> implements FlatJoinFunction< Tuple3<K, K, Edge<K, EV>>, Vertex<K, VV>, Tuple2<K, VV>> { public void join(Tuple3<K, K, Edge<K, EV>> keysWithEdge, Vertex<K, VV> neighbor, Collector<Tuple2<K, VV>> out) { out.collect(new Tuple2<>(keysWithEdge.f0, neighbor.getValue())); } }
@ForwardedFieldsFirst("1 -> 0") @ForwardedFieldsSecond("1 -> 1") private static class ForwardedBothAnnotationJoin<A, B, C, D> implements JoinFunction<Tuple2<A, B>, Tuple2<C, D>, Tuple2<B, D>> { @Override public Tuple2<B, D> join(Tuple2<A, B> first, Tuple2<C, D> second) { return new Tuple2<B, D>(first.f1, second.f1); } }
@SuppressWarnings("serial") @ForwardedFieldsSecond("f1->f0") private static final class ProjectKeyWithNeighborOUT<K, VV, EV> implements FlatJoinFunction< Vertex<K, VV>, Edge<K, EV>, Tuple2<K, Neighbor<VV, EV>>> { public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getTarget(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }