Source:
private Set<StoreKey> getMissingStoreKeys(ReplicaMetadataResponseInfo replicaMetadataResponseInfo, DataNodeId remoteNode, RemoteReplicaInfo remoteReplicaInfo) throws Exception { long startTime = SystemTime.getInstance().milliseconds(); List<MessageInfo> messageInfoList = replicaMetadataResponseInfo.getMessageInfoList(); List<StoreKey> storeKeysToCheck = new ArrayList<>(messageInfoList.size()); for (MessageInfo messageInfo : messageInfoList) { storeKeysToCheck.add(messageInfo.getStoreKey()); logger.trace("Remote node: Thread name: Remote replica: Key from remote: {}", remoteNode, threadName, remoteReplicaInfo.getReplicaId(), messageInfo.getStoreKey()); } Map<StoreKey, StoreKey> originalToConverted = new HashMap<>(); for (StoreKey storeKey : storeKeysToCheck) { originalToConverted.put(storeKey, storeKeyConverter.getConverted(storeKey)); } List<StoreKey> convertedKeys = new ArrayList<>(); for (StoreKey val : originalToConverted.values()) { if (val != null) { convertedKeys.add(val); } } Set<StoreKey> convertedMissingStoreKeys = remoteReplicaInfo.getLocalStore().findMissingKeys(convertedKeys); Set<StoreKey> originalStoreKeys = new HashSet<>(); for (Map.Entry<StoreKey, StoreKey> entry : originalToConverted.entrySet()) { if (convertedMissingStoreKeys.contains(entry.getValue())) { logger.trace("Remote node: Thread name: Remote replica: Key missing id (converted): Key missing id (original): {}", remoteNode, threadName, remoteReplicaInfo.getReplicaId(), entry.getValue(), entry.getKey()); originalStoreKeys.add(entry.getKey()); } } replicationMetrics.updateCheckMissingKeysTime(SystemTime.getInstance().milliseconds() - startTime, replicatingFromRemoteColo, datacenterName); return originalStoreKeys; }

Target:
private Set<StoreKey> getMissingStoreKeys(ReplicaMetadataResponseInfo replicaMetadataResponseInfo, DataNodeId remoteNode, RemoteReplicaInfo remoteReplicaInfo) throws Exception { long startTime = SystemTime.getInstance().milliseconds(); List<MessageInfo> messageInfoList = replicaMetadataResponseInfo.getMessageInfoList(); Map<StoreKey, StoreKey> remoteToConvertedNonNull = new HashMap<>(); for (MessageInfo messageInfo : messageInfoList) { StoreKey storeKey = messageInfo.getStoreKey(); logger.trace("Remote node: Thread name: Remote replica: Key from remote: {}", remoteNode, threadName, remoteReplicaInfo.getReplicaId(), storeKey); StoreKey convertedKey = storeKeyConverter.getConverted(storeKey); if (convertedKey != null) { remoteToConvertedNonNull.put(storeKey, convertedKey); } } Set<StoreKey> convertedMissingStoreKeys = remoteReplicaInfo.getLocalStore().findMissingKeys(new ArrayList<>(remoteToConvertedNonNull.values())); Set<StoreKey> missingRemoteStoreKeys = new HashSet<>(); remoteToConvertedNonNull.forEach((remoteKey, convertedKey) -> { if (convertedMissingStoreKeys.contains(convertedKey)) { logger.trace( "Remote node: Thread name: Remote replica: Key missing id (converted): Key missing id (remote): {}", remoteNode, threadName, remoteReplicaInfo.getReplicaId(), convertedKey, remoteKey); missingRemoteStoreKeys.add(remoteKey); } }); replicationMetrics.updateCheckMissingKeysTime(SystemTime.getInstance().milliseconds() - startTime, replicatingFromRemoteColo, datacenterName); return missingRemoteStoreKeys; }