Project

General

Profile

« Previous | Next » 

Revision 1898

bin/map: map_rows()/map_table(): Pass kw_args to process_rows() so rows_start can be specified when using them. DB inputs: Skip the pre-start rows in the SQL query itself, so that they don't need to be iterated over by the cursor in the main loop.

View differences:

bin/map
193 193
            row_ct = i-start
194 194
            return row_ct
195 195
        
196
        def map_rows(get_value, rows):
196
        def map_rows(get_value, rows, **kw_args):
197 197
            '''Maps input rows
198 198
            @param get_value(in_, row):str
199 199
            '''
......
207 207
                    if value != None:
208 208
                        log_start('Putting '+str(out), debug)
209 209
                        xpath.put_obj(root, out, row_id, has_types, value)
210
            return process_rows(process_row, rows)
210
            return process_rows(process_row, rows, **kw_args)
211 211
        
212
        def map_table(col_names, rows):
212
        def map_table(col_names, rows, **kw_args):
213 213
            col_names_ct = len(col_names)
214 214
            col_idxs = util.list_flip(col_names)
215 215
            
......
230 230
                return util.ListDict(util.list_as_length(row, col_names_ct),
231 231
                    col_names, col_idxs) # handle CSV rows of different lengths
232 232
            
233
            return map_rows(get_value, util.WrapIter(wrap_row, rows))
233
            return map_rows(get_value, util.WrapIter(wrap_row, rows), **kw_args)
234 234
        
235 235
        stdin = streams.LineCountStream(sys.stdin)
236 236
        def on_error(e):
......
241 241
            assert in_is_xpaths
242 242
            
243 243
            in_db = connect_db(in_db_config)
244
            cur = sql.select(in_db, table=in_root, fields=None, conds=None,
245
                limit=end, start=0)
246
            row_ct = map_table(list(sql.col_names(cur)), sql.rows(cur))
244
            cur = sql.select(in_db, table=in_root, limit=end, start=start)
245
            row_ct = map_table(list(sql.col_names(cur)), sql.rows(cur),
246
                rows_start=start) # rows_start: pre-start rows have been skipped
247 247
            
248 248
            in_db.db.close()
249 249
        elif in_is_xml:

Also available in: Unified diff