Skip to content

Commit

Permalink
Deduping validDocIdsMetadata response
Browse files Browse the repository at this point in the history
  • Loading branch information
tibrewalpratik17 committed Feb 20, 2024
1 parent 7d5474b commit c987ff1
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,25 @@ public List<ValidDocIdsMetadataInfo> getValidDocIdsMetadataFromServer(String tab
completionServiceHelper.doMultiPostRequest(serverURLsAndBodies, tableNameWithType, false, requestHeaders,
timeoutMs, null);

List<ValidDocIdsMetadataInfo> validDocIdsMetadataInfos = new ArrayList<>();
Map<String, ValidDocIdsMetadataInfo> validDocIdsMetadataInfos = new HashMap<>();
int failedParses = 0;
int returnedServersCount = 0;
for (Map.Entry<String, String> streamResponse : serviceResponse._httpResponses.entrySet()) {
try {
String validDocIdsMetadataList = streamResponse.getValue();
List<ValidDocIdsMetadataInfo> validDocIdsMetadataInfo =
List<ValidDocIdsMetadataInfo> validDocIdsMetadataInfoList =
JsonUtils.stringToObject(validDocIdsMetadataList, new TypeReference<ArrayList<ValidDocIdsMetadataInfo>>() {
});
validDocIdsMetadataInfos.addAll(validDocIdsMetadataInfo);
for (ValidDocIdsMetadataInfo validDocIdsMetadataInfo: validDocIdsMetadataInfoList) {
validDocIdsMetadataInfos.put(validDocIdsMetadataInfo.getSegmentName(), validDocIdsMetadataInfo);
}
returnedServersCount++;
} catch (Exception e) {
failedParses++;
LOGGER.error("Unable to parse server {} response due to an error: ", streamResponse.getKey(), e);
}
}

if (failedParses != 0) {
LOGGER.error("Unable to parse server {} / {} response due to an error: ", failedParses,
serverURLsAndBodies.size());
Expand All @@ -283,7 +286,7 @@ public List<ValidDocIdsMetadataInfo> getValidDocIdsMetadataFromServer(String tab

LOGGER.info("Retrieved validDocIds metadata for {} segments from {} servers.", validDocIdsMetadataInfos.size(),
returnedServersCount);
return validDocIdsMetadataInfos;
return new ArrayList<>(validDocIdsMetadataInfos.values());
}

/**
Expand Down

0 comments on commit c987ff1

Please sign in to comment.