Skip to content

Commit

Permalink
fix(core): support order by id (apache#2233)
Browse files Browse the repository at this point in the history
* revert sslmode
  • Loading branch information
liuxiaocs7 committed Jun 21, 2023
1 parent 80a4cd6 commit 5227248
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
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();
Expand Down Expand Up @@ -407,6 +407,11 @@ public int hashCode() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,48 @@ public void testFileSerialize() {
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);
}
}

0 comments on commit 5227248

Please sign in to comment.