Search in sources :

Example 6 with HugeElement

use of com.baidu.hugegraph.structure.HugeElement in project incubator-hugegraph by apache.

the class VertexCoreTest method testScanVertexInPaging.

@Test
public void testScanVertexInPaging() {
    HugeGraph graph = graph();
    Assume.assumeTrue("Not support scan", storeFeatures().supportsScanToken() || storeFeatures().supportsScanKeyRange());
    this.init10VerticesAndCommit();
    List<Vertex> vertices = new LinkedList<>();
    ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
    String backend = graph.backend();
    if (backend.equals("cassandra") || backend.equals("scylladb")) {
        query.scan(String.valueOf(Long.MIN_VALUE), String.valueOf(Long.MAX_VALUE));
    } else {
        query.scan(BackendTable.ShardSplitter.START, BackendTable.ShardSplitter.END);
    }
    query.limit(1);
    String page = PageInfo.PAGE_NONE;
    while (page != null) {
        query.page(page);
        Iterator<Vertex> iterator = graph.vertices(query);
        while (iterator.hasNext()) {
            Vertex vertex = iterator.next();
            Assert.assertTrue(query.test((HugeElement) vertex));
            vertices.add(vertex);
        }
        page = PageInfo.pageInfo(iterator);
        CloseableIterator.closeIterator(iterator);
    }
    Assert.assertEquals(10, vertices.size());
}
Also used : FakeVertex(com.baidu.hugegraph.testutil.FakeObjects.FakeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) HugeGraph(com.baidu.hugegraph.HugeGraph) ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) LinkedList(java.util.LinkedList) HugeElement(com.baidu.hugegraph.structure.HugeElement) Test(org.junit.Test)

Aggregations

HugeElement (com.baidu.hugegraph.structure.HugeElement)6 GraphTransaction (com.baidu.hugegraph.backend.tx.GraphTransaction)3 HugeType (com.baidu.hugegraph.type.HugeType)3 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)2 IdQuery (com.baidu.hugegraph.backend.query.IdQuery)2 SchemaLabel (com.baidu.hugegraph.schema.SchemaLabel)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 HugeGraph (com.baidu.hugegraph.HugeGraph)1 HugeGraphParams (com.baidu.hugegraph.HugeGraphParams)1 Id (com.baidu.hugegraph.backend.id.Id)1 Query (com.baidu.hugegraph.backend.query.Query)1 SchemaTransaction (com.baidu.hugegraph.backend.tx.SchemaTransaction)1 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)1 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)1 SchemaElement (com.baidu.hugegraph.schema.SchemaElement)1 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)1 FakeVertex (com.baidu.hugegraph.testutil.FakeObjects.FakeVertex)1 SchemaStatus (com.baidu.hugegraph.type.define.SchemaStatus)1 LockUtil (com.baidu.hugegraph.util.LockUtil)1 ImmutableSet (com.google.common.collect.ImmutableSet)1