use of com.alibaba.maxgraph.proto.groot.LoadJsonSchemaResponse in project GraphScope by alibaba.
the class MaxTestGraph method loadSchema.
public void loadSchema(LoadGraphWith.GraphData graphData) throws URISyntaxException, IOException {
String schemaResource = graphData.name().toLowerCase() + ".schema";
Path path = Paths.get(Thread.currentThread().getContextClassLoader().getResource(schemaResource).toURI());
String json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
CompletableFuture<String> future = new CompletableFuture<>();
clientService.loadJsonSchema(LoadJsonSchemaRequest.newBuilder().setSchemaJson(json).build(), new StreamObserver<LoadJsonSchemaResponse>() {
@Override
public void onNext(LoadJsonSchemaResponse value) {
future.complete(value.getGraphDef().toString());
}
@Override
public void onError(Throwable t) {
future.completeExceptionally(t);
}
@Override
public void onCompleted() {
}
});
try {
String schemaString = future.get();
logger.info("load json schema: " + schemaString);
} catch (Exception e) {
throw new MaxGraphException(e);
}
}
Aggregations