Revert "Query splitter complete"
This reverts commit c4e258bbf9d5e0d70eb9ef6800fe2491cabec8bd. Because I had committed by mistake changes to guihandler
This commit is contained in:
parent
ae042a7ae4
commit
47bc995fd9
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
from relational import optimizations
|
from relational import optimizations
|
||||||
from relational import parser
|
from relational import parser
|
||||||
from relational import querysplit
|
|
||||||
from relational.maintenance import UserInterface
|
from relational.maintenance import UserInterface
|
||||||
|
|
||||||
|
|
||||||
@ -58,8 +57,8 @@ def optimize_program(code, rels):
|
|||||||
parsed = parser.tree(query)
|
parsed = parser.tree(query)
|
||||||
optimizations.replace_leaves(parsed, context)
|
optimizations.replace_leaves(parsed, context)
|
||||||
context[res] = parsed
|
context[res] = parsed
|
||||||
node = optimize_all(context[last_res], rels, tostr=False)
|
result = optimize_all(context[last_res], rels)
|
||||||
return querysplit.split(node, rels)
|
return result
|
||||||
|
|
||||||
|
|
||||||
def optimize_all(expression, rels, specific=True, general=True, debug=None,tostr=True):
|
def optimize_all(expression, rels, specific=True, general=True, debug=None,tostr=True):
|
||||||
|
@ -19,52 +19,6 @@
|
|||||||
# This module splits a query into a program.
|
# This module splits a query into a program.
|
||||||
|
|
||||||
|
|
||||||
from relational import parser
|
|
||||||
|
|
||||||
|
|
||||||
class Program:
|
|
||||||
def __init__(self, rels):
|
|
||||||
self.queries = []
|
|
||||||
self.dictionary = {} # Key is the query, value is the relation
|
|
||||||
self.vgen = vargen(rels, 'optm_')
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
r = ''
|
|
||||||
for q in self.queries:
|
|
||||||
r += '%s = %s' % (q[0], q[1]) + '\n'
|
|
||||||
return r.rstrip()
|
|
||||||
|
|
||||||
def append_query(self, node):
|
|
||||||
strnode = str(node)
|
|
||||||
|
|
||||||
rel = self.dictionary.get(strnode)
|
|
||||||
if rel:
|
|
||||||
return rel
|
|
||||||
|
|
||||||
qname = next(self.vgen)
|
|
||||||
self.queries.append((qname, node))
|
|
||||||
n = parser.Node()
|
|
||||||
n.kind = parser.RELATION
|
|
||||||
n.name = qname
|
|
||||||
self.dictionary[strnode] = n
|
|
||||||
return n
|
|
||||||
|
|
||||||
def _separate(node, program):
|
|
||||||
if node.kind == parser.UNARY and node.child.kind != parser.RELATION:
|
|
||||||
_separate(node.child, program)
|
|
||||||
rel = program.append_query(node.child)
|
|
||||||
node.child = rel
|
|
||||||
elif node.kind == parser.BINARY:
|
|
||||||
if node.left.kind != parser.RELATION:
|
|
||||||
_separate(node.left, program)
|
|
||||||
rel = program.append_query(node.left)
|
|
||||||
node.left = rel
|
|
||||||
if node.right.kind != parser.RELATION:
|
|
||||||
_separate(node.right, program)
|
|
||||||
rel = program.append_query(node.right)
|
|
||||||
node.right = rel
|
|
||||||
program.append_query(node)
|
|
||||||
|
|
||||||
def vargen(avoid, prefix=''):
|
def vargen(avoid, prefix=''):
|
||||||
'''
|
'''
|
||||||
Generates temp variables.
|
Generates temp variables.
|
||||||
@ -86,14 +40,3 @@ def vargen(avoid, prefix=''):
|
|||||||
if r not in avoid:
|
if r not in avoid:
|
||||||
yield r
|
yield r
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
def split(node, rels):
|
|
||||||
'''
|
|
||||||
Split a query into a program.
|
|
||||||
|
|
||||||
The idea is that if there are duplicated subdtrees they
|
|
||||||
get executed only once.
|
|
||||||
'''
|
|
||||||
p = Program(rels)
|
|
||||||
_separate(node, p)
|
|
||||||
return str(p)
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
|
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
|
||||||
import base64
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||||
@ -363,13 +362,10 @@ class relForm(QtWidgets.QMainWindow):
|
|||||||
self.settings.setValue('maingui/geometry', self.saveGeometry())
|
self.settings.setValue('maingui/geometry', self.saveGeometry())
|
||||||
self.settings.setValue('maingui/windowState', self.saveState())
|
self.settings.setValue('maingui/windowState', self.saveState())
|
||||||
self.settings.setValue('maingui/splitter', self.ui.splitter.saveState())
|
self.settings.setValue('maingui/splitter', self.ui.splitter.saveState())
|
||||||
self.settings.setValue('maingui/relations', base64.b64encode(self.user_interface.session_dump()).decode())
|
self.settings.setValue('maingui/relations', self.user_interface.session_dump())
|
||||||
|
|
||||||
def _restore_settings(self):
|
def _restore_settings(self):
|
||||||
try:
|
self.user_interface.session_restore(self.settings.value('maingui/relations'))
|
||||||
self.user_interface.session_restore(base64.b64decode(self.settings.value('maingui/relations')))
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
self.updateRelations()
|
self.updateRelations()
|
||||||
|
|
||||||
self.setMultiline(self.settings.value('multiline', 'false') == 'true')
|
self.setMultiline(self.settings.value('multiline', 'false') == 'true')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user