private void setMaxTxnAndWriteIdFromPartition(Path partPath, CheckResult.PartitionResult res) throws IOException {
    FileSystem fs = partPath.getFileSystem(conf);
    FileStatus[] deltaOrBaseFiles = fs.listStatus(partPath, HIDDEN_FILES_PATH_FILTER);

    // Read the writeIds from every base and delta directory and find the max
    long maxWriteId = 0L;
    long maxVisibilityId = 0L;
    for (FileStatus fileStatus : deltaOrBaseFiles) {
      if (!fileStatus.isDirectory()) {
        continue;
      }
      long writeId = 0L;
      long visibilityId = 0L;
      String folder = fileStatus.getPath().getName();
      String visParts[] = folder.split(VISIBILITY_PREFIX);
      if (visParts.length > 1) {
        visibilityId = Long.parseLong(visParts[1]);
        folder = visParts[0];
      }
      if (folder.startsWith(BASE_PREFIX)) {
        writeId = Long.parseLong(folder.substring(BASE_PREFIX.length()));
      } else if (folder.startsWith(DELTA_PREFIX) || folder.startsWith(DELETE_DELTA_PREFIX)) {
        // See AcidUtils.parseDelta
        boolean isDeleteDelta = folder.startsWith(DELETE_DELTA_PREFIX);
        String rest = folder.substring((isDeleteDelta ? DELETE_DELTA_PREFIX : DELTA_PREFIX).length());
        String[] nameParts = rest.split("_");
        // We always want the second part (it is either the same or greater if it is a compacted delta)
        writeId = Long.parseLong(nameParts.length > 1 ? nameParts[1] : nameParts[0]);
      }
      if (writeId > maxWriteId) {
        maxWriteId = writeId;
      }
      if (visibilityId > maxVisibilityId) {
        maxVisibilityId = visibilityId;
      }
    }
    LOG.debug("Max writeId {}, max txnId {} found in partition {}", maxWriteId, maxVisibilityId,
        partPath.toUri().toString());
    res.setMaxWriteId(maxWriteId);
    res.setMaxTxnId(maxVisibilityId);
  }
Calculate the maximum seen writeId from the acid directory structure
@param partPath Path of the partition directory
@param res Partition result to write the max ids
@throws IOException ex
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java