forked from hugegraph/hugegraph-sync
fix: useless ring detection removed valid path (#1723)
* remove useless ring detection due to it will remove valid path * limit max depth to 5000 to avoid stackoverflow
This commit is contained in:
parent
35cffbc032
commit
5bf0290e54
|
|
@ -68,7 +68,7 @@ public class NeighborRankAPI extends API {
|
|||
"The source of rank request can't be null");
|
||||
E.checkArgument(request.steps != null && !request.steps.isEmpty(),
|
||||
"The steps of rank request can't be empty");
|
||||
E.checkArgument(request.steps.size() <= Long.parseLong(DEFAULT_MAX_DEPTH),
|
||||
E.checkArgument(request.steps.size() <= DEFAULT_MAX_DEPTH,
|
||||
"The steps length of rank request can't exceed %s",
|
||||
DEFAULT_MAX_DEPTH);
|
||||
E.checkArgument(request.alpha > 0 && request.alpha <= 1.0,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package com.baidu.hugegraph.api.traversers;
|
|||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -114,9 +115,9 @@ public class PathsAPI extends TraverserAPI {
|
|||
"The targets of request can't be null");
|
||||
E.checkArgumentNotNull(request.step,
|
||||
"The step of request can't be null");
|
||||
E.checkArgument(request.depth > 0,
|
||||
"The depth of request must be > 0, but got: %s",
|
||||
request.depth);
|
||||
E.checkArgument(request.depth > 0 && request.depth <= DEFAULT_MAX_DEPTH,
|
||||
"The depth of request must be in (0, %s], " +
|
||||
"but got: %s", DEFAULT_MAX_DEPTH, request.depth);
|
||||
|
||||
LOG.debug("Graph [{}] get paths from source vertices '{}', target " +
|
||||
"vertices '{}', with step '{}', max depth '{}', " +
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class PersonalRankAPI extends API {
|
|||
"The limit of rank request must be > 0 or == -1, " +
|
||||
"but got: %s", request.limit);
|
||||
E.checkArgument(request.maxDepth > 1L &&
|
||||
request.maxDepth <= Long.parseLong(DEFAULT_MAX_DEPTH),
|
||||
request.maxDepth <= DEFAULT_MAX_DEPTH,
|
||||
"The max depth of rank request must be " +
|
||||
"in range (1, %s], but got '%s'",
|
||||
DEFAULT_MAX_DEPTH, request.maxDepth);
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ public class HugeTraverser {
|
|||
public static final String DEFAULT_MAX_DEGREE = "10000";
|
||||
public static final String DEFAULT_SKIP_DEGREE = "100000";
|
||||
public static final String DEFAULT_SAMPLE = "100";
|
||||
public static final String DEFAULT_MAX_DEPTH = "50";
|
||||
public static final String DEFAULT_WEIGHT = "0";
|
||||
public static final int DEFAULT_MAX_DEPTH = 5000;
|
||||
|
||||
protected static final int MAX_VERTICES = 10;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
package com.baidu.hugegraph.traversal.algorithm;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Edge;
|
||||
|
||||
|
|
@ -52,7 +51,9 @@ public class PathsTraverser extends HugeTraverser {
|
|||
sourceDir == targetDir.opposite(),
|
||||
"Source direction must equal to target direction" +
|
||||
" or opposite to target direction");
|
||||
checkPositive(depth, "max depth");
|
||||
E.checkArgument(depth > 0 && depth <= DEFAULT_MAX_DEPTH,
|
||||
"The depth must be in (0, %s], but got: %s",
|
||||
DEFAULT_MAX_DEPTH, depth);
|
||||
checkDegree(degree);
|
||||
checkCapacity(capacity);
|
||||
checkLimit(limit);
|
||||
|
|
@ -124,9 +125,6 @@ public class PathsTraverser extends HugeTraverser {
|
|||
PathSet results = this.record.findPath(target, null,
|
||||
true, false);
|
||||
for (Path path : results) {
|
||||
if (Objects.equals(target, targetV)) {
|
||||
continue;
|
||||
}
|
||||
this.paths.add(path);
|
||||
if (this.reachLimit()) {
|
||||
return;
|
||||
|
|
@ -160,9 +158,6 @@ public class PathsTraverser extends HugeTraverser {
|
|||
PathSet results = this.record.findPath(target, null,
|
||||
true, false);
|
||||
for (Path path : results) {
|
||||
if (Objects.equals(target, sourceV)) {
|
||||
continue;
|
||||
}
|
||||
this.paths.add(path);
|
||||
if (this.reachLimit()) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue