Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 126

Show
Ignore:
Timestamp:
08/09/07 20:54:53
Author:
fumanchu
Message:

Collapsed selectwriter output_* attrs into a single tuple for speed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ast/geniusql/objects.py

    r125 r126  
    951951            data, _ = self.fetch(selsql) 
    952952             
     953            output_keys = [names[0] for names in sel.output] 
    953954            for row in Dataset(sel, data): 
    954                 row = dict(zip(sel.output_keys, row)) 
     955                row = dict(zip(output_keys, row)) 
    955956                # Run a dummy object through our restriction before inserting. 
    956957                if not query.restriction(_ImperfectDummy(**row)): 
     
    959960                newtable.insert(**row) 
    960961        else: 
     962            qnames = [names[2] for names in sel.output] 
    961963            sql = ("INSERT INTO %s (%s) %s" % 
    962                    (newtable.qname, ", ".join(sel.output_qnames), selsql)) 
     964                   (newtable.qname, ", ".join(qnames), selsql)) 
    963965            self.execute(sql) 
    964966         
     
    997999        # pre-fetch cols and cache in an optimal format. 
    9981000        c = dataset.selector.output_cols 
    999         self.cols = [c[key] for key in dataset.selector.output_keys
     1001        self.cols = [c[coldata[0]] for coldata in dataset.selector.output
    10001002     
    10011003    def __iter__(self): 
  • branches/ast/geniusql/select.py

    r125 r126  
    193193    input_list: a list of SQL expressions, one for each column in the 
    194194        SELECT clause. These will include any "expr AS name" alias. 
    195     output_names: a list of the SQL names (aliases), one per output column. 
    196     output_qnames: a list of quoted SQL names (aliases), one per output column. 
    197     output_keys: the keys for each column in the final table
     195    output: a list of tuples of the form: 
     196        (column key, column, SQL name (alias), quoted SQL name (alias)) 
     197        One per output column
    198198    output_cols: a dict of source cols for the final table. 
    199199    """ 
     
    229229         
    230230        self.input_list = [] 
    231         self.output_names = [] 
    232         self.output_qnames = [] 
    233         self.output_keys = [] 
     231        self.output = [] 
    234232        self.output_cols = {} 
    235233        self._groupby = [] 
     
    269267        """ 
    270268        newtable = self.schema.table(name) 
    271         for colkey, name, qname in zip(self.output_keys, self.output_names, 
    272                                        self.output_qnames): 
     269        for colkey, name, qname in self.output: 
    273270            col = self.output_cols[colkey] 
    274271            newcol = col.copy() 
     
    308305            selname = '%s AS %s' % (selname, colqname) 
    309306        self.input_list.append(selname) 
    310         self.output_names.append(colname) 
    311         self.output_qnames.append(colqname) 
    312         self.output_keys.append(colkey) 
     307        self.output.append((colkey, colname, colqname)) 
    313308        self.output_cols[colkey] = col 
    314309     
     
    461456            qname = self.db.quote(atom.name) 
    462457            self.input_list.append('%s AS %s' % (atom.sql, qname)) 
    463             self.output_keys.append(atom.name) 
    464             self.output_names.append(atom.name) 
    465             self.output_qnames.append(qname) 
     458            self.output.append((atom.name, atom.name, qname)) 
    466459            if not atom.aggregate: 
    467460                self._groupby.append(atom.sql)