Skip to content

Commit

Permalink
tiny improve
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin committed Nov 28, 2023
1 parent e08b25e commit c0e2ea6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@

import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_LIMIT;

import com.codahale.metrics.annotation.Timed;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.inject.Singleton;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import java.util.Iterator;

import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.backend.id.Id;
import org.apache.hugegraph.core.GraphManager;
Expand All @@ -35,7 +31,18 @@
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.slf4j.Logger;

import java.util.Iterator;
import com.codahale.metrics.annotation.Timed;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.inject.Singleton;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;

@Path("graphs/{graph}/traversers/edgeexist")
@Singleton
Expand All @@ -58,7 +65,7 @@ public String get(@Context GraphManager manager,
@DefaultValue(DEFAULT_EMPTY) String sortValues,
@QueryParam("limit")
@DefaultValue(DEFAULT_LIMIT) long limit) {
LOG.debug("Graph [{}] get edgeexistence with " +
LOG.debug("Graph [{}] get edgeExistence with " +

Check warning on line 68 in hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java#L68

Added line #L68 was not covered by tests
"source '{}', target '{}', edgeLabel '{}', sortValue '{}', limit '{}'",
graph, source, target, edgeLabel, sortValues, limit);

Check warning on line 70 in hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java#L70

Added line #L70 was not covered by tests

Expand All @@ -69,7 +76,8 @@ public String get(@Context GraphManager manager,
Id targetId = HugeVertex.getIdValue(target);
HugeGraph hugegraph = graph(manager, graph);
EdgeExistenceTraverser traverser = new EdgeExistenceTraverser(hugegraph);
Iterator<Edge> edges = traverser.queryEdgeExistence(sourceId, targetId, edgeLabel, sortValues, limit);
Iterator<Edge> edges = traverser.queryEdgeExistence(sourceId, targetId, edgeLabel,

Check warning on line 79 in hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java#L75-L79

Added lines #L75 - L79 were not covered by tests
sortValues, limit);

return manager.serializer(hugegraph).writeEdges(edges, false);

Check warning on line 82 in hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java#L82

Added line #L82 was not covered by tests
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class ApiVersion {
* [0.2] HugeGraph-527: First add the version to the hugegraph module
* [0.3] HugeGraph-525: Add versions check of components and api
* [0.4] HugeGraph-162: Add schema builder to separate client and inner interface.
* [0.5] HugeGraph-498: Support three kind of id strategy
* [0.5] HugeGraph-498: Support three kinds of id strategy
* <p>
* version 0.3:
* <p>
Expand All @@ -41,12 +41,12 @@ public final class ApiVersion {
* <p>
* version 0.4:
* [0.11] HugeGraph-938: Remove useless index-names field in VL/EL API
* [0.12] HugeGraph-589: Add schema id for all schema element
* [0.12] HugeGraph-589: Add schema id for all schema elements
* [0.13] HugeGraph-956: Support customize string/number id strategy
* <p>
* version 0.5:
* [0.14] HugeGraph-1085: Add enable_label_index to VL/EL
* [0.15] HugeGraph-1105: Support paging for large amounts of records
* [0.15] HugeGraph-1105: Support paging for large numbers of records
* [0.16] HugeGraph-944: Support rest shortest path, k-out, k-neighbor
* [0.17] HugeGraph-944: Support rest shortest path, k-out, k-neighbor
* [0.18] HugeGraph-81: Change argument "checkVertex" to "check_vertex"
Expand Down Expand Up @@ -75,7 +75,7 @@ public final class ApiVersion {
* [0.34] Issue-307: Let VertexAPI use simplified property serializer
* [0.35] Issue-287: Support pagination when do index query
* [0.36] Issue-360: Support paging for scan api
* [0.37] Issue-391: Add skip_super_node for shortest path
* [0.37] Issue-391: Add skip_super_node for the shortest path
* [0.38] Issue-274: Add personal-rank and neighbor-rank RESTful API
* <p>
* version 0.10:
Expand Down Expand Up @@ -120,11 +120,12 @@ public final class ApiVersion {

/**
* The second parameter of Version.of() is for IDE running without JAR
* Note: Also update the version number in hugegraph-api/pom.xml
*/
public static final Version VERSION = Version.of(ApiVersion.class, "0.71");

public static void check() {
// Check version of hugegraph-core. Firstly do check from version 0.3
// Check the version of hugegraph-core. Do first check from version 0.3
VersionUtil.check(CoreVersion.VERSION, "1.0", "1.6", CoreVersion.NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.hugegraph.traversal.algorithm;

import java.util.Iterator;

import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.backend.id.Id;
import org.apache.hugegraph.backend.query.ConditionQuery;
Expand All @@ -27,8 +29,6 @@
import org.apache.hugegraph.type.define.HugeKeys;
import org.apache.tinkerpop.gremlin.structure.Edge;

import java.util.Iterator;

public class EdgeExistenceTraverser extends HugeTraverser {

public EdgeExistenceTraverser(HugeGraph graph) {
Expand All @@ -37,7 +37,7 @@ public EdgeExistenceTraverser(HugeGraph graph) {

public Iterator<Edge> queryEdgeExistence(Id sourceId, Id targetId, String label,
String sortValues, long limit) {
// If no label provided, fallback to slow query by filtering
// If no label provided, fallback to a slow query by filtering
if (label == null || label.isEmpty()) {
return queryByNeighbors(sourceId, targetId, limit);

Check warning on line 42 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/EdgeExistenceTraverser.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/EdgeExistenceTraverser.java#L42

Added line #L42 was not covered by tests
}
Expand All @@ -60,7 +60,7 @@ public Iterator<Edge> queryEdgeExistence(Id sourceId, Id targetId, String label,
}

private Iterator<Edge> queryByNeighbors(Id sourceId, Id targetId, long limit) {
return new FilterIterator<>(edgesOfVertex(sourceId, Directions.OUT, (Id) null, limit),
return new FilterIterator<>(edgesOfVertex(sourceId, Directions.OUT, (Id) null, limit),
edge -> targetId.equals(edge.inVertex().id()));

Check warning on line 64 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/EdgeExistenceTraverser.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/EdgeExistenceTraverser.java#L63-L64

Added lines #L63 - L64 were not covered by tests
}
}

0 comments on commit c0e2ea6

Please sign in to comment.