Exemplo n.º 1
0
 def relbind(self, db):
     self.indb = db
     name = self.name
     target = self.target = db.get_for_update(name)
     (attb, relb, amb, ambatts) = db.bindings([(name, name)])
     cond = self.condition = self.condition.relbind(attb, db)
     # compute domain of cond
     # do nothing with it (should add sanity check)
     cond_domain = cond.domain()
     constraints = cond.constraints
     if constraints is not None:
         cassns = constraints.assns
         self.eqs = constraints.eqs
     else:
         self.eqs = cassns = None
     # compute projection/rename
     from sqlsem import kjbuckets
     condatts = kjbuckets.kjGraph(cond.domain().items()).neighbors(name)
     translate = kjbuckets.kjDict()
     for att in condatts:
         translate[(name, att)] = att
     self.translate = translate
     invtrans = self.invtrans = ~translate
     if cassns is not None:
         self.rassns = invtrans * cassns
     else:
         self.rassns = None
     return self
Exemplo n.º 2
0
 def relbind(self, db):
     self.indb = db
     name = self.name
     target = self.target = db.get_for_update(name)
     (attb, relb, amb, ambatts) = db.bindings( [ (name, name) ] )
     cond = self.condition = self.condition.relbind(attb, db)
     # compute domain of cond
     # do nothing with it (should add sanity check)
     cond_domain = cond.domain()
     constraints = cond.constraints
     if constraints is not None:
         cassns = constraints.assns
         self.eqs = constraints.eqs
     else:
         self.eqs = cassns = None
     # compute projection/rename
     from sqlsem import kjbuckets
     condatts = kjbuckets.kjGraph(cond.domain().items()).neighbors(name)
     translate = kjbuckets.kjDict()
     for att in condatts:
         translate[(name, att)] = att
     self.translate = translate
     invtrans = self.invtrans = ~translate
     if cassns is not None:
         self.rassns = invtrans * cassns
     else:
         self.rassns = None
     return self
Exemplo n.º 3
0
 def drop_indices(self, db):
     for index in self.index_list:
         name = index.name
         db.drop_datadef(name)
         db.drop_index(name)
     self.index_list = []
     from sqlsem import kjbuckets
     self.indices = kjbuckets.kjGraph()
Exemplo n.º 4
0
 def drop_indices(self, db):
     for index in self.index_list:
         name = index.name
         db.drop_datadef(name)
         db.drop_index(name)
     self.index_list = []
     from sqlsem import kjbuckets
     self.indices = kjbuckets.kjGraph()
Exemplo n.º 5
0
 def relbind(self, db, atts):
     """bind self to db, ignore atts"""
     name = self.name
     selection = self.selection
     selection = self.selection = selection.relbind(db)
     namelist = self.namelist
     if namelist is not None:
         from sqlsem import kjbuckets
         target_atts = selection.attributes()
         if len(namelist)!=len(target_atts):
             raise "select list and namelist don't match in %s"%name
         pairs = map(None, namelist, target_atts)
         self.translate = kjbuckets.kjGraph(pairs)
     return self
Exemplo n.º 6
0
 def relbind(self, db, atts):
     """bind self to db, ignore atts"""
     name = self.name
     selection = self.selection
     selection = self.selection = selection.relbind(db)
     namelist = self.namelist
     if namelist is not None:
         from sqlsem import kjbuckets
         target_atts = selection.attributes()
         if len(namelist) != len(target_atts):
             raise "select list and namelist don't match in %s" % name
         pairs = map(None, namelist, target_atts)
         self.translate = kjbuckets.kjGraph(pairs)
     return self
Exemplo n.º 7
0
 def __init__(self, attribute_names, tuples=None, filter=None):
     from sqlsem import kjbuckets
     self.indices = kjbuckets.kjGraph()
     self.index_list = []
     self.attribute_names = attribute_names
     if tuples is None:
         tuples = []
     self.filter = filter
     self.set_empty()
     self.add_tuples(tuples)
     # indices map attname > indices containing att
     # relation to shadow and log (if non-null)
     self.log = None
     self.name = None # anonymous by default
     self.is_shadow = 0
     self.touched = 0
Exemplo n.º 8
0
 def __init__(self, attribute_names, tuples=None, filter=None):
     from sqlsem import kjbuckets
     self.indices = kjbuckets.kjGraph()
     self.index_list = []
     self.attribute_names = attribute_names
     if tuples is None:
         tuples = []
     self.filter = filter
     self.set_empty()
     self.add_tuples(tuples)
     # indices map attname > indices containing att
     # relation to shadow and log (if non-null)
     self.log = None
     self.name = None  # anonymous by default
     self.is_shadow = 0
     self.touched = 0