Skip to content

Commit

Permalink
fix: isolated vertex result type
Browse files Browse the repository at this point in the history
  • Loading branch information
diaohancai committed Oct 23, 2023
1 parent d59676e commit d6a23d2
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ public void init(Config config) {
"actual got '%s'",
OPTION_WALK_PER_NODE, this.walkPerNode);
}
LOG.info("[RandomWalk] algorithm param, {}: {}", OPTION_WALK_PER_NODE, walkPerNode);

this.walkLength = config.getInt(OPTION_WALK_LENGTH, 3);
if (this.walkLength < 1) {
throw new ComputerException("The param %s must be greater than 1, " +
"actual got '%s'",
OPTION_WALK_LENGTH, this.walkLength);
}
LOG.info("[RandomWalk] algorithm param, {}: {}", OPTION_WALK_LENGTH, walkLength);

this.random = new Random();
}
Expand All @@ -93,7 +95,7 @@ public void compute0(ComputationContext context, Vertex vertex) {

if (vertex.numEdges() <= 0) {
// isolated vertex
vertex.value(message.path());
this.savePath(vertex, message.path()); // save result
vertex.inactivate();
return;
}
Expand All @@ -111,8 +113,7 @@ public void compute(ComputationContext context, Vertex vertex, Iterator<RandomWa
RandomWalkMessage message = messages.next();

if (message.getIsFinish()) {
// save result
this.savePath(vertex, message.path());
this.savePath(vertex, message.path()); // save result

vertex.inactivate();
continue;
Expand All @@ -135,8 +136,7 @@ public void compute(ComputationContext context, Vertex vertex, Iterator<RandomWa

if (vertex.id().equals(sourceId)) {
// current vertex is the source vertex,no need to send message once more
// save result
this.savePath(vertex, message.path());
this.savePath(vertex, message.path()); // save result
} else {
context.sendMessage(sourceId, message);
}
Expand Down

0 comments on commit d6a23d2

Please sign in to comment.