work on progress on subsequent renames

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@155 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2009-05-08 15:42:02 +07:00
parent c7f1aa060e
commit 9cf8cc34a1
2 changed files with 29 additions and 3 deletions

@ -117,5 +117,31 @@ def selection_inside_projection(n):
changes+=selection_inside_projection(n.right)
changes+=selection_inside_projection(n.left)
return changes
def subsequent_renames(n):
'''This function removes redoundant subsequent renames'''
changes=0
print "in"
if n.name=='π' and n.child.name==n.name:
changes=1
print "in-in"
n.prop+=','+n.child.prop
_vars={}
for i in n.child.prop.split(','):
q=i.split('')
c_vars[q[0]]=q[1]
n.child=n.child.child
general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection]
#recoursive scan
if n.kind==optimizer.UNARY:
changes+=subsequent_renames(n.child)
elif n.kind==optimizer.BINARY:
changes+=subsequent_renames(n.right)
changes+=subsequent_renames(n.left)
return changes
general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection,subsequent_renames]

@ -193,8 +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))")
a=general_optimize("σ i==2 (c d - (aᑎb))")
a=general_optimize("π age➡a(π ciccio➡age(R))")
#a=general_optimize("σ i==2 (σ b>5 (d))")
print a
print '=========',a
#print node(a)
#print tokenize("(a)")