Search in sources :

Example 81 with Edge

use of com.baidu.hugegraph.structure.graph.Edge 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 82 with Edge

use of com.baidu.hugegraph.structure.graph.Edge 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 83 with Edge

use of com.baidu.hugegraph.structure.graph.Edge 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)

Example 84 with Edge

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

the class BatchUpdateElementApiTest method testEdgeBatchUpdateWithNullValues.

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

Example 85 with Edge

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

the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategySum.

/* Edge Test */
@Test
public void testEdgeBatchUpdateStrategySum() {
    BatchEdgeRequest req = batchEdgeRequest("price", -1, 1, UpdateStrategy.SUM);
    List<Edge> edges = edgeAPI.update(req);
    assertBatchResponse(edges, "price", 0);
    req = batchEdgeRequest("price", 2, 3, UpdateStrategy.SUM);
    edges = edgeAPI.update(req);
    assertBatchResponse(edges, "price", 5);
}
Also used : BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test)

Aggregations

Edge (com.baidu.hugegraph.structure.graph.Edge)103 Test (org.junit.Test)73 Vertex (com.baidu.hugegraph.structure.graph.Vertex)33 ArrayList (java.util.ArrayList)22 BaseClientTest (com.baidu.hugegraph.BaseClientTest)20 BatchEdgeRequest (com.baidu.hugegraph.structure.graph.BatchEdgeRequest)12 HugeClient (com.baidu.hugegraph.driver.HugeClient)10 Path (com.baidu.hugegraph.structure.graph.Path)9 Result (com.baidu.hugegraph.structure.gremlin.Result)8 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)7 RestResult (com.baidu.hugegraph.rest.RestResult)5 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)5 GraphManager (com.baidu.hugegraph.driver.GraphManager)4 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)4 GraphView (com.baidu.hugegraph.entity.query.GraphView)4 Edges (com.baidu.hugegraph.structure.graph.Edges)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 GremlinResult (com.baidu.hugegraph.entity.query.GremlinResult)3 TypedResult (com.baidu.hugegraph.entity.query.TypedResult)3