[Checkins] SVN: Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/ simple modification in walk method to filter algebra objects

Charith Paranaliyanage paranaliyanage at gmail.com
Sun Jul 6 12:31:32 EDT 2008


Log message for revision 88071:
  simple modification in walk method to filter algebra objects

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

-=-
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-06 16:27:54 UTC (rev 88070)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/algebra.py	2008-07-06 16:31:31 UTC (rev 88071)
@@ -34,8 +34,9 @@
     def walk(self):
         yield self
         for child in self.children:
-            for t in child.walk():
-                yield t
+            if isinstance(self, Algebra):#can be removed if collection type wrapped by a algebra class
+                for t in child.walk():
+                    yield t
 
 class Empty(BaseAlgebra):
 

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-06 16:27:54 UTC (rev 88070)
+++ Sandbox/adamg/ocql/branches/alg-compiler/src/ocql/rewriter/rewriter.py	2008-07-06 16:31:31 UTC (rev 88071)
@@ -28,14 +28,8 @@
 
     def __call__(self):
         query = self.context
-        alg = query.rewrite(target_algebra)        
-        self._preorder(alg)
+        alg = query.rewrite(target_algebra)
         alg.__name__ = 'head'
+        alg.walk()
         return alg
-    
-    def _preorder(self, alg):
-        if isinstance(alg, Algebra):
-            for child in alg.children:
-                if isinstance(child, Algebra):
-                    self._preorder(child.children)
-                    name = child.__name__
+    
\ No newline at end of file



More information about the Checkins mailing list