hama-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edward J. Yoon" <edward.y...@samsung.com>
Subject RE: Do Hama support member member variable?
Date Tue, 26 Jan 2016 23:15:48 GMT
Hi,

You should use readState() and writeState() methods like below:

public static class ProbMatchVertex extends Vertex<Text, NullWritable,
TriTextPair> {
  private boolean match = false;

  public void readState(DataInput in) throws IOException {
    match = in.readBoolean();
  }

  public void writeState(DataOutput out) throws IOException {
    out.writeBoolean(match);
  }

  ..

}

--
Best Regards, Edward J. Yoon

-----Original Message-----
From: 꼍행暾 [mailto:mailliuping@qq.com]
Sent: Tuesday, January 26, 2016 10:16 PM
To: user
Subject: Do Hama support member member variable?

Hello,
      I'm trying to run a graph job. But i have got some problems.
      I want to use member variable in vertex class, the code is as follow.
I have changed the value of the member variable in one superstep. But when I
use this member variable in next superstep, the value of this member
variable is still the defalult value. For example, "match" is the member
variable. I have changed the value of "match" to be ture in superstep 0, but
when I print "match" in superstep 1, the result was "match: false".
      Could anyone tell me why the value of member variable is changed?
Thanks very much.
      Best wishes.


      public static class ProbMatchVertex extends Vertex<Text, NullWritable,
TriTextPair> {
		private boolean match = false;


		@Override
		public void compute(Iterable<TriTextPair> messages) throws
IOException {
			if (getSuperstepCount() == 0) {
				match = true;
				sendMessageToNeighbors(new
TriTextPair(getVertexID(),
						getVertexLabel(), new
Text("")));
			} else if(getSuperstepCount() == 1){
				System.out.println("match:" +  match);
				parents = new ArrayList<TriTextPair>();
				for(TriTextPair msg : messages){
					parents.add(msg);
					sendMessage(msg.getFirst(), new
TriTextPair(getVertexID(), getVertexLabel(), new Text("")));
				}
			}
		}




Ping Liu



Mime
View raw message