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(algorithm): record loop is not copied #276

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -83,7 +83,7 @@ public void compute(ComputationContext context, Vertex vertex,
if (isMin) {
sequence.add(id);
IdListList sequences = vertex.value();
sequences.add(sequence);
sequences.add(sequence.copy());
}
} else {
boolean contains = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.hugegraph.computer.algorithm.AlgorithmTestBase;
import org.apache.hugegraph.computer.core.config.ComputerOptions;
Expand Down Expand Up @@ -124,6 +125,10 @@ private void assertResult(Id id, List<String> rings) {
Set<String> expect = EXPECT_RINGS.getOrDefault(id.toString(),
new HashSet<>());

rings = rings.stream()
.distinct()
.collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems don't need to distinct since the rings is a Set

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems don't need to distinct since the rings is a Set

rings is a List.

private void assertResult(Id id, List<String> rings) {
   ...
}

Before fix this bug, it is also a problem that our test can pass.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry


Assert.assertEquals(expect.size(), rings.size());
for (String ring : rings) {
String error = "Expect: '" + ring + "' in " + expect;
Expand Down
Loading