diff --git a/hugegraph-api/pom.xml b/hugegraph-api/pom.xml
index 6d588f5a44..2b20c21659 100644
--- a/hugegraph-api/pom.xml
+++ b/hugegraph-api/pom.xml
@@ -101,7 +101,7 @@
- 0.31.0.0
+ 0.32.0.0
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/CrosspointsAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/CrosspointsAPI.java
index 4322f7fb2c..4cec79b3fd 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/CrosspointsAPI.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/CrosspointsAPI.java
@@ -59,15 +59,15 @@ public String get(@Context GraphManager manager,
@QueryParam("target") String target,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("max_depth") int maxDepth,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_depth") int depth,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("capacity") @DefaultValue("-1") long capacity,
@QueryParam("limit") @DefaultValue("10") long limit) {
LOG.debug("Graph [{}] get crosspoints with paths from '{}', to '{}' " +
"with direction '{}', edge label '{}', max depth '{}', " +
- "degree '{}', capacity '{}' and limit '{}'",
+ "max degree '{}', capacity '{}' and limit '{}'",
graph, source, target, direction, edgeLabel,
- maxDepth, degree, capacity, limit);
+ depth, degree, capacity, limit);
Id sourceId = VertexAPI.checkAndParseVertexId(source);
Id targetId = VertexAPI.checkAndParseVertexId(target);
@@ -77,9 +77,9 @@ public String get(@Context GraphManager manager,
HugeTraverser traverser = new HugeTraverser(g);
Set paths = traverser.paths(sourceId, dir,
targetId, dir,
- edgeLabel, maxDepth,
+ edgeLabel, depth,
degree, capacity,
limit);
return manager.serializer(g).writePaths("crosspoints", paths, true);
}
-}
\ No newline at end of file
+}
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KneighborAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KneighborAPI.java
index 04d965d429..273cdd86f7 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KneighborAPI.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KneighborAPI.java
@@ -58,12 +58,12 @@ public String get(@Context GraphManager manager,
@QueryParam("source") String sourceV,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("depth") int depth,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_depth") int depth,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("limit") @DefaultValue("-1") long limit) {
LOG.debug("Graph [{}] get k-neighbor from '{}' with " +
- "direction '{}', edge label '{}', depth '{}', " +
- "degree '{}' and limit '{}'",
+ "direction '{}', edge label '{}', max depth '{}', " +
+ "max degree '{}' and limit '{}'",
graph, sourceV, direction, edgeLabel, depth,
degree, limit);
@@ -77,4 +77,4 @@ public String get(@Context GraphManager manager,
degree, limit);
return manager.serializer(g).writeIds("vertices", ids);
}
-}
\ No newline at end of file
+}
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KoutAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KoutAPI.java
index 4374c516a2..6fc5e7d6f0 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KoutAPI.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/KoutAPI.java
@@ -58,15 +58,15 @@ public String get(@Context GraphManager manager,
@QueryParam("source") String source,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("depth") int depth,
+ @QueryParam("max_depth") int depth,
@QueryParam("nearest")
@DefaultValue("true") boolean nearest,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("capacity") @DefaultValue("-1") long capacity,
@QueryParam("limit") @DefaultValue("-1") long limit) {
LOG.debug("Graph [{}] get k-out from '{}' with " +
- "direction '{}', edge label '{}', depth '{}', nearest '{}'," +
- " degree '{}', capacity '{}' and limit '{}'",
+ "direction '{}', edge label '{}', max depth '{}', nearest " +
+ "'{}', max degree '{}', capacity '{}' and limit '{}'",
graph, source, direction, edgeLabel, depth, nearest,
degree, capacity, limit);
@@ -80,4 +80,4 @@ public String get(@Context GraphManager manager,
nearest, degree, capacity, limit);
return manager.serializer(g).writeIds("vertices", ids);
}
-}
\ No newline at end of file
+}
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/PathsAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/PathsAPI.java
index dd08312933..823d03c93f 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/PathsAPI.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/PathsAPI.java
@@ -59,14 +59,14 @@ public String get(@Context GraphManager manager,
@QueryParam("target") String target,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("max_depth") int maxDepth,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_depth") int depth,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("capacity") @DefaultValue("-1") long capacity,
@QueryParam("limit") @DefaultValue("10") long limit) {
LOG.debug("Graph [{}] get paths from '{}', to '{}' with " +
"direction {}, edge label {}, max depth '{}', " +
- "degree '{}', capacity '{}' and limit '{}'",
- graph, source, target, direction, edgeLabel, maxDepth,
+ "max degree '{}', capacity '{}' and limit '{}'",
+ graph, source, target, direction, edgeLabel, depth,
degree, capacity, limit);
Id sourceId = VertexAPI.checkAndParseVertexId(source);
@@ -77,7 +77,7 @@ public String get(@Context GraphManager manager,
HugeTraverser traverser = new HugeTraverser(g);
Set paths;
paths = traverser.paths(sourceId, dir, targetId, dir.opposite(),
- edgeLabel, maxDepth, degree, capacity, limit);
+ edgeLabel, depth, degree, capacity, limit);
return manager.serializer(g).writePaths("paths", paths, false);
}
}
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rays.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rays.java
index cde50b8243..059f2d54c5 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rays.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rays.java
@@ -58,13 +58,13 @@ public String get(@Context GraphManager manager,
@QueryParam("source") String sourceV,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("depth") int depth,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_depth") int depth,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("capacity") @DefaultValue("-1") long capacity,
@QueryParam("limit") @DefaultValue("-1") long limit) {
LOG.debug("Graph [{}] get rays paths from '{}' with " +
- "direction '{}', edge label '{}', depth '{}', " +
- "degree '{}' and limit '{}'",
+ "direction '{}', edge label '{}', max depth '{}', " +
+ "max degree '{}' and limit '{}'",
graph, sourceV, direction, edgeLabel, depth, degree, limit);
Id source = VertexAPI.checkAndParseVertexId(sourceV);
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rings.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rings.java
index a9ca719bbf..7e1f4444c0 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rings.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/Rings.java
@@ -58,13 +58,13 @@ public String get(@Context GraphManager manager,
@QueryParam("source") String sourceV,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("depth") int depth,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_depth") int depth,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("capacity") @DefaultValue("-1") long capacity,
@QueryParam("limit") @DefaultValue("-1") long limit) {
LOG.debug("Graph [{}] get rings paths reachable from '{}' with " +
- "direction '{}', edge label '{}', depth '{}', " +
- "degree '{}' and limit '{}'",
+ "direction '{}', edge label '{}', max depth '{}', " +
+ "max degree '{}' and limit '{}'",
graph, sourceV, direction, edgeLabel, depth, degree, limit);
Id source = VertexAPI.checkAndParseVertexId(sourceV);
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/ShortestPathAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/ShortestPathAPI.java
index 78c9d53e38..13e6687c13 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/ShortestPathAPI.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/ShortestPathAPI.java
@@ -59,14 +59,14 @@ public String get(@Context GraphManager manager,
@QueryParam("target") String target,
@QueryParam("direction") String direction,
@QueryParam("label") String edgeLabel,
- @QueryParam("max_depth") int maxDepth,
- @QueryParam("degree") @DefaultValue("-1") long degree,
+ @QueryParam("max_depth") int depth,
+ @QueryParam("max_degree") @DefaultValue("-1") long degree,
@QueryParam("capacity")
@DefaultValue("-1") long capacity) {
LOG.debug("Graph [{}] get shortest path from '{}', to '{}' with " +
"direction {}, edge label {}, max depth '{}', " +
- "degree '{}' and capacity '{}'",
- graph, source, target, direction, edgeLabel, maxDepth,
+ "max degree '{}' and capacity '{}'",
+ graph, source, target, direction, edgeLabel, depth,
degree, capacity);
Id sourceId = VertexAPI.checkAndParseVertexId(source);
@@ -77,8 +77,8 @@ public String get(@Context GraphManager manager,
HugeTraverser traverser = new HugeTraverser(g);
List path = traverser.shortestPath(sourceId, targetId, dir,
- edgeLabel, maxDepth,
- degree, capacity);
+ edgeLabel, depth, degree,
+ capacity);
return manager.serializer(g).writeIds("path", path);
}
-}
\ No newline at end of file
+}
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/version/ApiVersion.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/version/ApiVersion.java
index 868e1c2035..2a285b8326 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/version/ApiVersion.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/version/ApiVersion.java
@@ -75,10 +75,11 @@ public final class ApiVersion {
* [0.29] Issue-39: Add rays and rings RESTful API
* [0.30] Issue-32: Change index create API to return indexLabel and task id
* [0.31] Issue-182: Support restore graph in restoring and merging mode
+ * [0.32] Issue-250: Keep depth and degree consistent for traverser api
*/
// The second parameter of Version.of() is for IDE running without JAR
- public static final Version VERSION = Version.of(ApiVersion.class, "0.31");
+ public static final Version VERSION = Version.of(ApiVersion.class, "0.32");
public static final void check() {
// Check version of hugegraph-core. Firstly do check from version 0.3
diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java
index b438b87e0b..6110e381ce 100644
--- a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java
+++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java
@@ -427,6 +427,7 @@ public boolean indexValueChanged(Vertex oldV, HugeVertex newV) {
return false;
}
+ @SuppressWarnings("unused")
private void deleteIndex(HugeVertex vertex) {
// Delete the old record if exist
Iterator old = this.queryVertices(vertex.id());
diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeTraverser.java
index 03d7822e09..0d2f26db28 100644
--- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeTraverser.java
+++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeTraverser.java
@@ -60,12 +60,12 @@ public HugeTraverser(HugeGraph graph) {
}
public List shortestPath(Id sourceV, Id targetV, Directions dir,
- String label, int maxDepth,
- long degree, long capacity) {
+ String label, int depth, long degree,
+ long capacity) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(targetV, "target vertex id");
E.checkNotNull(dir, "direction");
- checkPositive(maxDepth, "Shortest path max depth");
+ checkPositive(depth, "max depth");
checkDegree(degree);
checkCapacity(capacity);
@@ -81,12 +81,12 @@ public List shortestPath(Id sourceV, Id targetV, Directions dir,
while (true) {
// Found, reach max depth or reach capacity, stop searching
if ((path = traverser.forward()) != PATH_NONE ||
- --maxDepth <= 0 || traverser.reachCapacity()) {
+ --depth <= 0 || traverser.reachCapacity()) {
break;
}
if ((path = traverser.backward()) != PATH_NONE ||
- --maxDepth <= 0 || traverser.reachCapacity()) {
+ --depth <= 0 || traverser.reachCapacity()) {
Collections.reverse(path);
break;
}
@@ -95,9 +95,8 @@ public List shortestPath(Id sourceV, Id targetV, Directions dir,
}
public Set paths(Id sourceV, Directions sourceDir,
- Id targetV, Directions targetDir,
- String label, int maxDepth,
- long degree, long capacity, long limit) {
+ Id targetV, Directions targetDir, String label,
+ int depth, long degree, long capacity, long limit) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(targetV, "target vertex id");
E.checkNotNull(sourceDir, "source direction");
@@ -106,7 +105,7 @@ public Set paths(Id sourceV, Directions sourceDir,
sourceDir == targetDir.opposite(),
"Source direction must equal to target direction," +
"or opposite to target direction");
- checkPositive(maxDepth, "Paths max depth");
+ checkPositive(depth, "max depth");
checkDegree(degree);
checkCapacity(capacity);
checkLimit(limit);
@@ -120,13 +119,13 @@ public Set paths(Id sourceV, Directions sourceDir,
PathsTraverser traverser = new PathsTraverser(sourceV, targetV, labelId,
degree, capacity, limit);
while (true) {
- if (--maxDepth < 0 || traverser.reachLimit()) {
+ if (--depth < 0 || traverser.reachLimit()) {
break;
}
List foundPaths = traverser.forward(sourceDir);
paths.addAll(foundPaths);
- if (--maxDepth < 0 || traverser.reachLimit()) {
+ if (--depth < 0 || traverser.reachLimit()) {
break;
}
foundPaths = traverser.backward(targetDir);
@@ -139,25 +138,23 @@ public Set paths(Id sourceV, Directions sourceDir,
}
public List rays(Id sourceV, Directions dir, String label,
- int maxDepth, long degree, long capacity,
- long limit) {
- return this.subGraphPaths(sourceV, dir, label, maxDepth, degree,
+ int depth, long degree, long capacity, long limit) {
+ return this.subGraphPaths(sourceV, dir, label, depth, degree,
capacity, limit, false);
}
public List rings(Id sourceV, Directions dir, String label,
- int maxDepth, long degree, long capacity,
- long limit) {
- return this.subGraphPaths(sourceV, dir, label, maxDepth, degree,
+ int depth, long degree, long capacity, long limit) {
+ return this.subGraphPaths(sourceV, dir, label, depth, degree,
capacity, limit, true);
}
private List subGraphPaths(Id sourceV, Directions dir, String label,
- int maxDepth, long degree, long capacity,
+ int depth, long degree, long capacity,
long limit, boolean rings) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(dir, "direction");
- checkPositive(maxDepth, "Paths max depth");
+ checkPositive(depth, "max depth");
checkDegree(degree);
checkCapacity(capacity);
checkLimit(limit);
@@ -169,7 +166,7 @@ private List subGraphPaths(Id sourceV, Directions dir, String label,
List paths = new ArrayList<>();
while (true) {
paths.addAll(traverser.forward(dir));
- if (--maxDepth < 0 || traverser.reachLimit() ||
+ if (--depth < 0 || traverser.reachLimit() ||
traverser.finished()) {
break;
}
@@ -182,7 +179,7 @@ public Set kout(Id sourceV, Directions dir, String label,
long degree, long capacity, long limit) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(dir, "direction");
- checkPositive(depth, "K-out depth");
+ checkPositive(depth, "k-out depth");
checkDegree(degree);
checkCapacity(capacity);
checkLimit(limit);
@@ -238,7 +235,7 @@ public Set kneighbor(Id sourceV, Directions dir,
long degree, long limit) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(dir, "direction");
- checkPositive(depth, "K-neighbor depth");
+ checkPositive(depth, "k-neighbor depth");
checkDegree(degree);
checkLimit(limit);
@@ -312,24 +309,25 @@ private Id getEdgeLabelId(Object label) {
private static void checkPositive(int value, String name) {
E.checkArgument(value > 0,
- "%s must be > 0, but got '%s'", name, value);
+ "The %s parameter must be > 0, but got '%s'",
+ name, value);
}
private static void checkDegree(long degree) {
- checkLimit(degree, "Degree");
+ checkPositiveOrNoLimit(degree, "max degree");
}
private static void checkCapacity(long capacity) {
- checkLimit(capacity, "Capacity");
+ checkPositiveOrNoLimit(capacity, "capacity");
}
private static void checkLimit(long limit) {
- checkLimit(limit, "Limit");
+ checkPositiveOrNoLimit(limit, "limit");
}
- private static void checkLimit(long value, String name) {
+ private static void checkPositiveOrNoLimit(long value, String name) {
E.checkArgument(value > 0 || value == NO_LIMIT,
- "%s must be > 0 or == %s, but got: %s",
+ "The %s parameter must be > 0 or == %s, but got: %s",
name, NO_LIMIT, value);
}