Search in sources :

Example 1 with Edges

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

the class CommonTraverserApiTest method testScanEdgeInPaging.

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

Example 2 with Edges

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

the class CommonTraverserApiTest method testScanEdge.

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

Example 3 with Edges

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

the class BackupManager method backupEdgeShard.

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

Example 4 with Edges

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

the class TraverserManager method edges.

public Edges edges(Shard shard, String page, long pageLimit) {
    E.checkArgument(page == null || pageLimit >= 0, "Page limit must be >= 0 when page is not null");
    Edges edges = this.edgesAPI.scan(shard, page, pageLimit);
    for (Edge edge : edges.results()) {
        edge.attachManager(this.graphManager);
    }
    return edges;
}
Also used : Edges(com.baidu.hugegraph.structure.graph.Edges) Edge(com.baidu.hugegraph.structure.graph.Edge)

Example 5 with Edges

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

the class TraverserManager method edges.

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

Aggregations

Edges (com.baidu.hugegraph.structure.graph.Edges)5 Edge (com.baidu.hugegraph.structure.graph.Edge)4 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)2 Shard (com.baidu.hugegraph.structure.graph.Shard)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