This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
The following commit(s) were added to refs/heads/master by this push:
new 522724879 fix(core): support order by id (#2233)
522724879 is described below
commit 5227248799198086c032ac4c43585c227aeca82c
Author: Liu Xiao <[email protected]>
AuthorDate: Wed Jun 21 18:12:02 2023 +0800
fix(core): support order by id (#2233)
* revert sslmode
---
.../apache/hugegraph/structure/HugeElement.java | 7 +++-
.../org/apache/hugegraph/api/GremlinApiTest.java | 44 ++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
diff --git
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
index 652360307..54e85cc37 100644
---
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
+++
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
@@ -52,7 +52,7 @@ import
org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.eclipse.collections.api.iterator.IntIterator;
import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
-public abstract class HugeElement implements Element, GraphType, Idfiable {
+public abstract class HugeElement implements Element, GraphType, Idfiable,
Comparable<HugeElement> {
private static final MutableIntObjectMap<HugeProperty<?>> EMPTY_MAP =
CollectionFactory.newIntObjectMap();
@@ -407,6 +407,11 @@ public abstract class HugeElement implements Element,
GraphType, Idfiable {
return ElementHelper.hashCode(this);
}
+ @Override
+ public int compareTo(HugeElement o) {
+ return this.id().compareTo(o.id());
+ }
+
/**
* Classify parameter list(pairs) from call request
* @param keyValues The property key-value pair of the vertex or edge
diff --git
a/hugegraph-test/src/main/java/org/apache/hugegraph/api/GremlinApiTest.java
b/hugegraph-test/src/main/java/org/apache/hugegraph/api/GremlinApiTest.java
index 3b4d646e0..57aefeb9b 100644
--- a/hugegraph-test/src/main/java/org/apache/hugegraph/api/GremlinApiTest.java
+++ b/hugegraph-test/src/main/java/org/apache/hugegraph/api/GremlinApiTest.java
@@ -219,4 +219,48 @@ public class GremlinApiTest extends BaseApiTest {
Map data = ((List<Map>) assertMapContains(result, "data")).get(0);
Assert.assertEquals("test.text", data.get("file"));
}
+
+ @Test
+ public void testVertexOrderByDesc() {
+ String body = "{" +
+ "\"gremlin\":\"g.V().order().by(desc)\"," +
+ "\"bindings\":{}," +
+ "\"language\":\"gremlin-groovy\"," +
+ "\"aliases\":{\"g\":\"__g_hugegraph\"}}";
+ Response response = client().post(path, body);
+ assertResponseStatus(200, response);
+ }
+
+ @Test
+ public void testVertexOrderByAsc() {
+ String body = "{" +
+ "\"gremlin\":\"g.V().order().by(asc)\"," +
+ "\"bindings\":{}," +
+ "\"language\":\"gremlin-groovy\"," +
+ "\"aliases\":{\"g\":\"__g_hugegraph\"}}";
+ Response response = client().post(path, body);
+ assertResponseStatus(200, response);
+ }
+
+ @Test
+ public void testEegeOrderByDesc() {
+ String body = "{" +
+ "\"gremlin\":\"g.E().order().by(desc)\"," +
+ "\"bindings\":{}," +
+ "\"language\":\"gremlin-groovy\"," +
+ "\"aliases\":{\"g\":\"__g_hugegraph\"}}";
+ Response response = client().post(path, body);
+ assertResponseStatus(200, response);
+ }
+
+ @Test
+ public void testEdgeOrderByAsc() {
+ String body = "{" +
+ "\"gremlin\":\"g.E().order().by(asc)\"," +
+ "\"bindings\":{}," +
+ "\"language\":\"gremlin-groovy\"," +
+ "\"aliases\":{\"g\":\"__g_hugegraph\"}}";
+ Response response = client().post(path, body);
+ assertResponseStatus(200, response);
+ }
}