[Checkins] SVN: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/ add head object to the algebra object tree

Charith Paranaliyanage paranaliyanage at gmail.com
Mon Jul 7 12:03:58 EDT 2008


Log message for revision 88082:
  add head object to the algebra object tree

Changed:
  U   Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/compiler/compiler.py
  U   Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py
  U   Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/interfaces.py
  U   Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/rewriter.py

-=-
Modified: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/compiler/compiler.py
===================================================================
--- Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/compiler/compiler.py	2008-07-07 10:12:57 UTC (rev 88081)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/compiler/compiler.py	2008-07-07 16:03:56 UTC (rev 88082)
@@ -16,6 +16,7 @@
 from ocql.interfaces import IAlgebraPartCompiler
 from ocql.interfaces import IOptimizedAlgebraObject
 #from ocql.interfaces import ICompiledAlgebraObject
+from ocql.rewriter.algebra import Head
 
 from ocql.rewriter.interfaces import *
 
@@ -30,9 +31,12 @@
         #self.db = db
 
     def __call__(self, metadata, algebra):
-        algebra = self.context
+        if isinstance(algebra, Head):
+            algebra = self.context.tree
+        else:
+            algebra = self.context
         #code = algebra.compile()
-        adapter = IAlgebraPartCompiler(self.context)
+        adapter = IAlgebraPartCompiler(algebra)
         code = adapter()
         run = RunnableQuery(metadata, algebra, code)
         return run

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-07 10:12:57 UTC (rev 88081)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py	2008-07-07 16:03:56 UTC (rev 88082)
@@ -16,7 +16,16 @@
 from ocql.rewriter.interfaces import *
 from zope.location import Location, locate
 
+class Head:
+    implements(IHead)
+    
+    def __init__(self, tree):
+        name = 'head'
+        self.tree = tree
 
+    def __repr__(self):
+        return ('%s') % (self.tree)
+
 class Algebra:
     """Signature definition of Algebra operation classes.
     shall be moved to an IF later

Modified: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/interfaces.py
===================================================================
--- Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/interfaces.py	2008-07-07 10:12:57 UTC (rev 88081)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/interfaces.py	2008-07-07 16:03:56 UTC (rev 88082)
@@ -1,9 +1,15 @@
 # -*- coding: UTF-8 -*-
 
 from ocql.interfaces import IAlgebraObject
-from zope.schema import Dict, Text, Int
-from zope.interface import Attribute
+from zope.schema import Dict, Text, Int, TextLine
+from zope.interface import Attribute, Interface
 
+class IHead(IAlgebraObject):
+    """Represents head of the algebra object tree
+    """
+    __name__ = TextLine()
+    tree = Attribute('hold algebra object tree')
+    
 ################
 #Algebra operation interfaces
 ################

Modified: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/rewriter.py
===================================================================
--- Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/rewriter.py	2008-07-07 10:12:57 UTC (rev 88081)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/rewriter.py	2008-07-07 16:03:56 UTC (rev 88082)
@@ -15,7 +15,7 @@
 
 from ocql.interfaces import IRewriter
 from ocql.interfaces import IOptimizedObjectQuery
-from ocql.rewriter.algebra import Algebra
+from ocql.rewriter.algebra import Head
 
 from ocql.rewriter import algebra as target_algebra
 
@@ -29,7 +29,6 @@
     def __call__(self):
         query = self.context
         alg = query.rewrite(target_algebra)
-        alg.__name__ = 'head'
-        alg.walk()
-        return alg
+        head = Head(alg)
+        return head
     
\ No newline at end of file



More information about the Checkins mailing list