Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public CountTraverser(HugeGraph graph) {

public long count(Id source, List<Step> steps,
boolean containsTraversed, long dedupSize) {
E.checkArgumentNotNull(source, "The source can't be null");
E.checkNotNull(source, "source vertex id");
this.checkVertexExist(source, "source vertex");
E.checkArgument(steps != null && !steps.isEmpty(),
"The steps can't be empty");
checkDedupSize(dedupSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.tx.GraphTransaction;
import com.baidu.hugegraph.exception.NotFoundException;
import com.baidu.hugegraph.iterator.ExtendableIterator;
import com.baidu.hugegraph.iterator.MapperIterator;
import com.baidu.hugegraph.schema.SchemaLabel;
Expand Down Expand Up @@ -92,6 +93,7 @@ public Set<Id> kout(Id sourceV, Directions dir, String label,
int depth, boolean nearest,
long degree, long capacity, long limit) {
E.checkNotNull(sourceV, "source vertex id");
this.checkVertexExist(sourceV, "source vertex");
E.checkNotNull(dir, "direction");
checkPositive(depth, "k-out max_depth");
checkDegree(degree);
Expand Down Expand Up @@ -148,6 +150,7 @@ public Set<Id> kneighbor(Id sourceV, Directions dir,
String label, int depth,
long degree, long limit) {
E.checkNotNull(sourceV, "source vertex id");
this.checkVertexExist(sourceV, "source vertex");
E.checkNotNull(dir, "direction");
checkPositive(depth, "k-neighbor max_depth");
checkDegree(degree);
Expand Down Expand Up @@ -178,6 +181,8 @@ public Set<Id> sameNeighbors(Id vertex, Id other, Directions direction,
String label, long degree, long limit) {
E.checkNotNull(vertex, "vertex id");
E.checkNotNull(other, "the other vertex id");
this.checkVertexExist(vertex, "vertex");
this.checkVertexExist(other, "other vertex");
E.checkNotNull(direction, "direction");
checkDegree(degree);
checkLimit(limit);
Expand All @@ -201,6 +206,8 @@ public double jaccardSimilarity(Id vertex, Id other, Directions dir,
String label, long degree) {
E.checkNotNull(vertex, "vertex id");
E.checkNotNull(other, "the other vertex id");
this.checkVertexExist(vertex, "vertex");
this.checkVertexExist(other, "other vertex");
E.checkNotNull(dir, "direction");
checkDegree(degree);

Expand Down Expand Up @@ -380,6 +387,15 @@ protected Id getEdgeLabelId(Object label) {
return SchemaLabel.getLabelId(this.graph, HugeType.EDGE, label);
}

protected void checkVertexExist(Id vertexId, String name) {
try {
this.graph.vertex(vertexId);
} catch (NotFoundException e) {
throw new IllegalArgumentException(String.format(
"The %s with id '%s' does not exist", name, vertexId), e);
}
}

public static void checkDegree(long degree) {
checkPositiveOrNoLimit(degree, "max degree");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public NeighborRankTraverser(HugeGraph graph, double alpha, long capacity) {
}

public List<Map<Id, Double>> neighborRank(Id source, List<Step> steps) {
E.checkArgumentNotNull(source, "The source vertex id can't be null");
E.checkNotNull(source, "source vertex id");
this.checkVertexExist(source, "source vertex");
E.checkArgument(!steps.isEmpty(), "The steps can't be empty");

MultivaluedMap<Id, Node> sources = newMultivalueMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public PathSet paths(Id sourceV, Directions sourceDir,
int depth, long degree, long capacity, long limit) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(targetV, "target vertex id");
this.checkVertexExist(sourceV, "source vertex");
this.checkVertexExist(targetV, "target vertex");
E.checkNotNull(sourceDir, "source direction");
E.checkNotNull(targetDir, "target direction");
E.checkArgument(sourceDir == targetDir ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public PersonalRankTraverser(HugeGraph graph, double alpha,

public Map<Id, Double> personalRank(Id source, String label,
WithLabel withLabel) {
E.checkArgumentNotNull(source, "The source vertex id can't be null");
E.checkNotNull(source, "source vertex id");
this.checkVertexExist(source, "source vertex");
E.checkArgumentNotNull(label, "The edge label can't be null");

Map<Id, Double> ranks = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public Path shortestPath(Id sourceV, Id targetV, Directions dir,
long skipDegree, long capacity) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(targetV, "target vertex id");
this.checkVertexExist(sourceV, "source vertex");
this.checkVertexExist(targetV, "target vertex");
E.checkNotNull(dir, "direction");
checkPositive(depth, "max depth");
checkDegree(degree);
Expand Down Expand Up @@ -84,6 +86,8 @@ public PathSet allShortestPaths(Id sourceV, Id targetV, Directions dir,
long skipDegree, long capacity) {
E.checkNotNull(sourceV, "source vertex id");
E.checkNotNull(targetV, "target vertex id");
this.checkVertexExist(sourceV, "source vertex");
this.checkVertexExist(targetV, "target vertex");
E.checkNotNull(dir, "direction");
checkPositive(depth, "max depth");
checkDegree(degree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public WeightedPaths singleSourceShortestPaths(Id sourceV, Directions dir,
long degree, long skipDegree,
long capacity, long limit) {
E.checkNotNull(sourceV, "source vertex id");
this.checkVertexExist(sourceV, "source vertex");
E.checkNotNull(dir, "direction");
checkDegree(degree);
checkCapacity(capacity);
Expand All @@ -75,6 +76,7 @@ public NodeWithWeight weightedShortestPath(Id sourceV, Id targetV,
String weight, long degree,
long skipDegree, long capacity) {
E.checkNotNull(sourceV, "source vertex id");
this.checkVertexExist(sourceV, "source vertex");
E.checkNotNull(dir, "direction");
E.checkNotNull(weight, "weight property");
checkDegree(degree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private PathSet subGraphPaths(Id sourceV, Directions dir, String label,
long limit, boolean rings,
boolean sourceInRing) {
E.checkNotNull(sourceV, "source vertex id");
this.checkVertexExist(sourceV, "source vertex");
E.checkNotNull(dir, "direction");
checkPositive(depth, "max depth");
checkDegree(degree);
Expand Down