Search in sources :

Example 1 with Vertices

use of com.baidu.hugegraph.structure.graph.Vertices in project incubator-hugegraph-toolchain by apache.

the class TraverserManager method vertices.

public Vertices vertices(Shard shard) {
    Vertices vertices = this.vertices(shard, null, 0L);
    E.checkState(vertices.page() == null, "Can't contains page when not in paging");
    return vertices;
}
Also used : Vertices(com.baidu.hugegraph.structure.graph.Vertices) PathsWithVertices(com.baidu.hugegraph.structure.traverser.PathsWithVertices)

Example 2 with Vertices

use of com.baidu.hugegraph.structure.graph.Vertices in project incubator-hugegraph-toolchain by apache.

the class TraverserManager method vertices.

public Vertices vertices(Shard shard, String page, long pageLimit) {
    E.checkArgument(page == null || pageLimit >= 0, "Page limit must be >= 0 when page is not null");
    Vertices vertices = this.verticesAPI.scan(shard, page, pageLimit);
    for (Vertex vertex : vertices.results()) {
        vertex.attachManager(this.graphManager);
    }
    return vertices;
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Vertices(com.baidu.hugegraph.structure.graph.Vertices) PathsWithVertices(com.baidu.hugegraph.structure.traverser.PathsWithVertices)

Example 3 with Vertices

use of com.baidu.hugegraph.structure.graph.Vertices in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testScanVertexInPaging.

@Test
public void testScanVertexInPaging() {
    List<Shard> shards = verticesAPI.shards(1 * 1024 * 1024);
    List<Vertex> vertices = new LinkedList<>();
    for (Shard shard : shards) {
        String page = "";
        while (page != null) {
            Vertices results = verticesAPI.scan(shard, page, DEFAULT_PAGE_LIMIT);
            vertices.addAll(ImmutableList.copyOf(results.results()));
            page = results.page();
        }
    }
    Assert.assertEquals(6, vertices.size());
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Shard(com.baidu.hugegraph.structure.graph.Shard) LinkedList(java.util.LinkedList) Vertices(com.baidu.hugegraph.structure.graph.Vertices) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Example 4 with Vertices

use of com.baidu.hugegraph.structure.graph.Vertices in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testScanVertex.

@Test
public void testScanVertex() {
    List<Shard> shards = verticesAPI.shards(1 * 1024 * 1024);
    List<Vertex> vertices = new LinkedList<>();
    for (Shard shard : shards) {
        Vertices results = verticesAPI.scan(shard, null, 0L);
        vertices.addAll(ImmutableList.copyOf(results.results()));
        Assert.assertNull(results.page());
    }
    Assert.assertEquals(6, vertices.size());
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Shard(com.baidu.hugegraph.structure.graph.Shard) LinkedList(java.util.LinkedList) Vertices(com.baidu.hugegraph.structure.graph.Vertices) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Example 5 with Vertices

use of com.baidu.hugegraph.structure.graph.Vertices in project incubator-hugegraph-toolchain by apache.

the class BackupManager method backupVertexShard.

private void backupVertexShard(Shard shard) {
    String desc = String.format("backing up vertices[shard:%s]", shard);
    Vertices vertices = null;
    String page = this.initPage();
    TraverserManager g = client.traverser();
    do {
        String p = page;
        try {
            if (page == null) {
                vertices = retry(() -> g.vertices(shard), desc);
            } else {
                vertices = retry(() -> g.vertices(shard, p), desc);
            }
        } catch (ToolsException e) {
            this.exceptionHandler(e, HugeType.VERTEX, shard);
        }
        if (vertices == null) {
            return;
        }
        List<Vertex> vertexList = vertices.results();
        if (vertexList == null || vertexList.isEmpty()) {
            return;
        }
        long count = this.backup(HugeType.VERTEX, suffix.get(), vertexList);
        this.vertexCounter.getAndAdd(count);
        Printer.printInBackward(this.vertexCounter.get());
    } while ((page = vertices.page()) != null);
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) ToolsException(com.baidu.hugegraph.exception.ToolsException) TraverserManager(com.baidu.hugegraph.driver.TraverserManager) Vertices(com.baidu.hugegraph.structure.graph.Vertices)

Aggregations

Vertices (com.baidu.hugegraph.structure.graph.Vertices)5 Vertex (com.baidu.hugegraph.structure.graph.Vertex)4 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)2 Shard (com.baidu.hugegraph.structure.graph.Shard)2 PathsWithVertices (com.baidu.hugegraph.structure.traverser.PathsWithVertices)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 TraverserManager (com.baidu.hugegraph.driver.TraverserManager)1 ToolsException (com.baidu.hugegraph.exception.ToolsException)1