Source:
private TaskTracker forExistingTable(AddPartitionDesc lastPartitionReplicated) throws Exception { boolean encounteredTheLastReplicatedPartition = (lastPartitionReplicated == null); Map<String, String> lastReplicatedPartSpec = null; if (!encounteredTheLastReplicatedPartition) { lastReplicatedPartSpec = lastPartitionReplicated.getPartition(0).getPartSpec(); LOG.info("Start processing from partition info spec : {}", StringUtils.mapToString(lastReplicatedPartSpec)); } ReplicationSpec replicationSpec = event.replicationSpec(); Iterator<AddPartitionDesc> partitionIterator = event.partitionDescriptions(tableDesc).iterator(); while (!encounteredTheLastReplicatedPartition && partitionIterator.hasNext()) { AddPartitionDesc addPartitionDesc = partitionIterator.next(); Map<String, String> currentSpec = addPartitionDesc.getPartition(0).getPartSpec(); encounteredTheLastReplicatedPartition = lastReplicatedPartSpec.equals(currentSpec); } while (partitionIterator.hasNext() && tracker.canAddMoreTasks()) { AddPartitionDesc addPartitionDesc = partitionIterator.next(); Map<String, String> partSpec = addPartitionDesc.getPartition(0).getPartSpec(); Partition ptn = context.hiveDb.getPartition(table, partSpec, false); if (ptn == null) { if (!replicationSpec.isMetadataOnly()) { addPartition(addPartitionDesc); } } else { if (replicationSpec.allowReplacementInto(ptn.getParameters())) { if (replicationSpec.isMetadataOnly()) { tracker.addTask(alterSinglePartition(addPartitionDesc, replicationSpec, ptn)); if (!tracker.canAddMoreTasks()) { tracker.setReplicationState( new ReplicationState( new PartitionState(table.getTableName(), addPartitionDesc) ) ); } } else { addPartition(addPartitionDesc); } } else { } } } return tracker; }

Target:
private TaskTracker forExistingTable(AddPartitionDesc lastPartitionReplicated) throws Exception { boolean encounteredTheLastReplicatedPartition = (lastPartitionReplicated == null); Map<String, String> lastReplicatedPartSpec = null; if (!encounteredTheLastReplicatedPartition) { lastReplicatedPartSpec = lastPartitionReplicated.getPartition(0).getPartSpec(); LOG.info("Start processing from partition info spec : {}", StringUtils.mapToString(lastReplicatedPartSpec)); } ReplicationSpec replicationSpec = event.replicationSpec(); Iterator<AddPartitionDesc> partitionIterator = event.partitionDescriptions(tableDesc).iterator(); while (!encounteredTheLastReplicatedPartition && partitionIterator.hasNext()) { AddPartitionDesc addPartitionDesc = partitionIterator.next(); Map<String, String> currentSpec = addPartitionDesc.getPartition(0).getPartSpec(); encounteredTheLastReplicatedPartition = lastReplicatedPartSpec.equals(currentSpec); } while (partitionIterator.hasNext() && tracker.canAddMoreTasks()) { AddPartitionDesc addPartitionDesc = partitionIterator.next(); Map<String, String> partSpec = addPartitionDesc.getPartition(0).getPartSpec(); Partition ptn = context.hiveDb.getPartition(table, partSpec, false); if (ptn == null) { if (!replicationSpec.isMetadataOnly()) { addPartition(partitionIterator.hasNext(), addPartitionDesc); } } else { if (replicationSpec.allowReplacementInto(ptn.getParameters())) { if (replicationSpec.isMetadataOnly()) { tracker.addTask(alterSinglePartition(addPartitionDesc, replicationSpec, ptn)); if (!tracker.canAddMoreTasks()) { tracker.setReplicationState( new ReplicationState( new PartitionState(table.getTableName(), addPartitionDesc) ) ); } } else { addPartition(partitionIterator.hasNext(), addPartitionDesc); } } else { } } } return tracker; }