added module to contain optimizations
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@134 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
256cd3e4ca
commit
923ac12588
28
relational/optimizations.py
Normal file
28
relational/optimizations.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Relational
|
||||||
|
# Copyright (C) 2009 Salvo "LtWorf" Tomaselli
|
||||||
|
#
|
||||||
|
# Relation is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
|
||||||
|
|
||||||
|
'''This module contains functions to perform various optimizations on the expression trees.
|
||||||
|
The list general_optimizations contains pointers to general functions, so they can be called
|
||||||
|
within a cycle.'''
|
||||||
|
|
||||||
|
def duplicated_select(n):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
general_optimizations=[duplicated_select]
|
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
'''This module optimizes relational expressions into ones that require less time to be executed
|
'''This module optimizes relational expressions into ones that require less time to be executed
|
||||||
For now it is highly experimental, and it shouldn't be used in 3rd party applications.'''
|
For now it is highly experimental, and it shouldn't be used in 3rd party applications.'''
|
||||||
|
|
||||||
|
import optimizations
|
||||||
|
|
||||||
RELATION=0
|
RELATION=0
|
||||||
UNARY=1
|
UNARY=1
|
||||||
BINARY=2
|
BINARY=2
|
||||||
@ -165,12 +168,14 @@ def tokenize(expression):
|
|||||||
def tree(expression):
|
def tree(expression):
|
||||||
'''This function parses a relational algebra expression into a tree and returns
|
'''This function parses a relational algebra expression into a tree and returns
|
||||||
the root node using the Node class defined in this module.'''
|
the root node using the Node class defined in this module.'''
|
||||||
#isinstance(k,list)
|
|
||||||
return node(tokenize(expression))
|
return node(tokenize(expression))
|
||||||
|
|
||||||
def optimize(expression):
|
def general_optimize(expression):
|
||||||
|
'''This function performs general optimizations. Means that it will not need to
|
||||||
|
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:
|
||||||
|
n=i(n) #Performs the optimization
|
||||||
return n.__str__()
|
return n.__str__()
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user