Skip to content

Commit 0705b1d

Browse files
committed
FactorGen: Change group-by attribute to equivalent ones to improve readability
1 parent ffd25d7 commit 0705b1d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,21 +468,23 @@ object FactorGenerationStage extends DatagenStage with Logging {
468468
},
469469
// friends
470470
"personNumFriendsOfFriends" -> Factor(PersonKnowsPersonType, PersonType) { case Seq(personKnowsPerson, person1) =>
471+
// direct friends
471472
val knows1 = person1
472473
.as("Person1")
473474
.join(undirectedKnows(personKnowsPerson).as("knows"), $"Person1.id" === $"knows.Person1Id", "leftouter")
474475

475476
val personNumFriends = frequency(knows1, value = $"knows.Person2Id", by = Seq($"Person1.id"), agg = count)
476477
.select($"Person1.id".as("Person1Id"), $"frequency".as("numFriends"))
477478

479+
// friends of friends
478480
val personFriendsOfFriends = personNumFriends.as("personNumFriends1")
479481
.join(undirectedKnows(personKnowsPerson).as("knows"), $"personNumFriends1.Person1Id" === $"knows.Person1Id", "leftouter")
480482
.join(personNumFriends.as("personNumFriends2"), $"personNumFriends2.Person1Id" === $"knows.Person2Id", "leftouter")
481483

482484
val personNumFriendsOfFriends = frequency(
483485
personFriendsOfFriends,
484486
value = $"personNumFriends2.numFriends",
485-
by = Seq($"knows.Person1Id", $"personNumFriends1.numFriends"),
487+
by = Seq($"personNumFriends1.Person1Id", $"personNumFriends1.numFriends"),
486488
agg = sum
487489
).select($"Person1Id", $"numFriends", $"frequency".as("numFriendsOfFriends"))
488490

@@ -506,9 +508,9 @@ object FactorGenerationStage extends DatagenStage with Logging {
506508
val numFriendPosts = frequency(
507509
friendPosts,
508510
value = $"numPersonPosts2.numDirectPosts",
509-
by = Seq($"knows.Person1Id", $"numPersonPosts1.numDirectPosts"),
511+
by = Seq($"numPersonPosts1.Person1Id", $"numPersonPosts1.numDirectPosts"),
510512
agg = sum
511-
).select($"knows.Person1Id".as("Person1Id"), $"numDirectPosts", $"frequency".as("numFriendPosts"))
513+
).select($"numPersonPosts1.Person1Id".as("Person1Id"), $"numDirectPosts", $"frequency".as("numFriendPosts"))
512514

513515
// posts of friends of friends
514516
val friendOfFriendPosts = numFriendPosts.as("numFriendPosts1")

0 commit comments

Comments
 (0)