Search in sources :

Example 66 with HugeClient

use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.

the class InsertTask method updateBatch.

@SuppressWarnings("unchecked")
protected void updateBatch(List<Record> batch, boolean checkVertex) {
    HugeClient client = this.context.client();
    List<GraphElement> elements = new ArrayList<>(batch.size());
    batch.forEach(r -> elements.add(r.element()));
    // CreateIfNotExist dose not support false now
    if (this.type().isVertex()) {
        BatchVertexRequest.Builder req = new BatchVertexRequest.Builder();
        req.vertices((List<Vertex>) (Object) elements).updatingStrategies(this.mapping.updateStrategies()).createIfNotExist(true);
        client.graph().updateVertices(req.build());
    } else {
        BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder();
        req.edges((List<Edge>) (Object) elements).updatingStrategies(this.mapping.updateStrategies()).checkVertex(checkVertex).createIfNotExist(true);
        client.graph().updateEdges(req.build());
    }
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) BatchVertexRequest(com.baidu.hugegraph.structure.graph.BatchVertexRequest) BatchEdgeRequest(com.baidu.hugegraph.structure.graph.BatchEdgeRequest) GraphElement(com.baidu.hugegraph.structure.GraphElement) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

HugeClient (com.baidu.hugegraph.driver.HugeClient)66 Vertex (com.baidu.hugegraph.structure.graph.Vertex)21 ArrayList (java.util.ArrayList)16 ExternalException (com.baidu.hugegraph.exception.ExternalException)15 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)14 ServerException (com.baidu.hugegraph.exception.ServerException)12 GraphManager (com.baidu.hugegraph.driver.GraphManager)11 Edge (com.baidu.hugegraph.structure.graph.Edge)10 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)9 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)8 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)8 Test (org.junit.Test)8 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)7 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)6 ExecuteHistory (com.baidu.hugegraph.entity.query.ExecuteHistory)4 GraphView (com.baidu.hugegraph.entity.query.GraphView)4 LoadOptions (com.baidu.hugegraph.loader.executor.LoadOptions)4 ClientException (com.baidu.hugegraph.rest.ClientException)4 BeforeClass (org.junit.BeforeClass)4 GraphConnection (com.baidu.hugegraph.entity.GraphConnection)3