sankarh commented on a change in pull request #1275: URL: https://github.com/apache/hive/pull/1275#discussion_r461412352
########## File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorUtil.java ########## @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hive.ql.txn.compactor; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import org.apache.hadoop.hive.conf.HiveConf; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; + +public class CompactorUtil { + public interface ThrowingRunnable<E extends Exception> { Review comment: nit: Make it 2 space tabs. ########## File path: ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java ########## @@ -274,6 +285,55 @@ public void droppedPartition() throws Exception { ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); Assert.assertEquals(0, rsp.getCompactsSize()); } + + @Test + public void processCompactionCandidatesInParallel() throws Exception { + Table t = newTable("default", "camipc", true); + List<Partition> partitions = new ArrayList<>(); + Partition p = null; + for(int i=0; i<10; i++) { + p = newPartition(t, "today" + i); + + addBaseFile(t, p, 20L, 20); + addDeltaFile(t, p, 21L, 22L, 2); + addDeltaFile(t, p, 23L, 24L, 2); + addDeltaFile(t, p, 21L, 24L, 4); + partitions.add(p); + } + burnThroughTransactions("default", "camipc", 25); Review comment: nit: Need a blank line after closing braces, ########## File path: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ########## @@ -3028,6 +3028,9 @@ private static void populateLlapDaemonVarsSet(Set<String> llapDaemonVarsSetLocal HIVE_COMPACTOR_CLEANER_RUN_INTERVAL("hive.compactor.cleaner.run.interval", "5000ms", new TimeValidator(TimeUnit.MILLISECONDS), "Time between runs of the cleaner thread"), + HIVE_COMPACTOR_CLEANER_REQUEST_QUEUE("hive.compactor.cleaner.request.queue", 1, Review comment: The config name can be relevant. It actually represent how many threads that we use for parallelly run the cleaner. But, the name sounds like Queue name. Can we change it to "HIVE_COMPACTOR_CLEANER_THREADS_NUM"? ########## File path: ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java ########## @@ -274,6 +285,55 @@ public void droppedPartition() throws Exception { ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); Assert.assertEquals(0, rsp.getCompactsSize()); } + + @Test + public void processCompactionCandidatesInParallel() throws Exception { + Table t = newTable("default", "camipc", true); + List<Partition> partitions = new ArrayList<>(); + Partition p = null; + for(int i=0; i<10; i++) { Review comment: nit: Make it "for (int i = 0; i < 10; i++)". Check other places in this patch. ########## File path: ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java ########## @@ -274,6 +285,55 @@ public void droppedPartition() throws Exception { ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); Assert.assertEquals(0, rsp.getCompactsSize()); } + + @Test + public void processCompactionCandidatesInParallel() throws Exception { + Table t = newTable("default", "camipc", true); + List<Partition> partitions = new ArrayList<>(); + Partition p = null; + for(int i=0; i<10; i++) { + p = newPartition(t, "today" + i); + + addBaseFile(t, p, 20L, 20); + addDeltaFile(t, p, 21L, 22L, 2); + addDeltaFile(t, p, 23L, 24L, 2); + addDeltaFile(t, p, 21L, 24L, 4); + partitions.add(p); + } + burnThroughTransactions("default", "camipc", 25); + for(int i=0; i<10; i++) { + CompactionRequest rqst = new CompactionRequest("default", "camipc", CompactionType.MINOR); + rqst.setPartitionname("ds=today"+i); + txnHandler.compact(rqst); + CompactionInfo ci = txnHandler.findNextToCompact("fred"); + ci.runAs = System.getProperty("user.name"); + txnHandler.updateCompactorState(ci, openTxn()); + txnHandler.markCompacted(ci); + } + + conf.setIntVar(HiveConf.ConfVars.HIVE_COMPACTOR_CLEANER_REQUEST_QUEUE, 3); + startCleaner(); + + // Check there are no compactions requests left. + ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); + Assert.assertEquals(10, rsp.getCompactsSize()); + Assert.assertTrue(TxnStore.SUCCEEDED_RESPONSE.equals(rsp.getCompacts().get(0).getState())); + + // Check that the files are removed + for (Partition pa : partitions) { + List<Path> paths = getDirectories(conf, t, pa); + Assert.assertEquals(2, paths.size()); + boolean sawBase = false, sawDelta = false; + for (Path path : paths) { + if (path.getName().equals("base_20")) sawBase = true; Review comment: nit: Keep the code block of "if", "else if" and "else" in new line with a tab space. ---------------------------------------------------------------- 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: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
