use of com.vaticle.typedb.core.reasoner.resolution.answer.AnswerState in project grakn by graknlabs.
the class DisjunctionResolver 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);
RequestState requestState = requestStates.get(fromUpstream);
assert fromDownstream.answer().isCompound();
AnswerState answer = toUpstreamAnswer(fromDownstream.answer().asCompound(), fromDownstream);
boolean acceptedAnswer = tryAcceptUpstreamAnswer(answer, fromUpstream, iteration);
if (!acceptedAnswer)
nextAnswer(fromUpstream, requestState, iteration);
}
use of com.vaticle.typedb.core.reasoner.resolution.answer.AnswerState in project grakn by graknlabs.
the class ConjunctionResolver 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);
RequestState requestState = requestStates.get(fromUpstream);
Plans.Plan plan = plans.getActive(fromUpstream);
// this could be either implemented with a different response type: FinalAnswer, or splitting Request into ReusableRequest vs SingleRequest
if (plan.get(toDownstream.planIndex()).isNegated())
requestState.downstreamManager().removeDownstream(toDownstream);
Partial.Compound<?, ?> partialAnswer = fromDownstream.answer().asCompound();
if (plan.isLast(fromDownstream.planIndex())) {
Optional<AnswerState> upstreamAnswer = toUpstreamAnswer(partialAnswer);
boolean answerAccepted = upstreamAnswer.isPresent() && tryAcceptUpstreamAnswer(upstreamAnswer.get(), fromUpstream, iteration);
if (!answerAccepted)
nextAnswer(fromUpstream, requestState, iteration);
} else {
toNextChild(fromDownstream, iteration, fromUpstream, requestState, plan);
}
}
Aggregations