question: private void prefetchStatementData ( StatementData data ) throws ReplicatorException { statements ++ ; String sqlQuery = null ; try { if ( data . getQuery ( ) != null ) sqlQuery = data . getQuery ( ) ; else { try { sqlQuery = new String ( data . getQueryAsBytes ( ) , data . getCharset ( ) ) ; } catch ( UnsupportedEncodingException e ) { sqlQuery = new String ( data . getQueryAsBytes ( ) ) ; } } statement . clearBatch ( ) ; boolean hasTransform = false ; boolean fetchSecondaryIndexes = false ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Seeking prefetch transformation query: " + sqlQuery ) ; } SqlOperation parsing = ( SqlOperation ) data . getParsingMetadata ( ) ; if ( parsing . getOperation ( ) == SqlOperation . INSERT ) { Matcher m = insert . matcher ( sqlQuery ) ; if ( m . matches ( ) ) { if ( m . group ( 1 ) != null ) sqlQuery = m . group ( 1 ) ; else sqlQuery = m . group ( 2 ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "Transformed INSERT to prefetch query: " + sqlQuery ) ; transformed ++ ; hasTransform = true ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Unable to match INSERT for transformation: " + sqlQuery ) ; } } else if ( parsing . getOperation ( ) == SqlOperation . DELETE ) { Matcher m = delete . matcher ( sqlQuery ) ; if ( m . matches ( ) ) { sqlQuery = "SELECT * FROM " + m . group ( 1 ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "Transformed DELETE to prefetch query: " + sqlQuery ) ; transformed ++ ; hasTransform = true ; fetchSecondaryIndexes = true ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Unable to match DELETE for transformation: " + sqlQuery ) ; } } else if ( parsing . getOperation ( ) == SqlOperation . UPDATE ) { Matcher m = update . matcher ( sqlQuery ) ; if ( m . matches ( ) ) { sqlQuery = "SELECT * FROM " + m . group ( 1 ) + " " + m . group ( 2 ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "Transformed UPDATE to prefetch query: " + sqlQuery ) ; transformed ++ ; hasTransform = true ; fetchSecondaryIndexes = true ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Unable to match UPDATE for transformation: " + sqlQuery ) ; } } else if ( parsing . getOperation ( ) == SqlOperation . SET ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Allowing SET operation to proceed: " + sqlQuery ) ; hasTransform = true ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Ignoring unmatched statement: " + sqlQuery ) ; } String schema = data . getDefaultSchema ( ) ; Long timestamp = data . getTimestamp ( ) ; List < ReplOption > options = data . getOptions ( ) ; applyUseSchema ( schema ) ; applySetTimestamp ( timestamp ) ; applySessionVariables ( options ) ; try { statement . executeBatch ( ) ; } catch ( SQLWarning e ) { String msg = "Warning generated when setting context of query: original=" + data . toString ( ) + " warning=" + e . getMessage ( ) ; logger . warn ( msg ) ; } catch ( SQLException e ) { if ( data . getErrorCode ( ) == 0 ) { String msg = "Error generated when seting context of prefetch query: original=" + data . toString ( ) ; SQLException sqlException = new SQLException ( msg ) ; sqlException . initCause ( e ) ; throw sqlException ; } } finally { statement . clearBatch ( ) ; } ResultSet rs = null ; if ( hasTransform ) { if ( prefetchRowLimit > 0 ) sqlQuery = prefetchTransformer . addLimitToQuery ( sqlQuery , prefetchRowLimit ) ; try { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Executing transformed query: " + sqlQuery ) ; rs = statement . executeQuery ( sqlQuery ) ; prefetchedQueries ++ ; if ( fetchSecondaryIndexes ) { prefetchIndexesForStatement ( data , parsing , rs ) ; } } finally { closeResultSet ( rs ) ; } } } catch ( SQLException e ) { logFailedStatementSQL ( data . getQuery ( ) , e ) ; throw new ApplierException ( e ) ; } }
target:  Prefetch data for statements.