[Checkins] SVN: Sandbox/adamg/ocql/trunk/src/ocql/ cleaning up
Adam Groszer
agroszer at gmail.com
Thu Aug 21 03:31:22 EDT 2008
Log message for revision 90050:
cleaning up
Changed:
A Sandbox/adamg/ocql/trunk/src/ocql/TODO.txt
U Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.py
U Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.txt
U Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/tests.py
U Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.py
A Sandbox/adamg/ocql/trunk/src/ocql/compiler/debug.txt
U Sandbox/adamg/ocql/trunk/src/ocql/compiler/runnablequery.py
U Sandbox/adamg/ocql/trunk/src/ocql/compiler/tests.py
U Sandbox/adamg/ocql/trunk/src/ocql/database/index.py
U Sandbox/adamg/ocql/trunk/src/ocql/parser/queryparser.py
U Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/qoptimizer.py
U Sandbox/adamg/ocql/trunk/src/ocql/queryobject/queryobject.py
U Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.py
U Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra_checks.txt
U Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.py
U Sandbox/adamg/ocql/trunk/src/ocql/testing/database.py
-=-
Added: Sandbox/adamg/ocql/trunk/src/ocql/TODO.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/TODO.txt (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/TODO.txt 2008-08-21 07:31:22 UTC (rev 90050)
@@ -0,0 +1,6 @@
+
+TODOs
+=====
+
+Problem: we want to test object equality by intid, what if the object defines
+ it's own __cmp__? Needs to be loaded and called.
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/TODO.txt
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Modified: Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -1,15 +1,12 @@
# -*- coding: UTF-8 -*-
-""" Optimizing will be done later,
-at the moment this is just a stub returning it's input
+""" Algebra optimizer
$Id$
"""
-from collections import deque
+
from zope.component import adapts
from zope.interface import implements
-from zope.location import locate
-#from zope.security.proxy import removeSecurityProxy
from zope.interface import directlyProvidedBy
from zope.interface import directlyProvides
@@ -91,7 +88,6 @@
def __init__(self, context):
self.context = context
- #self.db = db
def __call__(self, metadata):
results = findItrTreePattern(self.context.tree)
Modified: Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.txt 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/aoptimizer.txt 2008-08-21 07:31:22 UTC (rev 90050)
@@ -30,6 +30,8 @@
>>> out.tree
`foo-bar`
+The algebra optimizer adds the marker interface IOptimizedAlgebraObject:
+
>>> IOptimizedAlgebraObject.providedBy(out)
True
Modified: Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/tests.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/tests.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/tests.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -7,8 +7,6 @@
def test_suite():
flags = doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
return unittest.TestSuite((
-# avoid this tests for convenient while adding new implementation to the algebra optimizer
-#need to add aoptimizer.txt
DocFileSuite('aoptimizer.txt',
optionflags=flags,
setUp = utils.setupAdapters),
Modified: Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -5,9 +5,6 @@
$Id$
"""
-#BIG-BIG-BIG TODO:
-# move all class.compile to here, using the adapter pattern
-
from zope.component import adapts
from zope.interface import implements
from zope.component import provideAdapter
@@ -50,7 +47,7 @@
class BaseCompiler(object):
def __init__(self, context):
- #context becomes the adapted object
+ #context becomes the adapted (algebra) object
self.context = context
class EmptyCompiler(BaseCompiler):
Added: Sandbox/adamg/ocql/trunk/src/ocql/compiler/debug.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/compiler/debug.txt (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/compiler/debug.txt 2008-08-21 07:31:22 UTC (rev 90050)
@@ -0,0 +1,49 @@
+
+Debugging queries
+=================
+
+There are some helper functions built into runnablequery to ease
+debugging.
+Debugging cannot be tested here, but results still need to be the
+same with or without debugging.
+Only difference canbe the returned type's class.
+
+ >>> from zope.component import provideAdapter
+ >>> from ocql.testing.database import TestMetadata
+ >>> provideAdapter(TestMetadata)
+ >>> from ocql.engine import OCQLEngine
+
+
+ >>> engine = OCQLEngine()
+ >>> run = engine.compile("set [ | 1 ]")
+
+ >>> run.execute()
+ set([1])
+
+ >>> run.execute(debug=True)
+ d_set([1])
+
+
+ >>> engine = OCQLEngine()
+ >>> run = engine.compile("set [ i in ICourse | i ]")
+
+ >>> result = run.execute()
+ >>> sorted(list(result), key=lambda i: i.code)
+ [Course <C1>, Course <C2>, Course <C3>]
+
+ >>> result = run.execute(debug=True)
+ >>> sorted(list(result), key=lambda i: i.code)
+ [Course <C1>, Course <C2>, Course <C3>]
+
+
+
+ >>> engine = OCQLEngine()
+ >>> run = engine.compile("set [ c in ICourse | c.code ]")
+
+ >>> result = run.execute()
+ >>> sorted(list(result))
+ ['C1', 'C2', 'C3']
+
+ >>> result = run.execute(debug=True)
+ >>> sorted(list(result))
+ ['C1', 'C2', 'C3']
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/compiler/debug.txt
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Modified: Sandbox/adamg/ocql/trunk/src/ocql/compiler/runnablequery.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/compiler/runnablequery.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/compiler/runnablequery.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -1,6 +1,8 @@
# -*- coding: UTF-8 -*-
"""Runnable query object
+
+Contains the runnable python code
This will return the resultset
$Id$
@@ -15,6 +17,8 @@
_marker = object()
#these are here helper functions to debug compiled code
+#set breakpoints here
+#feel free to add classes and methods to debug
def d_reduce(function, sequence, initializer=_marker):
if initializer is _marker:
Modified: Sandbox/adamg/ocql/trunk/src/ocql/compiler/tests.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/compiler/tests.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/compiler/tests.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -13,6 +13,9 @@
DocFileSuite('compiler_optimized.txt',
optionflags=flags,
setUp = utils.setupAdapters),
+ DocFileSuite('debug.txt',
+ optionflags=flags,
+ setUp = utils.setupAdapters),
))
Modified: Sandbox/adamg/ocql/trunk/src/ocql/database/index.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/database/index.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/database/index.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -7,6 +7,8 @@
#TODO: not optimal, uses FieldIndex with a value of always 1
+#TODO: later: keep a count of objects stored for len() and optimization
+
import zope.index.field
import zope.interface
import zope.schema
Modified: Sandbox/adamg/ocql/trunk/src/ocql/parser/queryparser.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/parser/queryparser.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/parser/queryparser.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -5,10 +5,9 @@
"""
#TODOs:
-#add metadata into the picture!!!
#remove shift/reduce conflicts, when possible
#look after raise "Help"
-#revise according to new grammar
+#parser caching does not work yet
from ply import lex, yacc
from collections import deque
@@ -39,7 +38,12 @@
def current(self):
return self.stack[-1]
-tokens = ('SET', 'LIST', 'COMMA', 'NOT_EQUAL', 'UNION', 'AS', 'EVERY', 'ATMOST', 'LT', 'GT', 'ELLIPSIS', 'BRACKET_R', 'OR', 'PIPE', 'DOT', 'IN', 'LTE', 'SOME', 'AND', 'CBRACKET_L', 'CONSTANT', 'EQUAL', 'GTE', 'ISINSTANCE', 'SEMI_COLON', 'BRACKET_L', 'ASSIGN', 'NOT_ASSIGN', 'FOR', 'CBRACKET_R', 'JUST', 'IDENTIFIER', 'DIFFER', 'LEN', 'BAG', 'SBRACKET_L', 'NOT', 'ATLEAST', 'SBRACKET_R')
+tokens = ('SET', 'LIST', 'COMMA', 'NOT_EQUAL', 'UNION', 'AS', 'EVERY',
+ 'ATMOST', 'LT', 'GT', 'ELLIPSIS', 'BRACKET_R', 'OR', 'PIPE',
+ 'DOT', 'IN', 'LTE', 'SOME', 'AND', 'CBRACKET_L', 'CONSTANT',
+ 'EQUAL', 'GTE', 'ISINSTANCE', 'SEMI_COLON', 'BRACKET_L', 'ASSIGN',
+ 'NOT_ASSIGN', 'FOR', 'CBRACKET_R', 'JUST', 'IDENTIFIER', 'DIFFER',
+ 'LEN', 'BAG', 'SBRACKET_L', 'NOT', 'ATLEAST', 'SBRACKET_R')
precedence = (
('left', 'UNION'),
@@ -50,9 +54,9 @@
('left', 'AND'),
('left', 'OR'),
('right', 'NOT'),
- #('left', 'COND_OP'),
-# ('left', 'PLUS', 'MINUS'),
-# ('left', 'MUL', 'DIV'),
+# ('left', 'COND_OP'),
+# ('left', 'PLUS', 'MINUS'),
+# ('left', 'MUL', 'DIV'),
# ('token', 'IDENTIFIER'),
# ('token', 'BRACEL'),
# ('token', 'BRACER'),
@@ -378,7 +382,7 @@
else:
t[0] = t[1]
t[0].extend(t[3])
-
+
if DEBUG: print 'reducing "qualifier SEMI_COLON qualifier" to "qualifier"', t[0]
# def p_qualifier_6(self, t):
@@ -522,7 +526,7 @@
def p_definition_as(self, t):
r'''definition : IDENTIFIER AS expression
'''
- t[0] = Alias(self.metadata, self.symbols,
+ t[0] = Alias(self.metadata, self.symbols,
Identifier(self.metadata, self.symbols, t[1]),
t[3])
if DEBUG: print 'reducing "IDENTIFIER AS expression" to "definition"', t[0]
Modified: Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/qoptimizer.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/qoptimizer.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/qoptimizer.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -1,6 +1,8 @@
# -*- coding: UTF-8 -*-
-""" Optimizing will be done later,
+""" Query optimizer
+
+Optimizing will be done later,
at the moment this is just a stub returning it's input
$Id$
Modified: Sandbox/adamg/ocql/trunk/src/ocql/queryobject/queryobject.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/queryobject/queryobject.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/queryobject/queryobject.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -6,12 +6,7 @@
"""
#TODOS:
-#move self.rewrite to ocql.rewriter into adapters
-#add self.__repr__ to ALL, see Query class
-
-#implement a traversable tree of queryobjects (parent, child, sibling, ....)
-
# TODO: missing:
#xi{Es}
#xi{E1..E2}
Modified: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -5,11 +5,6 @@
$Id$
"""
-#
-# decided to let these depend on the database
-# so this is the implementation
-#
-
from zope.interface import implements
from ocql.interfaces import IAlgebraObject
@@ -270,11 +265,4 @@
# return '%s.%s' (self.left.compile(),self.right.compile())
#
# def __repr__(self):
-# return '%s.%s' (self.left,self.right)
-
-def _test():
- import doctest
- doctest.testmod()
-
-if __name__ == "__main__":
- _test()
+# return '%s.%s' (self.left,self.right)
\ No newline at end of file
Modified: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra_checks.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra_checks.txt 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra_checks.txt 2008-08-21 07:31:22 UTC (rev 90050)
@@ -65,11 +65,11 @@
>>> verifyObject(IMake, Make(baseAlgebra, baseAlgebra, baseAlgebra))
True
- #Uncomment this after merge other branch modifications
- #>>> verifyClass(IMakeFromIndex, MakeFromIndex)
- #True
- #>>> verifyObject(IMakeFromIndex, MakeFromIndex(baseAlgebra, baseAlgebra, baseAlgebra, baseAlgebra))
- #True
+ Uncomment this after merge other branch modifications
+ >>> verifyClass(IMakeFromIndex, MakeFromIndex)
+ True
+ >>> verifyObject(IMakeFromIndex, MakeFromIndex(baseAlgebra, baseAlgebra, baseAlgebra, baseAlgebra, baseAlgebra, baseAlgebra))
+ True
>>> verifyClass(IIf, If)
True
Modified: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -5,10 +5,6 @@
$Id$
"""
-#BIG-BIG-BIG TODO:
-# move all queryobject.rewrite to this package
-# using adapters to do the rewrite
-
from zope.component import adapts
from zope.interface import implements
from zope.location import locate
@@ -89,7 +85,7 @@
elif isinstance(firstTerm, ocql.queryobject.queryobject.Alias):
rv = Iter(
self.context.collection_type,
- Lambda(IRewriter(firstTerm.identifier)(),
+ Lambda(IRewriter(firstTerm.identifier)(),
Single(self.context.collection_type, IRewriter(firstTerm.identifier)())),
Single(self.context.collection_type, IRewriter(firstTerm.expression)()))
Modified: Sandbox/adamg/ocql/trunk/src/ocql/testing/database.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/testing/database.py 2008-08-21 07:01:08 UTC (rev 90049)
+++ Sandbox/adamg/ocql/trunk/src/ocql/testing/database.py 2008-08-21 07:31:22 UTC (rev 90050)
@@ -36,43 +36,6 @@
required=True
)
-#I moved these classes to metadata, is it ok?
-
-#class MClass(metadata.MetaType):
- #interface suspect thing
-# def __init__(self, klass):
-# self.klass = klass
-
- #def is_collection(self):
- # return True
-
-# def get_collection_type(self):
-# return set
-
-# def get_contained(self):
-# return self.klass
-
-# def __getitem__(self, name):
-# x = self.klass[name]._type
-# try:
-# return x[-1]
-# except TypeError:
-# return x
-
-class MType(MetaType):
- def __init__(self, klass, collection_type=None):
- self.klass = klass
- self.collection_type = collection_type
-
- def is_collection(self):
- return (self.collection_type is not None)
-
- def get_collection_type(self):
- return self.collection_type
-
- def get_contained(self):
- return self.klass
-
class Department(object):
implements(IDepartments)
More information about the Checkins
mailing list