hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1669999 - in /hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore: KCoreMessage.java KCoreVertex.java KCoreVertexReader.java
Date Mon, 30 Mar 2015 06:09:05 GMT
Author: edwardyoon
Date: Mon Mar 30 06:09:04 2015
New Revision: 1669999

URL: http://svn.apache.org/r1669999
Log:
Code Reformatting

Modified:
    hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreMessage.java
    hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertex.java
    hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertexReader.java

Modified: hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreMessage.java
URL: http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreMessage.java?rev=1669999&r1=1669998&r2=1669999&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreMessage.java (original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreMessage.java Mon Mar 30 06:09:04
2015
@@ -48,12 +48,12 @@ public class KCoreMessage implements Wri
     output.writeLong(vertexID);
     output.writeInt(core);
   }
-  
-  public long getVertexID(){
+
+  public long getVertexID() {
     return vertexID;
   }
-  
-  public int getCore(){
+
+  public int getCore() {
     return core;
   }
 }

Modified: hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertex.java
URL: http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertex.java?rev=1669999&r1=1669998&r2=1669999&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertex.java (original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertex.java Mon Mar 30 06:09:04
2015
@@ -34,7 +34,7 @@ import com.google.common.collect.Lists;
 public class KCoreVertex extends
     Vertex<LongWritable, LongWritable, KCoreMessage> {
 
-  private static final Logger logger = Logger.getLogger(KCoreVertex.class);
+  private static final Logger LOG = Logger.getLogger(KCoreVertex.class);
   private int core;
   private boolean changed;
   private HashMap<Long, Integer> estimates;
@@ -90,9 +90,9 @@ public class KCoreVertex extends
   }
 
   public void logNeighborEstimates(long vertexId) {
-    logger.info(vertexId + " neighbor estimates: ");
+    LOG.info(vertexId + " neighbor estimates: ");
     for (Map.Entry<Long, Integer> entry : estimates.entrySet()) {
-      logger.info("\t" + entry.getKey() + "-" + entry.getValue());
+      LOG.info("\t" + entry.getKey() + "-" + entry.getValue());
     }
   }
 
@@ -141,36 +141,36 @@ public class KCoreVertex extends
     double[] count = new double[this.core + 1];
 
     for (Map.Entry<Long, Integer> entry : this.estimates.entrySet()) {
-      logger.info("Processing " + entry.getKey() + ": " + entry.getValue());
+      LOG.info("Processing " + entry.getKey() + ": " + entry.getValue());
       double j = Math.min(this.core, entry.getValue().doubleValue());
-      logger.info("Min: " + j);
+      LOG.info("Min: " + j);
       count[(int) j] = count[(int) j] + 1;
     }
 
-    logger.info("Count before");
+    LOG.info("Count before");
     int i;
     for (i = 0; i < count.length; i++) {
-      logger.info(i + " " + count[i]);
+      LOG.info(i + " " + count[i]);
     }
 
     for (i = this.core; i > 1; i--)
       count[i - 1] = count[i - 1] + count[i];
 
-    logger.info("Count after");
+    LOG.info("Count after");
     for (i = 0; i < count.length; i++) {
-      logger.info(i + " " + count[i]);
+      LOG.info(i + " " + count[i]);
     }
 
     i = this.core;
     while ((i > 1) && (count[i] < i)) {
-      logger.info("Decrementing" + i + " down one because " + count[i]
+      LOG.info("Decrementing" + i + " down one because " + count[i]
           + " is less than that");
       i = i - 1;
     }
-    logger.info("Loop terminated: i: " + i + " and count[i] = " + count[i]);
+    LOG.info("Loop terminated: i: " + i + " and count[i] = " + count[i]);
 
     if (i != old) {
-      logger.info("New Core Estimate: " + i + "\n");
+      LOG.info("New Core Estimate: " + i + "\n");
     }
     return i;
   }
@@ -178,59 +178,53 @@ public class KCoreVertex extends
   @Override
   public void compute(Iterable<KCoreMessage> msgs) throws IOException {
     if (this.getSuperstepCount() == 0) {
-        this.core = getEdges().size();
+      this.core = getEdges().size();
 
-        for (Edge<LongWritable, LongWritable> edge : getEdges()) {
-            sendMessage(edge, new KCoreMessage(getVertexID().get(),
-                    getCore()));
-        }
+      for (Edge<LongWritable, LongWritable> edge : getEdges()) {
+        sendMessage(edge, new KCoreMessage(getVertexID().get(), getCore()));
+      }
 
     } else {
-        logger.info("getSuperstepCount = " + getSuperstepCount()
-                + " vertex = " + getVertexID() + " Core = " + getCore());
+      LOG.info("getSuperstepCount = " + getSuperstepCount() + " vertex = "
+          + getVertexID() + " Core = " + getCore());
 
-        List<KCoreMessage> messages = Lists.newArrayList(msgs);
-        if (this.getSuperstepCount() == 1) {
-            for (KCoreMessage message : messages) {
-                estimates.put(message.getVertexID(),
-                        (Integer.MAX_VALUE));
-            }
+      List<KCoreMessage> messages = Lists.newArrayList(msgs);
+      if (this.getSuperstepCount() == 1) {
+        for (KCoreMessage message : messages) {
+          estimates.put(message.getVertexID(), (Integer.MAX_VALUE));
         }
+      }
 
-        logger.info(getVertexID() + " got estimates of: ");
-        for (KCoreMessage message : messages) {
+      LOG.info(getVertexID() + " got estimates of: ");
+      for (KCoreMessage message : messages) {
+
+        LOG.info("Processing message from " + message.getVertexID());
 
-            logger.info("Processing message from "
-                    + message.getVertexID());
+        double temp = getNeighborEstimate(message.getVertexID());
 
-            double temp = getNeighborEstimate(message.getVertexID());
+        if (message.getCore() < temp) {
+          setNeighborNewEstimate(message.getVertexID(), message.getCore());
 
-            if (message.getCore() < temp) {
-                setNeighborNewEstimate(message.getVertexID(),
-                        message.getCore());
-
-                int t = computeEstimate();
-
-                if (t < getCore()) {
-                    logger.info("Setting new core value! \n\n");
-                    setCore(t);
-                    setChanged(true);
-                }
-            }
+          int t = computeEstimate();
+
+          if (t < getCore()) {
+            LOG.info("Setting new core value! \n\n");
+            setCore(t);
+            setChanged(true);
+          }
         }
-        logger.info("Done recomputing estimate for node " + getVertexID());
+      }
+      LOG.info("Done recomputing estimate for node " + getVertexID());
 
-        if (!isChanged()) {
-            this.voteToHalt();
-        } else {
-            for (Edge<LongWritable, LongWritable> edge : getEdges()) {
-                sendMessage(edge, new KCoreMessage(getVertexID().get(),
-                        getCore()));
-            }
-            setChanged(false);
+      if (!isChanged()) {
+        this.voteToHalt();
+      } else {
+        for (Edge<LongWritable, LongWritable> edge : getEdges()) {
+          sendMessage(edge, new KCoreMessage(getVertexID().get(), getCore()));
         }
+        setChanged(false);
+      }
     }
-}
-
+  }
 
 }

Modified: hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertexReader.java
URL: http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertexReader.java?rev=1669999&r1=1669998&r2=1669999&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertexReader.java (original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/kcore/KCoreVertexReader.java Mon Mar 30
06:09:04 2015
@@ -27,9 +27,9 @@ import org.apache.hama.graph.Vertex;
 import org.apache.hama.graph.VertexInputReader;
 
 /**
-* VertexInputFormat for the KCore algorithm
-* specified in tab-delimited text file format.
-*/
+ * VertexInputFormat for the KCore algorithm specified in tab-delimited text
+ * file format.
+ */
 public class KCoreVertexReader
     extends
     VertexInputReader<LongWritable, Text, LongWritable, LongWritable, KCoreMessage>
{
@@ -39,12 +39,13 @@ public class KCoreVertexReader
       Vertex<LongWritable, LongWritable, KCoreMessage> vertex) throws Exception {
     String[] vertices = value.toString().split("\t");
     List<Edge<LongWritable, LongWritable>> edges = new ArrayList<Edge<LongWritable,
LongWritable>>();
-    
-    for(int i=1; i<vertices.length; i++){
+
+    for (int i = 1; i < vertices.length; i++) {
       LongWritable destID = new LongWritable(Long.parseLong(vertices[i]));
-      edges.add(new Edge<LongWritable, LongWritable>(destID, new LongWritable(0)));
+      edges.add(new Edge<LongWritable, LongWritable>(destID,
+          new LongWritable(0)));
     }
-    
+
     vertex.setEdges(edges);
     vertex.setValue(new KCoreMessage());
     vertex.setVertexID(new LongWritable(Long.parseLong(vertices[0])));



Mime
View raw message