in graphjet-core/src/main/java/com/twitter/graphjet/algorithms/socialproof/NodeMetadataSocialProofGenerator.java [103:141]
private void addSocialProof(
byte nodeMetaDataType,
int metadataId,
byte edgeType,
long leftNode,
long rightNode
) {
Int2ObjectMap<Byte2ObjectMap<Long2ObjectMap<LongSet>>> nodeMetadataToSocialProofMap =
socialProofs.get(nodeMetaDataType);
if (!nodeMetadataToSocialProofMap.containsKey(metadataId)) {
// We choose ArrayMap over OpenHashMap since the request will have at most a few edge types,
// usually less than five.
nodeMetadataToSocialProofMap.put(metadataId, new Byte2ObjectArrayMap<>());
}
Byte2ObjectMap<Long2ObjectMap<LongSet>> socialProofMap =
nodeMetadataToSocialProofMap.get(metadataId);
// Get the user to tweets map variable by the engagement type.
if (!socialProofMap.containsKey(edgeType)) {
// We choose to use an OpenHashMap since a single edge type may have dozens or even hundreds
// of user seed ids associated.
socialProofMap.put(edgeType, new Long2ObjectOpenHashMap<>());
}
Long2ObjectMap<LongSet> userToTweetsMap = socialProofMap.get(edgeType);
// Add the connecting user to the user map.
if (!userToTweetsMap.containsKey(leftNode)) {
// We choose to use an OpenHashSet since a single user may engage with dozens or even
// hundreds of tweet ids.
userToTweetsMap.put(leftNode, new LongOpenHashSet());
}
LongSet connectingTweets = userToTweetsMap.get(leftNode);
// Add the connecting tweet to the tweet set.
if (!connectingTweets.contains(rightNode)) {
connectingTweets.add(rightNode);
}
}