Skip to content

Commit

Permalink
Merge pull request #2636 from eclipse/GH-2632-rsx-sh_or-bug-performance
Browse files Browse the repository at this point in the history
GH-2632 performance fix
  • Loading branch information
hmottestad authored Nov 8, 2020
2 parents ed8fb47 + 1a389b9 commit 7480f8b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,30 @@ public String buildSparqlValidNodes(String targetVar) {

@Override
public Stream<StatementPattern> getStatementPatterns() {
StatementPattern subject = new StatementPattern(
new Var("?this"),
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString())
);

StatementPattern object = new StatementPattern(
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString()),
new Var("?this")
);
Stream<StatementPattern> allSubjectsObjects;

if (hasOwnPath()) {
StatementPattern subject = new StatementPattern(
new Var("?this"),
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString())
);

StatementPattern object = new StatementPattern(
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString()),
new Var("?this")
);

allSubjectsObjects = Stream.of(subject, object);
} else {
allSubjectsObjects = Stream.empty();
}

Stream<StatementPattern> statementPatternStream = and.stream()
.flatMap(Collection::stream)
.flatMap(PropertyShape::getStatementPatterns);

return Stream.concat(statementPatternStream, Stream.of(subject, object));
return Stream.concat(statementPatternStream, allSubjectsObjects);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,30 @@ public String buildSparqlValidNodes(String targetVar) {
@Override
public Stream<StatementPattern> getStatementPatterns() {

StatementPattern subject = new StatementPattern(
new Var("?this"),
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString())
);

StatementPattern object = new StatementPattern(
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString()),
new Var("?this")
);
Stream<StatementPattern> allSubjectsObjects;

if (hasOwnPath()) {
StatementPattern subject = new StatementPattern(
new Var("?this"),
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString())
);

StatementPattern object = new StatementPattern(
new Var(UUID.randomUUID().toString()),
new Var(UUID.randomUUID().toString()),
new Var("?this")
);

allSubjectsObjects = Stream.of(subject, object);
} else {
allSubjectsObjects = Stream.empty();
}

Stream<StatementPattern> statementPatternStream = or.stream()
.flatMap(Collection::stream)
.flatMap(PropertyShape::getStatementPatterns);

return Stream.concat(statementPatternStream, Stream.of(subject, object));
return Stream.concat(statementPatternStream, allSubjectsObjects);
}
}

0 comments on commit 7480f8b

Please sign in to comment.