diff --git ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorMR.java ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorMR.java index e5f30473ee..1a8132788c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorMR.java +++ ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorMR.java @@ -331,12 +331,39 @@ void run(HiveConf conf, String jobName, Table t, Partition p, StorageDescriptor return; } + StringBuilder msg = new StringBuilder(); + msg.append("Skipping minor compaction as"); + if ((ci.type == CompactionType.MINOR) && !shouldMinorCompact(parsedDeltas, msg)) { + LOG.error(msg.toString()); + return; + } + launchCompactionJob(job, baseDir, ci.type, dirsToSearch, dir.getCurrentDirectories(), dir.getCurrentDirectories().size(), dir.getObsolete().size(), conf, msc, ci.id, jobName); su.gatherStats(); } + private boolean shouldMinorCompact(List parsedDeltas, StringBuilder msg) { + switch (parsedDeltas.size()) { + case (0): + msg.append(" found no delta directories"); + return false; + case (1): + msg.append(" found a single delta directory"); + return false; + case (2): + if ((parsedDeltas.get(0).isDeleteDelta() && parsedDeltas.get(1).isDeleteDelta()) + || (!parsedDeltas.get(0).isDeleteDelta() && !parsedDeltas.get(1).isDeleteDelta())) { + return true; + } + msg.append(" found a single delta directory and a single delete delta directory"); + return false; + default: + return true; + } + } + /** * @param sd (this is the resolved StorageDescriptor, i.e. resolved to table or partition) * @param writeIds (valid write ids used to filter rows while they're being read for compaction)