コード例 #1
0
 def __call__(self):
     if ocql.queryobject.interfaces.IQuanted.providedBy(self.context.left):
         return IRewriter(self.context.left)(
             self.context.right, self.context)
     if ocql.queryobject.interfaces.IQuanted.providedBy(self.context.right):
         return IRewriter(self.context.right)(
             self.context.left, self.context)
     else:
         return Binary(
             IRewriter(self.context.left)(),
             IRewriter(self.context).get_operator(),
             IRewriter(self.context.right)())
コード例 #2
0
 def __call__(self):
     if isinstance(self.context.left, ocql.queryobject.queryobject.Quanted):
         return IRewriter(self.context.left)(self.context.right,
                                             self.context)
     if isinstance(self.context.right,
                   ocql.queryobject.queryobject.Quanted):
         return IRewriter(self.context.right)(self.context.left,
                                              self.context)
     else:
         return Binary(
             IRewriter(self.context.left)(),
             IRewriter(self.context).get_operator(),
             IRewriter(self.context.right)())
コード例 #3
0
 def __call__(self, expression, quanted, operator):
     ctype = quanted.get_collection_type()
     return Reduce(
         ctype,  # FIXME ?set? but which type() to take? quanted.expression?
         Identifier('False'),
         Lambda(
             'i',
             IRewriter(
                 operator.__class__(
                     self.context.metadata, self.context.symbols,
                     ocql.queryobject.queryobject.Identifier(
                         self.context.metadata, self.context.symbols, 'i'),
                     expression))()),
         Operator('or'),
         IRewriter(quanted)())
コード例 #4
0
 def __call__(self):
     return Reduce(
         set, # FIXME milyen bag
         Constant(0),
         Lambda('i', Constant(1)),
         Operator('+'),
         IRewriter(self.context.expression)()
         # FIXME ?set? must be determined by type(self.expression)
     )
コード例 #5
0
ファイル: engine.py プロジェクト: bendavis78/zope
    def compile(self, query):
        #TODO: later use maybe named adapters
        metadata = IDB(None)

        objectquery = IQueryParser(query)(metadata)
        optimizedoq = IQueryOptimizer(objectquery)()
        algebra = IRewriter(optimizedoq)()
        optimizedalgebra = IAlgebraOptimizer(algebra)()
        runnable = IAlgebraCompiler(optimizedalgebra)(metadata, algebra)

        return runnable
コード例 #6
0
    def compile(self, query):
        #TODO: later use maybe named adapters
        metadata = IDB(None)
        if IObjectQueryHead.providedBy(query):
            objectquery = query
        else:
            objectquery = IQueryParser(query)(metadata)
        
        optimizedoq = IQueryOptimizer(objectquery)()
        algebra = IRewriter(optimizedoq)()
        optimizedalgebra = IAlgebraOptimizer(algebra)(metadata)
        runnable = IAlgebraCompiler(optimizedalgebra)(metadata, optimizedalgebra)

        return runnable
コード例 #7
0
    def compile(self, query):
        #TODO: later use maybe named adapters
        metadata = IDB(None)
        if IObjectQueryHead.providedBy(query):
            objectquery = query
        else:
            objectquery = IQueryParser(query)(metadata)

        optimizedoq = IQueryOptimizer(objectquery)()
        algebra = IRewriter(optimizedoq)()
        optimizedalgebra = IAlgebraOptimizer(algebra)(metadata)
        #algebra is passed here to keep track of the original one, not the optimized
        runnable = IAlgebraCompiler(optimizedalgebra)(metadata, algebra)

        return runnable
コード例 #8
0
    def __call__(self):
        self.context.symbols.addlevel()
        rv = None

        if len(self.context.terms):
            for t in self.context.terms:
                t.addSymbol()

            firstTerm = self.context.terms[0]
            if isinstance(firstTerm, ocql.queryobject.queryobject.In):

                ctype = firstTerm.get_collection_type()

                rv = Iter(
                    self.context.collection_type,
                    Lambda(
                        firstTerm.identifier.name,
                        IRewriter(
                            ocql.queryobject.queryobject.Query(
                                self.context.metadata, self.context.symbols,
                                self.context.collection_type,
                                self.context.terms[1:],
                                self.context.target))()),
                    Make(
                        self.context.collection_type, ctype,
                        IRewriter(firstTerm.expression)()
                    )  # FIXME: ?set? must be determined by type(firstTerm.expression)
                )
            elif isinstance(firstTerm, ocql.queryobject.queryobject.Alias):
                rv = IRewriter(
                    ocql.queryobject.queryobject.Query(
                        self.context.metadata, self.context.symbols,
                        self.context.collection_type, [
                            ocql.queryobject.queryobject.In(
                                self.context.metadata, self.context.symbols,
                                firstTerm.identifier, firstTerm.expression)
                        ] + self.context.terms[1:], self.context.target))()
            else:
                rv = If(
                    IRewriter(firstTerm)(),
                    IRewriter(
                        ocql.queryobject.queryobject.Query(
                            self.context.metadata, self.context.symbols,
                            self.context.collection_type,
                            self.context.terms[1:], self.context.target))(),
                    Empty(self.context.collection_type))
        else:
            rv = Single(self.context.collection_type,
                        IRewriter(self.context.target)())

        self.context.symbols.dellevel()
        return rv
コード例 #9
0
 def __call__(self):
     query = self.context.tree
     adapter = IRewriter(query)
     alg = adapter()
     return Head(alg)
コード例 #10
0
 def __call__(self, expression, operator):
     return IRewriter(self.context.quantor)(
         expression, self.context.expression, operator)
コード例 #11
0
 def __call__(self):
     return Not(set, IRewriter(self.context.expression)())
コード例 #12
0
 def __call__(self):
     return Identifier(
         '.'.join([IRewriter(self.context.left)().name,
                   IRewriter(self.context.right)().name]))
コード例 #13
0
 def __call__(self):
     return Differ(
         self.context.left.get_collection_type(),
         IRewriter(self.context.left)(),
         IRewriter(self.context.right)())
コード例 #14
0
 def __call__(self):
     return Binary(IRewriter(self.context.left)(),
         IRewriter(self.context).get_operator(),
         IRewriter(self.context.right)())