Skip to content

Structured execution plan #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2019
Merged
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
22 changes: 5 additions & 17 deletions redisgraph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,16 @@ def query(self, q):
response = self.redis_con.execute_command("GRAPH.QUERY", self.name, q, "--compact")
return QueryResult(self, response)

def _execution_plan_to_string(self, plan, plan_str, ident=0):
plan_str += ("\t" * ident) + plan[0] + "\n"
for i in range (1, len(plan)):
plan_str = self._execution_plan_to_string(plan[i], plan_str, ident+1)
return plan_str
def _execution_plan_to_string(self, plan):
return "\n".join(plan)

def execution_plan(self, query):
"""
Get the execution plan for given query.
GRAPH.EXPLAIN returns a nested set of arrays
the first element of each array is a string representing
the current operation, followed by 0 or more sub-arrays
one for each child operation.
Get the execution plan for given query,
GRAPH.EXPLAIN returns an array of operations.
"""
plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query)
plan_str = ""
# TODO: Consider switching to a tree structure
# https://treelib.readthedocs.io/en/latest/
# make sure we're able to search for a specific operation
# within the tree.
plan_str = self._execution_plan_to_string(plan, plan_str)
return plan_str
return self._execution_plan_to_string(plan)

def delete(self):
"""
Expand Down