belugabehr commented on a change in pull request #2274: URL: https://github.com/apache/hive/pull/2274#discussion_r637098961
########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java ########## @@ -383,6 +384,37 @@ public static String getFullTableName(String dbName, String tableName) { return ret; } + /** + * Executes simple update queries based on output from TxnUtils#buildQueryWithINClauseStrings. + * Example: desired queries are "delete from x where y in (1, 2, 3)" and "delete from x where y in (4, 5, 6)" + * + * @param updateQueries List of: "delete from x where y in (?,?,?)", "delete from x where y in (?,?,?)" + * @param updateQueryCount Number of queries to execute, in the example: 2 + * @param ids to prepare statement with. In the example: List containing: 1, 2, 3, 4, 5, 6 + * @param dbConn database Connection + * @throws SQLException + */ + public static int executeUpdateQueries(List<String> updateQueries, List<Integer> updateQueryCount, List<Long> ids, + Connection dbConn) + throws SQLException { + int totalCount = 0; + int updatedCount = 0; + for (int i = 0; i < updateQueries.size(); i++) { + String query = updateQueries.get(i); + long insertCount = updateQueryCount.get(i); + LOG.debug("Going to execute update <" + query + ">"); + PreparedStatement pStmt = dbConn.prepareStatement(query); + for (int j = 0; j < insertCount; j++) { + pStmt.setLong(j + 1, ids.get(totalCount + j)); + } + totalCount += insertCount; + int count = pStmt.executeUpdate(); + LOG.debug("Updated " + count + " records"); Review comment: Use anchors. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org