From e1d02bcd4c366c39a06d2a232d145bb954cb79d1 Mon Sep 17 00:00:00 2001 From: LtWorf Date: Mon, 11 May 2009 16:51:43 +0000 Subject: [PATCH] removed debug prints and added comments git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@158 014f5005-505e-4b48-8d0a-63407b615a7c --- relational/optimizations.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/relational/optimizations.py b/relational/optimizations.py index b8a2cb1..8ad52e2 100644 --- a/relational/optimizations.py +++ b/relational/optimizations.py @@ -99,9 +99,7 @@ def duplicated_projection(n): def selection_inside_projection(n): '''This function locates things like σ j (π k(R)) and - converts them into π k(σ j (R))''' - #TODO Document this in the wiki. - + converts them into π k(σ j (R))''' changes=0 if n.name=='σ' and n.child.name=='π': @@ -125,30 +123,34 @@ def subsequent_renames(n): changes=0 if n.name=='ρ' and n.child.name==n.name: + #Located two nested renames. changes=1 - - print "PROP",n.prop,"==========",n.child.prop + #Joining the attribute into one n.prop+=','+n.child.prop - + n.child=n.child.child + + #Creating a dictionary with the attributes _vars={} for i in n.prop.split(','): q=i.split('➡') _vars[q[0].strip()]=q[1].strip() - n.child=n.child.child - print _vars + + #Scans dictionary to locate things like "a->b,b->c" and replace them with "a->c" for i in list(_vars.keys()): - print i if _vars[i] in _vars.keys(): #Double rename on attribute - print "i:%s\tvars[i]:%s\t_vars[_vars[i]]: %s\n" % (i,_vars[i],_vars[_vars[i]]) - _vars[i] = _vars[_vars[i]] - _vars.pop(i) + _vars[i] = _vars[_vars[i]] #Sets value + _vars.pop(i) #Removes the unused one + + #Reset prop var n.prop="" - print _vars + + #Generates new prop var for i in _vars.items(): n.prop+="%s➡%s," % (i[0],i[1]) n.prop=n.prop[:-1] #Removing ending comma + #recoursive scan if n.kind==optimizer.UNARY: changes+=subsequent_renames(n.child)