add test

git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_genomix@3108 123451ca-8445-de46-9d55-352943316053
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/MergeGraphVertex.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/MergeGraphVertex.java
index d8d7555..558b4fb 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/MergeGraphVertex.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/MergeGraphVertex.java
@@ -97,6 +97,7 @@
 						if(tmpChainVertexId.length == 0){
 							tmpMsg.setLengthOfChain(GraphVertexOperation.k);
 							tmpMsg.setChainVertexId(tmpVertextId);
+							sendMsg(new BytesWritable(tmpSourceVertextId),tmpMsg);
 						}
 						else{
 							tmpMsg.incrementLength();
@@ -104,9 +105,9 @@
 									tmpChainVertexId,
 									tmpMsg.getLengthOfChain()-1,
 									tmpVertextId));
-							//deleteVertex(getVertexId());
+							sendMsg(new BytesWritable(tmpSourceVertextId),tmpMsg);
+							deleteVertex(getVertexId());
 						}
-						sendMsg(new BytesWritable(tmpSourceVertextId),tmpMsg);
 						//test
 						GraphVertexOperation.testMessageCommunication(writer,getSuperstep(),tmpVertextId,
 								tmpSourceVertextId,tmpMsg);
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/TestLoadGraphVertex.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/TestLoadGraphVertex.java
index 733d683..3d97044 100644
--- a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/TestLoadGraphVertex.java
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/TestLoadGraphVertex.java
@@ -54,7 +54,7 @@
 	@Override
 	public void compute(Iterator<MessageWritable> msgIterator) {
 		deleteVertex(getVertexId());
-		/*tmpVertexId = getVertexId().getBytes();
+		tmpVertexId = getVertexId().getBytes();
 		String a1 = "100100";
 		byte[] b1 = BitwiseOperation.convertBinaryStringToBytes(a1);
 		String a2 = "000000"; //"001001";
@@ -62,15 +62,15 @@
 		String valueString = "00000000";
 		byte value = BitwiseOperation.convertBinaryStringToByte(valueString);
 		if(getSuperstep() == 1 && Arrays.equals(b1,tmpVertexId)){
-			newVertex = new TestLoadGraphVertex();
+			/*newVertex = new TestLoadGraphVertex();
             vid.set(new BytesWritable(b2));
             newVertex.setVertexId(vid);
             newVertex.setVertexValue(getVertexValue());
-            addVertex(vid, newVertex);
+            addVertex(vid, newVertex);*/
 			//vertex.initialize(new BytesWritable(b2), new ByteWritable(value), null, null);
 			//addVertex(new BytesWritable(b2),this.createdNewLiveVertex());
-			//deleteVertex(getVertexId());
-		}*/
+			deleteVertex(getVertexId());
+		}
 		/*String a2 = "100111";
 		byte[] b2 = BitwiseOperation.convertBinaryStringToBytes(a2);
 		String a3 = "11111111";
diff --git a/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/testDeleteVertexId.java b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/testDeleteVertexId.java
new file mode 100644
index 0000000..061b8b5
--- /dev/null
+++ b/genomix/genomix-pregelix/src/main/java/edu/uci/ics/pregelix/testDeleteVertexId.java
@@ -0,0 +1,74 @@
+package edu.uci.ics.pregelix;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hadoop.io.ByteWritable;
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.hadoop.io.NullWritable;
+
+import edu.uci.ics.pregelix.api.graph.Vertex;
+import edu.uci.ics.pregelix.api.job.PregelixJob;
+import edu.uci.ics.pregelix.bitwise.BitwiseOperation;
+import edu.uci.ics.pregelix.example.client.Client;
+import edu.uci.ics.pregelix.example.io.MessageWritable;
+
+/*
+ * vertexId: BytesWritable
+ * vertexValue: ByteWritable
+ * edgeValue: NullWritable
+ * message: MessageWritable
+ * 
+ * DNA:
+ * A: 00
+ * C: 01
+ * G: 10
+ * T: 11
+ * 
+ * succeed node
+ *  A 00000001 1
+ *  G 00000010 2
+ *  C 00000100 4
+ *  T 00001000 8
+ * precursor node
+ *  A 00010000 16
+ *  G 00100000 32
+ *  C 01000000 64
+ *  T 10000000 128
+ *  
+ * For example, ONE LINE in input file: 00,01,10	0001,0010,
+ * That means that vertexId is ACG, its succeed node is A and its precursor node is C.
+ * The succeed node and precursor node will be stored in vertexValue and we don't use edgeValue.
+ * The details about message are in edu.uci.ics.pregelix.example.io.MessageWritable. 
+ */
+public class testDeleteVertexId extends Vertex<BytesWritable, ByteWritable, NullWritable, MessageWritable>{
+
+	/**
+	 * For test
+	 */
+	@Override
+	public void compute(Iterator<MessageWritable> msgIterator) {
+		String s = "100100";
+		byte[] b = BitwiseOperation.convertBinaryStringToBytes(s);
+		if(getSuperstep() == 1 && Arrays.equals(b,getVertexId().getBytes())){
+			//deleteVertex(getVertexId());
+		}
+		voteToHalt();
+	}
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) throws Exception {
+        PregelixJob job = new PregelixJob(MergeGraphVertex.class.getSimpleName());
+        job.setVertexClass(TestLoadGraphVertex.class);
+        /**
+         * BinaryInput and BinaryOutput
+         */
+        job.setVertexInputFormatClass(BinaryLoadGraphInputFormat.class); 
+        job.setVertexOutputFormatClass(BinaryLoadGraphOutputFormat.class); 
+        job.setOutputKeyClass(BytesWritable.class);
+        job.setOutputValueClass(ByteWritable.class);
+        Client.run(args, job);
+	}
+}