[Checkins] SVN: Sandbox/ocql-foliage/src/ comments, long lines

Adam Groszer agroszer at gmail.com
Mon Sep 24 15:17:22 EDT 2007


Log message for revision 79894:
  comments, long lines

Changed:
  U   Sandbox/ocql-foliage/src/ocql/engine/algebra.py
  U   Sandbox/ocql-foliage/src/ocql/engine/algebracompiler.py
  U   Sandbox/ocql-foliage/src/ocql/engine/algebraoptimizer.py
  U   Sandbox/ocql-foliage/src/ocql/engine/queryobject.py
  U   Sandbox/ocql-foliage/src/ocql/engine/queryoptimizer.py
  U   Sandbox/ocql-foliage/src/ocql/engine/queryparser.py
  U   Sandbox/ocql-foliage/src/ocql/engine/rewriter.py
  U   Sandbox/ocql-foliage/src/ocql/engine/runnablequery.py
  A   Sandbox/ocql-foliage/src/status.txt
  U   Sandbox/ocql-foliage/src/testalgebra.py

-=-
Modified: Sandbox/ocql-foliage/src/ocql/engine/algebra.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/algebra.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/algebra.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,6 +1,10 @@
 class Algebra:
+    """Signature definition of Algebra operation classes.
+    shall be moved to an IF later
+    """
+    
     def compile(self):
-        """Returns the compiled python code"""
+        """Return the compiled python code"""
          
     def walk(self):
-        """Iterator on the tree"""
+        """Iterator the Algebra object tree"""

Modified: Sandbox/ocql-foliage/src/ocql/engine/algebracompiler.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/algebracompiler.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/algebracompiler.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,6 +1,7 @@
 class AlgebraCompiler:
     """
-    Common compiler methods
+    Actual compilation of the Algebra to Python is done
+    in each Algebra class/object at the moment
     """
     def __init__(self, engine):
         self.engine = engine
@@ -9,9 +10,7 @@
         pass
     
     def compile(self, alg):
-        print alg
-        #from pub.dbgpclient import brk; brk()
-
+        #print alg
         code = alg.compile()
-        print code
-        return compile(code,'','eval')
\ No newline at end of file
+        #print code
+        return compile(code,'<string>','eval')
\ No newline at end of file

Modified: Sandbox/ocql-foliage/src/ocql/engine/algebraoptimizer.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/algebraoptimizer.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/algebraoptimizer.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,3 +1,9 @@
+#
+# Optimization will be done later,
+# at the moment this is just a stub returning it's input
+#
+#
+
 class EliminateMake:
     def __init__(self, algebra):
         self.algebra = algebra

Modified: Sandbox/ocql-foliage/src/ocql/engine/queryobject.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/queryobject.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/queryobject.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,3 +1,7 @@
+#
+# Classes for the Query Object representation
+#
+
 class NotImplemented(Exception):
     pass
 
@@ -38,9 +42,11 @@
     pass
 
 class NumericConstant(Constant):
+    #TODO: convert value to string?
     pass
 
 class BooleanConstant(Constant):
+    #TODO: convert value to string?
     pass
    
 class Query(Expression):
@@ -53,11 +59,20 @@
         if len(self.terms):
             ft = self.terms[0]
             if isinstance(ft,In):
-                return algebra.Iter(self.collection,
-                    algebra.Lambda(ft.identifier.name,
-                        Query(self.collection,self.terms[1:],self.target).rewrite(algebra)
-                    ), algebra.Make(self.collection,set,ft.expression.rewrite(algebra)) # FIXME: ?set? 
- 
+                return algebra.Iter(
+                    self.collection,
+                    algebra.Lambda(
+                        ft.identifier.name,
+                        Query(
+                            self.collection,
+                            self.terms[1:],
+                            self.target
+                            ).rewrite(algebra)
+                    ), algebra.Make(
+                        self.collection,
+                        set,
+                        ft.expression.rewrite(algebra)
+                        ) # FIXME: ?set? 
                 )
             elif isinstance(ft,Alias):
                 return Query(self.collection, [In(ft.identifier,ft.expression)]+self.terms[1:], 
@@ -70,7 +85,6 @@
                 )
         else:
             return algebra.Single(self.collection,self.target.rewrite(algebra))
-            
 
 class In(Term):
     def __init__(self, identifier, expression):
@@ -91,16 +105,23 @@
         self.right = right
 
     def rewrite(self, algebra):
-        return algebra.Binary(self.left.rewrite(algebra),self.get_operator(algebra),self.right.rewrite(algebra))
+        return algebra.Binary(
+            self.left.rewrite(algebra),
+            self.get_operator(algebra),
+            self.right.rewrite(algebra))
 
 # Sets and properties
 class Union(Binary):
     def rewrite(self, algebra):
-        algebra.Union(left.rewrite(algebra),right.rewrite(algebra))
+        algebra.Union(
+            left.rewrite(algebra),
+            right.rewrite(algebra))
 
 class Differ(Binary):
     def rewrite(self, algebra):
-        algebra.Differ(left.rewrite(algebra),right.rewrite(algebra))
+        algebra.Differ(
+            left.rewrite(algebra),
+            right.rewrite(algebra))
 
 class And(Binary):
     def get_operator(self, algebra):
@@ -112,7 +133,8 @@
 
 class Property(Binary):
     def rewrite(self, algebra): # FIXME: Ezt gondold at...
-        return algebra.Identifier('.'.join([self.left.name,self.right.name]))
+        return algebra.Identifier(
+            '.'.join([self.left.name, self.right.name]))
 
 class Index(Binary):
     pass

Modified: Sandbox/ocql-foliage/src/ocql/engine/queryoptimizer.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/queryoptimizer.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/queryoptimizer.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,3 +1,9 @@
+#
+# Optimizing will be done later,
+# at the moment this is just a stub returning it's input
+#
+#
+
 class QueryOptimizer:
     def __init__(self, engine):
         self.engine = engine

Modified: Sandbox/ocql-foliage/src/ocql/engine/queryparser.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/queryparser.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/queryparser.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,3 +1,52 @@
+#
+# Stub of query parser at the moment
+#
+# A parser is easy to write
+# at the moment this returns a fixed Query object
+#
+
+from ocql.engine.queryobject import *
+
+#this is the wired query:
+"""
+set [
+    c in ICurses;
+    d in IDepartments;
+    d.name="Computing Science";
+    d = some c.runBy;
+    1<=c.credits;
+    c.credits <= 3
+    | c ]
+"""
+
+WIRED = Query(
+    set,
+    [
+        In(Identifier('c'),Identifier('ICurses')),
+        In(Identifier('d'),Identifier('IDepartments')),
+        Eq(
+            Property(Identifier('d'),Identifier('name')),
+            StringConstant('"Computing Science"')
+            ),
+        Eq(
+            Identifier('d'),
+            Quanted(
+                Some(),
+                Property(Identifier('c'),Identifier('runBy'))
+                )
+            ),
+        Le(
+            NumericConstant('1'),
+            Property(Identifier('c'),Identifier('credits'))
+            ),
+        Le(
+            Property(Identifier('c'),Identifier('credits')),
+            NumericConstant('3')
+            ),
+    ],
+    Identifier('c')
+)
+
 class QueryParser:
     def __init__(self, engine):
         self.metadata = engine.metadata
@@ -11,19 +60,4 @@
         return True
     
     def compile(self, query):
-        from ocql.engine.queryobject import *
-        
-        return \
-            Query(
-                set,
-                [
-                    In(Identifier('c'),Identifier('ICurses')),
-                    In(Identifier('d'),Identifier('IDepartments')),
-                    Eq(Property(Identifier('d'),Identifier('name')),Constant('"Computing Science"')),
-                    Eq(Identifier('d'),Quanted(Some(),Property(Identifier('c'),Identifier('runBy')))),
-                    Le(Property(Identifier('c'),Identifier('credits')),Constant('3')),
-                    Le(Constant('1'),Property(Identifier('c'),Identifier('credits'))),
-                ],
-                Identifier('c')
-            )
-        
\ No newline at end of file
+        return WIRED
\ No newline at end of file

Modified: Sandbox/ocql-foliage/src/ocql/engine/rewriter.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/rewriter.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/rewriter.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,3 +1,11 @@
+#
+# Rewrites the Query Object to Algebra Object
+#
+# rewrite is moved to the Query object classes
+# to their rewrite method
+#
+
+
 class Rewriter:
     def __init__(self, engine):
         self.engine = engine

Modified: Sandbox/ocql-foliage/src/ocql/engine/runnablequery.py
===================================================================
--- Sandbox/ocql-foliage/src/ocql/engine/runnablequery.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/ocql/engine/runnablequery.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -14,7 +14,7 @@
     def execute(self):
         metadata = self.engine.metadata
         
-        return reduce(set.union, map(lambda c: reduce(set.union, map(lambda d: ((d.name=="Computing Science") and (((d==set(filter(lambda i: i.runBy,c))) and (((c.credits<=3) and (((1<=c.credits) and (set([c])) or (set()))) or (set()))) or (set()))) or (set())),set(metadata.getAll("IDepartments"))) , set()),set(metadata.getAll("ICurses"))) , set())
+        #return reduce(set.union, map(lambda c: reduce(set.union, map(lambda d: ((d.name=="Computing Science") and (((d==set(filter(lambda i: i.runBy,c))) and (((c.credits<=3) and (((1<=c.credits) and (set([c])) or (set()))) or (set()))) or (set()))) or (set())),set(metadata.getAll("IDepartments"))) , set()),set(metadata.getAll("ICurses"))) , set())
         
         #return eval(self.code,
         #            {},

Added: Sandbox/ocql-foliage/src/status.txt
===================================================================
--- Sandbox/ocql-foliage/src/status.txt	                        (rev 0)
+++ Sandbox/ocql-foliage/src/status.txt	2007-09-24 19:17:22 UTC (rev 79894)
@@ -0,0 +1,102 @@
+Here are the statuses, problems and TODO of each component:
+===========================================================
+
+queryparser.py
+==============
+Stub of query parser at the moment
+
+State: stub
+TODO: implement, shall be an easy task
+Problems:
+
+
+queryoptimizer.py
+=================
+Optimizing will be done later,
+at the moment this is just a stub returning it's input
+
+State: stub
+TODO: Quite a lot, but shall be simple
+Problems:
+
+
+rewriter.py
+===========
+Rewrites the Query Object to Algebra Object
+
+State: good?
+TODO:
+Problems:
+
+
+algebra.py
+==========
+Signature definition of Algebra operation classes.
+
+State: good?
+TODO:
+Problems:
+
+testalgebra.py
+==============
+Implementation for algebra.py
+For ZODB, Zope 3, Indexes, hurry.query
+
+State: ?
+TODO:
+Problems:
+
+
+algebraoptimizer.py
+===================
+Optimization will be done later,
+at the moment this is just a stub returning it's input
+
+State:
+TODO: Hell lot, but later!
+Problems:
+
+
+algebracompiler.py
+==================
+Actual compilation of the Algebra to Python is done
+in each Algebra class/object at the moment
+
+State: good?
+TODO:
+Problems:
+
+
+metadata.py
+===========
+
+State:
+TODO:
+Problems:
+
+
+queryobject.py
+==============
+Classes for the Query Object representation
+
+State:
+TODO: yes, see file
+Problems:
+
+
+runnablequery.py
+================
+
+State:
+TODO:
+Problems:
+
+
+ocqlengine.py
+=============
+
+State:
+TODO:
+Problems:
+
+


Property changes on: Sandbox/ocql-foliage/src/status.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author Id Revision
Name: svn:eol-style
   + native

Modified: Sandbox/ocql-foliage/src/testalgebra.py
===================================================================
--- Sandbox/ocql-foliage/src/testalgebra.py	2007-09-24 19:15:11 UTC (rev 79893)
+++ Sandbox/ocql-foliage/src/testalgebra.py	2007-09-24 19:17:22 UTC (rev 79894)
@@ -1,6 +1,10 @@
 #
 # Algebra operators
 #
+# decided to let these depend on the database
+# so this is the implementation
+# interface goes to ocql/engine/algebra.py
+#
 from ocql.engine.algebra import Algebra
 
 class BaseAlgebra(Algebra):



More information about the Checkins mailing list