use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class HugeClientPoolService method remove.
public void remove(GraphConnection connection) {
HugeClient client = super.remove(connection.getId());
if (client == null) {
return;
}
client.close();
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class OltpAlgoService method shortestPath.
public GremlinResult shortestPath(int connId, ShortestPath body) {
HugeClient client = this.getClient(connId);
TraverserManager traverser = client.traverser();
Path result = traverser.shortestPath(body.getSource(), body.getTarget(), body.getDirection(), body.getLabel(), body.getMaxDepth(), body.getMaxDegree(), body.getSkipDegree(), body.getCapacity());
JsonView jsonView = new JsonView();
jsonView.setData(result.objects());
Date createTime = HubbleUtil.nowDate();
TableView tableView = this.buildPathTableView(result);
GraphView graphView = this.buildPathGraphView(result);
// Insert execute history
ExecuteStatus status = ExecuteStatus.SUCCESS;
ExecuteHistory history;
history = new ExecuteHistory(null, connId, 0L, ExecuteType.ALGORITHM, body.toString(), status, AsyncTaskStatus.UNKNOWN, -1L, createTime);
this.historyService.save(history);
return GremlinResult.builder().type(GremlinResult.Type.PATH).jsonView(jsonView).tableView(tableView).graphView(graphView).build();
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method checkUsing.
public boolean checkUsing(String name, int connId) {
HugeClient client = this.client(connId);
List<EdgeLabel> edgeLabels = client.schema().getEdgeLabels();
for (EdgeLabel edgeLabel : edgeLabels) {
if (edgeLabel.linkedVertexLabel(name)) {
return true;
}
}
return false;
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method reuse.
public void reuse(ConflictDetail detail, int connId) {
// Assume that the conflict detail is valid
Ex.check(!detail.hasConflict(), "schema.cannot-reuse-conflict");
HugeClient client = this.client(connId);
List<PropertyKey> propertyKeys = this.pkService.filter(detail, client);
if (!propertyKeys.isEmpty()) {
try {
this.pkService.addBatch(propertyKeys, client);
} catch (Exception e) {
throw new ExternalException("schema.propertykey.reuse.failed", e);
}
}
List<VertexLabel> vertexLabels = this.filter(detail, client);
// Filter propertykeys and propertyindexes
if (!vertexLabels.isEmpty()) {
try {
this.addBatch(vertexLabels, client);
} catch (Exception e) {
this.pkService.removeBatch(propertyKeys, client);
throw new ExternalException("schema.vertexlabel.reuse.failed", e);
}
}
List<IndexLabel> indexLabels = this.piService.filter(detail, client);
if (!indexLabels.isEmpty()) {
try {
this.piService.addBatch(indexLabels, client);
} catch (Exception e) {
this.removeBatch(vertexLabels, client);
this.pkService.removeBatch(propertyKeys, client);
throw new ExternalException("schema.propertyindex.reuse.failed", e);
}
}
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method remove.
public void remove(String name, int connId) {
HugeClient client = this.client(connId);
client.schema().removeVertexLabelAsync(name);
}
Aggregations