- Fixed futile_union_intersection_subtraction optimization that didn't work when selection operator was in the left subtree

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@262 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2010-10-11 12:06:41 +07:00
parent 3d6e0590c0
commit 99692f7d70
2 changed files with 20 additions and 9 deletions

@ -8,6 +8,7 @@
- Added testsuite
- Fixed python expression tokenization, now uses native tokenizer
- Fixed optimization involving selection and parenthesis in the expression (Rev 260)
- Fixed futile_union_intersection_subtraction optimization that didn't work when selection operator was in the left subtree (Rev 261)
0.11
- Font is set only on windows (Rev 206)

@ -115,28 +115,38 @@ def futile_union_intersection_subtraction(n):
changes=0
#Union and intersection of the same thing
if n.name in ('','') and n.left==n.right:
changes=1
replace_node(n,n.left)
elif (n.name == '' and ((n.left.name=='σ' and n.left.child==n.right) or (n.right.name=='σ' and n.right.child==n.left))): #Union of two equal things, but one has a selection
#selection and union of the same thing
elif (n.name == ''):
if n.left.name=='σ' and n.left.child==n.right:
changes=1
if n.left=='σ':#Selection on left. replacing self with right.
replace_node(n,n.right)
else:#Selection on left. replacing self with right.
replace_node(n,n.left)
elif (n.name == '' and ((n.left.name=='σ' and n.left.child==n.right) or (n.right.name=='σ' and n.right.child==n.left))): #Intersection of two equal things, but one has a selection
elif n.right.name=='σ' and n.right.child==n.left:
changes=1
if n.left=='σ':#Swapping with the selection
replace_node(n,n.left)
else:
#selection and intersection of the same thing
elif n.name == '':
if n.left.name=='σ' and n.left.child==n.right:
changes=1
replace_node(n,n.left)
elif n.right.name=='σ' and n.right.child==n.left:
changes=1
replace_node(n,n.right)
#TODO make work the following line...
#Subtraction and selection of the same thing
elif (n.name == '-' and (n.right.name=='σ' and n.right.child==n.left)): #Subtraction of two equal things, but one has a selection
n.name=n.right.name
n.kind=n.right.kind
n.child=n.right.child
n.prop='(not (%s))' % n.right.prop
n.left=n.right=None
#Subtraction of the same thing or with selection on the left child
elif (n.name=='-' and ((n.left==n.right) or (n.left.name=='σ' and n.left.child==n.right)) ):#Empty relation
changes=1
n.kind=optimizer.UNARY