You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by to...@apache.org on 2013/02/05 09:09:08 UTC
svn commit: r1442490 - in
/hama/trunk/graph/src/main/java/org/apache/hama/graph: GraphJobRunner.java
VertexInputReader.java VerticesInfo.java
Author: tommaso
Date: Tue Feb 5 08:09:07 2013
New Revision: 1442490
URL: http://svn.apache.org/viewvc?rev=1442490&view=rev
Log:
HAMA-572 - fixed some declaration redundancies
Modified:
hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java
hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInputReader.java
hama/trunk/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java
Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java?rev=1442490&r1=1442489&r2=1442490&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java Tue Feb 5 08:09:07 2013
@@ -80,9 +80,6 @@ public final class GraphJobRunner<V exte
private int maxIteration = -1;
private long iteration;
- private Class<V> vertexIdClass;
- private Class<M> vertexValueClass;
- private Class<E> edgeValueClass;
private Class<Vertex<V, E, M>> vertexClass;
private AggregationRunner<V, E, M> aggregationRunner;
@@ -232,13 +229,13 @@ public final class GraphJobRunner<V exte
maxIteration = peer.getConfiguration().getInt("hama.graph.max.iteration",
-1);
- vertexIdClass = (Class<V>) conf.getClass(GraphJob.VERTEX_ID_CLASS_ATTR,
- Text.class, Writable.class);
- vertexValueClass = (Class<M>) conf.getClass(
- GraphJob.VERTEX_VALUE_CLASS_ATTR, IntWritable.class, Writable.class);
- edgeValueClass = (Class<E>) conf.getClass(
- GraphJob.VERTEX_EDGE_VALUE_CLASS_ATTR, IntWritable.class,
- Writable.class);
+ Class<V> vertexIdClass = (Class<V>) conf.getClass(GraphJob.VERTEX_ID_CLASS_ATTR,
+ Text.class, Writable.class);
+ Class<M> vertexValueClass = (Class<M>) conf.getClass(
+ GraphJob.VERTEX_VALUE_CLASS_ATTR, IntWritable.class, Writable.class);
+ Class<E> edgeValueClass = (Class<E>) conf.getClass(
+ GraphJob.VERTEX_EDGE_VALUE_CLASS_ATTR, IntWritable.class,
+ Writable.class);
vertexClass = (Class<Vertex<V, E, M>>) conf.getClass(
"hama.graph.vertex.class", Vertex.class);
@@ -281,7 +278,7 @@ public final class GraphJobRunner<V exte
if (LOG.isDebugEnabled())
LOG.debug("Vertex class: " + vertexClass);
- KeyValuePair<Writable, Writable> next = null;
+ KeyValuePair<Writable, Writable> next;
while ((next = peer.readNext()) != null) {
Vertex<V, E, M> vertex = (Vertex<V, E, M>) next.getKey();
vertex.runner = this;
@@ -327,7 +324,7 @@ public final class GraphJobRunner<V exte
}
peer.sync();
- GraphJobMessage msg = null;
+ GraphJobMessage msg;
while ((msg = peer.getCurrentMessage()) != null) {
V vertexName = (V) msg.getVertexId();
@@ -342,7 +339,6 @@ public final class GraphJobRunner<V exte
}
newVertex.setup(conf);
tmp.put(vertexName, newVertex);
- newVertex = null;
}
for (Vertex<V, E, M> e : vertices) {
@@ -370,7 +366,7 @@ public final class GraphJobRunner<V exte
peer.sync();
- GraphJobMessage msg = null;
+ GraphJobMessage msg;
while ((msg = peer.getCurrentMessage()) != null) {
if (msg.isVerticesSizeMessage()) {
numberVertices += msg.getVerticesSize().get();
@@ -392,7 +388,7 @@ public final class GraphJobRunner<V exte
private Map<V, List<M>> parseMessages(
BSPPeer<Writable, Writable, Writable, Writable, GraphJobMessage> peer)
throws IOException {
- GraphJobMessage msg = null;
+ GraphJobMessage msg;
final Map<V, List<M>> msgMap = new HashMap<V, List<M>>();
while ((msg = peer.getCurrentMessage()) != null) {
// either this is a vertex message or a directive that must be read
@@ -511,10 +507,8 @@ public final class GraphJobRunner<V exte
*/
public static <V extends Writable, E extends Writable, M extends Writable> Vertex<V, E, M> newVertexInstance(
Class<?> vertexClass, Configuration conf) {
- @SuppressWarnings("unchecked")
- Vertex<V, E, M> vertex = (Vertex<V, E, M>) ReflectionUtils.newInstance(
+ return (Vertex<V, E, M>) ReflectionUtils.newInstance(
vertexClass, conf);
- return vertex;
}
}
Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInputReader.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInputReader.java?rev=1442490&r1=1442489&r2=1442490&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInputReader.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexInputReader.java Tue Feb 5 08:09:07 2013
@@ -35,7 +35,7 @@ public abstract class VertexInputReader<
private static final Log LOG = LogFactory.getLog(VertexInputReader.class);
- private KeyValuePair<Writable, Writable> outputRecord = new KeyValuePair<Writable, Writable>();
+ private final KeyValuePair<Writable, Writable> outputRecord = new KeyValuePair<Writable, Writable>();
/**
* Parses a given key and value into the given vertex. If returned true, the
@@ -51,7 +51,7 @@ public abstract class VertexInputReader<
KeyValuePair<Writable, Writable> inputRecord, Configuration conf) {
Class<Vertex<V, E, M>> vertexClass = (Class<Vertex<V, E, M>>) conf
.getClass(GraphJob.VERTEX_CLASS_ATTR, Vertex.class);
- boolean vertexCreation = true;
+ boolean vertexCreation;
Vertex<V, E, M> vertex = GraphJobRunner
.newVertexInstance(vertexClass, conf);
try {
Modified: hama/trunk/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java?rev=1442490&r1=1442489&r2=1442490&view=diff
==============================================================================
--- hama/trunk/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java (original)
+++ hama/trunk/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java Tue Feb 5 08:09:07 2013
@@ -35,7 +35,7 @@ import org.apache.hadoop.io.Writable;
public class VerticesInfo<V extends Writable, E extends Writable, M extends Writable>
implements Iterable<Vertex<V, E, M>> {
- private List<Vertex<V, E, M>> vertices = new ArrayList<Vertex<V, E, M>>(100);
+ private final List<Vertex<V, E, M>> vertices = new ArrayList<Vertex<V, E, M>>(100);
public void addVertex(Vertex<V, E, M> vertex) {
int i = 0;