public SnapshotResult copyTables() {
        // This result object will be returned to the caller to summarize the feed and report any critical errors.
        SnapshotResult result = new SnapshotResult();

        try {
            long startTime = System.currentTimeMillis();
            // We get a single connection object and share it across several different methods.
            // This ensures that actions taken in one method are visible to all subsequent SQL statements.
            // If we create a schema or table on one connection, then access it in a separate connection, we have no
            // guarantee that it exists when the accessing statement is executed.
            connection = dataSource.getConnection();
            // Generate a unique prefix that will identify this feed.
            this.tablePrefix = randomIdString();
            result.uniqueIdentifier = tablePrefix;
            // Create entry in snapshots table.
            registerSnapshot();
            // Include the dot separator in the table prefix.
            // This allows everything to work even when there's no prefix.
            this.tablePrefix += ".";
            // Copy each table in turn
            // FIXME: NO non-fatal exception errors are being captured during copy operations.
            result.agency = copy(Table.AGENCY, true);
            result.calendar = copy(Table.CALENDAR, true);
            result.calendarDates = copy(Table.CALENDAR_DATES, true);
            result.fareAttributes = copy(Table.FARE_ATTRIBUTES, true);
            result.fareRules = copy(Table.FARE_RULES, true);
            result.feedInfo = copy(Table.FEED_INFO, true);
            result.frequencies = copy(Table.FREQUENCIES, true);
            result.routes = copy(Table.ROUTES, true);
            // FIXME: Find some place to store errors encountered on copy for patterns and pattern stops.
            copy(Table.PATTERNS, true);
            copy(Table.PATTERN_STOP, true);
            // see method comments fo why different logic is needed for this table
            result.scheduleExceptions = createScheduleExceptionsTable();
            result.shapes = copy(Table.SHAPES, true);
            result.stops = copy(Table.STOPS, true);
            // TODO: Should we defer index creation on stop times?
            // Copying all tables for STIF w/ stop times idx = 156 sec; w/o = 28 sec
            // Other feeds w/ stop times AC Transit = 3 sec; Brooklyn bus =
            result.stopTimes = copy(Table.STOP_TIMES, true);
            result.transfers = copy(Table.TRANSFERS, true);
            result.trips = copy(Table.TRIPS, true);
            result.completionTime = System.currentTimeMillis();
            result.loadTimeMillis = result.completionTime - startTime;
            LOG.info("Copying tables took {} sec", (result.loadTimeMillis) / 1000);
        } catch (Exception ex) {
            // Note: Exceptions that occur during individual table loads are separately caught and stored in
            // TableLoadResult.
            LOG.error("Exception while creating snapshot: {}", ex.toString());
            ex.printStackTrace();
            result.fatalException = ex.toString();
        }
        return result;
    }
public SnapshotResult copyTables() {
        
        SnapshotResult result = new SnapshotResult();

        try {
            long startTime = System.currentTimeMillis();
            
            
            
            
            connection = dataSource.getConnection();
            
            this.tablePrefix = randomIdString();
            result.uniqueIdentifier = tablePrefix;
            
            registerSnapshot();
            
            
            this.tablePrefix += ".";
            
            
            result.agency = copy(Table.AGENCY, true);
            result.calendar = copy(Table.CALENDAR, true);
            result.calendarDates = copy(Table.CALENDAR_DATES, true);
            result.fareAttributes = copy(Table.FARE_ATTRIBUTES, true);
            result.fareRules = copy(Table.FARE_RULES, true);
            result.feedInfo = copy(Table.FEED_INFO, true);
            result.frequencies = copy(Table.FREQUENCIES, true);
            result.routes = copy(Table.ROUTES, true);
            
            copy(Table.PATTERNS, true);
            copy(Table.PATTERN_STOP, true);
            
            result.scheduleExceptions = createScheduleExceptionsTable();
            result.shapes = copy(Table.SHAPES, true);
            result.stops = copy(Table.STOPS, true);
            
            
            
            result.stopTimes = copy(Table.STOP_TIMES, true);
            result.transfers = copy(Table.TRANSFERS, true);
            result.trips = copy(Table.TRIPS, true);
            result.completionTime = System.currentTimeMillis();
            result.loadTimeMillis = result.completionTime - startTime;
            LOG.info("Copying tables took {} sec", (result.loadTimeMillis) / 1000);
        } catch (Exception ex) {
            
            
            LOG.error("Exception while creating snapshot: {}", ex.toString());
            ex.printStackTrace();
            result.fatalException = ex.toString();
        }
        return result;
    }
public SnapshotResult copyTables ( ) { // This result object will be returned to the caller to summarize the feed and report any critical errors. SnapshotResult result = new SnapshotResult ( ) ; try { long startTime = System . currentTimeMillis ( ) ; // We get a single connection object and share it across several different methods. // This ensures that actions taken in one method are visible to all subsequent SQL statements. // If we create a schema or table on one connection, then access it in a separate connection, we have no // guarantee that it exists when the accessing statement is executed. connection = dataSource . getConnection ( ) ; // Generate a unique prefix that will identify this feed. this . tablePrefix = randomIdString ( ) ; result . uniqueIdentifier = tablePrefix ; // Create entry in snapshots table. registerSnapshot ( ) ; // Include the dot separator in the table prefix. // This allows everything to work even when there's no prefix. this . tablePrefix += "." ; // Copy each table in turn // FIXME: NO non-fatal exception errors are being captured during copy operations. result . agency = copy ( Table . AGENCY , true ) ; result . calendar = copy ( Table . CALENDAR , true ) ; result . calendarDates = copy ( Table . CALENDAR_DATES , true ) ; result . fareAttributes = copy ( Table . FARE_ATTRIBUTES , true ) ; result . fareRules = copy ( Table . FARE_RULES , true ) ; result . feedInfo = copy ( Table . FEED_INFO , true ) ; result . frequencies = copy ( Table . FREQUENCIES , true ) ; result . routes = copy ( Table . ROUTES , true ) ; // FIXME: Find some place to store errors encountered on copy for patterns and pattern stops. copy ( Table . PATTERNS , true ) ; copy ( Table . PATTERN_STOP , true ) ; // see method comments fo why different logic is needed for this table result . scheduleExceptions = createScheduleExceptionsTable ( ) ; result . shapes = copy ( Table . SHAPES , true ) ; result . stops = copy ( Table . STOPS , true ) ; // TODO: Should we defer index creation on stop times? // Copying all tables for STIF w/ stop times idx = 156 sec; w/o = 28 sec // Other feeds w/ stop times AC Transit = 3 sec; Brooklyn bus = result . stopTimes = copy ( Table . STOP_TIMES , true ) ; result . transfers = copy ( Table . TRANSFERS , true ) ; result . trips = copy ( Table . TRIPS , true ) ; result . completionTime = System . currentTimeMillis ( ) ; result . loadTimeMillis = result . completionTime - startTime ; LOG . info ( "Copying tables took {} sec" , ( result . loadTimeMillis ) / 1000 ) ; } catch ( Exception ex ) { // Note: Exceptions that occur during individual table loads are separately caught and stored in // TableLoadResult. LOG . error ( "Exception while creating snapshot: {}" , ex . toString ( ) ) ; ex . printStackTrace ( ) ; result . fatalException = ex . toString ( ) ; } return result ; }
Copy primary entity tables as well as Pattern and PatternStops tables.
Copy primary entity tables as well as Pattern and PatternStops tables .