use of com.vaticle.typedb.core.reasoner.resolution.framework.Request in project grakn by graknlabs.
the class ConcludableResolver method receiveFail.
@Override
protected void receiveFail(Response.Fail fromDownstream, int iteration) {
LOG.trace("{}: received Fail: {}", name(), fromDownstream);
if (isTerminated())
return;
Request toDownstream = fromDownstream.sourceRequest();
Request fromUpstream = fromUpstream(toDownstream);
if (iteration < iterationByRoot.get(fromUpstream.partialAnswer().root())) {
// short circuit old iteration failed messages to upstream
failToUpstream(fromUpstream, iteration);
} else {
CachingRequestState<?, ConceptMap> requestState = this.requestStates.get(fromUpstream);
assert iteration == requestState.iteration();
if (requestState.isExploration()) {
requestState.asExploration().downstreamManager().removeDownstream(fromDownstream.sourceRequest());
}
nextAnswer(fromUpstream, requestState, iteration);
}
}
use of com.vaticle.typedb.core.reasoner.resolution.framework.Request in project grakn by graknlabs.
the class ConclusionResolver method receiveAnswer.
@Override
protected void receiveAnswer(Response.Answer fromDownstream, int iteration) {
LOG.trace("{}: received Answer: {}", name(), fromDownstream);
if (isTerminated())
return;
Request toDownstream = fromDownstream.sourceRequest();
Request fromUpstream = fromUpstream(toDownstream);
ConclusionRequestState<? extends Partial.Concludable<?>> requestState = this.requestStates.get(fromUpstream);
if (!requestState.isComplete()) {
FunctionalIterator<Map<Identifier.Variable, Concept>> materialisations = conclusion.materialise(fromDownstream.answer().conceptMap(), traversalEngine, conceptMgr);
if (!materialisations.hasNext())
throw TypeDBException.of(ILLEGAL_STATE);
requestState.newMaterialisedAnswers(fromDownstream.answer(), materialisations);
}
nextAnswer(fromUpstream, requestState, iteration);
}
use of com.vaticle.typedb.core.reasoner.resolution.framework.Request in project grakn by graknlabs.
the class ConjunctionResolver method receiveFail.
@Override
protected void receiveFail(Response.Fail fromDownstream, int iteration) {
LOG.trace("{}: Receiving Exhausted: {}", name(), fromDownstream);
if (isTerminated())
return;
Request toDownstream = fromDownstream.sourceRequest();
Request fromUpstream = fromUpstream(toDownstream);
RequestState requestState = this.requestStates.get(fromUpstream);
if (iteration < requestState.iteration()) {
// short circuit old iteration failed messages to upstream
failToUpstream(fromUpstream, iteration);
return;
}
requestState.downstreamManager().removeDownstream(fromDownstream.sourceRequest());
nextAnswer(fromUpstream, requestState, iteration);
}
use of com.vaticle.typedb.core.reasoner.resolution.framework.Request in project grakn by graknlabs.
the class NegationResolver method tryAnswer.
private void tryAnswer(Request fromUpstream, BoundsState boundsState) {
/*
NOTE:
Correctness: concludables that get reused in the negated portion, would conflate recursion/reiteration state from
the toplevel root with the negation iterations, which we cannot allow. So, we must use THIS resolver
as a sort of new root!
*/
assert fromUpstream.partialAnswer().isCompound();
Compound.Nestable downstreamPartial = fromUpstream.partialAnswer().asCompound().filterToNestable(negated.retrieves());
Request request = Request.create(driver(), this.downstream, downstreamPartial);
requestFromDownstream(request, fromUpstream, 0);
boundsState.setRequested();
}
use of com.vaticle.typedb.core.reasoner.resolution.framework.Request in project grakn by graknlabs.
the class NegationResolver method receiveAnswer.
@Override
protected void receiveAnswer(com.vaticle.typedb.core.reasoner.resolution.framework.Response.Answer fromDownstream, int iteration) {
LOG.trace("{}: received Answer: {}, therefore is FAILED", name(), fromDownstream);
if (isTerminated())
return;
Request toDownstream = fromDownstream.sourceRequest();
Request fromUpstream = fromUpstream(toDownstream);
BoundsState boundsState = this.boundsStates.get(fromUpstream.partialAnswer().conceptMap());
boundsState.setFailed();
for (BoundsState.Awaiting awaiting : boundsState.awaiting) {
failToUpstream(awaiting.request, awaiting.iterationRequested);
}
boundsState.clearAwaiting();
}
Aggregations