redoundant renames still under work... this thing is harder than i though
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@156 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
9cf8cc34a1
commit
04cc61d317
@ -121,22 +121,34 @@ def selection_inside_projection(n):
|
||||
def subsequent_renames(n):
|
||||
'''This function removes redoundant subsequent renames'''
|
||||
changes=0
|
||||
print "in"
|
||||
if n.name=='π' and n.child.name==n.name:
|
||||
changes=1
|
||||
print "in-in"
|
||||
|
||||
n.prop+=','+n.child.prop
|
||||
|
||||
_vars={}
|
||||
for i in n.child.prop.split(','):
|
||||
q=i.split('➡')
|
||||
c_vars[q[0]]=q[1]
|
||||
n.child=n.child.child
|
||||
|
||||
|
||||
if n.name=='ρ' and n.child.name==n.name:
|
||||
changes=1
|
||||
|
||||
|
||||
print "PROP",n.prop,"==========",n.child.prop
|
||||
n.prop+=','+n.child.prop
|
||||
|
||||
_vars={}
|
||||
for i in n.prop.split(','):
|
||||
q=i.split('➡')
|
||||
_vars[q[0]]=q[1]
|
||||
n.child=n.child.child
|
||||
print _vars
|
||||
for i in list(_vars.keys()):
|
||||
print i
|
||||
if _vars[i] in _vars.keys():
|
||||
#Double rename on attribute
|
||||
print "i:%s\tvars[i]:%s\t_vars[_vars[i]]: %s\n" % (i,_vars[i],_vars[_vars[i]])
|
||||
_vars[i] = _vars[_vars[i]]
|
||||
_vars.pop(i)
|
||||
n.prop=""
|
||||
print _vars
|
||||
for i in _vars.items():
|
||||
n.prop+="%s➡%s" % (i[0],i[1])
|
||||
|
||||
#recoursive scan
|
||||
if n.kind==optimizer.UNARY:
|
||||
if n.kind==optimizer.UNARY:
|
||||
changes+=subsequent_renames(n.child)
|
||||
elif n.kind==optimizer.BINARY:
|
||||
changes+=subsequent_renames(n.right)
|
||||
|
@ -192,8 +192,11 @@ if __name__=="__main__":
|
||||
#a= tokenize("(a - (a ᑌ b) * π a,b (a-b)) - ρ 123 (a)")
|
||||
#a= tokenize(u"π a,b (a*b)")
|
||||
#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(π ciccio➡age(R))")
|
||||
#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(ρ ciccio➡age(R))")
|
||||
#a=general_optimize("σ i==2 (σ b>5 (d))")
|
||||
print '=========',a
|
||||
#print node(a)
|
||||
|
Loading…
x
Reference in New Issue
Block a user