use of com.baidu.hugegraph.entity.query.ExecuteHistory 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.entity.query.ExecuteHistory in project incubator-hugegraph-toolchain by apache.
the class GremlinQueryController method execute.
@PostMapping
public GremlinResult execute(@PathVariable("connId") int connId, @RequestBody GremlinQuery query) {
this.checkParamsValid(query);
Date createTime = HubbleUtil.nowDate();
// Insert execute history
ExecuteStatus status = ExecuteStatus.RUNNING;
ExecuteHistory history;
history = new ExecuteHistory(null, connId, 0L, ExecuteType.GREMLIN, query.getContent(), status, AsyncTaskStatus.UNKNOWN, -1L, createTime);
this.historyService.save(history);
StopWatch timer = StopWatch.createStarted();
try {
GremlinResult result = this.queryService.executeQuery(connId, query);
status = ExecuteStatus.SUCCESS;
return result;
} catch (Throwable e) {
status = ExecuteStatus.FAILED;
throw e;
} finally {
timer.stop();
long duration = timer.getTime(TimeUnit.MILLISECONDS);
history.setStatus(status);
history.setDuration(duration);
this.historyService.update(history);
}
}
Aggregations