Skip to content

Commit

Permalink
[hotfix] [gelly] Explicit type can be replaced with <>
Browse files Browse the repository at this point in the history
In Java 8 the diamond operator can be used in cases which would result
in an error in Java 7. In Gelly we have often desired to use the diamond
operator and only discovered an issue when running tests on TravisCI.

This closes apache#4457.
  • Loading branch information
greghogan authored and zentol committed Aug 7, 2017
1 parent 0910bc5 commit 27429a7
Show file tree
Hide file tree
Showing 115 changed files with 538 additions and 568 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public String getLongDescription() {
@Override
public DataSet plan(Graph<K, VV, EV> graph) throws Exception {
return graph
.mapVertices(new MapVertices<K, VV>())
.run(new GSAConnectedComponents<K, K, EV>(Integer.MAX_VALUE));
.mapVertices(new MapVertices<>())
.run(new GSAConnectedComponents<>(Integer.MAX_VALUE));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public DataSet plan(Graph<K, VV, EV> graph) throws Exception {

if (hasNullValueEdges(edges)) {
return edges
.map(new EdgeToTuple2Map<K, EV>())
.map(new EdgeToTuple2Map<>())
.name("Edge to Tuple2")
.setParallelism(parallelism.getValue().intValue());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public <T extends Comparable<T>> Graph<T, NullValue, NullValue> simplify(Graph<T
switch (value) {
case DIRECTED:
graph = graph
.run(new org.apache.flink.graph.asm.simple.directed.Simplify<T, NullValue, NullValue>());
.run(new org.apache.flink.graph.asm.simple.directed.Simplify<>());
break;
case UNDIRECTED:
graph = graph
.run(new org.apache.flink.graph.asm.simple.undirected.Simplify<T, NullValue, NullValue>(false));
.run(new org.apache.flink.graph.asm.simple.undirected.Simplify<>(false));
break;
case UNDIRECTED_CLIP_AND_FLIP:
graph = graph
.run(new org.apache.flink.graph.asm.simple.undirected.Simplify<T, NullValue, NullValue>(true));
.run(new org.apache.flink.graph.asm.simple.undirected.Simplify<>(true));
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public Tuple3<Long, Long, Double> map(Triplet<Long, Point, Double> triplet)
Vertex<Long, Point> srcVertex = triplet.getSrcVertex();
Vertex<Long, Point> trgVertex = triplet.getTrgVertex();

return new Tuple3<Long, Long, Double>(srcVertex.getId(), trgVertex.getId(),
srcVertex.getValue().euclideanDistance(trgVertex.getValue()));
return new Tuple3<>(srcVertex.getId(), trgVertex.getId(),
srcVertex.getValue().euclideanDistance(trgVertex.getValue()));
}
});

Expand Down Expand Up @@ -186,7 +186,7 @@ private static DataSet<Vertex<Long, Point>> getVerticesDataSet(ExecutionEnvironm

@Override
public Vertex<Long, Point> map(Tuple3<Long, Double, Double> value) throws Exception {
return new Vertex<Long, Point>(value.f0, new Point(value.f1, value.f2));
return new Vertex<>(value.f0, new Point(value.f1, value.f2));
}
});
} else {
Expand All @@ -203,7 +203,7 @@ private static DataSet<Edge<Long, Double>> getEdgesDataSet(ExecutionEnvironment

@Override
public Edge<Long, Double> map(Tuple2<Long, Long> tuple2) throws Exception {
return new Edge<Long, Double>(tuple2.f0, tuple2.f1, 0.0);
return new Edge<>(tuple2.f0, tuple2.f1, 0.0);
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws E
parameters.setOptNumVertices(true);

return networkWithWeights.runGatherSumApplyIteration(new GatherRanks(), new SumRanks(),
new UpdateRanks<K>(beta), maxIterations, parameters)
new UpdateRanks<>(beta), maxIterations, parameters)
.getVertices();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private static DataSet<Edge<Long, Double>> getEdgeDataSet(ExecutionEnvironment e
.fieldDelimiter("\t")
.lineDelimiter("\n")
.types(Long.class, Long.class, Double.class)
.map(new Tuple3ToEdgeMap<Long, Double>());
.map(new Tuple3ToEdgeMap<>());
} else {
return SingleSourceShortestPathsData.getDefaultEdgeDataSet(env);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private static Graph<Long, Double, Double> getSSSPGraph(ExecutionEnvironment env

private static Edge<Long, Double> getEdgeToBeRemoved() {
if (fileOutput) {
return new Edge<Long, Double>(srcEdgeToBeRemoved, trgEdgeToBeRemoved, valEdgeToBeRemoved);
return new Edge<>(srcEdgeToBeRemoved, trgEdgeToBeRemoved, valEdgeToBeRemoved);
} else {
return IncrementalSSSPData.getDefaultEdgeToBeRemoved();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public Long map(String value) {
.map(new MapFunction<Tuple2<Long, String>, Tuple2<String, Long>>() {
@Override
public Tuple2<String, Long> map(Tuple2<Long, String> tuple2) throws Exception {
return new Tuple2<String, Long>(tuple2.f1, tuple2.f0);
return new Tuple2<>(tuple2.f1, tuple2.f0);
}
});

Expand All @@ -154,7 +154,7 @@ public Tuple2<String, Long> map(Tuple2<Long, String> tuple2) throws Exception {
public Long vertexJoin(Long vertexValue, Long inputValue) {
return inputValue;
}
}).run(new LabelPropagation<String, Long, NullValue>(maxIterations));
}).run(new LabelPropagation<>(maxIterations));

if (fileOutput) {
verticesWithCommunity.writeAsCsv(communitiesOutputPath, "\n", "\t");
Expand All @@ -172,7 +172,7 @@ private static final class ExtractMismatchSongIds implements MapFunction<String,
public Tuple1<String> map(String value) {
String[] tokens = value.split("\\s+");
String songId = tokens[1].substring(1);
return new Tuple1<String>(songId);
return new Tuple1<>(songId);
}
}

Expand Down Expand Up @@ -211,22 +211,22 @@ public void iterateEdges(Vertex<String, NullValue> vertex,
topSong = edge.getTarget();
}
}
out.collect(new Tuple2<String, String>(vertex.getId(), topSong));
out.collect(new Tuple2<>(vertex.getId(), topSong));
}
}

private static final class CreateSimilarUserEdges implements GroupReduceFunction<Edge<String, Integer>,
Edge<String, NullValue>> {

public void reduce(Iterable<Edge<String, Integer>> edges, Collector<Edge<String, NullValue>> out) {
List<String> listeners = new ArrayList<String>();
List<String> listeners = new ArrayList<>();
for (Edge<String, Integer> edge : edges) {
listeners.add(edge.getSource());
}
for (int i = 0; i < listeners.size() - 1; i++) {
for (int j = i + 1; j < listeners.size(); j++) {
out.collect(new Edge<String, NullValue>(listeners.get(i),
listeners.get(j), NullValue.getInstance()));
out.collect(new Edge<>(listeners.get(i),
listeners.get(j), NullValue.getInstance()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws E
ScatterGatherConfiguration parameters = new ScatterGatherConfiguration();
parameters.setOptNumVertices(true);

return networkWithWeights.runScatterGatherIteration(new RankMessenger<K>(),
new VertexRankUpdater<K>(beta), maxIterations, parameters)
return networkWithWeights.runScatterGatherIteration(new RankMessenger<>(),
new VertexRankUpdater<>(beta), maxIterations, parameters)
.getVertices();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static DataSet<Edge<Long, Double>> getEdgesDataSet(ExecutionEnvironment
.fieldDelimiter("\t")
.ignoreComments("%")
.types(Long.class, Long.class, Double.class)
.map(new Tuple3ToEdgeMap<Long, Double>());
.map(new Tuple3ToEdgeMap<>());
} else {
return SingleSourceShortestPathsData.getDefaultEdgeDataSet(env);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static DataSet<Edge<Long, Double>> getEdgesDataSet(ExecutionEnvironment
.lineDelimiter("\n")
.fieldDelimiter("\t")
.types(Long.class, Long.class, Double.class)
.map(new Tuple3ToEdgeMap<Long, Double>());
.map(new Tuple3ToEdgeMap<>());
} else {
return SingleSourceShortestPathsData.getDefaultEdgeDataSet(env);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,52 +43,52 @@ public class CommunityDetectionData {

public static DataSet<Edge<Long, Double>> getDefaultEdgeDataSet(ExecutionEnvironment env) {

List<Edge<Long, Double>> edges = new ArrayList<Edge<Long, Double>>();
edges.add(new Edge<Long, Double>(1L, 2L, 1.0));
edges.add(new Edge<Long, Double>(1L, 3L, 2.0));
edges.add(new Edge<Long, Double>(1L, 4L, 3.0));
edges.add(new Edge<Long, Double>(2L, 3L, 4.0));
edges.add(new Edge<Long, Double>(2L, 4L, 5.0));
edges.add(new Edge<Long, Double>(3L, 5L, 6.0));
edges.add(new Edge<Long, Double>(5L, 6L, 7.0));
edges.add(new Edge<Long, Double>(5L, 7L, 8.0));
edges.add(new Edge<Long, Double>(6L, 7L, 9.0));
edges.add(new Edge<Long, Double>(7L, 12L, 10.0));
edges.add(new Edge<Long, Double>(8L, 9L, 11.0));
edges.add(new Edge<Long, Double>(8L, 10L, 12.0));
edges.add(new Edge<Long, Double>(8L, 11L, 13.0));
edges.add(new Edge<Long, Double>(9L, 10L, 14.0));
edges.add(new Edge<Long, Double>(9L, 11L, 15.0));
edges.add(new Edge<Long, Double>(10L, 11L, 16.0));
edges.add(new Edge<Long, Double>(10L, 12L, 17.0));
edges.add(new Edge<Long, Double>(11L, 12L, 18.0));
List<Edge<Long, Double>> edges = new ArrayList<>();
edges.add(new Edge<>(1L, 2L, 1.0));
edges.add(new Edge<>(1L, 3L, 2.0));
edges.add(new Edge<>(1L, 4L, 3.0));
edges.add(new Edge<>(2L, 3L, 4.0));
edges.add(new Edge<>(2L, 4L, 5.0));
edges.add(new Edge<>(3L, 5L, 6.0));
edges.add(new Edge<>(5L, 6L, 7.0));
edges.add(new Edge<>(5L, 7L, 8.0));
edges.add(new Edge<>(6L, 7L, 9.0));
edges.add(new Edge<>(7L, 12L, 10.0));
edges.add(new Edge<>(8L, 9L, 11.0));
edges.add(new Edge<>(8L, 10L, 12.0));
edges.add(new Edge<>(8L, 11L, 13.0));
edges.add(new Edge<>(9L, 10L, 14.0));
edges.add(new Edge<>(9L, 11L, 15.0));
edges.add(new Edge<>(10L, 11L, 16.0));
edges.add(new Edge<>(10L, 12L, 17.0));
edges.add(new Edge<>(11L, 12L, 18.0));

return env.fromCollection(edges);
}

public static DataSet<Edge<Long, Double>> getSimpleEdgeDataSet(ExecutionEnvironment env) {

List<Edge<Long, Double>> edges = new ArrayList<Edge<Long, Double>>();
edges.add(new Edge<Long, Double>(1L, 2L, 1.0));
edges.add(new Edge<Long, Double>(1L, 3L, 2.0));
edges.add(new Edge<Long, Double>(1L, 4L, 3.0));
edges.add(new Edge<Long, Double>(1L, 5L, 4.0));
edges.add(new Edge<Long, Double>(2L, 6L, 5.0));
edges.add(new Edge<Long, Double>(6L, 7L, 6.0));
edges.add(new Edge<Long, Double>(6L, 8L, 7.0));
edges.add(new Edge<Long, Double>(7L, 8L, 8.0));
List<Edge<Long, Double>> edges = new ArrayList<>();
edges.add(new Edge<>(1L, 2L, 1.0));
edges.add(new Edge<>(1L, 3L, 2.0));
edges.add(new Edge<>(1L, 4L, 3.0));
edges.add(new Edge<>(1L, 5L, 4.0));
edges.add(new Edge<>(2L, 6L, 5.0));
edges.add(new Edge<>(6L, 7L, 6.0));
edges.add(new Edge<>(6L, 8L, 7.0));
edges.add(new Edge<>(7L, 8L, 8.0));

return env.fromCollection(edges);
}

private CommunityDetectionData() {}

public static DataSet<Edge<Long, Double>> getTieEdgeDataSet(ExecutionEnvironment env) {
List<Edge<Long, Double>> edges = new ArrayList<Edge<Long, Double>>();
edges.add(new Edge<Long, Double>(1L, 2L, 1.0));
edges.add(new Edge<Long, Double>(1L, 3L, 1.0));
edges.add(new Edge<Long, Double>(1L, 4L, 1.0));
edges.add(new Edge<Long, Double>(1L, 5L, 1.0));
List<Edge<Long, Double>> edges = new ArrayList<>();
edges.add(new Edge<>(1L, 2L, 1.0));
edges.add(new Edge<>(1L, 3L, 1.0));
edges.add(new Edge<>(1L, 4L, 1.0));
edges.add(new Edge<>(1L, 5L, 1.0));

return env.fromCollection(edges);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public class EuclideanGraphData {

public static DataSet<Vertex<Long, EuclideanGraphWeighing.Point>> getDefaultVertexDataSet(ExecutionEnvironment env) {

List<Vertex<Long, EuclideanGraphWeighing.Point>> vertices = new ArrayList<Vertex<Long, EuclideanGraphWeighing.Point>>();
List<Vertex<Long, EuclideanGraphWeighing.Point>> vertices = new ArrayList<>();
for (int i = 1; i <= NUM_VERTICES; i++) {
vertices.add(new Vertex<Long, EuclideanGraphWeighing.Point>(new Long(i),
new EuclideanGraphWeighing.Point(new Double(i), new Double(i))));
vertices.add(new Vertex<>(new Long(i),
new EuclideanGraphWeighing.Point(new Double(i), new Double(i))));
}

return env.fromCollection(vertices);
Expand All @@ -55,23 +55,23 @@ public static DataSet<Vertex<Long, EuclideanGraphWeighing.Point>> getDefaultVert

public static DataSet<Edge<Long, Double>> getDefaultEdgeDataSet(ExecutionEnvironment env) {

List<Edge<Long, Double>> edges = new ArrayList<Edge<Long, Double>>();
edges.add(new Edge<Long, Double>(1L, 2L, 0.0));
edges.add(new Edge<Long, Double>(1L, 4L, 0.0));
edges.add(new Edge<Long, Double>(2L, 3L, 0.0));
edges.add(new Edge<Long, Double>(2L, 4L, 0.0));
edges.add(new Edge<Long, Double>(2L, 5L, 0.0));
edges.add(new Edge<Long, Double>(3L, 5L, 0.0));
edges.add(new Edge<Long, Double>(4L, 5L, 0.0));
edges.add(new Edge<Long, Double>(4L, 6L, 0.0));
edges.add(new Edge<Long, Double>(5L, 7L, 0.0));
edges.add(new Edge<Long, Double>(5L, 9L, 0.0));
edges.add(new Edge<Long, Double>(6L, 7L, 0.0));
edges.add(new Edge<Long, Double>(6L, 8L, 0.0));
edges.add(new Edge<Long, Double>(6L, 8L, 0.0));
edges.add(new Edge<Long, Double>(7L, 8L, 0.0));
edges.add(new Edge<Long, Double>(7L, 9L, 0.0));
edges.add(new Edge<Long, Double>(8L, 9L, 0.0));
List<Edge<Long, Double>> edges = new ArrayList<>();
edges.add(new Edge<>(1L, 2L, 0.0));
edges.add(new Edge<>(1L, 4L, 0.0));
edges.add(new Edge<>(2L, 3L, 0.0));
edges.add(new Edge<>(2L, 4L, 0.0));
edges.add(new Edge<>(2L, 5L, 0.0));
edges.add(new Edge<>(3L, 5L, 0.0));
edges.add(new Edge<>(4L, 5L, 0.0));
edges.add(new Edge<>(4L, 6L, 0.0));
edges.add(new Edge<>(5L, 7L, 0.0));
edges.add(new Edge<>(5L, 9L, 0.0));
edges.add(new Edge<>(6L, 7L, 0.0));
edges.add(new Edge<>(6L, 8L, 0.0));
edges.add(new Edge<>(6L, 8L, 0.0));
edges.add(new Edge<>(7L, 8L, 0.0));
edges.add(new Edge<>(7L, 9L, 0.0));
edges.add(new Edge<>(8L, 9L, 0.0));

return env.fromCollection(edges);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public class IncrementalSSSPData {

public static DataSet<Vertex<Long, Double>> getDefaultVertexDataSet(ExecutionEnvironment env) {

List<Vertex<Long, Double>> vertices = new ArrayList<Vertex<Long, Double>>();
vertices.add(new Vertex<Long, Double>(1L, 6.0));
vertices.add(new Vertex<Long, Double>(2L, 2.0));
vertices.add(new Vertex<Long, Double>(3L, 3.0));
vertices.add(new Vertex<Long, Double>(4L, 1.0));
vertices.add(new Vertex<Long, Double>(5L, 0.0));
List<Vertex<Long, Double>> vertices = new ArrayList<>();
vertices.add(new Vertex<>(1L, 6.0));
vertices.add(new Vertex<>(2L, 2.0));
vertices.add(new Vertex<>(3L, 3.0));
vertices.add(new Vertex<>(4L, 1.0));
vertices.add(new Vertex<>(5L, 0.0));

return env.fromCollection(vertices);
}
Expand All @@ -53,13 +53,13 @@ public static DataSet<Vertex<Long, Double>> getDefaultVertexDataSet(ExecutionEnv

public static final DataSet<Edge<Long, Double>> getDefaultEdgeDataSet(ExecutionEnvironment env) {

List<Edge<Long, Double>> edges = new ArrayList<Edge<Long, Double>>();
edges.add(new Edge<Long, Double>(1L, 3L, 3.0));
edges.add(new Edge<Long, Double>(2L, 4L, 3.0));
edges.add(new Edge<Long, Double>(2L, 5L, 2.0));
edges.add(new Edge<Long, Double>(3L, 2L, 1.0));
edges.add(new Edge<Long, Double>(3L, 5L, 5.0));
edges.add(new Edge<Long, Double>(4L, 5L, 1.0));
List<Edge<Long, Double>> edges = new ArrayList<>();
edges.add(new Edge<>(1L, 3L, 3.0));
edges.add(new Edge<>(2L, 4L, 3.0));
edges.add(new Edge<>(2L, 5L, 2.0));
edges.add(new Edge<>(3L, 2L, 1.0));
edges.add(new Edge<>(3L, 5L, 5.0));
edges.add(new Edge<>(4L, 5L, 1.0));

return env.fromCollection(edges);
}
Expand All @@ -68,11 +68,11 @@ public static final DataSet<Edge<Long, Double>> getDefaultEdgeDataSet(ExecutionE

public static final DataSet<Edge<Long, Double>> getDefaultEdgesInSSSP(ExecutionEnvironment env) {

List<Edge<Long, Double>> edges = new ArrayList<Edge<Long, Double>>();
edges.add(new Edge<Long, Double>(1L, 3L, 3.0));
edges.add(new Edge<Long, Double>(2L, 5L, 2.0));
edges.add(new Edge<Long, Double>(3L, 2L, 1.0));
edges.add(new Edge<Long, Double>(4L, 5L, 1.0));
List<Edge<Long, Double>> edges = new ArrayList<>();
edges.add(new Edge<>(1L, 3L, 3.0));
edges.add(new Edge<>(2L, 5L, 2.0));
edges.add(new Edge<>(3L, 2L, 1.0));
edges.add(new Edge<>(4L, 5L, 1.0));

return env.fromCollection(edges);
}
Expand All @@ -85,7 +85,7 @@ public static final DataSet<Edge<Long, Double>> getDefaultEdgesInSSSP(ExecutionE

public static final Edge<Long, Double> getDefaultEdgeToBeRemoved() {

return new Edge<Long, Double>(2L, 5L, 2.0);
return new Edge<>(2L, 5L, 2.0);
}

public static final String RESULTED_VERTICES = "1," + Double.MAX_VALUE + "\n" + "2," + Double.MAX_VALUE + "\n"
Expand Down
Loading

0 comments on commit 27429a7

Please sign in to comment.