Skip to content

Commit d65ec32

Browse files
authored
switched to a single array representation (#39)
1 parent 62c591d commit d65ec32

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

redisgraph/graph.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,16 @@ def query(self, q):
112112
response = self.redis_con.execute_command("GRAPH.QUERY", self.name, q, "--compact")
113113
return QueryResult(self, response)
114114

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

121118
def execution_plan(self, query):
122119
"""
123-
Get the execution plan for given query.
124-
GRAPH.EXPLAIN returns a nested set of arrays
125-
the first element of each array is a string representing
126-
the current operation, followed by 0 or more sub-arrays
127-
one for each child operation.
120+
Get the execution plan for given query,
121+
GRAPH.EXPLAIN returns an array of operations.
128122
"""
129123
plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query)
130-
plan_str = ""
131-
# TODO: Consider switching to a tree structure
132-
# https://treelib.readthedocs.io/en/latest/
133-
# make sure we're able to search for a specific operation
134-
# within the tree.
135-
plan_str = self._execution_plan_to_string(plan, plan_str)
136-
return plan_str
124+
return self._execution_plan_to_string(plan)
137125

138126
def delete(self):
139127
"""

0 commit comments

Comments
 (0)