finally subsequent_renames optimization is working
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@157 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
04cc61d317
commit
f273425312
@ -100,6 +100,8 @@ def duplicated_projection(n):
|
|||||||
def selection_inside_projection(n):
|
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))'''
|
||||||
|
#TODO Document this in the wiki.
|
||||||
|
|
||||||
changes=0
|
changes=0
|
||||||
|
|
||||||
if n.name=='σ' and n.child.name=='π':
|
if n.name=='σ' and n.child.name=='π':
|
||||||
@ -132,7 +134,7 @@ def subsequent_renames(n):
|
|||||||
_vars={}
|
_vars={}
|
||||||
for i in n.prop.split(','):
|
for i in n.prop.split(','):
|
||||||
q=i.split('➡')
|
q=i.split('➡')
|
||||||
_vars[q[0]]=q[1]
|
_vars[q[0].strip()]=q[1].strip()
|
||||||
n.child=n.child.child
|
n.child=n.child.child
|
||||||
print _vars
|
print _vars
|
||||||
for i in list(_vars.keys()):
|
for i in list(_vars.keys()):
|
||||||
@ -145,8 +147,8 @@ def subsequent_renames(n):
|
|||||||
n.prop=""
|
n.prop=""
|
||||||
print _vars
|
print _vars
|
||||||
for i in _vars.items():
|
for i in _vars.items():
|
||||||
n.prop+="%s➡%s" % (i[0],i[1])
|
n.prop+="%s➡%s," % (i[0],i[1])
|
||||||
|
n.prop=n.prop[:-1] #Removing ending comma
|
||||||
#recoursive scan
|
#recoursive scan
|
||||||
if n.kind==optimizer.UNARY:
|
if n.kind==optimizer.UNARY:
|
||||||
changes+=subsequent_renames(n.child)
|
changes+=subsequent_renames(n.child)
|
||||||
|
@ -193,10 +193,8 @@ 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)")
|
||||||
#print tree("σ i==2 (c ᑌ d - (aᑎb))") == tree("σ i==3 (c ᑌ d - (aᑎb))")
|
#print tree("σ i==2 (c ᑌ d - (aᑎb))") == tree("σ i==3 (c ᑌ d - (aᑎb))")
|
||||||
print tree("ρ age➡a,cognome➡cogn(ρ ciccio➡age,nome➡nom(R))")
|
|
||||||
|
a=general_optimize("ρ age➡a,cognome➡cogn(ρ ciccio➡age,nome➡nom(R))")
|
||||||
|
|
||||||
a=general_optimize("ρ age➡a(ρ ciccio➡age(R))")
|
|
||||||
#a=general_optimize("σ i==2 (σ b>5 (d))")
|
#a=general_optimize("σ i==2 (σ b>5 (d))")
|
||||||
print '=========',a
|
print '=========',a
|
||||||
#print node(a)
|
#print node(a)
|
||||||
|
Loading…
Reference in New Issue
Block a user