@Override
  public List<Runnable> getTasks() throws MetaException {
    long minOpenTxnId = txnHandler.findMinOpenTxnIdForCleaner();
    long retentionTime = HiveConf.getBoolVar(conf, HIVE_COMPACTOR_DELAYED_CLEANUP_ENABLED)
            ? HiveConf.getTimeVar(conf, HIVE_COMPACTOR_CLEANER_RETENTION_TIME, TimeUnit.MILLISECONDS)
            : 0;
    List<CompactionInfo> readyToClean = txnHandler.findReadyToClean(minOpenTxnId, retentionTime);
    if (!readyToClean.isEmpty()) {
      long minTxnIdSeenOpen = Math.min(minOpenTxnId, txnHandler.findMinTxnIdSeenOpen());
      // For checking which compaction can be cleaned we can use the minOpenTxnId
      // However findReadyToClean will return all records that were compacted with old version of HMS
      // where the CQ_NEXT_TXN_ID is not set. For these compactions we need to provide minTxnIdSeenOpen
      // to the clean method, to avoid cleaning up deltas needed for running queries
      // when min_history_level is finally dropped, than every HMS will commit compaction the new way
      // and minTxnIdSeenOpen can be removed and minOpenTxnId can be used instead.
      return readyToClean.stream().map(ci -> {
        long cleanerWaterMark = (ci.minOpenWriteId >= 0) ? ci.nextTxnId + 1 : minTxnIdSeenOpen;
        LOG.info("Cleaning based on min open txn id: {}", cleanerWaterMark);
        return ThrowingRunnable.unchecked(() -> clean(ci, cleanerWaterMark, metricsEnabled));
      }).collect(Collectors.toList());
    }
    return Collections.emptyList();
  }
A compaction based implementation of TaskHandler.
Provides implementation of creation of compaction clean tasks.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/handler/CompactionCleaner.java