counting changes on the tree
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@138 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
4ba7209964
commit
ac0d6fae85
@ -70,3 +70,4 @@
|
|||||||
- Document about complexity of operations
|
- Document about complexity of operations
|
||||||
- Bug: error in update operation, it changed the original tuple, so also other relations using the same tuple would change. Now it copies it.
|
- Bug: error in update operation, it changed the original tuple, so also other relations using the same tuple would change. Now it copies it.
|
||||||
- Added make install and uninstall
|
- Added make install and uninstall
|
||||||
|
- Optimizer generate a tree from the expression
|
@ -24,20 +24,23 @@ within a cycle.'''
|
|||||||
import optimizer
|
import optimizer
|
||||||
|
|
||||||
def duplicated_select(n):
|
def duplicated_select(n):
|
||||||
|
changes=0
|
||||||
'''This function locates and deletes things like
|
'''This function locates and deletes things like
|
||||||
σ a ( σ a(C)) and the ones like σ a ( σ b(C))'''
|
σ a ( σ a(C)) and the ones like σ a ( σ b(C))'''
|
||||||
if n.name=='σ' and n.child.name=='σ':
|
if n.name=='σ' and n.child.name=='σ':
|
||||||
if n.prop != n.child.prop: #Nested but different, joining them
|
if n.prop != n.child.prop: #Nested but different, joining them
|
||||||
n.prop = n.prop + " and " + n.child.prop
|
n.prop = n.prop + " and " + n.child.prop
|
||||||
n.child=n.child.child
|
n.child=n.child.child
|
||||||
duplicated_select(n)
|
changes=1
|
||||||
|
changes+=duplicated_select(n)
|
||||||
|
|
||||||
|
|
||||||
#recoursive scan
|
#recoursive scan
|
||||||
if n.kind==optimizer.UNARY:
|
if n.kind==optimizer.UNARY:
|
||||||
duplicated_select(n.child)
|
changes+=duplicated_select(n.child)
|
||||||
elif n.kind==optimizer.BINARY:
|
elif n.kind==optimizer.BINARY:
|
||||||
duplicated_select(n.right)
|
changes+=duplicated_select(n.right)
|
||||||
duplicated_select(n.left)
|
changes+=duplicated_select(n.left)
|
||||||
return n
|
return changes
|
||||||
|
|
||||||
general_optimizations=[duplicated_select]
|
general_optimizations=[duplicated_select]
|
@ -165,7 +165,7 @@ def general_optimize(expression):
|
|||||||
know the fields used by the relations'''
|
know the fields used by the relations'''
|
||||||
n=tree(expression) #Gets the tree
|
n=tree(expression) #Gets the tree
|
||||||
for i in optimizations.general_optimizations:
|
for i in optimizations.general_optimizations:
|
||||||
n=i(n) #Performs the optimization
|
print "Changes done: ", i(n) #Performs the optimization
|
||||||
return n.__str__()
|
return n.__str__()
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
@ -178,6 +178,7 @@ if __name__=="__main__":
|
|||||||
#a= tokenize(u"π a,b (a*b)")
|
#a= tokenize(u"π a,b (a*b)")
|
||||||
#a=tokenize("(a-b*c)*(b-c)")
|
#a=tokenize("(a-b*c)*(b-c)")
|
||||||
a=general_optimize("σ i==2 (σ b>5 ( σ a>2 (C))) * σ a>2 ( σ a>2 (C))")
|
a=general_optimize("σ i==2 (σ b>5 ( σ a>2 (C))) * σ a>2 ( σ a>2 (C))")
|
||||||
|
#a=general_optimize("σ i==2 (σ b>5 (d))")
|
||||||
print a
|
print a
|
||||||
#print node(a)
|
#print node(a)
|
||||||
#print tokenize("(a)")
|
#print tokenize("(a)")
|
Loading…
Reference in New Issue
Block a user