public static BucketIdentifier parsePath(Path path) {
    try {
      Path parent = path.getParent();
      if (parent == null) {
        return null;
      }
      boolean isBase = parent.getName().startsWith(AcidUtils.BASE_PREFIX);
      boolean isDelta = parent.getName().startsWith(AcidUtils.DELTA_PREFIX)
          || parent.getName().startsWith(AcidUtils.DELETE_DELTA_PREFIX);
      if (isBase || isDelta) {
        if (isBase) {
          AcidUtils.ParsedBaseLight parsedBaseLight = AcidUtils.ParsedBaseLight.parseBase(parent);
          if (parsedBaseLight.getVisibilityTxnId() > 0) {
            // This file is a result of compaction. It may contain records from more than one write.
            return null;
          }
          return new BucketIdentifier(
              parsedBaseLight.getWriteId(),
              AcidUtils.parseBucketId(path));
        } else {
          AcidUtils.ParsedDeltaLight pd = AcidUtils.ParsedDeltaLight.parse(parent);
          if (pd.getMinWriteId() != pd.getMaxWriteId()) {
            // This file is a result of compaction. It contains records from more than one write.
            return null;
          }
          return new BucketIdentifier(
              pd.getMinWriteId(),
              AcidUtils.parseBucketId(path));
        }
      }
    } catch (NumberFormatException ex) {
      LOG.warn("Error while parsing path " + path, ex);
    }

    return null;
  }
Stores bucket and writeId of the bucket files.
ql/src/java/org/apache/hadoop/hive/ql/io/BucketIdentifier.java