Skip to content

Commit 3e09b09

Browse files
committed
FactorGen: Merge Comment-related tables to personNumFriendComments
1 parent 5a86fa4 commit 3e09b09

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/main/scala/ldbc/snb/datagen/factors/FactorGenerationStage.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -526,26 +526,26 @@ object FactorGenerationStage extends DatagenStage with Logging {
526526
numFriendOfFriendPosts
527527
},
528528
// comments
529-
"personNumComments" -> Factor(PersonType, PostType) { case Seq(person, comment) =>
530-
val comments = person
531-
.as("Person")
532-
.join(comment.as("comment"), $"comment.CreatorPersonId" === $"Person.id", "leftouter")
533-
534-
val numComments = frequency(comments, value = $"comment.id", by = Seq($"Person.id"))
535-
numComments
536-
},
537529
"personNumFriendComments" -> Factor(PersonType, PersonKnowsPersonType, CommentType) { case Seq(person, personKnowsPerson, comment) =>
530+
// direct comments
538531
val personComments = person
539532
.as("Person")
540533
.join(comment.as("Comment"), $"Comment.CreatorPersonId" === $"Person.id", "leftouter")
541534

542535
val numPersonComments = frequency(personComments, value = $"Comment.id", by = Seq($"Person.id"), agg = count)
543-
.select($"Person.id".as("Person1Id"), $"frequency")
536+
.select($"Person.id".as("Person1Id"), $"frequency".as("numDirectComments"))
544537

545-
val friendComments = numPersonComments.as("numPersonComments")
546-
.join(undirectedKnows(personKnowsPerson).as("knows"), $"numPersonComments.Person1Id" === $"knows.Person2Id", "leftouter")
538+
// friend comments
539+
val friendComments = numPersonComments.as("numPersonComments1")
540+
.join(undirectedKnows(personKnowsPerson).as("knows"), $"numPersonComments1.Person1Id" === $"knows.Person1Id", "leftouter")
541+
.join(numPersonComments.as("numPersonComments2"), $"numPersonComments2.Person1Id" === $"knows.Person2Id", "leftouter")
547542

548-
val numFriendComments = frequency(friendComments, value = $"frequency", by = Seq($"knows.Person1Id"), agg = sum)
543+
val numFriendComments = frequency(
544+
friendComments,
545+
value = $"numPersonComments2.numDirectComments",
546+
by = Seq($"numPersonComments1.Person1Id", $"numPersonComments1.numDirectComments"),
547+
agg = sum
548+
)
549549
numFriendComments
550550
},
551551
// likes

0 commit comments

Comments
 (0)