diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index ee2cea0..72a837c 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -1039,14 +1039,9 @@ private void drop_database_core(RawStore ms, ConfVars.METASTORE_BATCH_RETRIEVE_MAX); int startIndex = 0; - int endIndex = -1; // retrieve the tables from the metastore in batches to alleviate memory constraints - while (endIndex < allTables.size() - 1) { - startIndex = endIndex + 1; - endIndex = endIndex + tableBatchSize; - if (endIndex >= allTables.size()) { - endIndex = allTables.size() - 1; - } + while (startIndex < allTables.size()) { + int endIndex = Math.min(startIndex + tableBatchSize, allTables.size()); List tables = null; try { @@ -1082,6 +1077,8 @@ private void drop_database_core(RawStore ms, // Drop the table but not its data drop_table(name, table.getTableName(), false); } + + startIndex = endIndex; } }