Skip to content

Commit 55dcdb9

Browse files
committed
Fix language generation for Forums and (indirectly) Posts. Fixes #349
The old versions (including the legacy Hadoop Datagen) had a bug where the language of a Forum was selected as a random number between 0 and the number of languages a person spoke (0, 1, or 2). The fix is trivial: this random number should be used to *select* a language from the list of languages spoken by the person (instead of simply using this number as the id of the language).
1 parent 74a7b10 commit 55dcdb9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/ldbc/snb/datagen/generator/generators/ForumGenerator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class ForumGenerator {
6464
*/
6565
Forum createWall(RandomGeneratorFarm randomFarm, long forumId, Person person, long blockId) {
6666

67-
int language = randomFarm.get(RandomGeneratorFarm.Aspect.LANGUAGE).nextInt(person.getLanguages().size());
67+
int language = person.getLanguages().get(randomFarm.get(RandomGeneratorFarm.Aspect.LANGUAGE).nextInt(person.getLanguages().size()));
6868

6969
// Check moderator can be added
7070
if (person.getDeletionDate() - person.getCreationDate() + DatagenParams.delta < 0){
@@ -134,7 +134,7 @@ Forum createGroup(RandomGeneratorFarm randomFarm, long forumId, Person moderator
134134
// the hasModerator edge is deleted if either the Forum (group) or the Person (moderator) is deleted
135135
long moderatorDeletionDate = Math.min(groupDeletionDate, moderator.getDeletionDate());
136136

137-
int language = randomFarm.get(RandomGeneratorFarm.Aspect.LANGUAGE).nextInt(moderator.getLanguages().size());
137+
int language = moderator.getLanguages().get(randomFarm.get(RandomGeneratorFarm.Aspect.LANGUAGE).nextInt(moderator.getLanguages().size()));
138138

139139
Iterator<Integer> iter = moderator.getInterests().iterator();
140140
int idx = randomFarm.get(RandomGeneratorFarm.Aspect.FORUM_INTEREST).nextInt(moderator.getInterests().size());
@@ -273,8 +273,7 @@ Forum createAlbum(RandomGeneratorFarm randomFarm, long forumId, Person person, i
273273
albumDeletionDate = person.getDeletionDate();
274274
}
275275

276-
277-
int language = randomFarm.get(RandomGeneratorFarm.Aspect.LANGUAGE).nextInt(person.getLanguages().size());
276+
int language = person.getLanguages().get(randomFarm.get(RandomGeneratorFarm.Aspect.LANGUAGE).nextInt(person.getLanguages().size()));
278277
Forum forum = new Forum(SN.formId(SN.composeId(forumId, albumCreationDate), blockId),
279278
albumCreationDate,
280279
albumDeletionDate,

0 commit comments

Comments
 (0)