You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hama.apache.org by Chui-Hui Chiu <cc...@tigers.lsu.edu> on 2013/06/28 22:04:48 UTC

SSSP Sample code

Hello, all,

Here's the "compute" function is the SSSP sample.

@Override
    public void compute(Iterable<IntWritable> messages) throws IOException {
      int minDist = isStartVertex() ? 0 : Integer.MAX_VALUE;

      for (IntWritable msg : messages) {
        if (msg.get() < minDist) {
          minDist = msg.get();
        }
      }

      if (minDist < this.getValue().get()) {
        this.setValue(new IntWritable(minDist));
        for (Edge<Text, IntWritable> e : this.getEdges()) {
          sendMessage(e, new IntWritable(minDist + e.getValue().get()));
        }
      } else {
        voteToHalt();
      }
    }

Why does it fall through the end of the compute() without explicitly
calling the voteToHalt() after sending out all messages?  Does reaching the
end of the compute() imply calling the voteToHalt()?


Thanks,
Chui-hui

Re: SSSP Sample code

Posted by "Edward J. Yoon" <ed...@apache.org>.
A and B should be the same. But, B is recommended (to avoid
unnecessary calls of the compute() method).

Please use the TRUNK. There's a bug -
https://issues.apache.org/jira/browse/HAMA-771 - in the latest
release.

Thanks.

A:

       if (minDist < this.getValue().get()) {
         this.setValue(new IntWritable(minDist));
         for (Edge<Text, IntWritable> e : this.getEdges()) {
           sendMessage(e, new IntWritable(minDist + e.getValue().get()));
         }
       } else {
         voteToHalt();
       }

B:

       if (minDist < this.getValue().get()) {
         this.setValue(new IntWritable(minDist));
         for (Edge<Text, IntWritable> e : this.getEdges()) {
           sendMessage(e, new IntWritable(minDist + e.getValue().get()));
         }
       }
       voteToHalt();

On Sat, Jun 29, 2013 at 5:04 AM, Chui-Hui Chiu <cc...@tigers.lsu.edu> wrote:
> Hello, all,
>
> Here's the "compute" function is the SSSP sample.
>
> @Override
>     public void compute(Iterable<IntWritable> messages) throws IOException {
>       int minDist = isStartVertex() ? 0 : Integer.MAX_VALUE;
>
>       for (IntWritable msg : messages) {
>         if (msg.get() < minDist) {
>           minDist = msg.get();
>         }
>       }
>
>       if (minDist < this.getValue().get()) {
>         this.setValue(new IntWritable(minDist));
>         for (Edge<Text, IntWritable> e : this.getEdges()) {
>           sendMessage(e, new IntWritable(minDist + e.getValue().get()));
>         }
>       } else {
>         voteToHalt();
>       }
>     }
>
> Why does it fall through the end of the compute() without explicitly
> calling the voteToHalt() after sending out all messages?  Does reaching the
> end of the compute() imply calling the voteToHalt()?
>
>
> Thanks,
> Chui-hui



-- 
Best Regards, Edward J. Yoon
@eddieyoon

Re: SSSP Sample code

Posted by "Edward J. Yoon" <ed...@apache.org>.
A and B should be the same. But, B is recommended (to avoid
unnecessary calls of the compute() method).

Please use the TRUNK. There's a bug -
https://issues.apache.org/jira/browse/HAMA-771 - in the latest
release.

Thanks.

A:

       if (minDist < this.getValue().get()) {
         this.setValue(new IntWritable(minDist));
         for (Edge<Text, IntWritable> e : this.getEdges()) {
           sendMessage(e, new IntWritable(minDist + e.getValue().get()));
         }
       } else {
         voteToHalt();
       }

B:

       if (minDist < this.getValue().get()) {
         this.setValue(new IntWritable(minDist));
         for (Edge<Text, IntWritable> e : this.getEdges()) {
           sendMessage(e, new IntWritable(minDist + e.getValue().get()));
         }
       }
       voteToHalt();

On Sat, Jun 29, 2013 at 5:04 AM, Chui-Hui Chiu <cc...@tigers.lsu.edu> wrote:
> Hello, all,
>
> Here's the "compute" function is the SSSP sample.
>
> @Override
>     public void compute(Iterable<IntWritable> messages) throws IOException {
>       int minDist = isStartVertex() ? 0 : Integer.MAX_VALUE;
>
>       for (IntWritable msg : messages) {
>         if (msg.get() < minDist) {
>           minDist = msg.get();
>         }
>       }
>
>       if (minDist < this.getValue().get()) {
>         this.setValue(new IntWritable(minDist));
>         for (Edge<Text, IntWritable> e : this.getEdges()) {
>           sendMessage(e, new IntWritable(minDist + e.getValue().get()));
>         }
>       } else {
>         voteToHalt();
>       }
>     }
>
> Why does it fall through the end of the compute() without explicitly
> calling the voteToHalt() after sending out all messages?  Does reaching the
> end of the compute() imply calling the voteToHalt()?
>
>
> Thanks,
> Chui-hui



-- 
Best Regards, Edward J. Yoon
@eddieyoon