@FunctionAnnotation.ForwardedFields("0->4;1;1->3;2") @FunctionAnnotation.ReadFields("0;3;4") private static class DummyGroupReduceFunction1 implements GroupReduceFunction<Tuple5<Integer, Long, String, Long, Integer>, Tuple5<Integer, Long, String, Long, Integer>> { @Override public void reduce(Iterable<Tuple5<Integer, Long, String, Long, Integer>> values, Collector<Tuple5<Integer, Long, String, Long, Integer>> out) throws Exception { } }
@ForwardedFields("*->f0") private static class CreateVertex implements MapFunction<LongValue, Vertex<LongValue, NullValue>> { private Vertex<LongValue, NullValue> vertex = new Vertex<>(null, NullValue.getInstance()); @Override public Vertex<LongValue, NullValue> map(LongValue value) throws Exception { vertex.f0 = value; return vertex; } }
@ForwardedFields("f0; f1") private static final class ExtractEdgeIDsMapper<K, EV> implements MapFunction<Edge<K, EV>, Tuple2<K, K>> { @Override public Tuple2<K, K> map(Edge<K, EV> edge) throws Exception { return new Tuple2<>(edge.f0, edge.f1); } }
/** Sums and counts point coordinates. */ @ForwardedFields("0") public static final class CentroidAccumulator implements ReduceFunction<Tuple3<Integer, Point, Long>> { @Override public Tuple3<Integer, Point, Long> reduce(Tuple3<Integer, Point, Long> val1, Tuple3<Integer, Point, Long> val2) { return new Tuple3<>(val1.f0, val1.f1.add(val2.f1), val1.f2 + val2.f2); } }
@ForwardedFields("0->id") private static final class CentroidAverager implements MapFunction<Tuple3<Integer, Point, Long>, Centroid> { @Override public Centroid map(Tuple3<Integer, Point, Long> value) { return new Centroid(value.f0, value.f1.div(value.f2)); } }
@FunctionAnnotation.ForwardedFields("0->4;1;1->3;2") @FunctionAnnotation.ReadFields("0;3;4") private static class DummyReduceFunction1 implements ReduceFunction<Tuple5<Integer, Long, String, Long, Integer>> { @Override public Tuple5<Integer, Long, String, Long, Integer> reduce(Tuple5<Integer, Long, String, Long, Integer> v1, Tuple5<Integer, Long, String, Long, Integer> v2) throws Exception { return new Tuple5<Integer, Long, String, Long, Integer>(); } }
@ForwardedFields("f0") private static final class ApplyNeighborReduceFunction<K, VV> implements ReduceFunction<Tuple2<K, VV>> { private ReduceNeighborsFunction<VV> function; public ApplyNeighborReduceFunction(ReduceNeighborsFunction<VV> fun) { this.function = fun; } @Override public Tuple2<K, VV> reduce(Tuple2<K, VV> first, Tuple2<K, VV> second) throws Exception { first.f1 = function.reduceNeighbors(first.f1, second.f1); return first; } }
/** Computes new centroid from coordinate sum and count of points. */ @ForwardedFields("0->id") public static final class CentroidAverager implements MapFunction<Tuple3<Integer, Point, Long>, Centroid> { @Override public Centroid map(Tuple3<Integer, Point, Long> value) { return new Centroid(value.f0, value.f1.div(value.f2)); } } }
@ForwardedFields("0") public static final class DuplicateValue extends RichMapFunction<Tuple1<Long>, Tuple2<Long, Long>> { @Override public Tuple2<Long, Long> map(Tuple1<Long> value) throws Exception { return new Tuple2<Long, Long>(value.f0, value.f0); } }
@ForwardedFields("f0->*") private static class GroupReduce4 implements GroupReduceFunction<Tuple2<Long, Long>, Long> { @Override public void reduce(Iterable<Tuple2<Long, Long>> values, Collector<Long> out) throws Exception { Long id = 0L; for (Tuple2<Long, Long> value : values) { id = value.f0; } out.collect(id); } }
@ForwardedFields("f0;f1") private static class Map20 implements MapFunction<Tuple4<Integer, Integer, Integer, Integer>, Tuple4<Integer, Integer, Integer, Integer>> { @Override public Tuple4<Integer, Integer, Integer, Integer> map(Tuple4<Integer, Integer, Integer, Integer> value) throws Exception { Tuple4<Integer, Integer, Integer, Integer> t = new Tuple4<Integer, Integer, Integer, Integer>(); t.f0 = value.getField(0); t.f1 = value.getField((int) 1L); return t; } }
@ForwardedFields("*->f0") private static class Map19 implements MapFunction<Integer, Tuple1<Integer>> { @Override public Tuple1<Integer> map(Integer value) throws Exception { Tuple1<Integer> tuple = new Tuple1<Integer>(); tuple.f0 = value; Tuple1<Integer> tuple2 = new Tuple1<Integer>(); tuple2.f0 = tuple.f0; return tuple2; } }
@ForwardedFields("f0") private static class Map14 implements MapFunction<Tuple2<String, Integer>, Tuple2<String, String>> { public Tuple2<String, String> map(Tuple2<String, Integer> value) throws Exception { Tuple2<String, String> t = new Tuple2<String, String>(); t.f0 = value.f0; return t; } }
@ForwardedFields("f0->f0.f0;f0->f1.f0") private static class Map12 implements MapFunction<Tuple2<String, Integer>, Tuple2<Tuple1<String>, Tuple1<String>>> { public Tuple2<Tuple1<String>, Tuple1<String>> map(Tuple2<String, Integer> value) throws Exception { return new Tuple2<Tuple1<String>, Tuple1<String>>(new Tuple1<String>(value.f0), new Tuple1<String>( value.f0)); } }
@ForwardedFields("*->f0") private static class Map9 implements MapFunction<String, Tuple1<String>> { private Tuple1<String> tuple = new Tuple1<String>(); public Tuple1<String> map(String value) throws Exception { tuple.f0 = value; return tuple; } }
@ForwardedFields("f0->f1") private static class Map7 implements MapFunction<Tuple2<String, Integer>, Tuple2<String, String>> { public Tuple2<String, String> map(Tuple2<String, Integer> value) throws Exception { if (value.f0.equals("whatever")) { return new Tuple2<String, String>(value.f0, value.f0); } else { return new Tuple2<String, String>("hello", value.f0); } } }
@ForwardedFields("field->*") private static class Map6 implements MapFunction<MyPojo, String> { @Override public String map(MyPojo value) throws Exception { return value.field; } }
@ForwardedFields("f0->f0;f0->f1") private static class Map2 implements MapFunction<Tuple2<String, Integer>, Tuple2<String, String>> { public Tuple2<String, String> map(Tuple2<String, Integer> value) throws Exception { return new Tuple2<String, String>(value.f0, value.f0); } }
@ForwardedFields("*->f0;*->f1") private static final class DuplicateValue<T> implements MapFunction<T, Tuple2<T, T>> { @Override public Tuple2<T, T> map(T vertex) { return new Tuple2<T, T>(vertex, vertex); } }
/** Converts a Tuple2 into an Edge. */ @ForwardedFields("0;1") public static class TupleEdgeConverter implements MapFunction<Tuple2<Integer, Integer>, Edge> { private final Edge outEdge = new Edge(); @Override public Edge map(Tuple2<Integer, Integer> t) throws Exception { outEdge.copyVerticesFromTuple2(t); return outEdge; } }