Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 committed Jul 19, 2023
1 parent 8bfd40a commit 1088170
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,7 @@ protected String processContinuousCrossCounts(String continuousCrossCountRespons
return objectMapper.writeValueAsString(binnedContinuousCrossCounts);
}

binnedContinuousCrossCounts.forEach((key, value) -> {
value.forEach((innerKey, innerValue) -> {
Optional<String> aggregateCount = aggregateCountHelper(innerValue);
if (aggregateCount.isPresent()) {
value.put(innerKey, aggregateCount.get());
} else {
value.put(innerKey, randomize(innerValue.toString(), generatedVariance));
}
});
});

obfuscatedCrossCount(generatedVariance, binnedContinuousCrossCounts);

return objectMapper.writeValueAsString(binnedContinuousCrossCounts);
}
Expand Down Expand Up @@ -632,7 +622,19 @@ protected String processCategoricalCrossCounts(String categoricalEntityString, S
}

// Now we need to obfuscate our return data. The only consideration is do we apply < threshold or variance
categoricalCrossCount.forEach((key, value) -> {
obfuscatedCrossCount(generatedVariance, categoricalCrossCount);
return objectMapper.writeValueAsString(categoricalCrossCount);
}

/**
* This method will obfuscate the cross counts based on the generated variance. We do not have a return because
* we are modifying the passed crossCount object. Java passes objects by reference value, so we do not need to return.
*
* @param generatedVariance The variance for the request
* @param crossCount The cross count that will be obfuscated
*/
private void obfuscatedCrossCount(int generatedVariance, Map<String, Map<String, Object>> crossCount) {
crossCount.forEach((key, value) -> {
value.forEach((innerKey, innerValue) -> {
Optional<String> aggregateCount = aggregateCountHelper(innerValue);
if (aggregateCount.isPresent()) {
Expand All @@ -642,8 +644,6 @@ protected String processCategoricalCrossCounts(String categoricalEntityString, S
}
});
});

return objectMapper.writeValueAsString(categoricalCrossCount);
}

private boolean isCrossCountObfuscated(Map<String, String> crossCounts, int generatedVariance, String lessThanThresholdStr, String varianceStr) {
Expand Down

0 comments on commit 1088170

Please sign in to comment.