private void updateChromosomeChunks ( String chromosome , int numChunks , Connection conn ) throws SQLException { // insert all the chunks for that chromosome String minorChunkSuffix = ( chunkSize / 1000 ) * 64 + "k" ; String sql = "insert into chunk (chunk_id, chromosome, start, end) values (?, ?, ?, ?)" ; PreparedStatement insertChunk = conn . prepareStatement ( sql ) ; conn . setAutoCommit ( false ) ; for ( int i = 0 , j = 1 ; i < numChunks ; i ++ , j += chunkSize64k ) { String chunkId = chromosome + "_" + i + "_" + minorChunkSuffix ; // // // check if this chunk is in the dabasete // sql = "SELECT id FROM chunk where chunk_id = '" + chunkId + "'"; // ResultSet rs = stmt.executeQuery(sql); // if (!rs.next()) { // if this chunk is not in the database, then insert it insertChunk . setString ( 1 , chunkId ) ; insertChunk . setString ( 2 , chromosome ) ; insertChunk . setInt ( 3 , j ) ; insertChunk . setInt ( 4 , j + chunkSize64k - 1 ) ; insertChunk . addBatch ( ) ; // } } insertChunk . executeBatch ( ) ; conn . commit ( ) ; conn . setAutoCommit ( true ) ; initChunkMap ( ) ; }
Insert all the chunks for the given chromosome and update the internal map of chunks if necessary .