mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-02 09:18:49 +02:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
30 lines
913 B
Scala
30 lines
913 B
Scala
package com.twitter.recos.user_video_graph.util
|
|
|
|
import com.twitter.graphjet.bipartite.MultiSegmentIterator
|
|
import com.twitter.graphjet.bipartite.api.BipartiteGraph
|
|
import com.twitter.graphjet.bipartite.segment.BipartiteGraphSegment
|
|
import scala.collection.mutable.ListBuffer
|
|
|
|
object FetchRHSTweetsUtil {
|
|
// get RHS tweets given LHS users
|
|
def fetchRHSTweets(
|
|
userIds: Seq[Long],
|
|
bipartiteGraph: BipartiteGraph
|
|
): Seq[Long] = {
|
|
userIds.distinct
|
|
.flatMap { userId =>
|
|
val tweetIdsIterator = bipartiteGraph
|
|
.getLeftNodeEdges(userId).asInstanceOf[MultiSegmentIterator[BipartiteGraphSegment]]
|
|
|
|
val tweetIds = new ListBuffer[Long]()
|
|
if (tweetIdsIterator != null) {
|
|
while (tweetIdsIterator.hasNext) {
|
|
val rightNode = tweetIdsIterator.nextLong()
|
|
tweetIds += rightNode
|
|
}
|
|
}
|
|
tweetIds.distinct
|
|
}
|
|
}
|
|
}
|