use of ai.grakn.rpc.generated.GrpcIterator.IteratorId in project grakn by graknlabs.
the class GrpcServerTest method whenExecutingQueryWithoutInferenceSet_InferenceIsNotSet.
@Test
public void whenExecutingQueryWithoutInferenceSet_InferenceIsNotSet() throws InterruptedException {
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.WRITE));
tx.send(execQueryRequest(QUERY, null));
IteratorId iterator = tx.receive().ok().getIteratorId();
tx.send(nextRequest(iterator));
tx.send(stopRequest(iterator));
}
verify(tx.graql(), times(0)).infer(anyBoolean());
}
use of ai.grakn.rpc.generated.GrpcIterator.IteratorId in project grakn by graknlabs.
the class GrpcIterators method add.
/**
* Register a new iterator and return the ID of the iterator
*/
public IteratorId add(Iterator<TxResponse> iterator) {
IteratorId iteratorId = IteratorId.newBuilder().setId(iteratorIdCounter.getAndIncrement()).build();
iterators.put(iteratorId, iterator);
return iteratorId;
}
use of ai.grakn.rpc.generated.GrpcIterator.IteratorId in project grakn by graknlabs.
the class TxObserver method getAttributesByValue.
private void getAttributesByValue(AttributeValue attributeValue) {
Collection<Attribute<Object>> attributes = tx().getAttributesByValue(GrpcUtil.convert(attributeValue));
Iterator<TxResponse> iterator = attributes.stream().map(GrpcUtil::conceptResponse).iterator();
IteratorId iteratorId = grpcIterators.add(iterator);
responseObserver.onNext(TxResponse.newBuilder().setIteratorId(iteratorId).build());
}
use of ai.grakn.rpc.generated.GrpcIterator.IteratorId in project grakn by graknlabs.
the class TxObserver method execQuery.
private void execQuery(ExecQuery request) {
String queryString = request.getQuery().getValue();
QueryBuilder graql = tx().graql();
if (request.hasInfer()) {
graql = graql.infer(request.getInfer().getValue());
}
Stream<QueryResult> queryResultStream = graql.parse(queryString).results(GrpcConverter.get());
Stream<TxResponse> txResponseStream = queryResultStream.map(queryResult -> TxResponse.newBuilder().setQueryResult(queryResult).build());
Iterator<TxResponse> iterator = txResponseStream.iterator();
IteratorId iteratorId = grpcIterators.add(iterator);
responseObserver.onNext(TxResponse.newBuilder().setIteratorId(iteratorId).build());
}
use of ai.grakn.rpc.generated.GrpcIterator.IteratorId in project grakn by graknlabs.
the class TxObserver method stop.
private void stop(Stop stop) {
IteratorId iteratorId = stop.getIteratorId();
grpcIterators.stop(iteratorId);
responseObserver.onNext(GrpcUtil.doneResponse());
}
Aggregations