Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public class AskResult {
* Can be null, if the matcher is used instead of the reasoner.
*/
private ReasonerPlan reasonerPlan;

private Set<KnowledgeGap> knowledgeGaps;

private final Set<AskExchangeInfo> exchangeInfos;
/**
* Can contain both Post and Ask ExchangeInfo objects, because the reasoner can
* activate Post KIs while answering.
*/
private final Set<ExchangeInfo> exchangeInfos;

/**
* Create a {@link AskResult}.
Expand All @@ -41,14 +45,15 @@ public class AskResult {
* value for every available variable in the
* {@link GraphPattern}.
*/
public AskResult(BindingSet someBindings, Set<AskExchangeInfo> askExchangeInfos, ReasonerPlan aRootNode, Set<KnowledgeGap> kGaps) {
public AskResult(BindingSet someBindings, Set<ExchangeInfo> askExchangeInfos, ReasonerPlan aRootNode,
Set<KnowledgeGap> kGaps) {
this.bindings = someBindings;
this.exchangeInfos = askExchangeInfos;
this.reasonerPlan = aRootNode;
this.knowledgeGaps = kGaps;
}

public AskResult(BindingSet someBindings, Set<AskExchangeInfo> askExchangeInfos) {
public AskResult(BindingSet someBindings, Set<ExchangeInfo> askExchangeInfos) {
this(someBindings, askExchangeInfos, null, null);
}

Expand All @@ -60,20 +65,20 @@ public BindingSet getBindings() {
return this.bindings;
}

public Set<AskExchangeInfo> getExchangeInfoPerKnowledgeBase() {
public Set<ExchangeInfo> getExchangeInfoPerKnowledgeBase() {
return Collections.unmodifiableSet(exchangeInfos);
}

public Duration getTotalExchangeTime() {

Set<AskExchangeInfo> infos = this.getExchangeInfoPerKnowledgeBase();
Set<ExchangeInfo> infos = this.getExchangeInfoPerKnowledgeBase();

if (!infos.isEmpty()) {
Instant start = Instant.MAX;
Instant end = Instant.MIN;

// find the earliest and latest instant among the exchange infos.
for (AskExchangeInfo info : infos) {
for (ExchangeInfo info : infos) {

if (info.getExchangeStart().isBefore(start)) {
start = info.getExchangeStart();
Expand Down Expand Up @@ -109,6 +114,7 @@ public Set<KnowledgeGap> getKnowledgeGaps() {

@Override
public String toString() {
return "AskResult [bindings=" + bindings + ", exchangeInfoPerKnowledgeBase=" + exchangeInfos + ", knowledgeGaps=" + knowledgeGaps + "]";
return "AskResult [bindings=" + bindings + ", exchangeInfoPerKnowledgeBase=" + exchangeInfos
+ ", knowledgeGaps=" + knowledgeGaps + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ public class PostResult {
private static final Logger LOG = LoggerFactory.getLogger(PostResult.class);

private final BindingSet bindings;
private final Set<PostExchangeInfo> exchangeInfos;

/**
* The exchange infos can contain Post and Ask Exchange infos, because the
* reasoner can activate Ask KIs while reacting.
*/
private final Set<ExchangeInfo> exchangeInfos;
/**
* Can be null if the matcher is used instead of the reasoner.
*/
Expand All @@ -36,11 +41,11 @@ public class PostResult {
* value for every available variable in the
* {@link GraphPattern}.
*/
public PostResult(BindingSet someBindings, Set<PostExchangeInfo> postExchangeInfos) {
public PostResult(BindingSet someBindings, Set<ExchangeInfo> postExchangeInfos) {
this(someBindings, postExchangeInfos, null);
}

public PostResult(BindingSet someBindings, Set<PostExchangeInfo> postExchangeInfos, ReasonerPlan aNode) {
public PostResult(BindingSet someBindings, Set<ExchangeInfo> postExchangeInfos, ReasonerPlan aNode) {
this.bindings = someBindings;
this.exchangeInfos = postExchangeInfos;
this.rootNode = aNode;
Expand All @@ -54,20 +59,20 @@ public BindingSet getBindings() {
return this.bindings;
}

public Set<PostExchangeInfo> getExchangeInfoPerKnowledgeBase() {
public Set<ExchangeInfo> getExchangeInfoPerKnowledgeBase() {
return Collections.unmodifiableSet(exchangeInfos);
}

public Duration getTotalExchangeTime() {

Set<PostExchangeInfo> infos = this.getExchangeInfoPerKnowledgeBase();
Set<ExchangeInfo> infos = this.getExchangeInfoPerKnowledgeBase();

if (!infos.isEmpty()) {
Instant start = Instant.MAX;
Instant end = Instant.MIN;

// find the earliest and latest instant among the exchange infos.
for (PostExchangeInfo info : infos) {
for (ExchangeInfo info : infos) {

if (info.getExchangeStart().isBefore(start)) {
start = info.getExchangeStart();
Expand Down
Loading
Loading