Skip to content

Commit

Permalink
Failed experiments for speed (#28).
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbgn committed Aug 23, 2022
1 parent 6d15140 commit 67487fa
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions transformation_algebra/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ def assign_variables(self, node: Node, path: list[Node] = []) -> Variable:

return var

def run(self, graph: Graph) -> set[Node]:
"""
Find all workflows in a graph that match this query.
"""
return set(r.workflow for r in graph.query(self.sparql()))

def sparql(self) -> str:
"""
Obtain a SPARQL query.
Expand Down Expand Up @@ -307,6 +301,9 @@ def chronology(self) -> Iterator[str]:
if current in visited:
continue

# afters = " ".join(a.n3() for a in self.after[current])
# yield f"{{SELECT DISTINCT {current.n3()} {afters} WHERE {{"

# Connect the initial nodes (ie outputs)
if not self.after[current]:
assert current in self.outputs
Expand All @@ -332,6 +329,23 @@ def chronology(self) -> Iterator[str]:
yield from union(f"{current.n3()} :type/rdfs:subClassOf*",
self.type.get(current, ()))

# Make sure as early as possible that there is no earlier on the
# same branch
# for c in self.after[current]:
# types = self.type.get(current) or []
# if not len(types) == 1:
# continue
# between = next(self.generator)
# yield "FILTER NOT EXISTS {"
# yield f"{current.n3()} ^:to+ {between.n3()}."
# yield f"{c.n3()} :to* {between.n3()}."
# for t in types:
# yield f"{between.n3()} :type/rdfs:subClassOf* {t.n3()}."
# yield "}"

# Make sure we don't check the same node
# yield "}}"

visited.add(current)

# Add successors to queue
Expand Down

0 comments on commit 67487fa

Please sign in to comment.