You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hama.apache.org by 步青云 <ma...@qq.com> on 2016/01/26 14:16:11 UTC

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

RE: RE: RE: RE: Do Hama support member member variable?

Posted by "Edward J. Yoon" <ed...@samsung.com>.
Another one comment is:

@Override  public void compute(Iterable<TriTextPair> messages) throws 
IOException {
      match = true;
      writeState(out);
 }

You don't need to call writeState() method within compute(). The 
read/writeState() will be called automatically when serialize/deserialize 
phase.

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Thursday, January 28, 2016 12:03 PM
To: user
Subject: Re: RE: RE: RE: Do Hama support member member variable?

Maybe I know. By using readState() method, the value of member variable could 
be stored in file rather than memory. Am I right?
So, I can use these methods like this. yeah?
But how about object member like ArrayList?
I indeed need help. Thank you very much.




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

  private DataOutput out  = new DataOutputStream(new 
FileOutputStream("at.txt"));
  private DataInput in  = new DataInputStream(new FileOutputStream("at.txt"));


  @Override  public void compute(Iterable<TriTextPair> messages) throws 
IOException {
      match = true;
      writeState(out);
 }

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

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

  ..

}


Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 10:51 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: RE: RE: Do Hama support member member variable?



Nope, you should always need to use custom readState() and writeState()
methods. This is the way to keep compact size.

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 11:01 AM
To: user
Subject: Re: RE: RE: Do Hama support member member variable?

I know. If I use the static variable like "private static boolean match", I
could get the right value of match too. Could I use static variable?
Thanks a lot.
Best regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 09:39 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: RE: Do Hama support member member variable?



Basically Vertex object is writable, and we store the vertex objects in
serialized form. There are two purposes: 1) to reduce memory usage 2) to write
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use
readState() and writeState() methods. What is the input parameter DataInput in
and DataOutput out?  And as far as I know, I can assign the value of member
variable directly in hama-0.6.3, such as match = true. Why I can't do this in
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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



Re: RE: RE: RE: Do Hama support member member variable?

Posted by 步青云 <ma...@qq.com>.
Maybe I know. By using readState() method, the value of member variable could be stored in file rather than memory. Am I right?
So, I can use these methods like this. yeah?
But how about object member like ArrayList?
I indeed need help. Thank you very much.




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

  private DataOutput out  = new DataOutputStream(new FileOutputStream("at.txt"));
  private DataInput in  = new DataInputStream(new FileOutputStream("at.txt"));
 

  @Override  public void compute(Iterable<TriTextPair> messages) throws IOException {
      match = true;
      writeState(out);
 }

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

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

  ..

}


Best Regards, Ping Liu. 


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 10:51 AM
To:  "user"<us...@hama.apache.org>; 

Subject:  RE: RE: RE: Do Hama support member member variable?



Nope, you should always need to use custom readState() and writeState() 
methods. This is the way to keep compact size.

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 11:01 AM
To: user
Subject: Re: RE: RE: Do Hama support member member variable?

I know. If I use the static variable like "private static boolean match", I 
could get the right value of match too. Could I use static variable?
Thanks a lot.
Best regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 09:39 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: RE: Do Hama support member member variable?



Basically Vertex object is writable, and we store the vertex objects in
serialized form. There are two purposes: 1) to reduce memory usage 2) to write
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use
readState() and writeState() methods. What is the input parameter DataInput in
and DataOutput out?  And as far as I know, I can assign the value of member
variable directly in hama-0.6.3, such as match = true. Why I can't do this in
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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

RE: RE: RE: Do Hama support member member variable?

Posted by "Edward J. Yoon" <ed...@samsung.com>.
Nope, you should always need to use custom readState() and writeState() 
methods. This is the way to keep compact size.

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 11:01 AM
To: user
Subject: Re: RE: RE: Do Hama support member member variable?

I know. If I use the static variable like "private static boolean match", I 
could get the right value of match too. Could I use static variable?
Thanks a lot.
Best regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 09:39 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: RE: Do Hama support member member variable?



Basically Vertex object is writable, and we store the vertex objects in
serialized form. There are two purposes: 1) to reduce memory usage 2) to write
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use
readState() and writeState() methods. What is the input parameter DataInput in
and DataOutput out?  And as far as I know, I can assign the value of member
variable directly in hama-0.6.3, such as match = true. Why I can't do this in
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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



Re: RE: RE: RE: Do Hama support member member variable?

Posted by 步青云 <ma...@qq.com>.
Thank you very much. I'm trying use hama 0.7.1. 
In fact, as a user of hama, I would like to use member variable like "match=true;" rather than use readState() methods. It's confusion and complex, especially for object variable like ArrayList.
If I have problem in using hama 0.7.1, I would seek for help to you. 
Best Regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 03:12 PM
To:  "user"<us...@hama.apache.org>; 

Subject:  RE: RE: RE: Do Hama support member member variable?



Just FYI, Hama 0.7.1 release candidate is now available. Please feel free to 
use this, and it'd nice if you can let me know whether it works well with you.

Release tarball: http://people.apache.org/~edwardyoon/dist/0.7.1-RC1

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 11:01 AM
To: user
Subject: Re: RE: RE: Do Hama support member member variable?

I know. If I use the static variable like "private static boolean match", I 
could get the right value of match too. Could I use static variable?
Thanks a lot.
Best regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 09:39 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: RE: Do Hama support member member variable?



Basically Vertex object is writable, and we store the vertex objects in
serialized form. There are two purposes: 1) to reduce memory usage 2) to write
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use
readState() and writeState() methods. What is the input parameter DataInput in
and DataOutput out?  And as far as I know, I can assign the value of member
variable directly in hama-0.6.3, such as match = true. Why I can't do this in
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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

RE: RE: RE: Do Hama support member member variable?

Posted by "Edward J. Yoon" <ed...@samsung.com>.
Just FYI, Hama 0.7.1 release candidate is now available. Please feel free to 
use this, and it'd nice if you can let me know whether it works well with you.

Release tarball: http://people.apache.org/~edwardyoon/dist/0.7.1-RC1

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 11:01 AM
To: user
Subject: Re: RE: RE: Do Hama support member member variable?

I know. If I use the static variable like "private static boolean match", I 
could get the right value of match too. Could I use static variable?
Thanks a lot.
Best regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 09:39 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: RE: Do Hama support member member variable?



Basically Vertex object is writable, and we store the vertex objects in
serialized form. There are two purposes: 1) to reduce memory usage 2) to write
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use
readState() and writeState() methods. What is the input parameter DataInput in
and DataOutput out?  And as far as I know, I can assign the value of member
variable directly in hama-0.6.3, such as match = true. Why I can't do this in
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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



Re: RE: RE: Do Hama support member member variable?

Posted by 步青云 <ma...@qq.com>.
I know. If I use the static variable like "private static boolean match", I could get the right value of match too. Could I use static variable?
Thanks a lot. 
Best regards. Ping Liu.




------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 09:39 AM
To:  "user"<us...@hama.apache.org>; 

Subject:  RE: RE: Do Hama support member member variable?



Basically Vertex object is writable, and we store the vertex objects in 
serialized form. There are two purposes: 1) to reduce memory usage 2) to write 
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member 
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use 
readState() and writeState() methods. What is the input parameter DataInput in 
and DataOutput out?  And as far as I know, I can assign the value of member 
variable directly in hama-0.6.3, such as match = true. Why I can't do this in 
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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

RE: RE: Do Hama support member member variable?

Posted by "Edward J. Yoon" <ed...@samsung.com>.
Basically Vertex object is writable, and we store the vertex objects in 
serialized form. There are two purposes: 1) to reduce memory usage 2) to write 
on file system (checkpoint and recovery).

So, you should use readState() and writeState() methods to save object member 
variables.

Thanks!

--
Best Regards, Edward J. Yoon


-----Original Message-----
From: 步?云 [mailto:mailliuping@qq.com]
Sent: Wednesday, January 27, 2016 10:27 AM
To: user
Subject: Re: RE: Do Hama support member member variable?

Hi,
Thank you very much. You helped me a lot. But I still don't know how to use 
readState() and writeState() methods. What is the input parameter DataInput in 
and DataOutput out?  And as far as I know, I can assign the value of member 
variable directly in hama-0.6.3, such as match = true. Why I can't do this in 
Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>;

Subject:  RE: Do Hama support member member variable?



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



Re: RE: Do Hama support member member variable?

Posted by 步青云 <ma...@qq.com>.
Hi,
Thank you very much. You helped me a lot. But I still don't know how to use readState() and writeState() methods. What is the input parameter DataInput in and DataOutput out?  And as far as I know, I can assign the value of member variable directly in hama-0.6.3, such as match = true. Why I can't do this in Hama-0.7.0?
Waiting for your reply. Thanks.
Best Regards, Ping Liu.


------------------ Original ------------------
From:  "Edward J. Yoon";<ed...@samsung.com>;
Date:  Wed, Jan 27, 2016 07:15 AM
To:  "user"<us...@hama.apache.org>; 

Subject:  RE: Do Hama support member member variable?



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

RE: Do Hama support member member variable?

Posted by "Edward J. Yoon" <ed...@samsung.com>.
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