Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: superstep not take effect #237

Merged
merged 5 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,7 @@ private boolean finishedIteration(boolean masterContinue,
if (context.superstep() >= this.maxSuperStep - 1) {
return true;
}
long activeVertexCount = context.totalVertexCount() -
context.finishedVertexCount();
return context.messageCount() == 0L && activeVertexCount == 0L;
return false;
JackyYangPassion marked this conversation as resolved.
Show resolved Hide resolved
JackyYangPassion marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.hugegraph.computer.core.common.exception.ComputerException;
import org.apache.hugegraph.computer.core.config.ComputerOptions;
import org.apache.hugegraph.computer.core.config.Config;
import org.apache.hugegraph.computer.core.receiver.MessageStat;
import org.apache.hugegraph.util.InsertionOrderUtil;

public class MessageSendBuffers {
Expand Down Expand Up @@ -67,6 +68,13 @@ public Map<Integer, MessageSendPartition> all() {
return all;
}

public MessageStat messageStat(int partitionId) {
if (partitionId < 0 || partitionId >= this.buffers.length) {
throw new ComputerException("Invalid partition id %s", partitionId);
}
return this.buffers[partitionId].messageWritten();
}

public void clear() {
for (MessageSendPartition partition : this.buffers) {
partition.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void finishSend(MessageType type) {
}

public MessageStat messageStat(int partitionId) {
return this.buffers.get(partitionId).messageWritten();
return this.buffers.messageStat(partitionId);
}

public void clearBuffer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,29 @@
package org.apache.hugegraph.computer.algorithm.community.lpa;

import org.apache.hugegraph.computer.algorithm.AlgorithmTestBase;
import org.apache.hugegraph.computer.core.common.ComputerContext;
import org.apache.hugegraph.computer.core.output.hg.task.TaskManager;
import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.structure.gremlin.ResultSet;
import org.apache.hugegraph.testutil.Assert;
import org.junit.Test;

import java.util.LinkedHashMap;

public class LpaTest extends AlgorithmTestBase {

@Test
public void testRunAlgorithm() throws InterruptedException {
runAlgorithm(LpaParams.class.getName());

// check result
ComputerContext context = context();
TaskManager taskManager = new TaskManager(context.config());
HugeClient client = taskManager.client();
ResultSet result = client.gremlin().gremlin("g.V().group().by('lpa').by(T.id)").execute();

LinkedHashMap resultRow = (LinkedHashMap)result.data().get(0);
Assert.assertEquals(4, resultRow.size());

}
}