use of ai.grakn.util.REST.Request.Graql.LOADING_DATA in project grakn by graknlabs.
the class GraknClientImpl method graqlExecute.
@Override
public List<QueryResponse> graqlExecute(List<Query<?>> queryList, Keyspace keyspace) throws GraknClientException {
LOG.debug("Sending query list size {} to keyspace {}", queryList.size(), keyspace);
String body = queryList.stream().map(Object::toString).reduce("; ", String::concat).substring(2);
URI fullURI = UriBuilder.fromUri(uri.toURI()).path(REST.resolveTemplate(REST.WebPath.KEYSPACE_GRAQL, keyspace.getValue())).queryParam(ALLOW_MULTIPLE_QUERIES, true).queryParam(EXECUTE_WITH_INFERENCE, // Making inference true could lead to non-deterministic loading of data
false).queryParam(LOADING_DATA, // Skip serialising responses for the sake of efficiency
true).queryParam(TX_TYPE, GraknTxType.BATCH).build();
ClientResponse response = client.resource(fullURI).accept(APPLICATION_JSON).post(ClientResponse.class, body);
try {
Response.StatusType status = response.getStatusInfo();
String entity = response.getEntity(String.class);
if (!status.getFamily().equals(Family.SUCCESSFUL)) {
String queries = queryList.stream().map(Object::toString).collect(Collectors.joining("\n"));
throw new GraknClientException("Failed graqlExecute. Error status: " + status.getStatusCode() + ", error info: " + entity + "\nqueries: " + queries, response.getStatusInfo());
}
LOG.debug("Received {}", status.getStatusCode());
return queryList.stream().map(q -> QueryResponse.INSTANCE).collect(Collectors.toList());
} finally {
response.close();
}
}
Aggregations