cleanup the maximal clique example
git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_staging@2696 123451ca-8445-de46-9d55-352943316053
diff --git a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/CliquesWritable.java b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/CliquesWritable.java
index 69cb336..0e22ea1 100644
--- a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/CliquesWritable.java
+++ b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/CliquesWritable.java
@@ -53,13 +53,23 @@
}
/**
- * Set the clique vertexes
+ * Add the clique vertexes
*
* @param cliques
* the list of vertexes -- can contain multiple cliques
*/
- public void setCliques(List<VLongWritable> cliques) {
- this.cliques = cliques;
+ public void addCliques(CliquesWritable cliques) {
+ this.cliques.addAll(cliques.cliques);
+ }
+
+ /**
+ * Add the clique vertexes
+ *
+ * @param cliques
+ * the list of vertexes -- can contain multiple cliques
+ */
+ public void addCliques(List<VLongWritable> vertexes) {
+ this.cliques.addAll(vertexes);
}
/**
@@ -70,15 +80,6 @@
}
/**
- * Get clique vertexes --- can contain multiple vertexes
- *
- * @return all the vertexes
- */
- public List<VLongWritable> getVertexes() {
- return cliques;
- }
-
- /**
* rese the clique
*/
public void reset() {
diff --git a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueAggregator.java b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueAggregator.java
index d75de33..061e9e0 100644
--- a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueAggregator.java
+++ b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueAggregator.java
@@ -18,7 +18,7 @@
@Override
public void init() {
-
+ state.reset();
}
@Override
@@ -38,10 +38,10 @@
//reset the vertex state
state.reset();
state.setCliqueSize(cliques.getSizeOfClique());
- state.setCliques(cliques.getVertexes());
+ state.addCliques(cliques);
} else if (cliques.getSizeOfClique() == state.getSizeOfClique()) {
//add the new cliques
- state.getVertexes().addAll(cliques.getVertexes());
+ state.addCliques(cliques);
} else {
return;
}
diff --git a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueVertex.java b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueVertex.java
index 2c0de14..266feb7 100644
--- a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueVertex.java
+++ b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/maximalclique/MaximalCliqueVertex.java
@@ -69,6 +69,7 @@
invertedMap.clear();
currentMaximalCliques.clear();
cliques.clear();
+ tmpValue.reset();
// build the initial sub graph
while (values.hasNext()) {
@@ -121,7 +122,7 @@
int keyIndex = invertedMap.get(srcId);
clique.set(keyIndex);
generateClique(clique);
- tmpValue.setCliques(cliques);
+ tmpValue.addCliques(cliques);
tmpValue.setCliqueSize(clique.cardinality());
}
@@ -302,7 +303,6 @@
// only add emit for the vertexes whose id is smaller than the vertex id
// to avoid the duplicate removal step,
// because all the resulting cliques will have vertexes in the ascending order.
- getVertexValue().reset();
AdjacencyListWritable msg = new AdjacencyListWritable();
msg.setSource(getVertexId());
for (int j = i + 1; j < edges.size(); j++) {
diff --git a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/trianglecounting/TriangleCountingVertex.java b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/trianglecounting/TriangleCountingVertex.java
index ed51782..d3db095 100644
--- a/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/trianglecounting/TriangleCountingVertex.java
+++ b/pregelix/pregelix-example/src/main/java/edu/uci/ics/pregelix/example/trianglecounting/TriangleCountingVertex.java
@@ -20,7 +20,6 @@
import edu.uci.ics.pregelix.api.util.BspUtils;
import edu.uci.ics.pregelix.dataflow.util.IterationUtils;
import edu.uci.ics.pregelix.example.client.Client;
-import edu.uci.ics.pregelix.example.inputformat.TextPageRankInputFormat;
import edu.uci.ics.pregelix.example.io.VLongWritable;
/**
@@ -133,7 +132,7 @@
PregelixJob job = new PregelixJob(TriangleCountingVertex.class.getSimpleName());
job.setVertexClass(TriangleCountingVertex.class);
job.setGlobalAggregatorClass(TriangleCountingAggregator.class);
- job.setVertexInputFormatClass(TextPageRankInputFormat.class);
+ job.setVertexInputFormatClass(TextTriangleCountingInputFormat.class);
job.setVertexOutputFormatClass(TriangleCountingVertexOutputFormat.class);
Client.run(args, job);
System.out.println("triangle count: " + readTriangleCountingResult(job.getConfiguration()));
diff --git a/pregelix/pregelix-example/src/test/java/edu/uci/ics/pregelix/example/jobgen/JobGenerator.java b/pregelix/pregelix-example/src/test/java/edu/uci/ics/pregelix/example/jobgen/JobGenerator.java
index b131edc..c353d84 100644
--- a/pregelix/pregelix-example/src/test/java/edu/uci/ics/pregelix/example/jobgen/JobGenerator.java
+++ b/pregelix/pregelix-example/src/test/java/edu/uci/ics/pregelix/example/jobgen/JobGenerator.java
@@ -39,6 +39,7 @@
import edu.uci.ics.pregelix.example.maximalclique.MaximalCliqueVertex;
import edu.uci.ics.pregelix.example.maximalclique.MaximalCliqueVertex.MaximalCliqueVertexOutputFormat;
import edu.uci.ics.pregelix.example.maximalclique.TextMaximalCliqueInputFormat;
+import edu.uci.ics.pregelix.example.trianglecounting.TextTriangleCountingInputFormat;
import edu.uci.ics.pregelix.example.trianglecounting.TriangleCountingAggregator;
import edu.uci.ics.pregelix.example.trianglecounting.TriangleCountingVertex;
import edu.uci.ics.pregelix.example.trianglecounting.TriangleCountingVertex.TriangleCountingVertexOutputFormat;
@@ -197,7 +198,7 @@
PregelixJob job = new PregelixJob(jobName);
job.setVertexClass(TriangleCountingVertex.class);
job.setGlobalAggregatorClass(TriangleCountingAggregator.class);
- job.setVertexInputFormatClass(TextPageRankInputFormat.class);
+ job.setVertexInputFormatClass(TextTriangleCountingInputFormat.class);
job.setVertexOutputFormatClass(TriangleCountingVertexOutputFormat.class);
FileInputFormat.setInputPaths(job, HDFS_INPUTPATH3);
FileOutputFormat.setOutputPath(job, new Path(HDFS_OUTPUTPAH3));