Logo Search packages:      
Sourcecode: gadfly version File versions  Download package

def gadfly::semantics::Selector::eval (   self,
  dynamic = None,
  outerboundtuple = None 
)

leaves a lot to be desired.
   dynamic and outerboundtuple are mutually
   exclusive.  dynamic is only pertinent to
   top levels, outerboundtuple to subqueries

Definition at line 2670 of file semantics.py.

02670                                                       :
        """leaves a lot to be desired.
           dynamic and outerboundtuple are mutually
           exclusive.  dynamic is only pertinent to
           top levels, outerboundtuple to subqueries"""
        # only uncache if outerboundtuple is None (not subquery)
        # ???
        if outerboundtuple is None:
            self.uncache()
        query_plan = self.query_plan
        where_pred = self.where_pred.detrivialize()
        select_list = self.select_list
        # shortcut
        if where_pred is not None and where_pred.false:
            return store.Relation0(select_list.attorder, [])
        #print "where_pred", where_pred
        if where_pred is None or where_pred.constraints is None:
            assn0 = assn1 = kjbuckets.kjDict()
        else:
            assn1 = self.where_pred.constraints.assns
            assn0 = assn1 = kjbuckets.kjDict(assn1)
        # erase stored results from possible previous evaluation
        ndynamic = self.ndynamic
        if outerboundtuple is not None:
            assn1 = assn1 + outerboundtuple.assns
        elif ndynamic:
            dyn = dynamic_binding(ndynamic, dynamic)
            if len(dyn)!=1:
                raise ValueError, "only one dynamic subst for selection allowed"
            dyn = dyn[0]
            assn1 = assn1 + dyn
            #print "dynamic", bt
        #print "assn1", assn1
        # check unbound names
        unbound_set = self.unbound_set
        #print "unbound", unbound_set
        #print unbound_set
        #print self.rel_atts
        for pair in unbound_set.items():
            if not assn1.has_key(pair):
                raise KeyError, `pair`+": unbound in selection"
        assn1 = (unbound_set * assn1) + assn0
        #print "assn1 now", assn1
        substseq = [assn1]
        for h in query_plan:
            #print "***"
            #for x in substseq:
                #print x
            #print "***"
            substseq = h.join(substseq)
            if not substseq: break
            #print "***"
            #for x in substseq:
                #print x
            #print "***"
        # apply the rest of the where predicate at top level
        if substseq and where_pred is not None:
            #where_pred.uncache()
            substseq = where_pred(substseq, 1)
        # eliminate zeros/nulls
        substseq = no_ints_nulls(substseq)
        # apply grouping if present
        group_list = self.group_list
        if substseq and group_list:
            substseq = aggregate(substseq, group_list)
            having_cond = self.having_cond
            #print having_cond
            if having_cond is not None:
                #having_cond.uncache()
                substseq = no_ints_nulls(having_cond(substseq))
        elif self.all_aggregate:
            # universal group
            substseq = [kjbuckets.kjDict( [(None, substseq)] ) ]
        (tups, attorder) = select_list.map(substseq)
        # do UNION if present
        union_select = self.union_select
        if union_select is not None:
            tups = union_select.eval(tups, dynamic, outerboundtuple)
        # apply DISTINCT if appropriate
        if self.alldistinct=="DISTINCT":
            tups = kjbuckets.kjSet(tups).items()
        # apply ordering if present
        ob = self.order_by
        if ob:
            tups = order_tuples(ob, tups)
        return store.Relation0(attorder, tups)

    def __repr__(self):


Generated by  Doxygen 1.6.0   Back to index