Project

General

Profile

« Previous | Next » 

Revision 1991

bin/map: in_is_db: by_col: Create XML tree of sample row, with the input column names as the values. This tree will guide the sequencing and creation of the column-based queries.

View differences:

bin/map
140 140
        update_in_label()
141 141
    prep_root()
142 142
    
143
    # Define before the out_is_db section because it's used by by_col
144
    row_ins_ct_ref = [0]
145
    
143 146
    def process_input(root, row_ready, map_path):
144 147
        '''Inputs datasource to XML tree, mapping if needed'''
145 148
        # Load map header
......
263 266
                table = sql.qual_name(in_db, schema, table)
264 267
                table_is_esc = True
265 268
            
269
            # Fetch rows
270
            if by_col: limit = 0 # only fetch column names
271
            else: limit = n
272
            cur = sql.select(in_db, table, limit=limit, start=start,
273
                table_is_esc=table_is_esc)
274
            col_names = list(sql.col_names(cur))
275
            
266 276
            if by_col:
267
                # Mapping to same DB and by-column optimization enabled
277
                row_ready = lambda row_num, input_row: None# disable row_ready()
278
                map_table(col_names, [col_names]) # values are the column names
279
                sys.stderr.write(str(root))
268 280
                raise NotImplementedError(
269 281
                    'By-column optimization not available yet')
270 282
            else:
271 283
                # Use normal by-row method
272
                cur = sql.select(in_db, table, limit=n, start=start,
273
                    table_is_esc=table_is_esc)
274
                row_ct = map_table(list(sql.col_names(cur)), sql.rows(cur),
275
                    rows_start=start) # rows_start: pre-start rows were skipped
284
                row_ct = map_table(col_names, sql.rows(cur), rows_start=start)
285
                    # rows_start: pre-start rows have been skipped
276 286
            
277 287
            in_db.db.close()
278 288
        elif in_is_xml:
......
323 333
        out_db = connect_db(out_db_config)
324 334
        try:
325 335
            if redo: sql.empty_db(out_db)
326
            row_ins_ct_ref = [0]
327 336
            pool.share_vars(locals())
328 337
            
329 338
            def row_ready(row_num, input_row):

Also available in: Unified diff