completed implementation of selection_inside_projection

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@154 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
LtWorf 2009-05-08 14:51:31 +00:00
parent b3a9d98d24
commit c7f1aa060e
2 changed files with 18 additions and 2 deletions

View File

@ -73,4 +73,5 @@
- Optimizer generate a tree from the expression - Optimizer generate a tree from the expression
- Uses python-psyco when it is available - Uses python-psyco when it is available
- Ability to perform optimizations from GUI - Ability to perform optimizations from GUI
- Able to (temporarily) store queries with a name - Able to (temporarily) store queries with a name
- Mechanism to add new kind of optimizations, without having to edit all the code

View File

@ -101,6 +101,21 @@ def selection_inside_projection(n):
'''This function locates things like σ j (π k(R)) and '''This function locates things like σ j (π k(R)) and
converts them into π k(σ j (R))''' converts them into π k(σ j (R))'''
changes=0 changes=0
if n.name=='σ' and n.child.name=='π':
changes=1
temp=n.prop
n.prop=n.child.prop
n.child.prop=temp
n.name='π'
n.child.name='σ'
#recoursive scan
if n.kind==optimizer.UNARY:
changes+=selection_inside_projection(n.child)
elif n.kind==optimizer.BINARY:
changes+=selection_inside_projection(n.right)
changes+=selection_inside_projection(n.left)
return changes return changes
general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection] general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection]