private void writeArchivationToMetastore(PartSpecInfo partitionSpecInfo, List<Partition> partitions, Path originalDir)
      throws HiveException {
    try {
      URI archiveUri = new Path(originalDir, ARCHIVE_NAME).toUri();
      URI originalUri = ArchiveUtils.addSlash(originalDir.toUri());
      ArchiveUtils.HarPathHelper harHelper = new ArchiveUtils.HarPathHelper(context.getConf(), archiveUri, originalUri);

      for (Partition partition : partitions) {
        URI originalPartitionUri = ArchiveUtils.addSlash(partition.getDataLocation().toUri());
        URI harPartitionDir = harHelper.getHarUri(originalPartitionUri);
        StringBuilder authority = new StringBuilder();
        if (harPartitionDir.getUserInfo() != null) {
          authority.append(harPartitionDir.getUserInfo()).append("@");
        }
        authority.append(harPartitionDir.getHost());
        if (harPartitionDir.getPort() != -1) {
          authority.append(":").append(harPartitionDir.getPort());
        }

        // make in Path to ensure no slash at the end
        Path harPath = new Path(harPartitionDir.getScheme(), authority.toString(), harPartitionDir.getPath());
        setArchived(partition, harPath, partitionSpecInfo.values.size());
        // TODO: catalog
        context.getDb().alterPartition(desc.getTableName(), partition, null, true);
      }
    } catch (Exception e) {
      throw new HiveException("Unable to change the partition info for HAR", e);
    }
  }
Record the previous changes in the metastore.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/archive/AlterTableArchiveOperation.java