Skip to content

Commit

Permalink
refact: remove source from kneighbor/kout results & unify 'degree ' e…
Browse files Browse the repository at this point in the history
…rror info (apache#1463)

remove source vertex from kout algorithm
unify 'degree ' error info & remove source from kneighbor/kout result
  • Loading branch information
imbajin authored and jadepeng committed Jun 25, 2021
1 parent 8edd3cf commit 8a84180
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public String post(@Context GraphManager manager,
"The steps of request can't be null or empty");
E.checkArgumentNotNull(request.dedupSize == NO_LIMIT ||
request.dedupSize >= 0L,
"The dedupSize of request must >= 0, but got '%s'",
"The dedup size of request " +
"must >= 0 or == -1, but got: '%s'",
request.dedupSize);

HugeGraph g = graph(manager, graph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public String post(@Context GraphManager manager,
"The min neighbor count must be > 0, but got: %s",
request.minNeighbors);
E.checkArgument(request.maxDegree > 0L || request.maxDegree == NO_LIMIT,
"The max_degree of request must be > 0, but got: %s",
request.maxDegree);
"The max degree of request must be > 0 or == -1, " +
"but got: %s", request.maxDegree);
E.checkArgument(request.alpha > 0 && request.alpha <= 1.0,
"The alpha of request must be in range (0, 1], " +
"but got '%s'", request.alpha);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public String personalRank(@Context GraphManager manager,
"The alpha of rank request must be in range (0, 1], " +
"but got '%s'", request.alpha);
E.checkArgument(request.maxDegree > 0L || request.maxDegree == NO_LIMIT,
"The max_degree of rank request must be > 0, " +
"but got: %s", request.maxDegree);
"The max degree of rank request must be > 0 " +
"or == -1, but got: %s", request.maxDegree);
E.checkArgument(request.limit > 0L || request.limit == NO_LIMIT,
"The limit of rank request must be > 0, but got: %s",
request.limit);
"The limit of rank request must be > 0 or == -1, " +
"but got: %s", request.limit);
E.checkArgument(request.maxDepth > 0L &&
request.maxDepth <= Long.parseLong(DEFAULT_MAX_DEPTH),
"The max depth of rank request must be " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected void closeTx() {

public void setMinSaveInterval(long seconds) {
E.checkArgument(seconds > 0,
"Must set interval > 0, bug got '%s'", seconds);
"Must set interval > 0, but got '%s'", seconds);
this.saveInterval = seconds * 1000L;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,19 @@ protected Set<Id> adjacentVertices(Id source, EdgeStep step) {
return neighbors;
}

protected Set<Node> adjacentVertices(Set<Node> vertices, EdgeStep step,
Set<Node> excluded, long remaining) {
protected Set<Node> adjacentVertices(Id start, Set<Node> vertices,
EdgeStep step, Set<Node> excluded,
long remaining) {
Set<Node> neighbors = newSet();
for (Node source : vertices) {
Iterator<Edge> edges = this.edgesOfVertex(source.id(), step);
while (edges.hasNext()) {
Id target = ((HugeEdge) edges.next()).id().otherVertexId();
KNode kNode = new KNode(target, (KNode) source);
if ((excluded != null && excluded.contains(kNode)) ||
neighbors.contains(kNode)) {
boolean matchExcluded = (excluded != null &&
excluded.contains(kNode));
if (matchExcluded || neighbors.contains(kNode) ||
start.equals(kNode.id())) {
continue;
}
neighbors.add(kNode);
Expand Down Expand Up @@ -367,7 +370,7 @@ public static void checkSkipDegree(long skipDegree, long degree,
Query.DEFAULT_CAPACITY, skipDegree);
if (capacity != NO_LIMIT) {
E.checkArgument(degree != NO_LIMIT && degree < capacity,
"The degree must be < capacity");
"The max degree must be < capacity");
E.checkArgument(skipDegree < capacity,
"The skipped degree must be < capacity");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Set<Node> customizedKneighbor(Id source, EdgeStep step, int maxDepth,

while (maxDepth-- > 0) {
long remaining = limit == NO_LIMIT ? NO_LIMIT : limit - all.size();
latest = this.adjacentVertices(latest, step, all,
latest = this.adjacentVertices(source, latest, step, all,
remaining, single);
int size = all.size() + latest.size();
if (limit != NO_LIMIT && size >= limit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public Set<Node> customizedKout(Id source, EdgeStep step, int maxDepth,
NO_LIMIT : capacity - latest.size();
while (depth-- > 0) {
if (nearest) {
latest = this.adjacentVertices(latest, step, all,
latest = this.adjacentVertices(source, latest, step, all,
remaining, single);
all.addAll(latest);
} else {
latest = this.adjacentVertices(latest, step, null,
latest = this.adjacentVertices(source, latest, step, null,
remaining, single);
}
if (capacity != NO_LIMIT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ public void add(Node node) {

public long degree() {
E.checkArgument(this.degree > 0,
"The degree must be > 0, but got %s", this.degree);
"The max degree must be > 0, but got %s",
this.degree);
return this.degree;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public static void destroy() {
}
}

protected Set<Node> adjacentVertices(Set<Node> latest, EdgeStep step,
Set<Node> all, long remaining,
boolean single) {
protected Set<Node> adjacentVertices(Id source, Set<Node> latest,
EdgeStep step, Set<Node> all,
long remaining, boolean single) {
if (single) {
return this.adjacentVertices(latest, step, all, remaining);
return this.adjacentVertices(source, latest, step, all, remaining);
} else {
AtomicLong remain = new AtomicLong(remaining);
return this.adjacentVertices(latest, step, all, remain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public EdgeStep(HugeGraph g, Directions direction, List<String> labels,
Map<String, Object> properties,
long degree, long skipDegree) {
E.checkArgument(degree == NO_LIMIT || degree > 0L,
"The degree must be > 0 or == -1, but got: %s",
"The max degree must be > 0 or == -1, but got: %s",
degree);
HugeTraverser.checkSkipDegree(skipDegree, degree,
HugeTraverser.NO_LIMIT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public WeightedEdgeStep(HugeGraph g, Directions direction, List<String> labels,
"The sample must be > 0 or == -1, but got: %s",
sample);
E.checkArgument(maxDegree == NO_LIMIT || maxDegree >= sample,
"The max_degree must be greater than or equal to " +
"sample, but got max_degree %s and sample %s",
"The max degree must be greater than or equal to " +
"sample, but got max degree %s and sample %s",
maxDegree, sample);

this.edgeStep = new EdgeStep(g, direction, labels, properties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public static void initOptions(HugeConfig conf,
E.checkArgument(compressions.isEmpty() ||
compressions.size() == numLevels,
"Elements number of '%s' must be 0 or " +
"be the same as '%s', bug got %s != %s",
"be the same as '%s', but got %s != %s",
RocksDBOptions.LEVELS_COMPRESSIONS.name(),
RocksDBOptions.NUM_LEVELS.name(),
compressions.size(), numLevels);
Expand Down

0 comments on commit 8a84180

Please sign in to comment.