Return-Path: X-Original-To: apmail-giraph-commits-archive@www.apache.org Delivered-To: apmail-giraph-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 44390D2D3 for ; Tue, 10 Jul 2012 09:31:58 +0000 (UTC) Received: (qmail 34627 invoked by uid 500); 10 Jul 2012 09:31:58 -0000 Delivered-To: apmail-giraph-commits-archive@giraph.apache.org Received: (qmail 34564 invoked by uid 500); 10 Jul 2012 09:31:57 -0000 Mailing-List: contact commits-help@giraph.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@giraph.apache.org Delivered-To: mailing list commits@giraph.apache.org Received: (qmail 34543 invoked by uid 99); 10 Jul 2012 09:31:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2012 09:31:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2012 09:31:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D6DA6238890D; Tue, 10 Jul 2012 09:31:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1359536 - in /giraph/trunk: CHANGELOG src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java Date: Tue, 10 Jul 2012 09:31:35 -0000 To: commits@giraph.apache.org From: aching@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120710093135.D6DA6238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aching Date: Tue Jul 10 09:31:35 2012 New Revision: 1359536 URL: http://svn.apache.org/viewvc?rev=1359536&view=rev Log: GIRAPH-239: IntIntNullIntVertex doesn't save halted state (apresta via aching) Added: giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java Modified: giraph/trunk/CHANGELOG giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java Modified: giraph/trunk/CHANGELOG URL: http://svn.apache.org/viewvc/giraph/trunk/CHANGELOG?rev=1359536&r1=1359535&r2=1359536&view=diff ============================================================================== --- giraph/trunk/CHANGELOG (original) +++ giraph/trunk/CHANGELOG Tue Jul 10 09:31:35 2012 @@ -2,6 +2,9 @@ Giraph Change Log Release 0.2.0 - unreleased + GIRAPH-239: IntIntNullIntVertex doesn't save halted state (apresta + via aching) + GIRAPH-238: BasicVertex should have default Writable implementation (apresta via aching) Modified: giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java URL: http://svn.apache.org/viewvc/giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java?rev=1359536&r1=1359535&r2=1359536&view=diff ============================================================================== --- giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java (original) +++ giraph/trunk/src/main/java/org/apache/giraph/graph/IntIntNullIntVertex.java Tue Jul 10 09:31:35 2012 @@ -18,12 +18,11 @@ package org.apache.giraph.graph; +import com.google.common.collect.Iterables; import org.apache.giraph.utils.UnmodifiableIntArrayIterator; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.NullWritable; -import com.google.common.collect.Iterables; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -156,6 +155,7 @@ public abstract class IntIntNullIntVerte for (int n = 0; n < messages.length; n++) { out.writeInt(messages[n]); } + out.writeBoolean(halt); } @Override @@ -172,6 +172,7 @@ public abstract class IntIntNullIntVerte for (int n = 0; n < numMessages; n++) { messages[n] = in.readInt(); } + halt = in.readBoolean(); } } Added: giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java?rev=1359536&view=auto ============================================================================== --- giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java (added) +++ giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java Tue Jul 10 09:31:35 2012 @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.giraph.graph; + +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.NullWritable; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import com.google.common.collect.Lists; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * Tests {@link IntIntNullIntVertex}. + */ +public class TestIntIntNullIntVertex { + /** + * Simple instantiable class that extends {@link IntIntNullIntVertex}. + */ + private static class MyIntIntNullVertex extends IntIntNullIntVertex { + @Override + public void compute(Iterator msgIterator) throws IOException { + } + } + + @Test + public void testSerialize() throws IOException { + IntIntNullIntVertex vertex = new MyIntIntNullVertex(); + + Map edges = + new HashMap(); + edges.put(new IntWritable(3), NullWritable.get()); + edges.put(new IntWritable(47), NullWritable.get()); + + List messages = Lists.newArrayList(new IntWritable(943), + new IntWritable(571)); + + vertex.initialize(new IntWritable(23), new IntWritable(7), edges, + messages); + vertex.voteToHalt(); + + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + DataOutput out = new DataOutputStream(outStream); + vertex.write(out); + + IntIntNullIntVertex vertex1 = new MyIntIntNullVertex(); + + ByteArrayInputStream inStream = new ByteArrayInputStream( + outStream.toByteArray()); + DataInput in = new DataInputStream(inStream); + vertex1.readFields(in); + + assertEquals(2, vertex1.getNumOutEdges()); + assertEquals(Lists.newArrayList(new IntWritable(943), + new IntWritable(571)), Lists.newArrayList(vertex1.getMessages())); + assertEquals(true, vertex1.isHalted()); + } +}