Skip to content

Commit

Permalink
chore: log improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
diaohancai committed Feb 29, 2024
1 parent aa8238d commit 0b1c720
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,15 @@ public void compute0(ComputationContext context, Vertex vertex) {

// single target && source == target
if (this.targetQuantityType == QuantityType.SINGLE &&
this.sourceId.equals(this.targetIdSet.value().iterator().next())) {
LOG.debug("source vertex {} equals target vertex {}",
this.sourceId, this.targetIdSet.value().iterator().next());
this.targetIdSet.contains(this.sourceId)) {
LOG.debug("source vertex equals target vertex: {}", this.sourceId);
vertex.inactivate();
return;

Check warning on line 148 in computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java

View check run for this annotation

Codecov / codecov/patch

computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java#L146-L148

Added lines #L146 - L148 were not covered by tests
}

if (vertex.numEdges() <= 0) {
// isolated vertex
LOG.debug("source vertex {} is isolated", this.sourceId);
LOG.debug("The source vertex is isolated: {}", this.sourceId);
vertex.inactivate();
return;

Check warning on line 155 in computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java

View check run for this annotation

Codecov / codecov/patch

computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java#L153-L155

Added lines #L153 - L155 were not covered by tests
}
Expand Down Expand Up @@ -279,25 +278,4 @@ private boolean isAllTargetsReached(Vertex vertex) {
}
return false;

Check warning on line 279 in computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java

View check run for this annotation

Codecov / codecov/patch

computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java#L279

Added line #L279 was not covered by tests
}

static class VertexInputJson {
private String id;
private String idType;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getIdType() {
return idType;
}

public void setIdType(String idType) {
this.idType = idType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

// todo move to org.apache.hugegraph.util.JsonUtil later
// TODO: move to org.apache.hugegraph.util.JsonUtil later
public class JsonUtilExt {

Check warning on line 29 in computer-api/src/main/java/org/apache/hugegraph/computer/core/util/JsonUtilExt.java

View check run for this annotation

Codecov / codecov/patch

computer-api/src/main/java/org/apache/hugegraph/computer/core/util/JsonUtilExt.java#L29

Added line #L29 was not covered by tests

private static final ObjectMapper MAPPER = new ObjectMapper();

Check warning on line 31 in computer-api/src/main/java/org/apache/hugegraph/computer/core/util/JsonUtilExt.java

View check run for this annotation

Codecov / codecov/patch

computer-api/src/main/java/org/apache/hugegraph/computer/core/util/JsonUtilExt.java#L31

Added line #L31 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ public String value(org.apache.hugegraph.computer.core.graph.vertex.Vertex verte
if (vertex.id().value().toString().equals(TARGET_ID)) {
Map map = JsonUtil.fromJson(json, Map.class);

LOG.info("source vertex {} to target vertex {}, " +
LOG.info("source vertex to target vertex: {}, {}, " +
"shortest path: {}, total weight: {}",
SOURCE_ID, TARGET_ID, map.get("path"), map.get("total_weight"));
SOURCE_ID, TARGET_ID,
map.get("path"), map.get("total_weight"));
Assert.assertEquals(map.get("path"), SHORTEST_PATH);
Assert.assertEquals(map.get("total_weight"), TOTAL_WEIGHT);
}
Expand Down

0 comments on commit 0b1c720

Please sign in to comment.