in hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java [3753:3861]
public void testQueryOutEdgesOfVertexBySortkeyWithPrefixInPage() {
Assume.assumeTrue("Not support paging",
storeFeatures().supportsQueryByPage());
HugeGraph graph = graph();
SchemaManager schema = graph.schema();
schema.propertyKey("no").asText().create();
schema.propertyKey("callType").asText().create();
schema.propertyKey("calltime").asDate().create();
schema.vertexLabel("phone")
.properties("no")
.primaryKeys("no")
.enableLabelIndex(false)
.create();
schema.edgeLabel("call").multiTimes()
.properties("callType", "calltime")
.sourceLabel("phone").targetLabel("phone")
.sortKeys("callType", "calltime")
.create();
Vertex v1 = graph.addVertex(T.label, "phone", "no", "13812345678");
Vertex v2 = graph.addVertex(T.label, "phone", "no", "13866668888");
Vertex v10086 = graph.addVertex(T.label, "phone", "no", "10086");
v1.addEdge("call", v2, "callType", "work",
"calltime", "2017-5-1 23:00:00");
v1.addEdge("call", v2, "callType", "work",
"calltime", "2017-5-2 12:00:01");
v1.addEdge("call", v2, "callType", "work",
"calltime", "2017-5-3 12:08:02");
v1.addEdge("call", v2, "callType", "fun",
"calltime", "2017-5-3 22:22:03");
v1.addEdge("call", v2, "callType", "fun",
"calltime", "2017-5-4 20:33:04");
v1.addEdge("call", v10086, "callType", "work",
"calltime", "2017-5-2 15:30:05");
v1.addEdge("call", v10086, "callType", "work",
"calltime", "2017-5-3 14:56:06");
v2.addEdge("call", v10086, "callType", "fun",
"calltime", "2017-5-3 17:28:07");
graph.tx().commit();
Assert.assertEquals(8, graph.traversal().E().toList().size());
List<Edge> edges = graph.traversal().V(v1).outE("call")
.has("callType", "work")
.toList();
Assert.assertEquals(5, edges.size());
Assert.assertEquals(5, traverseInPage(page -> {
return graph.traversal().V(v1).outE("call")
.has("callType", "work")
.has("~page", page).limit(1);
}));
Assert.assertEquals(2, traverseInPage(page -> {
return graph.traversal().V(v1).outE("call")
.has("callType", "fun")
.has("~page", page).limit(1);
}));
edges = graph.traversal().V(v1).outE("call").has("callType", "work")
.has("calltime", "2017-5-1 23:00:00")
.toList();
Assert.assertEquals(1, edges.size());
Assert.assertEquals(Utils.date("2017-5-1 23:00:00"),
edges.get(0).value("calltime"));
edges = graph.traversal().V(v1).outE("call").has("callType", "work")
.has("calltime", P.lt("2017-5-2"))
.toList();
Assert.assertEquals(1, edges.size());
Assert.assertEquals(Utils.date("2017-5-1 23:00:00"),
edges.get(0).value("calltime"));
edges = graph.traversal().V(v1).outE("call").has("callType", "work")
.has("calltime", P.gte("2017-5-2"))
.toList();
Assert.assertEquals(4, edges.size());
Assert.assertEquals(Utils.date("2017-5-2 12:00:01"),
edges.get(0).value("calltime"));
Assert.assertEquals(Utils.date("2017-5-2 15:30:05"),
edges.get(1).value("calltime"));
Assert.assertEquals(Utils.date("2017-5-3 12:08:02"),
edges.get(2).value("calltime"));
Assert.assertEquals(Utils.date("2017-5-3 14:56:06"),
edges.get(3).value("calltime"));
Assert.assertEquals(4, traverseInPage(page -> {
return graph.traversal().V(v1).outE("call")
.has("callType", "work")
.has("calltime", P.gte("2017-5-2"))
.has("~page", page).limit(1);
}));
edges = graph.traversal().V(v1).outE("call")
.has("callType", "work")
.has("calltime", P.between("2017-5-2", "2017-5-4"))
.toList();
Assert.assertEquals(4, edges.size());
Assert.assertEquals(4, traverseInPage(page -> {
return graph.traversal().V(v1).outE("call")
.has("callType", "work")
.has("calltime", P.between("2017-5-2", "2017-5-4"))
.has("~page", page).limit(1);
}));
}