Skip to content

Commit

Permalink
[New] Execute sparql query of apply construct module in lexicographic…
Browse files Browse the repository at this point in the history
…al order
  • Loading branch information
blcham committed Nov 28, 2021
1 parent be9902c commit 99a30d4
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.topbraid.spin.system.SPINModuleRegistry;
import org.topbraid.spin.vocabulary.SP;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
* TODO Order of queries is not enforced.
Expand Down Expand Up @@ -108,20 +110,25 @@ public ExecutionContext executeSelf() {

Model inferredModel = ModelFactory.createDefaultModel();

List<Construct> constructQueriesSorted = constructQueries
.stream().map(r -> r.as(Construct.class))
.sorted(Comparator.comparing(this::getQueryComment))
.collect(Collectors.toList());

while (nNew > 0 && count++ < iterationCount) {
// set up variable bindings

Model inferredInSingleIterationModel = ModelFactory.createDefaultModel();
Model extendedInferredModel = JenaUtils.createUnion(defaultModel, inferredModel);

for (int i = 0; i < constructQueries.size(); i++) {
Construct spinConstructRes = constructQueries.get(i).as(Construct.class);
for (int i = 0; i < constructQueriesSorted.size(); i++) {
Construct spinConstructRes = constructQueriesSorted.get(i);

if (LOG.isTraceEnabled()) {
String queryComment = getQueryComment(spinConstructRes);;
String queryComment = getQueryComment(spinConstructRes);
LOG.trace(
"Executing iteration {}/{} with {}/{} query \"{}\" ...",
count, iterationCount, i + 1, constructQueries.size(), queryComment
count, iterationCount, i + 1, constructQueriesSorted.size(), queryComment
);
}

Expand Down

0 comments on commit 99a30d4

Please sign in to comment.