Skip to content

Commit b16c8f7

Browse files
committed
FactorGen: Include temporal attributes for the remaining Interactive factor tables
1 parent a6f25dd commit b16c8f7

File tree

1 file changed

+50
-27
lines changed

1 file changed

+50
-27
lines changed

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

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,12 @@ object FactorGenerationStage extends DatagenStage with Logging {
478478
.as("Person1")
479479
.join(undirectedKnows(personKnowsPerson).as("knows"), $"Person1.id" === $"knows.Person1Id", "leftouter")
480480

481-
val personNumFriends = frequency(knows1, value = $"knows.Person2Id", by = Seq($"Person1.id"), agg = count)
482-
.select($"Person1.id".as("Person1Id"), $"frequency".as("numFriends"))
481+
val personNumFriends = frequency(
482+
knows1,
483+
value = $"knows.Person2Id",
484+
by = Seq($"Person1.id", $"Person1.creationDate", $"Person1.deletionDate"),
485+
agg = count)
486+
.select($"Person1.id".as("Person1Id"), $"creationDate", $"deletionDate", $"frequency".as("numFriends"))
483487

484488
// friends of friends
485489
val personFriendsOfFriends = personNumFriends.as("personNumFriends1")
@@ -489,9 +493,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
489493
val personNumFriendsOfFriends = frequency(
490494
personFriendsOfFriends,
491495
value = $"personNumFriends2.numFriends",
492-
by = Seq($"personNumFriends1.Person1Id", $"personNumFriends1.numFriends"),
496+
by = Seq($"personNumFriends1.Person1Id", $"personNumFriends1.creationDate", $"personNumFriends1.deletionDate", $"personNumFriends1.numFriends"),
493497
agg = sum
494-
).select($"Person1Id", $"numFriends", $"frequency".as("numFriendsOfFriends"))
498+
).select($"Person1Id", $"creationDate", $"deletionDate", $"numFriends", $"frequency".as("numFriendsOfFriends"))
495499

496500
personNumFriendsOfFriends
497501
},
@@ -502,8 +506,12 @@ object FactorGenerationStage extends DatagenStage with Logging {
502506
.join(post.as("Post"), $"Post.CreatorPersonId" === $"Person.id", "leftouter")
503507

504508
// direct posts
505-
val numPersonPosts = frequency(personPosts, value = $"Post.id", by = Seq($"Person.id"), agg = count)
506-
.select($"Person.id".as("Person1Id"), $"frequency".as("numDirectPosts"))
509+
val numPersonPosts = frequency(
510+
personPosts,
511+
value = $"Post.id",
512+
by = Seq($"Person.id", $"Person.creationDate", $"Person.deletionDate"),
513+
agg = count
514+
).select($"Person.id".as("Person1Id"), $"creationDate", $"deletionDate", $"frequency".as("numDirectPosts"))
507515

508516
// posts of friends
509517
val friendPosts = numPersonPosts.as("numPersonPosts1")
@@ -513,9 +521,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
513521
val numFriendPosts = frequency(
514522
friendPosts,
515523
value = $"numPersonPosts2.numDirectPosts",
516-
by = Seq($"numPersonPosts1.Person1Id", $"numPersonPosts1.numDirectPosts"),
524+
by = Seq($"numPersonPosts1.Person1Id", $"numPersonPosts1.creationDate", $"numPersonPosts1.deletionDate", $"numPersonPosts1.numDirectPosts"),
517525
agg = sum
518-
).select($"numPersonPosts1.Person1Id".as("Person1Id"), $"numDirectPosts", $"frequency".as("numFriendPosts"))
526+
).select($"numPersonPosts1.Person1Id".as("Person1Id"), $"creationDate", $"deletionDate", $"numDirectPosts", $"frequency".as("numFriendPosts"))
519527

520528
// posts of friends of friends
521529
val friendOfFriendPosts = numFriendPosts.as("numFriendPosts1")
@@ -525,9 +533,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
525533
val numFriendOfFriendPosts = frequency(
526534
friendOfFriendPosts,
527535
value = $"numFriendPosts2.numFriendPosts",
528-
by = Seq($"numFriendPosts1.Person1Id", $"numFriendPosts1.numDirectPosts", $"numFriendPosts1.numFriendPosts"),
536+
by = Seq($"numFriendPosts1.Person1Id", $"numFriendPosts1.creationDate", $"numFriendPosts1.deletionDate", $"numFriendPosts1.numDirectPosts", $"numFriendPosts1.numFriendPosts"),
529537
agg = sum
530-
).select($"Person1Id", $"numDirectPosts", $"numFriendPosts", $"frequency".as("numFriendOfFriendPosts"))
538+
).select($"Person1Id", $"creationDate", $"deletionDate", $"numDirectPosts", $"numFriendPosts", $"frequency".as("numFriendOfFriendPosts"))
531539

532540
numFriendOfFriendPosts
533541
},
@@ -538,8 +546,12 @@ object FactorGenerationStage extends DatagenStage with Logging {
538546
.as("Person")
539547
.join(comment.as("Comment"), $"Comment.CreatorPersonId" === $"Person.id", "leftouter")
540548

541-
val numPersonComments = frequency(personComments, value = $"Comment.id", by = Seq($"Person.id"), agg = count)
542-
.select($"Person.id".as("Person1Id"), $"frequency".as("numDirectComments"))
549+
val numPersonComments = frequency(
550+
personComments,
551+
value = $"Comment.id",
552+
by = Seq($"Person.id", $"Person.creationDate", $"Person.deletionDate"),
553+
agg = count
554+
).select($"Person.id".as("Person1Id"), $"Person.creationDate", $"Person.deletionDate", $"frequency".as("numDirectComments"))
543555

544556
// friend comments
545557
val friendComments = numPersonComments.as("numPersonComments1")
@@ -549,16 +561,16 @@ object FactorGenerationStage extends DatagenStage with Logging {
549561
val numFriendComments = frequency(
550562
friendComments,
551563
value = $"numPersonComments2.numDirectComments",
552-
by = Seq($"numPersonComments1.Person1Id", $"numPersonComments1.numDirectComments"),
564+
by = Seq($"numPersonComments1.Person1Id", $"numPersonComments1.creationDate", $"numPersonComments1.deletionDate", $"numPersonComments1.numDirectComments"),
553565
agg = sum
554-
).select($"Person1Id", $"numDirectComments", $"frequency".as("numFriendComments"))
566+
).select($"Person1Id", $"creationDate", $"deletionDate", $"numDirectComments", $"frequency".as("numFriendComments"))
555567
numFriendComments
556568
},
557569
// likes
558570
"personLikesNumMessages" -> Factor(PersonType, PersonLikesCommentType, PersonLikesPostType) { case Seq(person, personLikesComment, personLikesPost) =>
559571
val personLikesMessage =
560572
personLikesComment.select($"PersonId", $"CommentId".as("MessageId")) |+|
561-
personLikesPost.select($"PersonId", $"PostId".as("MessageId"))
573+
personLikesPost.select($"PersonId", $"PostId".as("MessageId"))
562574

563575
val messages = person
564576
.as("Person")
@@ -567,9 +579,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
567579
val personLikesNumMessages = frequency(
568580
messages,
569581
value = $"personLikesMessage.MessageId",
570-
by = Seq($"Person.id"),
582+
by = Seq($"Person.id", $"Person.creationDate", $"Person.deletionDate"),
571583
agg = count
572-
)
584+
).select($"id".as("Person1Id"), $"creationDate", $"deletionDate", $"frequency")
573585
personLikesNumMessages
574586
},
575587
// tags
@@ -579,8 +591,12 @@ object FactorGenerationStage extends DatagenStage with Logging {
579591
.as("Person")
580592
.join(interest.as("interest"), $"interest.PersonId" === $"Person.id", "leftouter")
581593

582-
val numPersonTags = frequency(personComments, value = $"TagId", by = Seq($"PersonId"), agg = count)
583-
.select($"PersonId".as("Person1Id"), $"frequency".as("numDirectTags"))
594+
val numPersonTags = frequency(
595+
personComments,
596+
value = $"TagId",
597+
by = Seq($"PersonId", $"Person.creationDate", $"Person.deletionDate"),
598+
agg = count
599+
).select($"PersonId".as("Person1Id"), $"Person.creationDate", $"Person.deletionDate", $"frequency".as("numDirectTags"))
584600

585601
// tags of friends
586602
val friendTags = numPersonTags.as("numPersonTags1")
@@ -590,9 +606,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
590606
val numFriendTags = frequency(
591607
friendTags,
592608
value = $"numPersonTags2.numDirectTags",
593-
by = Seq($"numPersonTags1.Person1Id", $"numPersonTags1.numDirectTags"),
609+
by = Seq($"numPersonTags1.Person1Id", $"numPersonTags1.creationDate", $"numPersonTags1.deletionDate", $"numPersonTags1.numDirectTags"),
594610
agg = sum
595-
).select($"Person1Id", $"numDirectTags", $"frequency".as("numFriendTags"))
611+
).select($"Person1Id", $"creationDate", $"deletionDate", $"numDirectTags", $"frequency".as("numFriendTags"))
596612
numFriendTags
597613
},
598614
// forums
@@ -639,8 +655,12 @@ object FactorGenerationStage extends DatagenStage with Logging {
639655
val directCompanies = person.as("Person")
640656
.join(workAt.as("workAt"), $"workAt.PersonId" === $"Person.id", "leftouter")
641657

642-
val numCompanies = frequency(directCompanies, value = $"CompanyId", by = Seq($"Person.id"), agg = count)
643-
.select($"Person.id".as("Person1Id"), $"frequency".as("numDirectCompanies"))
658+
val numCompanies = frequency(
659+
directCompanies,
660+
value = $"CompanyId",
661+
by = Seq($"Person.id", $"Person.creationDate", $"Person.deletionDate"),
662+
agg = count
663+
).select($"Person.id".as("Person1Id"), $"Person.creationDate", $"Person.deletionDate", $"frequency".as("numDirectCompanies"))
644664

645665
val friendCompanies = numCompanies.as("numCompanies1")
646666
.join(undirectedKnows(personKnowsPerson).as("knows"), $"numCompanies1.Person1Id" === $"knows.Person1Id", "leftouter")
@@ -650,9 +670,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
650670
val numFriendCompanies = frequency(
651671
friendCompanies,
652672
value = $"numCompanies2.numDirectCompanies",
653-
by = Seq($"numCompanies1.Person1Id", $"numCompanies1.numDirectCompanies"),
673+
by = Seq($"numCompanies1.Person1Id", $"numCompanies1.creationDate", $"numCompanies1.deletionDate", $"numCompanies1.numDirectCompanies"),
654674
agg = sum
655-
).select($"Person1Id", $"numDirectCompanies", $"frequency".as("numFriendCompanies"))
675+
).select($"Person1Id", $"creationDate", $"deletionDate", $"numDirectCompanies", $"frequency".as("numFriendCompanies"))
656676

657677
// companies of friends of friends
658678
val friendOfFriendCompanies = numFriendCompanies.as("numFriendCompanies1")
@@ -662,9 +682,12 @@ object FactorGenerationStage extends DatagenStage with Logging {
662682
val numFriendOfFriendCompanies = frequency(
663683
friendOfFriendCompanies,
664684
value = $"numFriendCompanies2.numFriendCompanies",
665-
by = Seq($"numFriendCompanies1.Person1Id", $"numFriendCompanies1.numDirectCompanies", $"numFriendCompanies1.numFriendCompanies"),
685+
by = Seq(
686+
$"numFriendCompanies1.Person1Id", $"numFriendCompanies1.creationDate", $"numFriendCompanies1.deletionDate",
687+
$"numFriendCompanies1.numDirectCompanies", $"numFriendCompanies1.numFriendCompanies"
688+
),
666689
agg = sum
667-
).select($"Person1Id", $"numDirectCompanies", $"numFriendCompanies", $"frequency".as("numFriendOfFriendCompanies"))
690+
).select($"Person1Id", $"creationDate", $"deletionDate", $"numDirectCompanies", $"numFriendCompanies", $"frequency".as("numFriendOfFriendCompanies"))
668691

669692
numFriendOfFriendCompanies
670693
},

0 commit comments

Comments
 (0)