stub for swap_rename_select

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@160 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2009-05-12 06:38:58 +07:00
parent 824379cf4c
commit 952b31ac53
2 changed files with 17 additions and 3 deletions

@ -168,5 +168,19 @@ def subsequent_renames(n):
changes+=subsequent_renames(n.left)
return changes
def swap_rename_select(n):
'''This function locates things like σ k(ρ j(R)) and replaces
them with ρ j(σ k(R)). Renaming the attributes used in the
selection, so the operation is still valid.'''
#TODO document into the wiki
changes=0
#recoursive scan
if n.kind==optimizer.UNARY:
changes+=swap_rename_select(n.child)
elif n.kind==optimizer.BINARY:
changes+=swap_rename_select(n.right)
changes+=swap_rename_select(n.left)
return changes
general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection,subsequent_renames]
general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection,subsequent_renames,swap_rename_select]

@ -194,8 +194,8 @@ if __name__=="__main__":
#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("ρ age➡a,cognome➡cogn(ρ ciccio➡age,nome➡nom(R))")
a=general_optimize("σ age==3(ρ ciccio➡age,nome➡nom(R))")
#a=general_optimize("σ i==2 (σ b>5 (d))")
print '=========',a
print a
#print node(a)
#print tokenize("(a)")