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());
}
}
Aggregations