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)())
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)())
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)())
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) )
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
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
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
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
def __call__(self): query = self.context.tree adapter = IRewriter(query) alg = adapter() return Head(alg)
def __call__(self, expression, operator): return IRewriter(self.context.quantor)( expression, self.context.expression, operator)
def __call__(self): return Not(set, IRewriter(self.context.expression)())
def __call__(self): return Identifier( '.'.join([IRewriter(self.context.left)().name, IRewriter(self.context.right)().name]))
def __call__(self): return Differ( self.context.left.get_collection_type(), IRewriter(self.context.left)(), IRewriter(self.context.right)())
def __call__(self): return Binary(IRewriter(self.context.left)(), IRewriter(self.context).get_operator(), IRewriter(self.context.right)())