javeme commented on code in PR #285:
URL:
https://github.com/apache/incubator-hugegraph-computer/pull/285#discussion_r1501346254
##########
computer-test/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPathTest.java:
##########
@@ -40,8 +40,8 @@ public class SingleSourceShortestPathTest extends
AlgorithmTestBase {
public static final String EL = "road";
public static final String PROPERTY_KEY = "distance";
- public static final String SOURCE_ID = "A";
- public static final String TARGET_ID = "E";
+ public static final String SOURCE_ID = "{\"id\": \"A\", \"idType\":
\"string\"}";
Review Comment:
we can use id format like this (ref `VertexAPI.checkAndParseVertexId()`):
```
String SOURCE_ID = "\"abc\"";
String SOURCE_ID = "\"123\"";
String SOURCE_ID = "123";
String SOURCE_ID = "U\"uuid-xxxx\"";
```
##########
computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java:
##########
@@ -157,17 +158,16 @@ public void compute0(ComputationContext context, Vertex
vertex) {
// single target && source == target
if (this.targetQuantityType == QuantityType.SINGLE &&
- this.sourceIdStr.equals(this.targetIdStr)) {
+ this.sourceId.equals(this.targetIdSet.value().iterator().next())) {
Review Comment:
add a private method `targetIdOne()` for
`this.targetIdSet.value().iterator().next()`? we can also check there exist one
element in `targetIdOne()`
##########
computer-api/src/main/java/org/apache/hugegraph/computer/core/util/JsonUtilExt.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.core.util;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hugegraph.rest.SerializeException;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+// todo move to org.apache.hugegraph.util.JsonUtil later
Review Comment:
expect format `// TODO: xx`
##########
computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/shortest/SingleSourceShortestPath.java:
##########
@@ -157,17 +158,16 @@ public void compute0(ComputationContext context, Vertex
vertex) {
// single target && source == target
if (this.targetQuantityType == QuantityType.SINGLE &&
- this.sourceIdStr.equals(this.targetIdStr)) {
+ this.sourceId.equals(this.targetIdSet.value().iterator().next())) {
LOG.debug("source vertex {} equals target vertex {}",
- this.sourceIdStr, this.targetIdStr);
+ this.sourceId,
this.targetIdSet.value().iterator().next());
vertex.inactivate();
return;
}
if (vertex.numEdges() <= 0) {
// isolated vertex
- LOG.debug("source vertex {} can not reach target vertex {}",
- this.sourceIdStr, this.targetIdStr);
+ LOG.debug("source vertex {} is isolated", this.sourceId);
Review Comment:
this format is more convenient for retrieving logs: `The source vertex is
isolated: {}`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]