private String getValidWriteIdList(Table table, long writeId) throws LockException {
    if (desc.getReplicationSpec().isInReplicationScope() && desc.getPartitions().get(0).getWriteId() > 0) {
      // We need a valid writeId list for a transactional change. During replication we do not
      // have a valid writeId list which was used for this on the source. But we know for sure
      // that the writeId associated with it was valid then (otherwise the change would have
      // failed on the source). So use a valid transaction list with only that writeId.
      return new ValidReaderWriteIdList(TableName.getDbTable(table.getDbName(), table.getTableName()),
          new long[0], new BitSet(), writeId).writeToString();
    } else {
      AcidUtils.TableSnapshot tableSnapshot = AcidUtils.getTableSnapshot(context.getConf(), table, true);
      if (tableSnapshot != null && tableSnapshot.getWriteId() > 0) {
        return tableSnapshot.getValidWriteIdList();
      } else {
        return null;
      }
    }
  }
Operation process of adding a partition to a table.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/add/AlterTableAddPartitionOperation.java