forwardedFirst = ((ForwardedFieldsFirst) ann).value(); } else if (ann instanceof ForwardedFieldsSecond) { forwardedSecond = ((ForwardedFieldsSecond) ann).value(); } else if (ann instanceof NonForwardedFieldsFirst) { nonForwardedFirst = ((NonForwardedFieldsFirst) ann).value();
/** * Updates the id of an EPGM element in a Tuple2 by the GradoopId in the * second field. * * @param <EL> EPGM element type */ @FunctionAnnotation.ForwardedFieldsFirst("graphIds;label;properties") @FunctionAnnotation.ForwardedFieldsSecond("*->id") public class ElementIdUpdater<EL extends Element> implements MapFunction<Tuple2<EL, GradoopId>, EL> { @Override public EL map(Tuple2<EL, GradoopId> tuple2) { tuple2.f0.setId(tuple2.f1); return tuple2.f0; } }
@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; } }
@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; } }
@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; } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
@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())); } }
/** * 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); } }
@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())); } }
@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("*->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); } }
@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("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; 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)); } }
@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()))); } }
@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; } }