public int compactRegionsTTLOnTable(Configuration conf, String table, int concurrency, long sleep,
    int numServers, int numRegions, boolean dryRun, boolean skipWait) throws Exception {

    Connection conn = ConnectionFactory.createConnection(conf);
    TableName tableName = TableName.valueOf(table);

    TableDescriptor htd = conn.getAdmin().getDescriptor(tableName);
    if (!doesAnyColFamilyHaveTTL(htd)) {
      LOG.info("No TTL present for CF of table: " + tableName + ", skipping compaction");
      return 0;
    }

    LOG.info("Major compacting table " + tableName + " based on TTL");
    MajorCompactor compactor = new MajorCompactorTTL(conf, htd, concurrency, sleep);
    compactor.setNumServers(numServers);
    compactor.setNumRegions(numRegions);
    compactor.setSkipWait(skipWait);

    compactor.initializeWorkQueues();
    if (!dryRun) {
      compactor.compactAllRegions();
    }
    compactor.shutdown();
    return ERRORS.size();
  }
This tool compacts a table's regions that are beyond it's TTL. It helps to save disk space and
regions become empty as a result of compaction.
hbase-server/src/main/java/org/apache/hadoop/hbase/util/compaction/MajorCompactorTTL.java