[Checkins] SVN: Sandbox/adamg/ocql/ basic skeleton added
Adam Groszer
agroszer at gmail.com
Sun Jun 8 12:20:33 EDT 2008
Log message for revision 87243:
basic skeleton added
Changed:
A Sandbox/adamg/ocql/branches/
A Sandbox/adamg/ocql/tags/
A Sandbox/adamg/ocql/trunk/
A Sandbox/adamg/ocql/trunk/bootstrap.py
A Sandbox/adamg/ocql/trunk/buildout.cfg
A Sandbox/adamg/ocql/trunk/externals/
A Sandbox/adamg/ocql/trunk/setup.py
A Sandbox/adamg/ocql/trunk/src/
A Sandbox/adamg/ocql/trunk/src/ocql/
A Sandbox/adamg/ocql/trunk/src/ocql/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/
A Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/compiler/
A Sandbox/adamg/ocql/trunk/src/ocql/compiler/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/engine.py
A Sandbox/adamg/ocql/trunk/src/ocql/interfaces.py
A Sandbox/adamg/ocql/trunk/src/ocql/parser/
A Sandbox/adamg/ocql/trunk/src/ocql/parser/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/
A Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/rewriter/
A Sandbox/adamg/ocql/trunk/src/ocql/rewriter/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/testing/
A Sandbox/adamg/ocql/trunk/src/ocql/testing/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/testing/stubs.py
A Sandbox/adamg/ocql/trunk/src/ocql/tests/
A Sandbox/adamg/ocql/trunk/src/ocql/tests/__init__.py
A Sandbox/adamg/ocql/trunk/src/ocql/tests/test_skeleton.py
-=-
Property changes on: Sandbox/adamg/ocql/trunk
___________________________________________________________________
Name: svn:ignore
+ bin
develop-eggs
parts
Added: Sandbox/adamg/ocql/trunk/bootstrap.py
===================================================================
--- Sandbox/adamg/ocql/trunk/bootstrap.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/bootstrap.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: Sandbox/adamg/ocql/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/buildout.cfg
===================================================================
--- Sandbox/adamg/ocql/trunk/buildout.cfg (rev 0)
+++ Sandbox/adamg/ocql/trunk/buildout.cfg 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,27 @@
+[buildout]
+prefer-final = true
+
+develop = .
+
+parts = test checker
+
+[versions]
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = OCQL [test]
+
+[checker]
+recipe = lovely.recipe:importchecker
+path = src/ocql
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = OCQL [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/buildout.cfg
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/setup.py
===================================================================
--- Sandbox/adamg/ocql/trunk/setup.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/setup.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,44 @@
+"""Setup
+
+$Id$
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup (
+ name='OCQL',
+ version='0.0.2',
+ author = "Adam Groszer & Attila Gobi & Charith Paranaliyanage",
+ author_email = "agroszer at gmail.com",
+ description = "OCQL",
+ long_description=(""),
+ license = "ZPL V2.1",
+ keywords = "",
+ classifiers = [
+ 'Intended Audience :: Developers',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Framework :: Zope3'
+ ],
+ url = '',
+ packages = find_packages('src'),
+ package_dir = {'':'src'},
+ namespace_packages = ['ocql'],
+ extras_require = dict(
+ test = [
+ ],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'ply',
+ 'zope.interface',
+ 'zope.component'
+ ],
+
+ include_package_data = True,
+ zip_safe = False,
+ )
Property changes on: Sandbox/adamg/ocql/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Property changes on: Sandbox/adamg/ocql/trunk/src
___________________________________________________________________
Name: svn:ignore
+ OCQL.egg-info
Added: Sandbox/adamg/ocql/trunk/src/ocql/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/aoptimizer/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/compiler/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/compiler/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/compiler/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/compiler/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/engine.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/engine.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/engine.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,42 @@
+# -*- coding: UTF-8 -*-
+
+"""Main
+
+$Id$
+"""
+
+from zope.interface import implements
+from zope.component import getAdapter
+
+from ocql.interfaces import IEngine
+
+from ocql.interfaces import IQueryParser
+from ocql.interfaces import IQueryOptimizer
+from ocql.interfaces import IRewriter
+from ocql.interfaces import IAlgebraOptimizer
+from ocql.interfaces import IAlgebraCompiler
+from ocql.interfaces import IDB
+
+from ocql.interfaces import IObjectQuery
+from ocql.interfaces import IOptimizedObjectQuery
+from ocql.interfaces import IAlgebraObject
+from ocql.interfaces import IOptimizedAlgebraObject
+from ocql.interfaces import IRunnableQuery
+
+class OCQLEngine:
+ implements(IEngine)
+
+ def __init__(self):
+ pass
+
+ def compile(self, query):
+ #TODO: later use maybe named adapters
+ db = IDB(None)
+
+ objectquery = IQueryParser(query)()
+ optimizedoq = IQueryOptimizer(objectquery)()
+ algebra = IRewriter(optimizedoq)()
+ optimizedalgebra = IAlgebraOptimizer(algebra)()
+ runnable = IAlgebraCompiler(optimizedalgebra)()
+
+ return runnable
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/engine.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/interfaces.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/interfaces.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/interfaces.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,112 @@
+# -*- coding: UTF-8 -*-
+
+"""OCQL interfaces
+
+$Id$
+"""
+
+from zope.interface import Interface
+from zope.interface import Attribute
+
+################
+# Components
+################
+
+class IEngine(Interface):
+ def compile(query):
+ """
+ """
+
+class IQueryParser(Interface):
+ """Parse the query string and build a query object tree representing
+ the query.
+ """
+
+class IQueryOptimizer(Interface):
+ """Makes some simplifications on the query object tree. Input/output
+ is the same format: query object tree.
+ """
+
+class IRewriter(Interface):
+ """Rewrites the query object tree to Collection Algebra.
+ Output is an Algebra object.
+ """
+
+class IAlgebraOptimizer(Interface):
+ """Optimizes the query using the Collection Algebra identity operations.
+ This component contains only the code of the optimizer logic.
+ Input/output is the same format: Algebra object.
+ """
+
+class IAlgebraCompiler(Interface):
+ """ Compiles the algebra object into python lambda and list comprehension.
+ Output is an object that holds all information necessary to run the query.
+ Embeds the relation and index retrieval component information in the compiled object.
+ """
+
+class IDB(Interface):
+ """DB metadata and data provider
+ Provides database metadata to the engine.
+ - class/object declarations (from interface declarations)
+ - index information (from zope catalogs and indexes)
+ - relationship information ()
+ Provides data extraction support for
+ - index values/objects
+ - relation/related objects
+ """
+
+################
+# Objects passed around
+################
+
+class IObjectQuery(Interface):
+ """Objects providing this interface represent the OCQL query
+ as python objects
+ """
+
+class IOptimizedObjectQuery(Interface):
+ """Objects providing this interface represent the OCQL query
+ as python objects
+ """
+
+class IAlgebraObject(Interface):
+ """Objects providing this interface represent the
+ rewritten ObjectQuery to Algebra objects
+ """
+
+class IOptimizedAlgebraObject(Interface):
+ """Objects providing this interface represent the
+ rewritten ObjectQuery to Algebra objects
+ """
+
+class IRunnableQuery(Interface):
+ """Objects providing this interface represent the
+ runnable query
+ """
+
+ def execute():
+ """Run the query, return the resulting dataset
+ """
+
+ def reanalyze():
+ """Reanalyze and reoptimize the query according to the current
+ contents of the database
+ """
+
+################
+#
+################
+
+class ILogger(Interface):
+ """ Everything must be logged!
+ I want to be able to hunt for bugs and bottlenecks.
+ - component inputs
+ - component outputs
+ - component runtimes
+ All components shall log here.
+ """
+
+class IStatistics(Interface):
+ """Stores statistical data based on queries run before.
+ Provides statistical data for optimization.
+ """
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/parser/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/parser/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/parser/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/parser/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/qoptimizer/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/rewriter/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/rewriter/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/testing/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/testing/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/testing/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/testing/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/testing/stubs.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/testing/stubs.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/testing/stubs.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,107 @@
+# -*- coding: UTF-8 -*-
+
+"""component stubs for testing
+
+$Id$
+"""
+
+from zope.component import adapts
+from zope.component import provideAdapter
+from zope.interface import implements
+
+from ocql.interfaces import IQueryParser
+from ocql.interfaces import IQueryOptimizer
+from ocql.interfaces import IRewriter
+from ocql.interfaces import IAlgebraOptimizer
+from ocql.interfaces import IAlgebraCompiler
+from ocql.interfaces import IDB
+
+from ocql.interfaces import IObjectQuery
+from ocql.interfaces import IOptimizedObjectQuery
+from ocql.interfaces import IAlgebraObject
+from ocql.interfaces import IOptimizedAlgebraObject
+from ocql.interfaces import IRunnableQuery
+
+class ObjectQueryTree(object):
+ implements(IObjectQuery)
+
+class ObjectQueryTreeOptimized(object):
+ implements(IOptimizedObjectQuery)
+
+class Algebra(object):
+ implements(IAlgebraObject)
+
+class AlgebraOptimized(object):
+ implements(IOptimizedAlgebraObject)
+
+class RunnableQuery(object):
+ implements(IRunnableQuery)
+
+class QueryParser(object):
+ implements(IQueryParser)
+ adapts(basestring)
+
+ def __init__(self, context):
+ self.context = context
+ #self.db = db
+
+ def __call__(self):
+ strg = self.context
+ return ObjectQueryTree()
+
+class QueryOptimizer(object):
+ implements(IQueryOptimizer)
+ adapts(IObjectQuery)
+
+ def __init__(self, context):
+ self.context = context
+
+ def __call__(self):
+ return ObjectQueryTreeOptimized()
+
+class Rewriter(object):
+ implements(IRewriter)
+ adapts(IOptimizedObjectQuery)
+
+ def __init__(self, context):
+ self.context = context
+
+ def __call__(self):
+ return Algebra()
+
+class AlgebraOptimizer(object):
+ implements(IAlgebraOptimizer)
+ adapts(IAlgebraObject)
+
+ def __init__(self, context):
+ self.context = context
+ #self.db = db
+
+ def __call__(self):
+ return AlgebraOptimized()
+
+class AlgebraCompiler(object):
+ implements(IAlgebraCompiler)
+ adapts(IOptimizedAlgebraObject)
+
+ def __init__(self, context):
+ self.context = context
+ #self.db = db
+
+ def __call__(self):
+ return RunnableQuery()
+
+class DB(object):
+ implements(IDB)
+ adapts(None)
+
+ def __init__(self, context):
+ pass
+
+def registerStubs():
+ provideAdapter(QueryParser)
+ provideAdapter(QueryOptimizer)
+ provideAdapter(Rewriter)
+ provideAdapter(AlgebraOptimizer)
+ provideAdapter(AlgebraCompiler)
+ provideAdapter(DB)
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/testing/stubs.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/tests/__init__.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/tests/__init__.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/tests/__init__.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1 @@
+#
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
Added: Sandbox/adamg/ocql/trunk/src/ocql/tests/test_skeleton.py
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/tests/test_skeleton.py (rev 0)
+++ Sandbox/adamg/ocql/trunk/src/ocql/tests/test_skeleton.py 2008-06-08 16:20:32 UTC (rev 87243)
@@ -0,0 +1,28 @@
+# -*- coding: UTF-8 -*-
+
+"""Main
+
+$Id$
+"""
+
+import unittest
+
+from ocql.engine import OCQLEngine
+from ocql.testing.stubs import *
+
+class testSkeleton(unittest.TestCase):
+ def testSomething(self):
+ registerStubs()
+
+ e = OCQLEngine()
+ rq = e.compile("[ c in ICurses | c ]")
+
+ self.assert_(isinstance(rq, RunnableQuery))
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(testSkeleton))
+ return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
\ No newline at end of file
Property changes on: Sandbox/adamg/ocql/trunk/src/ocql/tests/test_skeleton.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Id Revision
Name: svn:eol-style
+ native
More information about the Checkins
mailing list