Show
Ignore:
Timestamp:
06/02/09 10:34:08 (3 years ago)
Author:
mloskot
Message:

[wktraster] Added new option -M, --vacuum to issue VACUUM FULL ANALYZE command for each generated table at the end of data loading. Print basic summary at the end of rasters / overviews processing.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • spike/wktraster/scripts/gdal2wktraster.py

    r4116 r4117  
    6666# UTILITIES 
    6767VERBOSE = False 
     68SUMMARY = [] 
    6869 
    6970def parse_command_line(): 
     
    115116    grp_t.add_option("-I", "--index", dest="index", action="store_true", default=False,  
    116117                     help="create a GiST index on the raster column") 
     118    grp_t.add_option("-M", "--vacuum", dest="vacuum", action="store_true", default=False,  
     119                     help="issue VACUUM command against all generated tables") 
    117120    grp_t.add_option('-V', '--create-raster-overviews', dest='create_raster_overviews_table', 
    118121                     action='store_true', default=False, 
     
    429432     
    430433    return sql 
    431      
     434 
     435def make_sql_vacuum(table): 
     436    sql = 'VACUUM FULL ANALYZE ' + quote_sql_name(table) + ';\n' 
     437    return sql 
     438 
    432439################################################################################ 
    433440# RASTER OPERATIONS 
     
    798805 
    799806    # Write (original) raster to hex binary output 
     807    tile_count = 0 
    800808    hexwkb = '' 
    801809 
     
    828836            sql = make_sql_insert_raster(options.table, options.column, hexwkb, options.filename, file) 
    829837            options.output.write(sql) 
     838            tile_count = tile_count + 1 
     839 
     840    # SUMMARY for base raster table 
     841    table_summary = ( options.table, tile_count ) 
     842    SUMMARY.append( table_summary ) 
    830843 
    831844    # EOF RASTER 
     
    869882            logit("MSG: Processing overview = %s using block = %s as grid = %s\n" % \ 
    870883                  (str(raster_size), str(block_size), str(grid_size))) 
     884             
     885            tile_count = 0 
    871886 
    872887            for xcell in range(0, grid_size[0]): 
     
    895910                    sql = make_sql_insert_raster(ov_table, options.column, hexwkb, options.filename, file) 
    896911                    options.output.write(sql) 
    897                      
    898     # EOF OVERVIES 
     912                    tile_count = tile_count + 1 
     913 
     914            # SUMMARY for overview 
     915            table_summary = ( ov_table, tile_count ) 
     916            SUMMARY.append( table_summary ) 
     917 
     918    # EOF OVERVIEWS 
    899919 
    900920    # Cleanup 
     
    909929    global VERBOSE 
    910930    VERBOSE = opts.verbose 
     931 
     932    global SUMMARY 
     933    SUMMARY = [] 
    911934     
    912935    saved_out = sys.stdout 
     
    955978    opts.output.write('COMMIT;\n') 
    956979 
     980    # VACUUM 
     981    if opts.vacuum: 
     982        for s in SUMMARY: 
     983            sql = make_sql_vacuum(s[0]) 
     984            opts.output.write(sql) 
     985 
    957986    # Cleanup 
    958987    sys.stdout = saved_out 
    959988 
    960     logit("MSG: Number of processed raster files: %d\n" % i) 
     989    print "------------------------------------------------------------" 
     990    print " Summary of GDAL to WKT Raster processing:" 
     991    print "------------------------------------------------------------" 
     992    print "Number of processed raster files: %d" % i 
     993    print "List of generated tables (number of tiles):" 
     994    i = 0 
     995    for s in SUMMARY: 
     996        i += 1 
     997        print "%d\t%s (%d)" % (i, s[0], s[1]) 
    961998 
    962999################################################################################