From e613e1c3a111dc7642de9de965cb2d3c6c357603 Mon Sep 17 00:00:00 2001 From: Roi Lipman Date: Wed, 5 Jun 2019 07:35:02 +0300 Subject: [PATCH] switched to a single array representation --- redisgraph/graph.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/redisgraph/graph.py b/redisgraph/graph.py index 1955ad8..d006546 100644 --- a/redisgraph/graph.py +++ b/redisgraph/graph.py @@ -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): """