Search in sources :

Example 6 with BatchEdgeRequest

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

the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategySmaller.

@Test
public void testEdgeBatchUpdateStrategySmaller() {
    BatchEdgeRequest req = batchEdgeRequest("price", -3, 1, UpdateStrategy.SMALLER);
    List<Edge> edges = edgeAPI.update(req);
    assertBatchResponse(edges, "price", -3);
    req = batchEdgeRequest("price", 7, 3, UpdateStrategy.SMALLER);
    edges = edgeAPI.update(req);
    assertBatchResponse(edges, "price", 3);
}
Also used : BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test)

Example 7 with BatchEdgeRequest

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

the class BatchElementRequestTest method testEdgeRequestBuildOK.

@Test
public void testEdgeRequestBuildOK() {
    List<Edge> edges = ImmutableList.of(createEdge());
    Map<String, UpdateStrategy> strategies = ImmutableMap.of("set", INTERSECTION);
    BatchEdgeRequest req;
    req = new BatchEdgeRequest.Builder().edges(edges).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
    Assert.assertNotNull(req);
    Object list = Whitebox.getInternalState(req, "edges");
    Assert.assertEquals(edges, list);
    Object map = Whitebox.getInternalState(req, "updateStrategies");
    Assert.assertEquals(strategies, map);
    Object checked = Whitebox.getInternalState(req, "checkVertex");
    Assert.assertEquals(false, checked);
    Object created = Whitebox.getInternalState(req, "createIfNotExist");
    Assert.assertEquals(true, created);
}
Also used : BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) UpdateStrategy(com.baidu.hugegraph.structure.graph.UpdateStrategy) Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test)

Example 8 with BatchEdgeRequest

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

the class BatchUpdateElementApiTest method batchEdgeRequest.

private BatchEdgeRequest batchEdgeRequest(String key, Object oldData, Object newData, UpdateStrategy strategy) {
    // Init old vertices & edges
    graph().addVertices(this.createNVertexBatch("object", oldData, BATCH_SIZE * 2));
    graph().addEdges(this.createNEdgesBatch("object", "updates", oldData, BATCH_SIZE));
    List<Edge> edges = this.createNEdgesBatch("object", "updates", newData, BATCH_SIZE);
    Map<String, UpdateStrategy> strategies = ImmutableMap.of(key, strategy);
    BatchEdgeRequest req;
    req = new BatchEdgeRequest.Builder().edges(edges).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
    return req;
}
Also used : BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) UpdateStrategy(com.baidu.hugegraph.structure.graph.UpdateStrategy) Edge(com.baidu.hugegraph.structure.graph.Edge)

Example 9 with BatchEdgeRequest

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

the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategyUnion.

@Test
public void testEdgeBatchUpdateStrategyUnion() {
    BatchEdgeRequest req = batchEdgeRequest("set", "old", "new", UpdateStrategy.UNION);
    List<Edge> edges = edgeAPI.update(req);
    assertBatchResponse(edges, "set", "new", "old");
    req = batchEdgeRequest("set", "old", "old", UpdateStrategy.UNION);
    edges = edgeAPI.update(req);
    assertBatchResponse(edges, "set", "old");
}
Also used : BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test)

Example 10 with BatchEdgeRequest

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

the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategyIntersection.

@Test
public void testEdgeBatchUpdateStrategyIntersection() {
    BatchEdgeRequest req = batchEdgeRequest("set", "old", "new", INTERSECTION);
    List<Edge> edges = edgeAPI.update(req);
    assertBatchResponse(edges, "set");
    req = batchEdgeRequest("set", "old", "old", INTERSECTION);
    edges = edgeAPI.update(req);
    assertBatchResponse(edges, "set", "old");
}
Also used : BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test)

Aggregations

BatchEdgeRequest (com.baidu.hugegraph.structure.graph.BatchEdgeRequest)13 Edge (com.baidu.hugegraph.structure.graph.Edge)12 Test (org.junit.Test)12 UpdateStrategy (com.baidu.hugegraph.structure.graph.UpdateStrategy)3