private static void processBaseDir(Path baseDir, ValidWriteIdList writeIdList, ValidTxnList validTxnList,
      AcidDirectory directory, AcidUtils.HdfsDirSnapshot dirSnapshot) throws IOException {
    ParsedBaseLight parsedBase = ParsedBaseLight.parseBase(baseDir);
    if (!isDirUsable(baseDir, parsedBase.getVisibilityTxnId(), directory.getAbortedDirectories(), validTxnList)) {
      return;
    }
    final long writeId = parsedBase.getWriteId();
    if (directory.getOldestBase() == null || directory.getOldestBase().writeId > writeId) {
      // keep track for error reporting
      directory.setOldestBase(parsedBase);
    }
    boolean isCompactedBase = isCompactedBase(parsedBase, directory.getFs(), dirSnapshot);
    // Handle aborted IOW base.
    if (writeIdList.isWriteIdAborted(writeId) && !isCompactedBase) {
      directory.getAbortedDirectories().add(baseDir);
      directory.getAbortedWriteIds().add(parsedBase.writeId);
      return;
    }
    if (directory.getBase() == null || directory.getBase().getWriteId() < writeId
      // If there are two competing versions of a particular write-id, one from the compactor and another from IOW,
      // always pick the compactor one once it is committed.
      || directory.getBase().getWriteId() == writeId &&
          isCompactedBase && validTxnList.isTxnValid(parsedBase.getVisibilityTxnId())) {

      if (isValidBase(parsedBase, writeIdList, directory.getFs(), dirSnapshot)) {
        List<HdfsFileStatusWithId> files = null;
        if (dirSnapshot != null) {
          files = dirSnapshot.getFiles().stream().map(HdfsFileStatusWithoutId::new).collect(Collectors.toList());
        }
        if (directory.getBase() != null) {
          directory.getObsolete().add(directory.getBase().getBaseDirPath());
        }
        directory.setBase(new ParsedBase(parsedBase, files));
      }
    } else {
      directory.getObsolete().add(baseDir);
    }
  }
Returns {@code true} if {@code parsedBase} was created by compaction.
As of Hive 4.0 we can tell if a directory is a result of compaction based on the
presence of {@link AcidUtils#VISIBILITY_PATTERN} suffix.  Base directories written prior to
that, have to rely on the {@link MetaDataFile} in the directory. So look at the filename first
since that is the cheaper test.
ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java