[Checkins] SVN: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/
add interface declerations to the algebra operation classes
Charith Paranaliyanage
paranaliyanage at gmail.com
Tue Jul 1 11:14:23 EDT 2008
Log message for revision 87887:
add interface declerations to the algebra operation classes
Changed:
U Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/interfaces.py
U Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py
-=-
Modified: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/interfaces.py
===================================================================
--- Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/interfaces.py 2008-07-01 15:12:59 UTC (rev 87886)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/interfaces.py 2008-07-01 15:14:22 UTC (rev 87887)
@@ -73,6 +73,11 @@
"""Objects providing this interface represent the
rewritten ObjectQuery to Algebra objects
"""
+ def compile(self):
+ """Return the compiled python code"""
+
+ def walk(self):
+ """Iterate the Algebra object tree"""
class IOptimizedAlgebraObject(Interface):
"""Objects providing this interface represent the
@@ -110,3 +115,77 @@
"""Stores statistical data based on queries run before.
Provides statistical data for optimization.
"""
+
+################
+#Algebra operation interfaces
+################
+
+class IEmpty(IAlgebraObject):
+ """Objects providing this interface represent the
+ Empty Algebra object
+ """
+
+class ISingle(IAlgebraObject):
+ """Objects providing this interface represent the
+ Single Algebra object
+ """
+
+class IUnion(IAlgebraObject):
+ """Objects providing this interface represent the
+ Union Algebra object
+ """
+
+class IIter(IAlgebraObject):
+ """Objects providing this interface represent the
+ Iter Algebra object
+ """
+
+class ISelect(IAlgebraObject):
+ """Objects providing this interface represent the
+ Select Algebra object
+ """
+
+class IReduce(IAlgebraObject):
+ """Objects providing this interface represent the
+ Reduce Algebra object
+ """
+
+class IRange(IAlgebraObject):
+ """Objects providing this interface represent the
+ Range Algebra object
+ """
+
+class IMake(IAlgebraObject):
+ """Objects providing this interface represent the
+ Make Algebra object
+ """
+
+class IIf(IAlgebraObject):
+ """Objects providing this interface represent the
+ If Algebra object
+ """
+
+class ILambda(IAlgebraObject):
+ """Objects providing this interface represent the
+ Lambda Algebra object
+ """
+
+class IConstant(IAlgebraObject):
+ """Objects providing this interface represent the
+ Constant Algebra object
+ """
+
+class IIdentifier(IAlgebraObject):
+ """Objects providing this interface represent the
+ Identifier Algebra object
+ """
+
+class IBinery(IAlgebraObject):
+ """Objects providing this interface represent the
+ Binery Algebra object
+ """
+
+class IOperator(IAlgebraObject):
+ """Objects providing this interface represent the
+ Operator Algebra object
+ """
Modified: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py
===================================================================
--- Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py 2008-07-01 15:12:59 UTC (rev 87886)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py 2008-07-01 15:14:22 UTC (rev 87887)
@@ -12,7 +12,7 @@
from zope.interface import implements
-from ocql.interfaces import IAlgebraObject
+from ocql.interfaces import *
class Algebra:
"""Signature definition of Algebra operation classes.
@@ -38,6 +38,9 @@
>>> Empty(list,None).compile()
'[]'
"""
+
+ implements(IEmpty)
+
def __init__(self, klass, expr):
self.klass = klass
@@ -61,6 +64,8 @@
'[c]'
"""
+ implements(ISingle)
+
def __init__(self, klass, expr):
self.klass = klass
self.expr = expr
@@ -86,6 +91,9 @@
>>> Union(list,Empty(list,None),Single(list,Identifier('c'))).compile()
'([])+([c])'
"""
+
+ implements(IUnion)
+
def __init__(self, klass, coll1, coll2):
self.klass=klass
self.coll1=coll1
@@ -125,6 +133,9 @@
class Iter(BaseAlgebra):
+
+ implements(IIter)
+
def __init__(self, klass, func, coll):
self.klass = klass
self.func = func
@@ -161,6 +172,9 @@
yield t
class Select(BaseAlgebra):
+
+ implements(ISelect)
+
def __init__(self, klass, func, coll):
self.klass = klass
self.func = func
@@ -187,6 +201,9 @@
yield t
class Reduce(BaseAlgebra):
+
+ implements(IReduce)
+
def __init__(self, klass, expr, func, aggreg, coll):
self.klass = klass
self.expr = expr
@@ -235,6 +252,9 @@
# return 'filter(%s,%s)' % (self.coll1.compile(),self.coll2.compile())
#
class Range(BaseAlgebra):
+
+ implements(IRange)
+
def __init__(self, klass, start, enf):
self.klass = klass
self.start = start
@@ -261,6 +281,9 @@
#class Index
class Make(BaseAlgebra):
+
+ implements(IMake)
+
def __init__(self, coll1, coll2, expr):
self.expr = expr
self.coll1 = coll1
@@ -284,6 +307,9 @@
#class Being:
class If(BaseAlgebra):
+
+ implements(IIf)
+
def __init__(self, cond, expr1, expr2):
self.cond = cond
self.expr1 = expr1
@@ -312,6 +338,9 @@
#
#
class Lambda(BaseAlgebra):
+
+ implements(ILambda)
+
def __init__(self, var, expr):
self.var = var
self.expr = expr
@@ -330,6 +359,9 @@
yield t
class Constant(BaseAlgebra):
+
+ implements(IConstant)
+
def __init__(self, value):
self.value = value
@@ -343,6 +375,9 @@
yield self
class Identifier(BaseAlgebra):
+
+ implements(IIdentifier)
+
def __init__(self, name):
self.name=name
@@ -356,6 +391,9 @@
yield self
class Binary(BaseAlgebra):
+
+ implements(IBinery)
+
def __init__(self, left, op, right):
self.left = left
self.op = op
@@ -377,6 +415,9 @@
yield t
class Operator(BaseAlgebra):
+
+ implements(IOperator)
+
ops = {
'or': 'operator.or_',
'and': 'operator.and_',
More information about the Checkins
mailing list