in graphjet-core/src/main/java/com/twitter/graphjet/algorithms/counting/tweet/TopSecondDegreeByCountTweetRecsGenerator.java [113:141]
private static boolean isLessThanMinUserSocialProofSizeCombined(
SmallArrayBasedLongToDoubleMap[] socialProofs,
int minUserSocialProofSize,
Set<byte[]> socialProofTypeUnions) {
if (socialProofTypeUnions.isEmpty() ||
// check if the size of any social proof union is greater than minUserSocialProofSize before dedupping
isSocialProofUnionSizeLessThanMin(socialProofs, minUserSocialProofSize, socialProofTypeUnions)) {
return true;
}
LongSet uniqueNodes = new LongOpenHashSet(minUserSocialProofSize);
for (byte[] socialProofTypeUnion: socialProofTypeUnions) {
// Clear removes all elements, but does not change the size of the set.
// Thus, we only use one LongOpenHashSet with at most a size of 2*minUserSocialProofSize
uniqueNodes.clear();
for (byte socialProofType: socialProofTypeUnion) {
if (socialProofs[socialProofType] != null) {
for (int i = 0; i < socialProofs[socialProofType].size(); i++) {
uniqueNodes.add(socialProofs[socialProofType].keys()[i]);
if (uniqueNodes.size() >= minUserSocialProofSize) {
return false;
}
}
}
}
}
return true;
}