finally subsequent_renames optimization is working

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@157 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2009-05-11 16:44:52 +07:00
parent 04cc61d317
commit f273425312
2 changed files with 7 additions and 7 deletions

@ -100,6 +100,8 @@ 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.
changes=0
if n.name=='σ' and n.child.name=='π':
@ -132,7 +134,7 @@ def subsequent_renames(n):
_vars={}
for i in n.prop.split(','):
q=i.split('')
_vars[q[0]]=q[1]
_vars[q[0].strip()]=q[1].strip()
n.child=n.child.child
print _vars
for i in list(_vars.keys()):
@ -145,8 +147,8 @@ def subsequent_renames(n):
n.prop=""
print _vars
for i in _vars.items():
n.prop+="%s%s" % (i[0],i[1])
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)

@ -193,10 +193,8 @@ if __name__=="__main__":
#a= tokenize(u"π a,b (a*b)")
#a=tokenize("(a-b*c)*(b-c)")
#print tree("σ i==2 (c d - (aᑎb))") == tree("σ i==3 (c d - (aᑎb))")
print tree("ρ age➡a,cognome➡cogn(ρ ciccio➡age,nome➡nom(R))")
a=general_optimize("ρ age➡a(ρ ciccio➡age(R))")
a=general_optimize("ρ age➡a,cognome➡cogn(ρ ciccio➡age,nome➡nom(R))")
#a=general_optimize("σ i==2 (σ b>5 (d))")
print '=========',a
#print node(a)